mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-22 15:07:43 +08:00
61ccd3f94f
So far, the printf family of functions has two output helper functions called __sprint_r and __sfputs_r. Both are called from all variants of vfprintf as well as vfwprintf. There are also analogue helper functions for the string-creating functions vsprintf/vswprintf called __ssprint_r and __ssputs_r. However, the helpers are built once when building vfprintf/vsprintf with the INTEGER_ONLY flag, and then they are part of the vfiprintf.c and vsiprintf.c files. The problem is this: Even if a process only calls vfwprintf or the non-INTEGER_ONLY vfprintf it will always have to include the INTEGER_ONLY vfiprintf. Otherwise the helper functions are undefined. Analogue for the string-creating functions. That's a useless waste of space by including one (or two) big, unused function, if newlib is linked in statically. Create new files to define the printf output helpers separately and split them into byte-oriented and wide-char-oriented functions. This allows to link only the required functions. Also, simplify the string output helpers and fix a potential (but unlikely) buffer overflow in __ssprint_r. Fixes: 8a0efa53e449 ("import newlib-2000-02-17 snapshot") Fixes: 6121968b198d ("* libc/include/stdio.h (__VALIST): Guard against multiple definition.") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
22 lines
370 B
C
22 lines
370 B
C
#include <newlib.h>
|
|
|
|
#ifndef _FVWRITE_IN_STREAMIO
|
|
|
|
#include <reent.h>
|
|
#include <stdio.h>
|
|
#include <wchar.h>
|
|
|
|
extern int __ssputs_r (struct _reent *ptr, FILE *fp, const char *buf,
|
|
size_t len);
|
|
|
|
int
|
|
__ssputws_r (struct _reent *ptr,
|
|
FILE *fp,
|
|
const wchar_t *buf,
|
|
size_t len)
|
|
{
|
|
return __ssputs_r (ptr, fp, (const char *) buf, len * sizeof (wchar_t));
|
|
}
|
|
|
|
#endif
|