diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/sprintf.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/sprintf.c index 9fd48b9d46..548991d686 100755 --- a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/sprintf.c +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/sprintf.c @@ -2,20 +2,41 @@ #include #include #include +#include + +int +vsnprintf(char *str, size_t size, const char *fmt, va_list ap) +{ + FILE _strbuf; + int len; + + _strbuf._flag = _IOWRT|_IOSTRG; + _strbuf._ptr = str; + _strbuf._cnt = size; + len = _doprnt(fmt, ap, &_strbuf); + *_strbuf._ptr = 0; + return len; +} + +int +snprintf(char *str, size_t size, const char *fmt, ...) +{ + int len; + va_list va; + va_start(va, fmt); + len = vsnprintf(str, size, fmt, va); + va_end(va); + return len; +} int sprintf(char *str, const char *fmt, ...) { - FILE _strbuf; int len; va_list va; va_start(va, fmt); - - _strbuf._flag = _IOWRT|_IOSTRG; - _strbuf._ptr = str; - _strbuf._cnt = INT_MAX; - len = _doprnt(fmt, va, &_strbuf); + len = vsnprintf(str, INT_MAX, fmt, va); va_end(va); - *_strbuf._ptr = 0; return len; } +