newlib/newlib/libc/stdio/fprintf.c

65 lines
1.6 KiB
C
Raw Normal View History

2000-02-17 20:39:52 +01:00
/*
* Copyright (c) 1990 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,
* and/or other materials related to such
2000-02-17 20:39:52 +01:00
* 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.
*/
Add support for asnprintf, and improve *printf documentation. * libc/stdio/Makefile.am (ELIX_SOURCES): Rename... (ELIX_2_SOURCES): ...to this. (ELIX_4_SOURCES): Add new variable. Build asnprintf. (GENERAL_SOURCES): Move dprintf to ELIX_4_SOURCES. (CHEWOUT_FILES): Include diprintf in documentation. * libc/stdio/Makefile.in: Regenerate. * libc/stdio/diprintf.c: Improve documentation. * libc/stdio/dprintf.c: Likewise. * libc/stdio/siprintf.c: Likewise. * libc/stdio/sprintf.c: Likewise. * libc/stdio/vfprintf.c: Likewise. * libc/stdio/viprintf.c: Likewise. * libc/stdio/vsniprintf.c: Consolidate documentation. * libc/stdio/asiprintf.c: Refer to documentation. * libc/stdio/asprintf.c: Likewise. * libc/stdio/fiprintf.c: Likewise. * libc/stdio/fprintf.c: Likewise. * libc/stdio/iprintf.c: Likewise. * libc/stdio/printf.c: Likewise. * libc/stdio/sniprintf.c: Likewise. * libc/stdio/vdiprintf.c: Likewise. * libc/stdio/vdprintf.c: Likewise. * libc/stdio/vsiprintf.c: Likewise. * libc/stdio/fvwrite.c (__sfvwrite_r): Handle asnprintf. * libc/stdio/asniprintf.c (asniprintf, _asniprintf_r): New file. * libc/stdio/asnprintf.c (asnprintf, _asnprintf_r): New file. * libc/stdio/vasniprintf.c (vasniprintf, _vasniprintf_r): New file. * libc/stdio/vasnprintf.c (vasnprintf, _vasnprintf_r): New file. * libc/stdio/vdprintf.c (_vdprintf_r): Rewrite to avoid malloc in typical case. * libc/stdio/vdiprintf.c (_vdiprintf_r): Likewise. * libc/include/stdio.h: Add prototypes for new functions; sort existing functions.
2007-05-04 04:55:16 +02:00
/* doc in sprintf.c */
2000-02-17 20:39:52 +01:00
#include <_ansi.h>
#include <reent.h>
2000-02-17 20:39:52 +01:00
#include <stdio.h>
#include <stdarg.h>
int
_fprintf_r (struct _reent *ptr,
FILE *__restrict fp,
const char *__restrict fmt, ...)
{
int ret;
va_list ap;
va_start (ap, fmt);
ret = _vfprintf_r (ptr, fp, fmt, ap);
va_end (ap);
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
_fiprintf_r (struct _reent *, FILE *, const char *, ...)
_ATTRIBUTE ((__alias__("_fprintf_r")));
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
#endif
#ifndef _REENT_ONLY
2000-02-17 20:39:52 +01:00
int
fprintf (FILE *__restrict fp,
const char *__restrict fmt, ...)
2000-02-17 20:39:52 +01:00
{
int ret;
va_list ap;
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
va_start (ap, fmt);
ret = _vfprintf_r (_REENT, fp, fmt, ap);
2000-02-17 20:39:52 +01:00
va_end (ap);
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
fiprintf (FILE *, const char *, ...)
_ATTRIBUTE ((__alias__("fprintf")));
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
#endif
#endif /* ! _REENT_ONLY */