libc/newlib/libc/stdio/vasprintf.c

78 lines
2.0 KiB
C
Raw Normal View History

/*
* Copyright (c) 1990, 2007 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
/* This code was based on vsprintf.c */
2004-04-23 Artem B. Bityuckiy <abitytsky@softminecorp.com> * libc/stdio/asprintf.c libc/stdio/clearerr.c, libc/stdio/fclose.c libc/stdio/fcloseall.c libc/stdio/fdopen.c, libc/stdio/feof.c libc/stdio/ferror.c libc/stdio/fflush.c, libc/stdio/fgetc.c libc/stdio/fgetpos.c libc/stdio/fgets.c, libc/stdio/fileno.c libc/stdio/findfp.c libc/stdio/fiprintf.c, libc/stdio/flags.c libc/stdio/fopen.c libc/stdio/fprintf.c, libc/stdio/fputc.c libc/stdio/fputs.c libc/stdio/fread.c, libc/stdio/freopen.c libc/stdio/fscanf.c libc/stdio/fseek.c, libc/stdio/fseeko.c libc/stdio/fsetpos.c libc/stdio/ftell.c, libc/stdio/ftello.c libc/stdio/fvwrite.c libc/stdio/fwalk.c, libc/stdio/fwrite.c libc/stdio/getc.c libc/stdio/getc_u.c, libc/stdio/getchar.c libc/stdio/getchar_u.c, libc/stdio/getdelim.c libc/stdio/getline.c libc/stdio/gets.c, libc/stdio/getw.c libc/stdio/iprintf.c libc/stdio/local.h, libc/stdio/makebuf.c libc/stdio/mktemp.c libc/stdio/perror.c, libc/stdio/printf.c libc/stdio/putc.c libc/stdio/putc_u.c, libc/stdio/putchar.c libc/stdio/putchar_u.c libc/stdio/puts.c, libc/stdio/putw.c libc/stdio/refill.c libc/stdio/remove.c, libc/stdio/rename.c libc/stdio/rewind.c libc/stdio/rget.c, libc/stdio/scanf.c libc/stdio/setbuf.c libc/stdio/setbuffer.c, libc/stdio/setlinebuf.c libc/stdio/setvbuf.c, libc/stdio/siprintf.c libc/stdio/snprintf.c, libc/stdio/sprintf.c libc/stdio/sscanf.c libc/stdio/stdio.c, libc/stdio/tmpfile.c libc/stdio/tmpnam.c libc/stdio/ungetc.c, libc/stdio/vasprintf.c libc/stdio/vfieeefp.h, libc/stdio/vfprintf.c libc/stdio/vfscanf.c, libc/stdio/vprintf.c libc/stdio/vscanf.c, libc/stdio/vsnprintf.c libc/stdio/vsprintf.c, libc/stdio/vsscanf.c libc/stdio/wbuf.c, libc/stdio/wsetup.c: Perform minor formatting changes. Move copyright notices to top of file, ensure that <_ansi.h> is included, be consistent with open parentheses, use _DEFUN macro, include "local.h" where needed, and remove various compiler warnings.
2004-04-23 22:01:55 +02:00
/* doc in vfprintf.c */
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "%W% (Berkeley) %G%";
#endif /* LIBC_SCCS and not lint */
#include <_ansi.h>
#include <stdio.h>
#include <limits.h>
#include <stdarg.h>
#include "local.h"
2003-08-22 Jeff Johnston <jjohnstn@redhat.com> * libc/include/sys/reent.h: Add _GLOBAL_REENT macro. * libc/stdio: Globally remove/replace all references to fp->_data. Replace with _REENT or _GLOBAL_REENT where appropriate. * libc/stdio/asprintf.c: Ditto. * libc/stdio/fclose.c: Ditto. * libc/stdio/fvwrite.c: Ditto. * libc/stdio/makebuf.c: Ditto. * libc/stdio/refill.c: Ditto. * libc/stdio/local.h: Ditto. * libc/stdio/setvbuf.c: Ditto. * libc/stdio/sscanf.c: Ditto. * libc/stdio/stdio.c: Ditto. * libc/stdio/ungetc.c: Ditto. * libc/stdio/vfscanf.c: Ditto. * libc/stdio/vsscanf.c: Ditto. * libc/stdio/fopen.c: Ditto. Also use _fseek_r in _fopen_r. * libc/stdio/vasprintf.c: Ditto. Also call _vfprintf_r directly. * libc/stdio/vsnprintf.c: Ditto. * libc/stdio/vsprintf.c: Ditto. * libc/stdio/fcloseall.c(fcloseall): Use _GLOBAL_REENT macro instead of _REENT to walk file list. * libc/stdio/fflush.c: Ditto. * libc/stdio/fgetpos.c: Add reentrant version and have regular version call reentrant version with _REENT argument. * libc/stdio/fsetpos.c: Ditto. * libc/stdio/fseek.c: Ditto. * libc/stdio/fseeko.c: Ditto. * libc/stdio/ftell.c: Ditto. * libc/stdio/ftello.c: Ditto. * libc/stdio/freopen.c: Ditto. * libc/stdio/findfp.c: Use _GLOBAL_REENT pointer when adding new files to chain. Also use _GLOBAL_REENT pointer for cleaning up. * libc/stdio/fiprintf.c: Reformatted to minimize duplicate code. * libc/stdio/siprintf.c: Ditto. * libc/stdio/iprintf.c: Ditto. * libc/stdio/fprintf.c: Ditto. * libc/stdio/printf.c: Ditto. * libc/stdio/snprintf.c: Call _vfprintf_r directly. * libc/stdio/sprintf.c: Ditto. * libc/stdio/vprintf.c: Ditto. Also add _REENT_ONLY check. * libc/stdio/rewind.c: Call _fseek_r directly. * libc/stdio/tmpfile.c: Call _fopen_r and _remove_r directly. * libc/stdio/vfprintf.c (_VFPRINTF_R): Change _r routines to use data pointer. (get_arg): Add extra struct _reent pointer argument. * libc/stdio64/fgetpos64.c: Add _r versions, remove any reference to fp->_data. * libc/stdio64/fopen64.c: Ditto. * libc/stdio64/freopen64.c: Ditto. * libc/stdio64/fsetpos64.c: Ditto. * libc/stdio64/ftello64.c: Ditto. * libc/stdio64/local64.h: Ditto. * libc/stdio64/stdio64.c: Ditto. * libc/stdio64/fseeko64.c: Ditto plus use _fstat_r instead of _fstat64_r for the meantime.
2003-08-22 20:52:25 +02:00
#ifndef _REENT_ONLY
int
2004-04-23 Artem B. Bityuckiy <abitytsky@softminecorp.com> * libc/stdio/asprintf.c libc/stdio/clearerr.c, libc/stdio/fclose.c libc/stdio/fcloseall.c libc/stdio/fdopen.c, libc/stdio/feof.c libc/stdio/ferror.c libc/stdio/fflush.c, libc/stdio/fgetc.c libc/stdio/fgetpos.c libc/stdio/fgets.c, libc/stdio/fileno.c libc/stdio/findfp.c libc/stdio/fiprintf.c, libc/stdio/flags.c libc/stdio/fopen.c libc/stdio/fprintf.c, libc/stdio/fputc.c libc/stdio/fputs.c libc/stdio/fread.c, libc/stdio/freopen.c libc/stdio/fscanf.c libc/stdio/fseek.c, libc/stdio/fseeko.c libc/stdio/fsetpos.c libc/stdio/ftell.c, libc/stdio/ftello.c libc/stdio/fvwrite.c libc/stdio/fwalk.c, libc/stdio/fwrite.c libc/stdio/getc.c libc/stdio/getc_u.c, libc/stdio/getchar.c libc/stdio/getchar_u.c, libc/stdio/getdelim.c libc/stdio/getline.c libc/stdio/gets.c, libc/stdio/getw.c libc/stdio/iprintf.c libc/stdio/local.h, libc/stdio/makebuf.c libc/stdio/mktemp.c libc/stdio/perror.c, libc/stdio/printf.c libc/stdio/putc.c libc/stdio/putc_u.c, libc/stdio/putchar.c libc/stdio/putchar_u.c libc/stdio/puts.c, libc/stdio/putw.c libc/stdio/refill.c libc/stdio/remove.c, libc/stdio/rename.c libc/stdio/rewind.c libc/stdio/rget.c, libc/stdio/scanf.c libc/stdio/setbuf.c libc/stdio/setbuffer.c, libc/stdio/setlinebuf.c libc/stdio/setvbuf.c, libc/stdio/siprintf.c libc/stdio/snprintf.c, libc/stdio/sprintf.c libc/stdio/sscanf.c libc/stdio/stdio.c, libc/stdio/tmpfile.c libc/stdio/tmpnam.c libc/stdio/ungetc.c, libc/stdio/vasprintf.c libc/stdio/vfieeefp.h, libc/stdio/vfprintf.c libc/stdio/vfscanf.c, libc/stdio/vprintf.c libc/stdio/vscanf.c, libc/stdio/vsnprintf.c libc/stdio/vsprintf.c, libc/stdio/vsscanf.c libc/stdio/wbuf.c, libc/stdio/wsetup.c: Perform minor formatting changes. Move copyright notices to top of file, ensure that <_ansi.h> is included, be consistent with open parentheses, use _DEFUN macro, include "local.h" where needed, and remove various compiler warnings.
2004-04-23 22:01:55 +02:00
_DEFUN(vasprintf, (strp, fmt, ap),
char **strp _AND
const char *fmt _AND
2004-04-23 Artem B. Bityuckiy <abitytsky@softminecorp.com> * libc/stdio/asprintf.c libc/stdio/clearerr.c, libc/stdio/fclose.c libc/stdio/fcloseall.c libc/stdio/fdopen.c, libc/stdio/feof.c libc/stdio/ferror.c libc/stdio/fflush.c, libc/stdio/fgetc.c libc/stdio/fgetpos.c libc/stdio/fgets.c, libc/stdio/fileno.c libc/stdio/findfp.c libc/stdio/fiprintf.c, libc/stdio/flags.c libc/stdio/fopen.c libc/stdio/fprintf.c, libc/stdio/fputc.c libc/stdio/fputs.c libc/stdio/fread.c, libc/stdio/freopen.c libc/stdio/fscanf.c libc/stdio/fseek.c, libc/stdio/fseeko.c libc/stdio/fsetpos.c libc/stdio/ftell.c, libc/stdio/ftello.c libc/stdio/fvwrite.c libc/stdio/fwalk.c, libc/stdio/fwrite.c libc/stdio/getc.c libc/stdio/getc_u.c, libc/stdio/getchar.c libc/stdio/getchar_u.c, libc/stdio/getdelim.c libc/stdio/getline.c libc/stdio/gets.c, libc/stdio/getw.c libc/stdio/iprintf.c libc/stdio/local.h, libc/stdio/makebuf.c libc/stdio/mktemp.c libc/stdio/perror.c, libc/stdio/printf.c libc/stdio/putc.c libc/stdio/putc_u.c, libc/stdio/putchar.c libc/stdio/putchar_u.c libc/stdio/puts.c, libc/stdio/putw.c libc/stdio/refill.c libc/stdio/remove.c, libc/stdio/rename.c libc/stdio/rewind.c libc/stdio/rget.c, libc/stdio/scanf.c libc/stdio/setbuf.c libc/stdio/setbuffer.c, libc/stdio/setlinebuf.c libc/stdio/setvbuf.c, libc/stdio/siprintf.c libc/stdio/snprintf.c, libc/stdio/sprintf.c libc/stdio/sscanf.c libc/stdio/stdio.c, libc/stdio/tmpfile.c libc/stdio/tmpnam.c libc/stdio/ungetc.c, libc/stdio/vasprintf.c libc/stdio/vfieeefp.h, libc/stdio/vfprintf.c libc/stdio/vfscanf.c, libc/stdio/vprintf.c libc/stdio/vscanf.c, libc/stdio/vsnprintf.c libc/stdio/vsprintf.c, libc/stdio/vsscanf.c libc/stdio/wbuf.c, libc/stdio/wsetup.c: Perform minor formatting changes. Move copyright notices to top of file, ensure that <_ansi.h> is included, be consistent with open parentheses, use _DEFUN macro, include "local.h" where needed, and remove various compiler warnings.
2004-04-23 22:01:55 +02:00
va_list ap)
{
return _vasprintf_r (_REENT, strp, fmt, ap);
}
2014-07-04 Bin Cheng <bin.cheng@arm.com> * README (--enable-newlib-nano-formatted-io): Describe. * acconfig.h (_NANO_FORMATTED_IO): Undef. * newlib.hin (_NANO_FORMATTED_IO): Undef. * configure.in (--enable-newlib-nano-formatted-io): New option. * configure: Regenerated. * libc/configure.in (--enable-newlib-nano-formatted-io): New option. * libc/configure: Regenerated. * libc/stdio/Makefile.am (NEWLIB_NANO_FORMATTED_IO): Support new configuration option. * libc/stdio/Makefile.in: Regenerated. * libc/stdio/asnprintf.c (_asniprintf_r, asniprintf): Use _NANO_FORMATTED_IO to declare alias prototypes. * libc/stdio/asprintf.c (_asiprintf_r, asiprintf): Ditto. * libc/stdio/dprintf.c (_diprintf_r, diprintf): Ditto. * libc/stdio/fprintf.c (_fiprintf_r, fiprintf): Ditto. * libc/stdio/fscanf.c (fiscanf, _fiscanf_r): Ditto. * libc/stdio/printf.c (_iprintf_r, iprintf): Ditto. * libc/stdio/scanf.c (iscanf, _iscanf_r): Ditto. * libc/stdio/snprintf.c (_sniprintf_r, sniprintf): Ditto. * libc/stdio/sprintf.c (_siprintf_r, siprintf): Ditto. * libc/stdio/sscanf.c (siscanf, _siscanf_r): Ditto. * libc/stdio/vasnprintf.c (_vasniprintf_r, vasniprintf): Ditto. * libc/stdio/vasprintf.c (vasiprintf, _vasiprintf_r): Ditto. * libc/stdio/vdprintf.c (_vdiprintf_r, vdiprintf): Ditto. * libc/stdio/vprintf.c (viprintf, _viprintf_r): Ditto. * libc/stdio/vscanf.c (viscanf, _viscanf_r): Ditto. * libc/stdio/vsnprintf.c (vsniprintf, _vsniprintf_r): Ditto. * libc/stdio/vsprintf.c (vsiprintf, _vsiprintf_r): Ditto. * libc/stdio/vsscanf.c (vsiscanf, _vsiscanf_r): Ditto. * libc/stdio/nano-vfprintf.c: New file. * libc/stdio/nano-vfprintf_float.c: New file. * libc/stdio/nano-vfprintf_i.c: New file. * libc/stdio/nano-vfprintf_local.h: New file. * libc/stdio/nano-vfscanf.c: New file. * libc/stdio/nano-vfscanf_float.c: New file. * libc/stdio/nano-vfscanf_i.c: New file. * libc/stdio/nano-vfscanf_local.h: New file.
2014-07-04 19:21:45 +02:00
#ifdef _NANO_FORMATTED_IO
int
_EXFUN(vasiprintf, (char **, const char *, __VALIST)
_ATTRIBUTE ((__alias__("vasprintf"))));
#endif
2003-08-22 Jeff Johnston <jjohnstn@redhat.com> * libc/include/sys/reent.h: Add _GLOBAL_REENT macro. * libc/stdio: Globally remove/replace all references to fp->_data. Replace with _REENT or _GLOBAL_REENT where appropriate. * libc/stdio/asprintf.c: Ditto. * libc/stdio/fclose.c: Ditto. * libc/stdio/fvwrite.c: Ditto. * libc/stdio/makebuf.c: Ditto. * libc/stdio/refill.c: Ditto. * libc/stdio/local.h: Ditto. * libc/stdio/setvbuf.c: Ditto. * libc/stdio/sscanf.c: Ditto. * libc/stdio/stdio.c: Ditto. * libc/stdio/ungetc.c: Ditto. * libc/stdio/vfscanf.c: Ditto. * libc/stdio/vsscanf.c: Ditto. * libc/stdio/fopen.c: Ditto. Also use _fseek_r in _fopen_r. * libc/stdio/vasprintf.c: Ditto. Also call _vfprintf_r directly. * libc/stdio/vsnprintf.c: Ditto. * libc/stdio/vsprintf.c: Ditto. * libc/stdio/fcloseall.c(fcloseall): Use _GLOBAL_REENT macro instead of _REENT to walk file list. * libc/stdio/fflush.c: Ditto. * libc/stdio/fgetpos.c: Add reentrant version and have regular version call reentrant version with _REENT argument. * libc/stdio/fsetpos.c: Ditto. * libc/stdio/fseek.c: Ditto. * libc/stdio/fseeko.c: Ditto. * libc/stdio/ftell.c: Ditto. * libc/stdio/ftello.c: Ditto. * libc/stdio/freopen.c: Ditto. * libc/stdio/findfp.c: Use _GLOBAL_REENT pointer when adding new files to chain. Also use _GLOBAL_REENT pointer for cleaning up. * libc/stdio/fiprintf.c: Reformatted to minimize duplicate code. * libc/stdio/siprintf.c: Ditto. * libc/stdio/iprintf.c: Ditto. * libc/stdio/fprintf.c: Ditto. * libc/stdio/printf.c: Ditto. * libc/stdio/snprintf.c: Call _vfprintf_r directly. * libc/stdio/sprintf.c: Ditto. * libc/stdio/vprintf.c: Ditto. Also add _REENT_ONLY check. * libc/stdio/rewind.c: Call _fseek_r directly. * libc/stdio/tmpfile.c: Call _fopen_r and _remove_r directly. * libc/stdio/vfprintf.c (_VFPRINTF_R): Change _r routines to use data pointer. (get_arg): Add extra struct _reent pointer argument. * libc/stdio64/fgetpos64.c: Add _r versions, remove any reference to fp->_data. * libc/stdio64/fopen64.c: Ditto. * libc/stdio64/freopen64.c: Ditto. * libc/stdio64/fsetpos64.c: Ditto. * libc/stdio64/ftello64.c: Ditto. * libc/stdio64/local64.h: Ditto. * libc/stdio64/stdio64.c: Ditto. * libc/stdio64/fseeko64.c: Ditto plus use _fstat_r instead of _fstat64_r for the meantime.
2003-08-22 20:52:25 +02:00
#endif /* !_REENT_ONLY */
int
2004-04-23 Artem B. Bityuckiy <abitytsky@softminecorp.com> * libc/stdio/asprintf.c libc/stdio/clearerr.c, libc/stdio/fclose.c libc/stdio/fcloseall.c libc/stdio/fdopen.c, libc/stdio/feof.c libc/stdio/ferror.c libc/stdio/fflush.c, libc/stdio/fgetc.c libc/stdio/fgetpos.c libc/stdio/fgets.c, libc/stdio/fileno.c libc/stdio/findfp.c libc/stdio/fiprintf.c, libc/stdio/flags.c libc/stdio/fopen.c libc/stdio/fprintf.c, libc/stdio/fputc.c libc/stdio/fputs.c libc/stdio/fread.c, libc/stdio/freopen.c libc/stdio/fscanf.c libc/stdio/fseek.c, libc/stdio/fseeko.c libc/stdio/fsetpos.c libc/stdio/ftell.c, libc/stdio/ftello.c libc/stdio/fvwrite.c libc/stdio/fwalk.c, libc/stdio/fwrite.c libc/stdio/getc.c libc/stdio/getc_u.c, libc/stdio/getchar.c libc/stdio/getchar_u.c, libc/stdio/getdelim.c libc/stdio/getline.c libc/stdio/gets.c, libc/stdio/getw.c libc/stdio/iprintf.c libc/stdio/local.h, libc/stdio/makebuf.c libc/stdio/mktemp.c libc/stdio/perror.c, libc/stdio/printf.c libc/stdio/putc.c libc/stdio/putc_u.c, libc/stdio/putchar.c libc/stdio/putchar_u.c libc/stdio/puts.c, libc/stdio/putw.c libc/stdio/refill.c libc/stdio/remove.c, libc/stdio/rename.c libc/stdio/rewind.c libc/stdio/rget.c, libc/stdio/scanf.c libc/stdio/setbuf.c libc/stdio/setbuffer.c, libc/stdio/setlinebuf.c libc/stdio/setvbuf.c, libc/stdio/siprintf.c libc/stdio/snprintf.c, libc/stdio/sprintf.c libc/stdio/sscanf.c libc/stdio/stdio.c, libc/stdio/tmpfile.c libc/stdio/tmpnam.c libc/stdio/ungetc.c, libc/stdio/vasprintf.c libc/stdio/vfieeefp.h, libc/stdio/vfprintf.c libc/stdio/vfscanf.c, libc/stdio/vprintf.c libc/stdio/vscanf.c, libc/stdio/vsnprintf.c libc/stdio/vsprintf.c, libc/stdio/vsscanf.c libc/stdio/wbuf.c, libc/stdio/wsetup.c: Perform minor formatting changes. Move copyright notices to top of file, ensure that <_ansi.h> is included, be consistent with open parentheses, use _DEFUN macro, include "local.h" where needed, and remove various compiler warnings.
2004-04-23 22:01:55 +02:00
_DEFUN(_vasprintf_r, (ptr, strp, fmt, ap),
struct _reent *ptr _AND
char **strp _AND
const char *fmt _AND
2004-04-23 Artem B. Bityuckiy <abitytsky@softminecorp.com> * libc/stdio/asprintf.c libc/stdio/clearerr.c, libc/stdio/fclose.c libc/stdio/fcloseall.c libc/stdio/fdopen.c, libc/stdio/feof.c libc/stdio/ferror.c libc/stdio/fflush.c, libc/stdio/fgetc.c libc/stdio/fgetpos.c libc/stdio/fgets.c, libc/stdio/fileno.c libc/stdio/findfp.c libc/stdio/fiprintf.c, libc/stdio/flags.c libc/stdio/fopen.c libc/stdio/fprintf.c, libc/stdio/fputc.c libc/stdio/fputs.c libc/stdio/fread.c, libc/stdio/freopen.c libc/stdio/fscanf.c libc/stdio/fseek.c, libc/stdio/fseeko.c libc/stdio/fsetpos.c libc/stdio/ftell.c, libc/stdio/ftello.c libc/stdio/fvwrite.c libc/stdio/fwalk.c, libc/stdio/fwrite.c libc/stdio/getc.c libc/stdio/getc_u.c, libc/stdio/getchar.c libc/stdio/getchar_u.c, libc/stdio/getdelim.c libc/stdio/getline.c libc/stdio/gets.c, libc/stdio/getw.c libc/stdio/iprintf.c libc/stdio/local.h, libc/stdio/makebuf.c libc/stdio/mktemp.c libc/stdio/perror.c, libc/stdio/printf.c libc/stdio/putc.c libc/stdio/putc_u.c, libc/stdio/putchar.c libc/stdio/putchar_u.c libc/stdio/puts.c, libc/stdio/putw.c libc/stdio/refill.c libc/stdio/remove.c, libc/stdio/rename.c libc/stdio/rewind.c libc/stdio/rget.c, libc/stdio/scanf.c libc/stdio/setbuf.c libc/stdio/setbuffer.c, libc/stdio/setlinebuf.c libc/stdio/setvbuf.c, libc/stdio/siprintf.c libc/stdio/snprintf.c, libc/stdio/sprintf.c libc/stdio/sscanf.c libc/stdio/stdio.c, libc/stdio/tmpfile.c libc/stdio/tmpnam.c libc/stdio/ungetc.c, libc/stdio/vasprintf.c libc/stdio/vfieeefp.h, libc/stdio/vfprintf.c libc/stdio/vfscanf.c, libc/stdio/vprintf.c libc/stdio/vscanf.c, libc/stdio/vsnprintf.c libc/stdio/vsprintf.c, libc/stdio/vsscanf.c libc/stdio/wbuf.c, libc/stdio/wsetup.c: Perform minor formatting changes. Move copyright notices to top of file, ensure that <_ansi.h> is included, be consistent with open parentheses, use _DEFUN macro, include "local.h" where needed, and remove various compiler warnings.
2004-04-23 22:01:55 +02:00
va_list ap)
{
int ret;
FILE f;
f._flags = __SWR | __SSTR | __SMBF ;
f._bf._base = f._p = NULL;
f._bf._size = f._w = 0;
f._file = -1; /* No file. */
2008-04-14 Jeff Johnston <jjohnstn@redhat.com> * libc/stdio/Makefile.am: Build vfprintf.c and vfscanf.c with -DSTRING_ONLY defined with and without -DINTEGER_ONLY defined to build special versions for sprintf/sscanf family functions. * libc/stdio/Makefile.in: Regenerated. * libc/stdio/vfprintf.c[STRING_ONLY][INTEGER_ONLY](_VFPRINTF_R): Redefine to be _svfiprintf_r which is optimized to work with siprintf family of functions (i.e. no I/O) and does not support floating-point. [STRING_ONLY][!INTEGER_ONLY](_VFPRINTF_R): Redefine to be _svfprintf_r which is optimized to work with sprintf family of functions and not use I/O. [STRING_ONLY](__sprint_r): New string only version of static function. designed to work with sprintf family of functions. * libc/stdio/vfscanf.c[STRING_ONLY][INTEGER_ONLY](_SVFSCANF_R): Redefine to be _ssvfiscanf_r which is optimized to work with siscanf family of functions (i.e. no I/O) and no float-point support. [STRING_ONLY][!INTEGER_ONLY](_SVFSCANF_R): Redefine to be __ssvfscanf_r which is optimized to work with sscanf family of functions and does not require I/O functions. * libc/stdio/asprintf.c: Call _svfprintf_r instead of _vfprintf_r. * libc/stdio/snprintf.c: Ditto. * libc/stdio/sprintf.c: Ditto. * libc/stdio/vasnprintf.c: Ditto. * libc/stdio/vasprintf.c: Ditto. * libc/stdio/siprintf.c: Call _svfiprintf_r instead of _vfiprintf_r. * libc/stdio/sniprintf.c: Ditto. * libc/stdio/vasiprintf.c: Ditto. * libc/stdio/vsiprintf.c: Ditto. * libc/stdio/vsniprintf.c: Ditto. * libc/stdio/vsprintf.c: Ditto. * libc/stdio/local.h: Add prototypes for _svfprintf_r, _svfiprintf_r, _ssvfscanf_r, and _ssvfiscanf_r. * libc/stdio/sscanf.c: Call _ssvfscanf_r instead of _svfscanf_r. * libc/stdio/vsscanf.c: Ditto. * libc/stdio/siscanf.c: Call _ssvfiscanf_r instead of _svfiscanf_r. * libc/stdio/vsiscanf.c: Ditto.
2008-04-14 23:14:55 +02:00
ret = _svfprintf_r (ptr, &f, fmt, ap);
if (ret >= 0)
{
*f._p = 0;
Throughout, run newlib with -Wall -Werror option and fix bugs and compiler warnings found this way. * libc/stdio/freopen.c (_freopen_r): Fix bug setting _flags. * libc/include/stdio.h (_rename): Define when building newlib. * libc/include/sys/signal.h (_kill): Ditto. * libc/include/sys/stat.h (_mkdir): Ditto. * libc/include/sys/time.h (_gettimeofday): Ditto. * libc/include/sys/times.h (_times): Ditto. * libc/include/sys/wait.h (_wait): Ditto. * libc/locale/lmessages.c (empty): Don't define for Cygwin. * libc/locale/lmonetary.c (cnv): Ditto. * libc/locale/nl_langinfo.c (nl_langinfo): Ditto for variable s. * libc/posix/collate.c: Throughout cast to avoid compiler warning. * libc/posix/engine.c (matcher): Initialize dp to avoid compiler warning. * libc/posix/glob.c: Disable on Cygwin. Explain why. * libc/posix/regcomp.c: Fix "uninitialized" compiler warnings. (dissect): Deliberately silence gcc compiler warning. Add comment to explain why. * libc/posix/wordexp.c (wordexp): Remove num_bytes variable since result is never used. * libc/posix/popen.c (popen): Ditto for variable last. * libc/reent/mkdirr.c: Include sys/stat.h. * libc/reent/renamer.c: Include stdio.h. * libc/search/hash.c: Throughout use underscored variants of the stat function family. (init_hash): Add missing definition for the __USE_INTERNAL_STAT64 case. * libc/search/hash_bigkey.c (__big_insert): Add parenthesis to avoid compiler warning. * libc/search/hash_page.c (overflow_page): Initalize freep to NULL to avoid compiler warning. * libc/stdio/asiprintf.c (_asiprintf_r): Cast unsigned char * to char * to avoid compiler warning. (asiprintf): Ditto. * libc/stdio/asprintf.c (_asprintf_r): Ditto. (asprintf): Ditto. * libc/stdio/vasiprintf.c (_vasiprintf_r): Ditto. * libc/stdio/vasprintf.c (_vasprintf_r): Ditto. * libc/stdio/mktemp.c (_gettemp): Cast to unsigned char in call to isdigit to avoid compiler warning. * libc/stdio/vfprintf.c (_VFPRINTF_R): Initialize variables used for grouping to avoid compiler warning. Only define and set nseps and nrepeats if they are really used. * libc/stdio/vfwprintf.c (_VFWPRINTF_R): Ditto. Only define state if it is really used. * libc/stdio/vfscanf.c (u_char): Revert to be defined as unsigned char. (__SVFSCANF_R): Cast fmt in call to __mbtowc. * libc/stdlib/mbtowc_r.c (JIS_state_table): Disable when building Cygwin. (JIS_action_table): Ditto. * libc/stdlib/wctomb_r.c (__utf8_wctomb): Add parenthesis to avoid compiler warning. * libc/string/strcasestr.c: Deliberately silence gcc compiler warning. Add comment to explain why. * libc/time/strptime.c (strptime): Cast to unsigned char in calls to isspace to avoid compiler warning. * libm/math/e_atan2.c (__ieee754_atan2): Add parenthesis to avoid compiler warning. * libm/math/e_exp.c (__ieee754_exp): Initialize k to 0 to avoid compiler warning. Drop setting it to 0 later. * libm/math/ef_exp.c (__ieee754_expf): Ditto. * libm/math/e_pow.c (__ieee754_pow): Add braces to avoid compiler warning. * libm/math/ef_pow.c (__ieee754_powf): Ditto. * libm/math/er_lgamma.c (__ieee754_lgamma_r): Initialize nadj to 0 to avoid compiler warning. * libm/math/erf_lgamma.c (__ieee754_lgammaf_r): Ditto. * libm/math/e_rem_pio2.c (__ieee754_rem_pio2): Ditto for variable z. * libm/common/sf_round.c (roundf): Remove signbit variable since result is never used.
2012-08-08 13:04:18 +02:00
*strp = (char *) f._bf._base;
}
return ret;
}
2014-07-04 Bin Cheng <bin.cheng@arm.com> * README (--enable-newlib-nano-formatted-io): Describe. * acconfig.h (_NANO_FORMATTED_IO): Undef. * newlib.hin (_NANO_FORMATTED_IO): Undef. * configure.in (--enable-newlib-nano-formatted-io): New option. * configure: Regenerated. * libc/configure.in (--enable-newlib-nano-formatted-io): New option. * libc/configure: Regenerated. * libc/stdio/Makefile.am (NEWLIB_NANO_FORMATTED_IO): Support new configuration option. * libc/stdio/Makefile.in: Regenerated. * libc/stdio/asnprintf.c (_asniprintf_r, asniprintf): Use _NANO_FORMATTED_IO to declare alias prototypes. * libc/stdio/asprintf.c (_asiprintf_r, asiprintf): Ditto. * libc/stdio/dprintf.c (_diprintf_r, diprintf): Ditto. * libc/stdio/fprintf.c (_fiprintf_r, fiprintf): Ditto. * libc/stdio/fscanf.c (fiscanf, _fiscanf_r): Ditto. * libc/stdio/printf.c (_iprintf_r, iprintf): Ditto. * libc/stdio/scanf.c (iscanf, _iscanf_r): Ditto. * libc/stdio/snprintf.c (_sniprintf_r, sniprintf): Ditto. * libc/stdio/sprintf.c (_siprintf_r, siprintf): Ditto. * libc/stdio/sscanf.c (siscanf, _siscanf_r): Ditto. * libc/stdio/vasnprintf.c (_vasniprintf_r, vasniprintf): Ditto. * libc/stdio/vasprintf.c (vasiprintf, _vasiprintf_r): Ditto. * libc/stdio/vdprintf.c (_vdiprintf_r, vdiprintf): Ditto. * libc/stdio/vprintf.c (viprintf, _viprintf_r): Ditto. * libc/stdio/vscanf.c (viscanf, _viscanf_r): Ditto. * libc/stdio/vsnprintf.c (vsniprintf, _vsniprintf_r): Ditto. * libc/stdio/vsprintf.c (vsiprintf, _vsiprintf_r): Ditto. * libc/stdio/vsscanf.c (vsiscanf, _vsiscanf_r): Ditto. * libc/stdio/nano-vfprintf.c: New file. * libc/stdio/nano-vfprintf_float.c: New file. * libc/stdio/nano-vfprintf_i.c: New file. * libc/stdio/nano-vfprintf_local.h: New file. * libc/stdio/nano-vfscanf.c: New file. * libc/stdio/nano-vfscanf_float.c: New file. * libc/stdio/nano-vfscanf_i.c: New file. * libc/stdio/nano-vfscanf_local.h: New file.
2014-07-04 19:21:45 +02:00
#ifdef _NANO_FORMATTED_IO
int
_EXFUN(_vasiprintf_r, (struct _reent *, char **, const char *, __VALIST)
_ATTRIBUTE ((__alias__("_vasprintf_r"))));
#endif