2000-02-18 03:39:52 +08:00
|
|
|
/*
|
2007-03-15 Eric Blake <ebb9@byu.net>
* libc/stdio/local.h (cantwrite, FREEUB, FREELB): Make reentrant.
(__smakebuf): Rename...
(__smakebuf_r): to this.
* libc/stdio/fvwrite.h (__swsetup_r): Rename, from __swsetup.
* libc/stdio/makebuf.c (__smakebuf): Detect failed asprint
allocation, then rename...
(__smakebuf_r): ...to this and fix reentrancy.
* libc/stdio/wsetup.c (__swsetup): Detect failed asprintf
allocation, then rename...
(__swsetup_r): ...to this and fix reentrancy.
* libc/stdio/fseek.c (_fseek_r): Fix reentrancy.
* libc/stdio/refill.c (__srefill_r): Likewise.
* libc/stdio/fclose.c (_fclose_r): Likewise.
* libc/stdio/fread.c (_fread_r): Likewise.
* libc/stdio/freopen.c (_freopen_r): Likewise.
* libc/stdio/wbuf.c (__swbuf_r): Likewise.
* libc/stdio64/fseeko64.c (_fseeko64_r): Likewise.
* libc/stdio/fvwrite.c (__sfvwrite_r): Set errno properly on
failed asprintf allocation, and fix reentrancy.
* libc/stdio/snprintf.c (snprintf, _snprintf_r): Report overflow,
as required by POSIX.
* libc/stdio/sniprintf.c (sniprintf, _sniprintf_r): Likewise.
* libc/stdio/vsnprintf.c (vsnprintf, _vsnprintf_r): Likewise.
* libc/stdio/vsniprintf.c (vsniprintf, _vsniprintf_r): Likewise.
2007-03-16 02:40:48 +08:00
|
|
|
* Copyright (c) 1990, 2007 The Regents of the University of California.
|
2000-02-18 03:39:52 +08:00
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* %W% (UofMD/Berkeley) %G%
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Information local to this implementation of stdio,
|
|
|
|
* in particular, macros and private variables.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <_ansi.h>
|
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-24 04:01:55 +08:00
|
|
|
#include <reent.h>
|
2000-02-18 03:39:52 +08:00
|
|
|
#include <stdarg.h>
|
2004-09-25 00:03:46 +08:00
|
|
|
#include <stdlib.h>
|
2000-02-18 03:39:52 +08:00
|
|
|
#include <unistd.h>
|
Implement funopen, fopencookie.
* libc/include/sys/reent.h (struct __sFILE, struct __sFILE64):
Switch to reentrant callbacks.
* libc/include/stdio.h (funopen): Fix declaration.
(fopencookie): Declare.
* libc/stdio/local.h (__sread, __swrite, __sseek, __sclose)
(__sseek64, __swrite64): Fix prototypes.
[__SCLE]: Pull in setmode declaration.
* libc/stdio/stdio.c (__sread, __swrite, __sseek, __sclose): Fix
reentrancy.
* libc/stdio64/stdio64.c (__sseek64_r, __swrite64_r): Delete.
(__sseek64, __swrite64): Fix reentrancy.
* libc/stdio/fseek.c (_fseek_r): Account for overflow, and fix
reentrancy.
* libc/stdio/ftell.c (_ftell_r): Likewise.
* libc/stdio/flags.c (__sflags): Don't lose __SAPP on "a+".
* libc/stdio/fclose.c (_fclose_r): Fix reentrancy.
* libc/stdio/freopen.c (_freopen_r): Likewise.
* libc/stdio/fvwrite.c (__sfvwrite_r): Likewise.
* libc/stdio/refill.c (__srefill_r): Likewise.
* libc/stdio/siscanf.c (eofread): Likewise.
* libc/stdio/sscanf.c (eofread): Likewise.
* libc/stdio/vsiscanf.c (eofread1): Likewise.
* libc/stdio/vsscanf.c (eofread1): Likewise.
* libc/stdio64/freopen64.c (_freopen64_r): Likewise.
* libc/stdio64/fseeko64.c (_fseeko64_r): Likewise.
* libc/stdio64/ftello64.c (_ftello64_r): Likewise.
* libc/stdio/fflush.c (fflush): Improve reentrancy, although more
could be fixed.
* libc/stdio/fopencookie.c (_fopencookie_r, fopencookie): New file.
* libc/stdio/funopen.c (_funopen_r, funopen): New file.
* libc/stdio/Makefile.am (ELIX_4_SOURCES, CHEWOUT_FILES): Build
new files.
* libc/stdio/Makefile.in: Regenerate.
2007-06-05 02:10:17 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
#ifdef __SCLE
|
|
|
|
# include <io.h>
|
|
|
|
#endif
|
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
|
2008-12-11 Craig Howland <howland@LGSInnovations.com>
* libc/include/sys/lock.h: Add void cast to avoid "statement has no
effect" warnings from gcc.
* libc/include/sys/stdio.h: Ditto.
* libc/include/sys/time.h: Correct gettimeofday() prototype.
* libc/stdlib/__exp10.c: Add #include "std.h" for function prototype.
* libc/stdlib/__ten_mu.c: Ditto.
* libc/stdlib/std.h: Correct __exp10's ANSI prototype.
* libc/stdlib/ldtoa.c: Change eiisinf definition to ANSI form. (Are
already others in file without _ansi method, so did not bother.)
* libc/stdlib/system.c: Use _ansi forms for function prototypes and
definitions.
* libc/time/mktime.c: Ditto.
* libc/misc/__dprintf.c: Ditto.
* libc/include/stdio.h: Add function prototypes for _fgetc_r,
_fgetpos_r, _fsetpos_r, _freopen_r, _rewind_r, freopen64, _freopen64_r,
_funopen_r, and _fopencookie_r.
* libc/include/reent.h: Add function prototype for _stat64_r, align
_execve_r prototype with POSIX definition for execve.
* libc/reent/execr.c: Align function prototype with POSIX definition.
* libc/stdio/asniprintf.c: Add #include "local.h".
* libc/stdio/vasniprintf.c: Ditto.
* libc/stdio/fread.c: Remove unused variable newcount.
* libc/stdio/local.h: Add function prototype for __sccl.
* libc/stdio/open_memstream.c: Remove unused variable flags.
* libc/stdio/vfscanf.c: Proper prototyping for ccfn, remove prototype
for __sccl since now in local.h.
* libc/string/memcpy.c: Add #include <string.h> (for real and for
traditional synopsis), remove extraneous stddef.h and limits.h.
* libc/syscalls/sysclose.c: Add #include <unistd.h>.
* libc/syscalls/sysfork.c: Ditto.
* libc/syscalls/sysgetpid.c: Ditto.
* libc/syscalls/sysexecve.c: Add #include <unistd.h>, align function
prototype with POSIX definition.
* libc/syscalls/sysfstat.c: Add #include <sys/stat.h>.
* libc/syscalls/sysgettod.c: Correct sys/times.h to sys/time.h.
* libc/syscalls/syskill.c: Add #include <signal.h>.
* libc/syscalls/syslink.c: Add #include <unistd.h>, fix prototype.
* libc/syscalls/sysunlink.c: Ditto.
* libc/syscalls/sysstat.c: Add #include <sys/stat.h>, fix prototype.
* libc/syscalls/syswait.c: Add #include <sys/wait.h>, fix prototype.
2008-12-12 01:27:56 +08:00
|
|
|
extern u_char *_EXFUN(__sccl, (char *, u_char *fmt));
|
2001-04-21 06:50:51 +08:00
|
|
|
extern int _EXFUN(__svfscanf_r,(struct _reent *,FILE *, _CONST char *,va_list));
|
2008-04-15 05:14:55 +08:00
|
|
|
extern int _EXFUN(__ssvfscanf_r,(struct _reent *,FILE *, _CONST char *,va_list));
|
2004-11-24 08:45:41 +08:00
|
|
|
extern int _EXFUN(__svfiscanf_r,(struct _reent *,FILE *, _CONST char *,va_list));
|
2008-04-15 05:14:55 +08:00
|
|
|
extern int _EXFUN(__ssvfiscanf_r,(struct _reent *,FILE *, _CONST char *,va_list));
|
* libc/include/wchar.h (fwscanf, swscanf, vfwscanf, vswscanf, vwscanf,
wscanf): Declare.
(_fwscanf_r, _swscanf_r, _vfwscanf_r, _vswscanf_r, _vwscanf_r,
_wscanf_r): Declare.
* libc/stdio/Makefile.am: Add new wscanf files.
* libc/stdio/Makefile.in: Regenerate.
* libc/stdio/fwscanf.c: New file.
* libc/stdio/local.h (__svfwscanf_r, __ssvfwscanf_r, __svfiwscanf_r,
__ssvfiwscanf_r): Declare.
* libc/stdio/stdio.tex: Add new documentation references.
* libc/stdio/swscanf.c: New file.
* libc/stdio/vfwscanf.c: New file.
* libc/stdio/vswscanf.c: New file.
* libc/stdio/vwscanf.c: New file.
* libc/stdio/wscanf.c: New file.
* libc/stdio/vfscanf.c (_sungetc_r): Make externaly available. Only
define if INTEGER_ONLY is defined. Declare otherwise.
(__ssrefill_r): Ditto.
(_sfread_r): Ditto.
Remove static eofread/eofread1 functions and use __seofread
function instead, throughout.
* libc/stdio/local.h (__seofread): Declare.
* libc/stdio/stdio.c (__seofread): Define.
* libc/stdio/fgetwc.c (__fgetwc): Fix compiler warning.
* libc/stdio/fgetws.c (_fgetws_r): Ditto.
* libc/stdio/fread.c (_fread_r): Ditto.
* libc/stdio/vfprintf.c: Ditto.
* libc/stdio/vswprintf.c: Ditto.
2009-03-11 19:53:22 +08:00
|
|
|
extern int _EXFUN(__svfwscanf_r,(struct _reent *,FILE *, _CONST wchar_t *,va_list));
|
|
|
|
extern int _EXFUN(__ssvfwscanf_r,(struct _reent *,FILE *, _CONST wchar_t *,va_list));
|
|
|
|
extern int _EXFUN(__svfiwscanf_r,(struct _reent *,FILE *, _CONST wchar_t *,va_list));
|
|
|
|
extern int _EXFUN(__ssvfiwscanf_r,(struct _reent *,FILE *, _CONST wchar_t *,va_list));
|
2008-04-15 05:14:55 +08:00
|
|
|
int _EXFUN(_svfprintf_r,(struct _reent *, FILE *, const char *,
|
|
|
|
va_list)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 3, 0))));
|
|
|
|
int _EXFUN(_svfiprintf_r,(struct _reent *, FILE *, const char *,
|
|
|
|
va_list)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 3, 0))));
|
* libc/include/stdio.h (__VALIST): Guard against multiple definition.
* libc/include/wchar.h: Include stdarg.h.
(__VALIST): Define conditionally.
(fwprintf, swprintf, vfwprintf, vswprintf, vwprintf, wprintf: Declare.
(_fwprintf_r, _swprintf_r, _vfwprintf_r, _vswprintf_r, _vwprintf_r,
_wprintf_r): Declare.
* libc/stdio/Makefile.am: Add new files.
* libc/stdio/Makefile.in: Regenerate.
* libc/stdio/fwprintf.c: New file.
* libc/stdio/local.h (_svfwprintf_r, _svfiwprintf_r): Declare.
(__CH_CLASS, __STATE, __ACTION): Move definition from vfprintf.c here
and move to the __ namespace.
(__chclass, __state_table, __action_table): Declare.
* libc/stdio/stdio.tex: Add new documentation references.
* libc/stdio/swprintf.c: New file.
* libc/stdio/vfprintf.c (__SPRINT): New macro to call the right
__sprint_r function according to compilation unit. Use throughout.
(__ssprint_r): Rename STRING_ONLY variant from __sprint_r.
Make externaly available. Only define if INTEGER_ONLY is defined.
(__sprint_r): Make externaly available. Only define if INTEGER_ONLY
is defined. Handle stream orientation.
(__sbprintf): Copy FILE's _flags2 member as well.
(__chclass, __state_table, __action_table): Prepend __ to name and
make externally available.
* libc/stdio/vfwprintf.c: New file.
* libc/stdio/vswprintf.c: New file.
* libc/stdio/vwprintf.c: New file.
* libc/stdio/wprintf.c: New file.
2009-03-06 17:55:52 +08:00
|
|
|
int _EXFUN(_svfwprintf_r,(struct _reent *, FILE *, const wchar_t *,
|
|
|
|
va_list));
|
|
|
|
int _EXFUN(_svfiwprintf_r,(struct _reent *, FILE *, const wchar_t *,
|
|
|
|
va_list));
|
2000-02-18 03:39:52 +08:00
|
|
|
extern FILE *_EXFUN(__sfp,(struct _reent *));
|
|
|
|
extern int _EXFUN(__sflags,(struct _reent *,_CONST char*, int*));
|
2011-01-28 18:49:11 +08:00
|
|
|
extern int _EXFUN(__sflush_r,(struct _reent *,FILE *));
|
2006-06-15 04:49:11 +08:00
|
|
|
extern int _EXFUN(__srefill_r,(struct _reent *,FILE *));
|
Implement funopen, fopencookie.
* libc/include/sys/reent.h (struct __sFILE, struct __sFILE64):
Switch to reentrant callbacks.
* libc/include/stdio.h (funopen): Fix declaration.
(fopencookie): Declare.
* libc/stdio/local.h (__sread, __swrite, __sseek, __sclose)
(__sseek64, __swrite64): Fix prototypes.
[__SCLE]: Pull in setmode declaration.
* libc/stdio/stdio.c (__sread, __swrite, __sseek, __sclose): Fix
reentrancy.
* libc/stdio64/stdio64.c (__sseek64_r, __swrite64_r): Delete.
(__sseek64, __swrite64): Fix reentrancy.
* libc/stdio/fseek.c (_fseek_r): Account for overflow, and fix
reentrancy.
* libc/stdio/ftell.c (_ftell_r): Likewise.
* libc/stdio/flags.c (__sflags): Don't lose __SAPP on "a+".
* libc/stdio/fclose.c (_fclose_r): Fix reentrancy.
* libc/stdio/freopen.c (_freopen_r): Likewise.
* libc/stdio/fvwrite.c (__sfvwrite_r): Likewise.
* libc/stdio/refill.c (__srefill_r): Likewise.
* libc/stdio/siscanf.c (eofread): Likewise.
* libc/stdio/sscanf.c (eofread): Likewise.
* libc/stdio/vsiscanf.c (eofread1): Likewise.
* libc/stdio/vsscanf.c (eofread1): Likewise.
* libc/stdio64/freopen64.c (_freopen64_r): Likewise.
* libc/stdio64/fseeko64.c (_fseeko64_r): Likewise.
* libc/stdio64/ftello64.c (_ftello64_r): Likewise.
* libc/stdio/fflush.c (fflush): Improve reentrancy, although more
could be fixed.
* libc/stdio/fopencookie.c (_fopencookie_r, fopencookie): New file.
* libc/stdio/funopen.c (_funopen_r, funopen): New file.
* libc/stdio/Makefile.am (ELIX_4_SOURCES, CHEWOUT_FILES): Build
new files.
* libc/stdio/Makefile.in: Regenerate.
2007-06-05 02:10:17 +08:00
|
|
|
extern _READ_WRITE_RETURN_TYPE _EXFUN(__sread,(struct _reent *, void *, char *,
|
|
|
|
int));
|
* libc/include/wchar.h (fwscanf, swscanf, vfwscanf, vswscanf, vwscanf,
wscanf): Declare.
(_fwscanf_r, _swscanf_r, _vfwscanf_r, _vswscanf_r, _vwscanf_r,
_wscanf_r): Declare.
* libc/stdio/Makefile.am: Add new wscanf files.
* libc/stdio/Makefile.in: Regenerate.
* libc/stdio/fwscanf.c: New file.
* libc/stdio/local.h (__svfwscanf_r, __ssvfwscanf_r, __svfiwscanf_r,
__ssvfiwscanf_r): Declare.
* libc/stdio/stdio.tex: Add new documentation references.
* libc/stdio/swscanf.c: New file.
* libc/stdio/vfwscanf.c: New file.
* libc/stdio/vswscanf.c: New file.
* libc/stdio/vwscanf.c: New file.
* libc/stdio/wscanf.c: New file.
* libc/stdio/vfscanf.c (_sungetc_r): Make externaly available. Only
define if INTEGER_ONLY is defined. Declare otherwise.
(__ssrefill_r): Ditto.
(_sfread_r): Ditto.
Remove static eofread/eofread1 functions and use __seofread
function instead, throughout.
* libc/stdio/local.h (__seofread): Declare.
* libc/stdio/stdio.c (__seofread): Define.
* libc/stdio/fgetwc.c (__fgetwc): Fix compiler warning.
* libc/stdio/fgetws.c (_fgetws_r): Ditto.
* libc/stdio/fread.c (_fread_r): Ditto.
* libc/stdio/vfprintf.c: Ditto.
* libc/stdio/vswprintf.c: Ditto.
2009-03-11 19:53:22 +08:00
|
|
|
extern _READ_WRITE_RETURN_TYPE _EXFUN(__seofread,(struct _reent *, void *,
|
|
|
|
char *, int));
|
Implement funopen, fopencookie.
* libc/include/sys/reent.h (struct __sFILE, struct __sFILE64):
Switch to reentrant callbacks.
* libc/include/stdio.h (funopen): Fix declaration.
(fopencookie): Declare.
* libc/stdio/local.h (__sread, __swrite, __sseek, __sclose)
(__sseek64, __swrite64): Fix prototypes.
[__SCLE]: Pull in setmode declaration.
* libc/stdio/stdio.c (__sread, __swrite, __sseek, __sclose): Fix
reentrancy.
* libc/stdio64/stdio64.c (__sseek64_r, __swrite64_r): Delete.
(__sseek64, __swrite64): Fix reentrancy.
* libc/stdio/fseek.c (_fseek_r): Account for overflow, and fix
reentrancy.
* libc/stdio/ftell.c (_ftell_r): Likewise.
* libc/stdio/flags.c (__sflags): Don't lose __SAPP on "a+".
* libc/stdio/fclose.c (_fclose_r): Fix reentrancy.
* libc/stdio/freopen.c (_freopen_r): Likewise.
* libc/stdio/fvwrite.c (__sfvwrite_r): Likewise.
* libc/stdio/refill.c (__srefill_r): Likewise.
* libc/stdio/siscanf.c (eofread): Likewise.
* libc/stdio/sscanf.c (eofread): Likewise.
* libc/stdio/vsiscanf.c (eofread1): Likewise.
* libc/stdio/vsscanf.c (eofread1): Likewise.
* libc/stdio64/freopen64.c (_freopen64_r): Likewise.
* libc/stdio64/fseeko64.c (_fseeko64_r): Likewise.
* libc/stdio64/ftello64.c (_ftello64_r): Likewise.
* libc/stdio/fflush.c (fflush): Improve reentrancy, although more
could be fixed.
* libc/stdio/fopencookie.c (_fopencookie_r, fopencookie): New file.
* libc/stdio/funopen.c (_funopen_r, funopen): New file.
* libc/stdio/Makefile.am (ELIX_4_SOURCES, CHEWOUT_FILES): Build
new files.
* libc/stdio/Makefile.in: Regenerate.
2007-06-05 02:10:17 +08:00
|
|
|
extern _READ_WRITE_RETURN_TYPE _EXFUN(__swrite,(struct _reent *, void *,
|
|
|
|
const char *, int));
|
|
|
|
extern _fpos_t _EXFUN(__sseek,(struct _reent *, void *, _fpos_t, int));
|
|
|
|
extern int _EXFUN(__sclose,(struct _reent *, void *));
|
2000-05-24 07:51:54 +08:00
|
|
|
extern int _EXFUN(__stextmode,(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-24 04:01:55 +08:00
|
|
|
extern _VOID _EXFUN(__sinit,(struct _reent *));
|
|
|
|
extern _VOID _EXFUN(_cleanup_r,(struct _reent *));
|
2007-03-15 Eric Blake <ebb9@byu.net>
* libc/stdio/local.h (cantwrite, FREEUB, FREELB): Make reentrant.
(__smakebuf): Rename...
(__smakebuf_r): to this.
* libc/stdio/fvwrite.h (__swsetup_r): Rename, from __swsetup.
* libc/stdio/makebuf.c (__smakebuf): Detect failed asprint
allocation, then rename...
(__smakebuf_r): ...to this and fix reentrancy.
* libc/stdio/wsetup.c (__swsetup): Detect failed asprintf
allocation, then rename...
(__swsetup_r): ...to this and fix reentrancy.
* libc/stdio/fseek.c (_fseek_r): Fix reentrancy.
* libc/stdio/refill.c (__srefill_r): Likewise.
* libc/stdio/fclose.c (_fclose_r): Likewise.
* libc/stdio/fread.c (_fread_r): Likewise.
* libc/stdio/freopen.c (_freopen_r): Likewise.
* libc/stdio/wbuf.c (__swbuf_r): Likewise.
* libc/stdio64/fseeko64.c (_fseeko64_r): Likewise.
* libc/stdio/fvwrite.c (__sfvwrite_r): Set errno properly on
failed asprintf allocation, and fix reentrancy.
* libc/stdio/snprintf.c (snprintf, _snprintf_r): Report overflow,
as required by POSIX.
* libc/stdio/sniprintf.c (sniprintf, _sniprintf_r): Likewise.
* libc/stdio/vsnprintf.c (vsnprintf, _vsnprintf_r): Likewise.
* libc/stdio/vsniprintf.c (vsniprintf, _vsniprintf_r): Likewise.
2007-03-16 02:40:48 +08:00
|
|
|
extern _VOID _EXFUN(__smakebuf_r,(struct _reent *, FILE *));
|
2000-02-18 03:39:52 +08:00
|
|
|
extern int _EXFUN(_fwalk,(struct _reent *, int (*)(FILE *)));
|
2004-04-29 02:02:38 +08:00
|
|
|
extern int _EXFUN(_fwalk_reent,(struct _reent *, int (*)(struct _reent *, FILE *)));
|
2000-02-18 03:39:52 +08:00
|
|
|
struct _glue * _EXFUN(__sfmoreglue,(struct _reent *,int n));
|
2008-11-25 05:27:33 +08:00
|
|
|
extern int _EXFUN(__submore, (struct _reent *, FILE *));
|
2000-02-18 03:39:52 +08:00
|
|
|
|
2007-05-02 07:03:36 +08:00
|
|
|
#ifdef __LARGE64_FILES
|
Implement funopen, fopencookie.
* libc/include/sys/reent.h (struct __sFILE, struct __sFILE64):
Switch to reentrant callbacks.
* libc/include/stdio.h (funopen): Fix declaration.
(fopencookie): Declare.
* libc/stdio/local.h (__sread, __swrite, __sseek, __sclose)
(__sseek64, __swrite64): Fix prototypes.
[__SCLE]: Pull in setmode declaration.
* libc/stdio/stdio.c (__sread, __swrite, __sseek, __sclose): Fix
reentrancy.
* libc/stdio64/stdio64.c (__sseek64_r, __swrite64_r): Delete.
(__sseek64, __swrite64): Fix reentrancy.
* libc/stdio/fseek.c (_fseek_r): Account for overflow, and fix
reentrancy.
* libc/stdio/ftell.c (_ftell_r): Likewise.
* libc/stdio/flags.c (__sflags): Don't lose __SAPP on "a+".
* libc/stdio/fclose.c (_fclose_r): Fix reentrancy.
* libc/stdio/freopen.c (_freopen_r): Likewise.
* libc/stdio/fvwrite.c (__sfvwrite_r): Likewise.
* libc/stdio/refill.c (__srefill_r): Likewise.
* libc/stdio/siscanf.c (eofread): Likewise.
* libc/stdio/sscanf.c (eofread): Likewise.
* libc/stdio/vsiscanf.c (eofread1): Likewise.
* libc/stdio/vsscanf.c (eofread1): Likewise.
* libc/stdio64/freopen64.c (_freopen64_r): Likewise.
* libc/stdio64/fseeko64.c (_fseeko64_r): Likewise.
* libc/stdio64/ftello64.c (_ftello64_r): Likewise.
* libc/stdio/fflush.c (fflush): Improve reentrancy, although more
could be fixed.
* libc/stdio/fopencookie.c (_fopencookie_r, fopencookie): New file.
* libc/stdio/funopen.c (_funopen_r, funopen): New file.
* libc/stdio/Makefile.am (ELIX_4_SOURCES, CHEWOUT_FILES): Build
new files.
* libc/stdio/Makefile.in: Regenerate.
2007-06-05 02:10:17 +08:00
|
|
|
extern _fpos64_t _EXFUN(__sseek64,(struct _reent *, void *, _fpos64_t, int));
|
|
|
|
extern _READ_WRITE_RETURN_TYPE _EXFUN(__swrite64,(struct _reent *, void *,
|
|
|
|
const char *, int));
|
2007-05-02 07:03:36 +08:00
|
|
|
#endif
|
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
/* Called by the main entry point fns to ensure stdio has been initialized. */
|
|
|
|
|
2006-09-27 05:22:19 +08:00
|
|
|
#ifdef _REENT_SMALL
|
|
|
|
#define CHECK_INIT(ptr, fp) \
|
|
|
|
do \
|
|
|
|
{ \
|
|
|
|
if ((ptr) && !(ptr)->__sdidinit) \
|
|
|
|
__sinit (ptr); \
|
|
|
|
if ((fp) == (FILE *)&__sf_fake_stdin) \
|
2007-03-16 05:32:13 +08:00
|
|
|
(fp) = _stdin_r(ptr); \
|
2006-09-27 05:22:19 +08:00
|
|
|
else if ((fp) == (FILE *)&__sf_fake_stdout) \
|
2007-03-16 05:32:13 +08:00
|
|
|
(fp) = _stdout_r(ptr); \
|
2006-09-27 05:22:19 +08:00
|
|
|
else if ((fp) == (FILE *)&__sf_fake_stderr) \
|
2007-03-16 05:32:13 +08:00
|
|
|
(fp) = _stderr_r(ptr); \
|
2006-09-27 05:22:19 +08:00
|
|
|
} \
|
|
|
|
while (0)
|
|
|
|
#else /* !_REENT_SMALL */
|
|
|
|
#define CHECK_INIT(ptr, fp) \
|
|
|
|
do \
|
|
|
|
{ \
|
|
|
|
if ((ptr) && !(ptr)->__sdidinit) \
|
|
|
|
__sinit (ptr); \
|
|
|
|
} \
|
|
|
|
while (0)
|
|
|
|
#endif /* !_REENT_SMALL */
|
|
|
|
|
|
|
|
#define CHECK_STD_INIT(ptr) \
|
2004-09-17 05:30:51 +08:00
|
|
|
do \
|
|
|
|
{ \
|
2005-02-08 09:33:19 +08:00
|
|
|
if ((ptr) && !(ptr)->__sdidinit) \
|
|
|
|
__sinit (ptr); \
|
2004-09-17 05:30:51 +08:00
|
|
|
} \
|
2000-02-18 03:39:52 +08:00
|
|
|
while (0)
|
|
|
|
|
2011-06-14 11:56:05 +08:00
|
|
|
/* Return true and set errno and stream error flag iff the given FILE
|
|
|
|
cannot be written now. */
|
2000-02-18 03:39:52 +08:00
|
|
|
|
2007-03-15 Eric Blake <ebb9@byu.net>
* libc/stdio/local.h (cantwrite, FREEUB, FREELB): Make reentrant.
(__smakebuf): Rename...
(__smakebuf_r): to this.
* libc/stdio/fvwrite.h (__swsetup_r): Rename, from __swsetup.
* libc/stdio/makebuf.c (__smakebuf): Detect failed asprint
allocation, then rename...
(__smakebuf_r): ...to this and fix reentrancy.
* libc/stdio/wsetup.c (__swsetup): Detect failed asprintf
allocation, then rename...
(__swsetup_r): ...to this and fix reentrancy.
* libc/stdio/fseek.c (_fseek_r): Fix reentrancy.
* libc/stdio/refill.c (__srefill_r): Likewise.
* libc/stdio/fclose.c (_fclose_r): Likewise.
* libc/stdio/fread.c (_fread_r): Likewise.
* libc/stdio/freopen.c (_freopen_r): Likewise.
* libc/stdio/wbuf.c (__swbuf_r): Likewise.
* libc/stdio64/fseeko64.c (_fseeko64_r): Likewise.
* libc/stdio/fvwrite.c (__sfvwrite_r): Set errno properly on
failed asprintf allocation, and fix reentrancy.
* libc/stdio/snprintf.c (snprintf, _snprintf_r): Report overflow,
as required by POSIX.
* libc/stdio/sniprintf.c (sniprintf, _sniprintf_r): Likewise.
* libc/stdio/vsnprintf.c (vsnprintf, _vsnprintf_r): Likewise.
* libc/stdio/vsniprintf.c (vsniprintf, _vsniprintf_r): Likewise.
2007-03-16 02:40:48 +08:00
|
|
|
#define cantwrite(ptr, fp) \
|
2000-02-18 03:39:52 +08:00
|
|
|
((((fp)->_flags & __SWR) == 0 || (fp)->_bf._base == NULL) && \
|
2007-03-15 Eric Blake <ebb9@byu.net>
* libc/stdio/local.h (cantwrite, FREEUB, FREELB): Make reentrant.
(__smakebuf): Rename...
(__smakebuf_r): to this.
* libc/stdio/fvwrite.h (__swsetup_r): Rename, from __swsetup.
* libc/stdio/makebuf.c (__smakebuf): Detect failed asprint
allocation, then rename...
(__smakebuf_r): ...to this and fix reentrancy.
* libc/stdio/wsetup.c (__swsetup): Detect failed asprintf
allocation, then rename...
(__swsetup_r): ...to this and fix reentrancy.
* libc/stdio/fseek.c (_fseek_r): Fix reentrancy.
* libc/stdio/refill.c (__srefill_r): Likewise.
* libc/stdio/fclose.c (_fclose_r): Likewise.
* libc/stdio/fread.c (_fread_r): Likewise.
* libc/stdio/freopen.c (_freopen_r): Likewise.
* libc/stdio/wbuf.c (__swbuf_r): Likewise.
* libc/stdio64/fseeko64.c (_fseeko64_r): Likewise.
* libc/stdio/fvwrite.c (__sfvwrite_r): Set errno properly on
failed asprintf allocation, and fix reentrancy.
* libc/stdio/snprintf.c (snprintf, _snprintf_r): Report overflow,
as required by POSIX.
* libc/stdio/sniprintf.c (sniprintf, _sniprintf_r): Likewise.
* libc/stdio/vsnprintf.c (vsnprintf, _vsnprintf_r): Likewise.
* libc/stdio/vsniprintf.c (vsniprintf, _vsniprintf_r): Likewise.
2007-03-16 02:40:48 +08:00
|
|
|
__swsetup_r(ptr, fp))
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
/* Test whether the given stdio file has an active ungetc buffer;
|
|
|
|
release such a buffer, without restoring ordinary unread data. */
|
|
|
|
|
|
|
|
#define HASUB(fp) ((fp)->_ub._base != NULL)
|
2007-03-15 Eric Blake <ebb9@byu.net>
* libc/stdio/local.h (cantwrite, FREEUB, FREELB): Make reentrant.
(__smakebuf): Rename...
(__smakebuf_r): to this.
* libc/stdio/fvwrite.h (__swsetup_r): Rename, from __swsetup.
* libc/stdio/makebuf.c (__smakebuf): Detect failed asprint
allocation, then rename...
(__smakebuf_r): ...to this and fix reentrancy.
* libc/stdio/wsetup.c (__swsetup): Detect failed asprintf
allocation, then rename...
(__swsetup_r): ...to this and fix reentrancy.
* libc/stdio/fseek.c (_fseek_r): Fix reentrancy.
* libc/stdio/refill.c (__srefill_r): Likewise.
* libc/stdio/fclose.c (_fclose_r): Likewise.
* libc/stdio/fread.c (_fread_r): Likewise.
* libc/stdio/freopen.c (_freopen_r): Likewise.
* libc/stdio/wbuf.c (__swbuf_r): Likewise.
* libc/stdio64/fseeko64.c (_fseeko64_r): Likewise.
* libc/stdio/fvwrite.c (__sfvwrite_r): Set errno properly on
failed asprintf allocation, and fix reentrancy.
* libc/stdio/snprintf.c (snprintf, _snprintf_r): Report overflow,
as required by POSIX.
* libc/stdio/sniprintf.c (sniprintf, _sniprintf_r): Likewise.
* libc/stdio/vsnprintf.c (vsnprintf, _vsnprintf_r): Likewise.
* libc/stdio/vsniprintf.c (vsniprintf, _vsniprintf_r): Likewise.
2007-03-16 02:40:48 +08:00
|
|
|
#define FREEUB(ptr, fp) { \
|
2000-02-18 03:39:52 +08:00
|
|
|
if ((fp)->_ub._base != (fp)->_ubuf) \
|
2007-03-15 Eric Blake <ebb9@byu.net>
* libc/stdio/local.h (cantwrite, FREEUB, FREELB): Make reentrant.
(__smakebuf): Rename...
(__smakebuf_r): to this.
* libc/stdio/fvwrite.h (__swsetup_r): Rename, from __swsetup.
* libc/stdio/makebuf.c (__smakebuf): Detect failed asprint
allocation, then rename...
(__smakebuf_r): ...to this and fix reentrancy.
* libc/stdio/wsetup.c (__swsetup): Detect failed asprintf
allocation, then rename...
(__swsetup_r): ...to this and fix reentrancy.
* libc/stdio/fseek.c (_fseek_r): Fix reentrancy.
* libc/stdio/refill.c (__srefill_r): Likewise.
* libc/stdio/fclose.c (_fclose_r): Likewise.
* libc/stdio/fread.c (_fread_r): Likewise.
* libc/stdio/freopen.c (_freopen_r): Likewise.
* libc/stdio/wbuf.c (__swbuf_r): Likewise.
* libc/stdio64/fseeko64.c (_fseeko64_r): Likewise.
* libc/stdio/fvwrite.c (__sfvwrite_r): Set errno properly on
failed asprintf allocation, and fix reentrancy.
* libc/stdio/snprintf.c (snprintf, _snprintf_r): Report overflow,
as required by POSIX.
* libc/stdio/sniprintf.c (sniprintf, _sniprintf_r): Likewise.
* libc/stdio/vsnprintf.c (vsnprintf, _vsnprintf_r): Likewise.
* libc/stdio/vsniprintf.c (vsniprintf, _vsniprintf_r): Likewise.
2007-03-16 02:40:48 +08:00
|
|
|
_free_r(ptr, (char *)(fp)->_ub._base); \
|
2000-02-18 03:39:52 +08:00
|
|
|
(fp)->_ub._base = NULL; \
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Test for an fgetline() buffer. */
|
|
|
|
|
|
|
|
#define HASLB(fp) ((fp)->_lb._base != NULL)
|
2007-03-15 Eric Blake <ebb9@byu.net>
* libc/stdio/local.h (cantwrite, FREEUB, FREELB): Make reentrant.
(__smakebuf): Rename...
(__smakebuf_r): to this.
* libc/stdio/fvwrite.h (__swsetup_r): Rename, from __swsetup.
* libc/stdio/makebuf.c (__smakebuf): Detect failed asprint
allocation, then rename...
(__smakebuf_r): ...to this and fix reentrancy.
* libc/stdio/wsetup.c (__swsetup): Detect failed asprintf
allocation, then rename...
(__swsetup_r): ...to this and fix reentrancy.
* libc/stdio/fseek.c (_fseek_r): Fix reentrancy.
* libc/stdio/refill.c (__srefill_r): Likewise.
* libc/stdio/fclose.c (_fclose_r): Likewise.
* libc/stdio/fread.c (_fread_r): Likewise.
* libc/stdio/freopen.c (_freopen_r): Likewise.
* libc/stdio/wbuf.c (__swbuf_r): Likewise.
* libc/stdio64/fseeko64.c (_fseeko64_r): Likewise.
* libc/stdio/fvwrite.c (__sfvwrite_r): Set errno properly on
failed asprintf allocation, and fix reentrancy.
* libc/stdio/snprintf.c (snprintf, _snprintf_r): Report overflow,
as required by POSIX.
* libc/stdio/sniprintf.c (sniprintf, _sniprintf_r): Likewise.
* libc/stdio/vsnprintf.c (vsnprintf, _vsnprintf_r): Likewise.
* libc/stdio/vsniprintf.c (vsniprintf, _vsniprintf_r): Likewise.
2007-03-16 02:40:48 +08:00
|
|
|
#define FREELB(ptr, fp) { _free_r(ptr,(char *)(fp)->_lb._base); \
|
|
|
|
(fp)->_lb._base = NULL; }
|
2000-02-18 03:39:52 +08:00
|
|
|
|
2008-12-10 Corinna Vinschen <corinna@vinschen.de>
Implement basic wide char stdio functionality, based on FreeBSD.
* libc/include/stdio.h (__SORD): Define.
(__SWID): Define.
* libc/include/wchar.h: Add declarations for new wide char functions.
(getwc): Define as macro.
(getwchar): Ditto.
(putwc): Ditto.
(putwchar): Ditto.
* libc/include/sys/reent.h (struct __sFILE): Add _mbstate member.
(struct __sFILE64): Ditto.
* libc/stdio/Makefile.am (ELIX_4_SOURCES): Add fgetwc.c, fgetws.c,
fputwc.c, fputws.c, fwide.c, getwc.c, getwchar.c, putwc.c, putwchar.c
and ungetwc.c.
(CHEWOUT_FILES): Add fgetwc.def, fgetws.def, fputwc.def, fputws.def,
fwide.def, getwc.def, getwchar.def, putwc.def, putwchar.def and
ungetwc.def.
Add header dependency rules for the new files.
* libc/stdio/Makefile.in: Regenerate.
* libc/stdio/fgetwc.c: New file, implementing fgetwc and _fgetwc_r.
* libc/stdio/fgetws.c: New file, implementing fgetws and _fgetws_r.
* libc/stdio/findfp.c (std): Initialize FILE's _mbstate member.
(__sfmoreglue): Ditto.
* libc/stdio/fputs.c (_fputs_r): Set stream orientation.
* libc/stdio/fputwc.c: New file, implementing fputwc and _fputwc_r.
* libc/stdio/fputws.c: New file, implementing fputws and _fputws_r.
* libc/stdio/fread.c (_fread_r): Set stream orientation.
* libc/stdio/freopen.c (_freopen_r): Reset stream orientation. Reset
_mbstate.
* libc/stdio/fseek.c (_fseek_r): Reset _mbstate.
* libc/stdio/fwide.c: New file, implementing fwide and _fwide_r.
* libc/stdio/fwrite.c (_fwrite_r): Set stream orientation.
* libc/stdio/getwc.c: New file, implementing getwc and _getwc_r.
* libc/stdio/getwchar.c: New file, implementing getwchar and
_getwchar_r.
* libc/stdio/local.h (ORIENT): New macro.
* libc/stdio/puts.c (_puts_r): Set stream orientation.
* libc/stdio/putwc.c: New file, implementing putwc and _putwc_r.
* libc/stdio/putwchar.c: New file, implementing putwchar and
_putwchar_r.
* libc/stdio/refill.c (__srefill_r): Set stream orientation.
* libc/stdio/stdio.tex: Add documentation for new functions.
* libc/stdio/ungetc.c (_ungetc_r): Set stream orientation.
* libc/stdio/ungetwc.c: New file, implementing ungetwc and _ungetwc_r.
* libc/stdio/vfscanf.c (__SVFSCANF_R): Set stream orientation.
* libc/stdio/wbuf.c (__swbuf_r): Ditto.
2008-12-11 07:43:12 +08:00
|
|
|
/*
|
|
|
|
* Set the orientation for a stream. If o > 0, the stream has wide-
|
|
|
|
* orientation. If o < 0, the stream has byte-orientation.
|
|
|
|
*/
|
|
|
|
#define ORIENT(fp,ori) \
|
|
|
|
do \
|
|
|
|
{ \
|
|
|
|
if (!((fp)->_flags & __SORD)) \
|
|
|
|
{ \
|
|
|
|
(fp)->_flags |= __SORD; \
|
|
|
|
if (ori > 0) \
|
|
|
|
(fp)->_flags2 |= __SWID; \
|
|
|
|
else \
|
|
|
|
(fp)->_flags2 &= ~__SWID; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
while (0)
|
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
/* WARNING: _dcvt is defined in the stdlib directory, not here! */
|
|
|
|
|
|
|
|
char *_EXFUN(_dcvt,(struct _reent *, char *, double, int, int, char, int));
|
|
|
|
char *_EXFUN(_sicvt,(char *, short, char));
|
|
|
|
char *_EXFUN(_icvt,(char *, int, char));
|
|
|
|
char *_EXFUN(_licvt,(char *, long, char));
|
|
|
|
#ifdef __GNUC__
|
|
|
|
char *_EXFUN(_llicvt,(char *, long long, char));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define CVT_BUF_SIZE 128
|
|
|
|
|
|
|
|
#define NDYNAMIC 4 /* add four more whenever necessary */
|
2004-03-26 06:29:18 +08:00
|
|
|
|
|
|
|
#ifdef __SINGLE_THREAD__
|
|
|
|
#define __sfp_lock_acquire()
|
|
|
|
#define __sfp_lock_release()
|
2005-02-08 09:05:50 +08:00
|
|
|
#define __sinit_lock_acquire()
|
|
|
|
#define __sinit_lock_release()
|
2004-03-26 06:29:18 +08:00
|
|
|
#else
|
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-24 04:01:55 +08:00
|
|
|
_VOID _EXFUN(__sfp_lock_acquire,(_VOID));
|
|
|
|
_VOID _EXFUN(__sfp_lock_release,(_VOID));
|
2005-02-08 09:05:50 +08:00
|
|
|
_VOID _EXFUN(__sinit_lock_acquire,(_VOID));
|
|
|
|
_VOID _EXFUN(__sinit_lock_release,(_VOID));
|
2004-03-26 06:29:18 +08:00
|
|
|
#endif
|
* libc/include/stdio.h (__VALIST): Guard against multiple definition.
* libc/include/wchar.h: Include stdarg.h.
(__VALIST): Define conditionally.
(fwprintf, swprintf, vfwprintf, vswprintf, vwprintf, wprintf: Declare.
(_fwprintf_r, _swprintf_r, _vfwprintf_r, _vswprintf_r, _vwprintf_r,
_wprintf_r): Declare.
* libc/stdio/Makefile.am: Add new files.
* libc/stdio/Makefile.in: Regenerate.
* libc/stdio/fwprintf.c: New file.
* libc/stdio/local.h (_svfwprintf_r, _svfiwprintf_r): Declare.
(__CH_CLASS, __STATE, __ACTION): Move definition from vfprintf.c here
and move to the __ namespace.
(__chclass, __state_table, __action_table): Declare.
* libc/stdio/stdio.tex: Add new documentation references.
* libc/stdio/swprintf.c: New file.
* libc/stdio/vfprintf.c (__SPRINT): New macro to call the right
__sprint_r function according to compilation unit. Use throughout.
(__ssprint_r): Rename STRING_ONLY variant from __sprint_r.
Make externaly available. Only define if INTEGER_ONLY is defined.
(__sprint_r): Make externaly available. Only define if INTEGER_ONLY
is defined. Handle stream orientation.
(__sbprintf): Copy FILE's _flags2 member as well.
(__chclass, __state_table, __action_table): Prepend __ to name and
make externally available.
* libc/stdio/vfwprintf.c: New file.
* libc/stdio/vswprintf.c: New file.
* libc/stdio/vwprintf.c: New file.
* libc/stdio/wprintf.c: New file.
2009-03-06 17:55:52 +08:00
|
|
|
|
|
|
|
/* Types used in positional argument support in vfprinf/vfwprintf.
|
|
|
|
The implementation is char/wchar_t dependent but the class and state
|
|
|
|
tables are only defined once in vfprintf.c. */
|
|
|
|
typedef enum {
|
|
|
|
ZERO, /* '0' */
|
|
|
|
DIGIT, /* '1-9' */
|
|
|
|
DOLLAR, /* '$' */
|
|
|
|
MODFR, /* spec modifier */
|
|
|
|
SPEC, /* format specifier */
|
|
|
|
DOT, /* '.' */
|
|
|
|
STAR, /* '*' */
|
|
|
|
FLAG, /* format flag */
|
|
|
|
OTHER, /* all other chars */
|
|
|
|
MAX_CH_CLASS /* place-holder */
|
|
|
|
} __CH_CLASS;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
START, /* start */
|
|
|
|
SFLAG, /* seen a flag */
|
|
|
|
WDIG, /* seen digits in width area */
|
|
|
|
WIDTH, /* processed width */
|
|
|
|
SMOD, /* seen spec modifier */
|
|
|
|
SDOT, /* seen dot */
|
|
|
|
VARW, /* have variable width specifier */
|
|
|
|
VARP, /* have variable precision specifier */
|
|
|
|
PREC, /* processed precision */
|
|
|
|
VWDIG, /* have digits in variable width specification */
|
|
|
|
VPDIG, /* have digits in variable precision specification */
|
|
|
|
DONE, /* done */
|
|
|
|
MAX_STATE, /* place-holder */
|
|
|
|
} __STATE;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
NOOP, /* do nothing */
|
|
|
|
NUMBER, /* build a number from digits */
|
|
|
|
SKIPNUM, /* skip over digits */
|
|
|
|
GETMOD, /* get and process format modifier */
|
|
|
|
GETARG, /* get and process argument */
|
|
|
|
GETPW, /* get variable precision or width */
|
|
|
|
GETPWB, /* get variable precision or width and pushback fmt char */
|
|
|
|
GETPOS, /* get positional parameter value */
|
|
|
|
PWPOS, /* get positional parameter value for variable width or precision */
|
|
|
|
} __ACTION;
|
|
|
|
|
2009-04-22 16:30:03 +08:00
|
|
|
extern _CONST __CH_CLASS __chclass[256];
|
|
|
|
extern _CONST __STATE __state_table[MAX_STATE][MAX_CH_CLASS];
|
|
|
|
extern _CONST __ACTION __action_table[MAX_STATE][MAX_CH_CLASS];
|