Skip to content

Commit

Permalink
added vsprintf declaration (an be useful)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephane-D committed May 31, 2024
1 parent 552749a commit 9b3c32d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
28 changes: 26 additions & 2 deletions inc/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,31 @@ char* strncpy(char *dest, const char *src, u16 len);
* Appends the source string to the destination string.
*/
char* strcat(char *dest, const char *src);

/**
* \brief
* Composes a string with the same text that would be printed if format was used on printf,
* but instead of being printed, the content is stored as a C string in the buffer pointed by str.
*
* \param buf
* Destination string (it must be large enough to receive result).
* \param fmt
* C string that contains the text to be written to destination string.<br />
* It can optionally contain embedded format specifiers.
* \param args
* Optional argument(s). Depending on the format string, the function may expect a sequence of additional arguments,<br>
* each containing a value to be used to replace a format specifier in the format string.
*
* There should be at least as many of these arguments as the number of values specified in the format specifiers.<br>
* Additional arguments are ignored by the function.
*
* \return On success, the total number of characters written is returned..
*
* Copy the string pointed by 'fmt' param to the 'buffer' param.<br>
* If 'fmt' includes format specifiers (subsequences beginning with %), the additional arguments following format are
* formatted and inserted in the resulting string replacing their respective specifiers
*/
int vsprintf(char *buffer, const char *fmt, va_list args);
/**
* \brief
* Composes a string with the same text that would be printed if format was used on printf,
Expand All @@ -145,9 +170,8 @@ char* strcat(char *dest, const char *src);
* Copy the string pointed by 'fmt' param to the 'buffer' param.<br>
* If 'fmt' includes format specifiers (subsequences beginning with %), the additional arguments following format are
* formatted and inserted in the resulting string replacing their respective specifiers
*
*/
int sprintf(char *buffer,const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
int sprintf(char *buffer, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));

#endif // ENABLE_NEWLIB

Expand Down
4 changes: 0 additions & 4 deletions src/tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ fix32 getFPS_f()
}


#if (ENABLE_NEWLIB == 0)
extern int vsprintf(char *buf, const char *fmt, va_list args);
#endif // ENABLE_NEWLIB

int kprintf(const char *fmt, ...)
{
char buffer[256];
Expand Down

0 comments on commit 9b3c32d

Please sign in to comment.