From efcfaf4b965644eebe4dfb99f09918b906e0db77 Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Tue, 2 Nov 2010 22:05:40 +0000 Subject: [PATCH] stdio: split vsprintf and vsnprintf - workaround for linking problems --- lib/libc/stdio/Makefile.inc | 1 + lib/libc/stdio/vsnprintf.c | 28 ++++++++++++++++++++++++++++ lib/libc/stdio/vsprintf.c | 21 --------------------- 3 files changed, 29 insertions(+), 21 deletions(-) create mode 100644 lib/libc/stdio/vsnprintf.c diff --git a/lib/libc/stdio/Makefile.inc b/lib/libc/stdio/Makefile.inc index 098733c89..3e04be276 100644 --- a/lib/libc/stdio/Makefile.inc +++ b/lib/libc/stdio/Makefile.inc @@ -53,5 +53,6 @@ SRCS+= \ vfprintf.c \ vprintf.c \ vscanf.c \ + vsnprintf.c \ vsprintf.c \ vsscanf.c diff --git a/lib/libc/stdio/vsnprintf.c b/lib/libc/stdio/vsnprintf.c new file mode 100644 index 000000000..429a33284 --- /dev/null +++ b/lib/libc/stdio/vsnprintf.c @@ -0,0 +1,28 @@ +/* $Header$ */ + +#include +#include +#include +#include "loc_incl.h" + +int +vsnprintf(char *s, size_t n, const char *format, va_list arg) +{ + int retval; + FILE tmp_stream; + + tmp_stream._fd = -1; + tmp_stream._flags = _IOWRITE + _IONBF + _IOWRITING; + tmp_stream._buf = (unsigned char *) s; + tmp_stream._ptr = (unsigned char *) s; + tmp_stream._count = n-1; + + retval = _doprnt(format, arg, &tmp_stream); + if(n > 0) { + tmp_stream._count = 1; + (void) putc('\0',&tmp_stream); + } + + return retval; +} + diff --git a/lib/libc/stdio/vsprintf.c b/lib/libc/stdio/vsprintf.c index 38b4964f3..84925316c 100644 --- a/lib/libc/stdio/vsprintf.c +++ b/lib/libc/stdio/vsprintf.c @@ -8,27 +8,6 @@ #include #include "loc_incl.h" -int -vsnprintf(char *s, size_t n, const char *format, va_list arg) -{ - int retval; - FILE tmp_stream; - - tmp_stream._fd = -1; - tmp_stream._flags = _IOWRITE + _IONBF + _IOWRITING; - tmp_stream._buf = (unsigned char *) s; - tmp_stream._ptr = (unsigned char *) s; - tmp_stream._count = n-1; - - retval = _doprnt(format, arg, &tmp_stream); - if(n > 0) { - tmp_stream._count = 1; - (void) putc('\0',&tmp_stream); - } - - return retval; -} - int vsprintf(char *s, const char *format, va_list arg) { -- 2.44.0