mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-19 04:49:25 +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>
31 lines
501 B
C
31 lines
501 B
C
#include <newlib.h>
|
|
|
|
#ifdef _FVWRITE_IN_STREAMIO
|
|
|
|
#include <reent.h>
|
|
#include <stdio.h>
|
|
#include "fvwrite.h"
|
|
|
|
/*
|
|
* Flush out all the vectors defined by the given uio,
|
|
* then reset it so that it can be reused.
|
|
*/
|
|
int
|
|
__sprint_r (struct _reent *ptr,
|
|
FILE *fp,
|
|
register struct __suio *uio)
|
|
{
|
|
register int err = 0;
|
|
|
|
if (uio->uio_resid == 0) {
|
|
uio->uio_iovcnt = 0;
|
|
return (0);
|
|
}
|
|
err = __sfvwrite_r(ptr, fp, uio);
|
|
uio->uio_resid = 0;
|
|
uio->uio_iovcnt = 0;
|
|
return (err);
|
|
}
|
|
|
|
#endif
|