diff options
Diffstat (limited to 'newlib/libc/stdio')
-rw-r--r-- | newlib/libc/stdio/Makefile.am | 3 | ||||
-rw-r--r-- | newlib/libc/stdio/Makefile.in | 81 | ||||
-rw-r--r-- | newlib/libc/stdio/dprintf.c | 129 | ||||
-rw-r--r-- | newlib/libc/stdio/fflush.c | 12 | ||||
-rw-r--r-- | newlib/libc/stdio/freopen.c | 65 | ||||
-rw-r--r-- | newlib/libc/stdio/fseek.c | 7 | ||||
-rw-r--r-- | newlib/libc/stdio/getdelim.c | 8 | ||||
-rw-r--r-- | newlib/libc/stdio/getw.c | 7 | ||||
-rw-r--r-- | newlib/libc/stdio/putw.c | 5 | ||||
-rw-r--r-- | newlib/libc/stdio/siprintf.c | 3 | ||||
-rw-r--r-- | newlib/libc/stdio/siscanf.c | 8 | ||||
-rw-r--r-- | newlib/libc/stdio/sprintf.c | 3 | ||||
-rw-r--r-- | newlib/libc/stdio/sscanf.c | 10 | ||||
-rw-r--r-- | newlib/libc/stdio/stdio.tex | 4 | ||||
-rw-r--r-- | newlib/libc/stdio/vdprintf.c | 46 | ||||
-rw-r--r-- | newlib/libc/stdio/vfprintf.c | 46 | ||||
-rw-r--r-- | newlib/libc/stdio/vfscanf.c | 4 | ||||
-rw-r--r-- | newlib/libc/stdio/viprintf.c | 19 | ||||
-rw-r--r-- | newlib/libc/stdio/viscanf.c | 4 | ||||
-rw-r--r-- | newlib/libc/stdio/wsetup.c | 6 |
20 files changed, 95 insertions, 375 deletions
diff --git a/newlib/libc/stdio/Makefile.am b/newlib/libc/stdio/Makefile.am index 1ae643f4d..df147caf8 100644 --- a/newlib/libc/stdio/Makefile.am +++ b/newlib/libc/stdio/Makefile.am @@ -6,7 +6,6 @@ INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS) GENERAL_SOURCES = \ clearerr.c \ - dprintf.c \ fclose.c \ fdopen.c \ feof.c \ @@ -71,7 +70,6 @@ GENERAL_SOURCES = \ tmpfile.c \ tmpnam.c \ ungetc.c \ - vdprintf.c \ viprintf.c \ viscanf.c \ vprintf.c \ @@ -141,7 +139,6 @@ vfiscanf.$(oext): vfscanf.c CHEWOUT_FILES = \ clearerr.def \ - dprintf.def \ fclose.def \ fcloseall.def \ fdopen.def \ diff --git a/newlib/libc/stdio/Makefile.in b/newlib/libc/stdio/Makefile.in index 49827e332..952e3341b 100644 --- a/newlib/libc/stdio/Makefile.in +++ b/newlib/libc/stdio/Makefile.in @@ -110,7 +110,7 @@ AUTOMAKE_OPTIONS = cygnus INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS) -GENERAL_SOURCES = clearerr.c dprintf.c fclose.c fdopen.c feof.c ferror.c fflush.c fgetc.c fgetpos.c fgets.c fileno.c findfp.c fiprintf.c flags.c fopen.c fprintf.c fputc.c fputs.c fread.c freopen.c fscanf.c fiscanf.c fseek.c fsetpos.c ftell.c fvwrite.c fwalk.c fwrite.c getc.c getchar.c getc_u.c getchar_u.c getdelim.c getline.c gets.c iprintf.c iscanf.c makebuf.c perror.c printf.c putc.c putchar.c putc_u.c putchar_u.c puts.c refill.c remove.c rename.c rewind.c rget.c scanf.c sccl.c setbuf.c setbuffer.c setlinebuf.c setvbuf.c siprintf.c siscanf.c sniprintf.c snprintf.c sprintf.c sscanf.c stdio.c tmpfile.c tmpnam.c ungetc.c vdprintf.c viprintf.c viscanf.c vprintf.c vscanf.c vsiprintf.c vsiscanf.c vsnprintf.c vsniprintf.c vsprintf.c vsscanf.c wbuf.c wsetup.c +GENERAL_SOURCES = clearerr.c fclose.c fdopen.c feof.c ferror.c fflush.c fgetc.c fgetpos.c fgets.c fileno.c findfp.c fiprintf.c flags.c fopen.c fprintf.c fputc.c fputs.c fread.c freopen.c fscanf.c fiscanf.c fseek.c fsetpos.c ftell.c fvwrite.c fwalk.c fwrite.c getc.c getchar.c getc_u.c getchar_u.c getdelim.c getline.c gets.c iprintf.c iscanf.c makebuf.c perror.c printf.c putc.c putchar.c putc_u.c putchar_u.c puts.c refill.c remove.c rename.c rewind.c rget.c scanf.c sccl.c setbuf.c setbuffer.c setlinebuf.c setvbuf.c siprintf.c siscanf.c sniprintf.c snprintf.c sprintf.c sscanf.c stdio.c tmpfile.c tmpnam.c ungetc.c viprintf.c viscanf.c vprintf.c vscanf.c vsiprintf.c vsiscanf.c vsnprintf.c vsniprintf.c vsprintf.c vsscanf.c wbuf.c wsetup.c @ELIX_LEVEL_1_TRUE@LIB_OBJS = @ELIX_LEVEL_1_FALSE@LIB_OBJS = asiprintf.$(oext) asprintf.$(oext) fcloseall.$(oext) fseeko.$(oext) ftello.$(oext) getw.$(oext) mktemp.$(oext) putw.$(oext) vasiprintf.$(oext) vasprintf.$(oext) @@ -132,7 +132,7 @@ libstdio_la_LDFLAGS = -Xcompiler -nostdlib @USE_LIBTOOL_FALSE@lib_a_LIBADD = $(LIBADD_OBJS) $(LIB_OBJS) @USE_LIBTOOL_FALSE@lib_a_DEPENDENCIES = $(LIBADD_OBJS) $(LIB_OBJS) -CHEWOUT_FILES = clearerr.def dprintf.def fclose.def fcloseall.def fdopen.def feof.def ferror.def fflush.def fgetc.def fgetpos.def fgets.def fileno.def fiprintf.def fopen.def fputc.def fputs.def fread.def freopen.def fseek.def fsetpos.def ftell.def fwrite.def getc.def getchar.def getc_u.def getchar_u.def getdelim.def getline.def gets.def getw.def mktemp.def perror.def putc.def putchar.def putc_u.def putchar_u.def puts.def putw.def remove.def rename.def rewind.def setbuf.def setbuffer.def setlinebuf.def setvbuf.def siprintf.def siscanf.def sprintf.def sscanf.def tmpfile.def tmpnam.def vfprintf.def vfscanf.def viprintf.def viscanf.def +CHEWOUT_FILES = clearerr.def fclose.def fcloseall.def fdopen.def feof.def ferror.def fflush.def fgetc.def fgetpos.def fgets.def fileno.def fiprintf.def fopen.def fputc.def fputs.def fread.def freopen.def fseek.def fsetpos.def ftell.def fwrite.def getc.def getchar.def getc_u.def getchar_u.def getdelim.def getline.def gets.def getw.def mktemp.def perror.def putc.def putchar.def putc_u.def putchar_u.def puts.def putw.def remove.def rename.def rewind.def setbuf.def setbuffer.def setlinebuf.def setvbuf.def siprintf.def siscanf.def sprintf.def sscanf.def tmpfile.def tmpnam.def vfprintf.def vfscanf.def viprintf.def viscanf.def SUFFIXES = .def @@ -150,56 +150,55 @@ LIBRARIES = $(noinst_LIBRARIES) DEFS = @DEFS@ -I. -I$(srcdir) CPPFLAGS = @CPPFLAGS@ LIBS = @LIBS@ -@USE_LIBTOOL_FALSE@lib_a_OBJECTS = clearerr.$(OBJEXT) dprintf.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@fclose.$(OBJEXT) fdopen.$(OBJEXT) feof.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@ferror.$(OBJEXT) fflush.$(OBJEXT) fgetc.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@fgetpos.$(OBJEXT) fgets.$(OBJEXT) fileno.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@findfp.$(OBJEXT) fiprintf.$(OBJEXT) flags.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@fopen.$(OBJEXT) fprintf.$(OBJEXT) fputc.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@fputs.$(OBJEXT) fread.$(OBJEXT) freopen.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@fscanf.$(OBJEXT) fiscanf.$(OBJEXT) fseek.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@fsetpos.$(OBJEXT) ftell.$(OBJEXT) fvwrite.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@fwalk.$(OBJEXT) fwrite.$(OBJEXT) getc.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@getchar.$(OBJEXT) getc_u.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@getchar_u.$(OBJEXT) getdelim.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@getline.$(OBJEXT) gets.$(OBJEXT) iprintf.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@iscanf.$(OBJEXT) makebuf.$(OBJEXT) perror.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@printf.$(OBJEXT) putc.$(OBJEXT) putchar.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@putc_u.$(OBJEXT) putchar_u.$(OBJEXT) puts.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@refill.$(OBJEXT) remove.$(OBJEXT) rename.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@rewind.$(OBJEXT) rget.$(OBJEXT) scanf.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@sccl.$(OBJEXT) setbuf.$(OBJEXT) setbuffer.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@lib_a_OBJECTS = clearerr.$(OBJEXT) fclose.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@fdopen.$(OBJEXT) feof.$(OBJEXT) ferror.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@fflush.$(OBJEXT) fgetc.$(OBJEXT) fgetpos.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@fgets.$(OBJEXT) fileno.$(OBJEXT) findfp.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@fiprintf.$(OBJEXT) flags.$(OBJEXT) fopen.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@fprintf.$(OBJEXT) fputc.$(OBJEXT) fputs.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@fread.$(OBJEXT) freopen.$(OBJEXT) fscanf.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@fiscanf.$(OBJEXT) fseek.$(OBJEXT) fsetpos.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@ftell.$(OBJEXT) fvwrite.$(OBJEXT) fwalk.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@fwrite.$(OBJEXT) getc.$(OBJEXT) getchar.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@getc_u.$(OBJEXT) getchar_u.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@getdelim.$(OBJEXT) getline.$(OBJEXT) gets.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@iprintf.$(OBJEXT) iscanf.$(OBJEXT) makebuf.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@perror.$(OBJEXT) printf.$(OBJEXT) putc.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@putchar.$(OBJEXT) putc_u.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@putchar_u.$(OBJEXT) puts.$(OBJEXT) refill.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@remove.$(OBJEXT) rename.$(OBJEXT) rewind.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@rget.$(OBJEXT) scanf.$(OBJEXT) sccl.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@setbuf.$(OBJEXT) setbuffer.$(OBJEXT) \ @USE_LIBTOOL_FALSE@setlinebuf.$(OBJEXT) setvbuf.$(OBJEXT) \ @USE_LIBTOOL_FALSE@siprintf.$(OBJEXT) siscanf.$(OBJEXT) \ @USE_LIBTOOL_FALSE@sniprintf.$(OBJEXT) snprintf.$(OBJEXT) \ @USE_LIBTOOL_FALSE@sprintf.$(OBJEXT) sscanf.$(OBJEXT) stdio.$(OBJEXT) \ @USE_LIBTOOL_FALSE@tmpfile.$(OBJEXT) tmpnam.$(OBJEXT) ungetc.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@vdprintf.$(OBJEXT) viprintf.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@viscanf.$(OBJEXT) vprintf.$(OBJEXT) vscanf.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@viprintf.$(OBJEXT) viscanf.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@vprintf.$(OBJEXT) vscanf.$(OBJEXT) \ @USE_LIBTOOL_FALSE@vsiprintf.$(OBJEXT) vsiscanf.$(OBJEXT) \ @USE_LIBTOOL_FALSE@vsnprintf.$(OBJEXT) vsniprintf.$(OBJEXT) \ @USE_LIBTOOL_FALSE@vsprintf.$(OBJEXT) vsscanf.$(OBJEXT) wbuf.$(OBJEXT) \ @USE_LIBTOOL_FALSE@wsetup.$(OBJEXT) LTLIBRARIES = $(noinst_LTLIBRARIES) -@USE_LIBTOOL_TRUE@libstdio_la_OBJECTS = clearerr.lo dprintf.lo \ -@USE_LIBTOOL_TRUE@fclose.lo fdopen.lo feof.lo ferror.lo fflush.lo \ -@USE_LIBTOOL_TRUE@fgetc.lo fgetpos.lo fgets.lo fileno.lo findfp.lo \ -@USE_LIBTOOL_TRUE@fiprintf.lo flags.lo fopen.lo fprintf.lo fputc.lo \ -@USE_LIBTOOL_TRUE@fputs.lo fread.lo freopen.lo fscanf.lo fiscanf.lo \ -@USE_LIBTOOL_TRUE@fseek.lo fsetpos.lo ftell.lo fvwrite.lo fwalk.lo \ -@USE_LIBTOOL_TRUE@fwrite.lo getc.lo getchar.lo getc_u.lo getchar_u.lo \ -@USE_LIBTOOL_TRUE@getdelim.lo getline.lo gets.lo iprintf.lo iscanf.lo \ -@USE_LIBTOOL_TRUE@makebuf.lo perror.lo printf.lo putc.lo putchar.lo \ -@USE_LIBTOOL_TRUE@putc_u.lo putchar_u.lo puts.lo refill.lo remove.lo \ -@USE_LIBTOOL_TRUE@rename.lo rewind.lo rget.lo scanf.lo sccl.lo \ -@USE_LIBTOOL_TRUE@setbuf.lo setbuffer.lo setlinebuf.lo setvbuf.lo \ -@USE_LIBTOOL_TRUE@siprintf.lo siscanf.lo sniprintf.lo snprintf.lo \ -@USE_LIBTOOL_TRUE@sprintf.lo sscanf.lo stdio.lo tmpfile.lo tmpnam.lo \ -@USE_LIBTOOL_TRUE@ungetc.lo vdprintf.lo viprintf.lo viscanf.lo \ -@USE_LIBTOOL_TRUE@vprintf.lo vscanf.lo vsiprintf.lo vsiscanf.lo \ -@USE_LIBTOOL_TRUE@vsnprintf.lo vsniprintf.lo vsprintf.lo vsscanf.lo \ -@USE_LIBTOOL_TRUE@wbuf.lo wsetup.lo +@USE_LIBTOOL_TRUE@libstdio_la_OBJECTS = clearerr.lo fclose.lo fdopen.lo \ +@USE_LIBTOOL_TRUE@feof.lo ferror.lo fflush.lo fgetc.lo fgetpos.lo \ +@USE_LIBTOOL_TRUE@fgets.lo fileno.lo findfp.lo fiprintf.lo flags.lo \ +@USE_LIBTOOL_TRUE@fopen.lo fprintf.lo fputc.lo fputs.lo fread.lo \ +@USE_LIBTOOL_TRUE@freopen.lo fscanf.lo fiscanf.lo fseek.lo fsetpos.lo \ +@USE_LIBTOOL_TRUE@ftell.lo fvwrite.lo fwalk.lo fwrite.lo getc.lo \ +@USE_LIBTOOL_TRUE@getchar.lo getc_u.lo getchar_u.lo getdelim.lo \ +@USE_LIBTOOL_TRUE@getline.lo gets.lo iprintf.lo iscanf.lo makebuf.lo \ +@USE_LIBTOOL_TRUE@perror.lo printf.lo putc.lo putchar.lo putc_u.lo \ +@USE_LIBTOOL_TRUE@putchar_u.lo puts.lo refill.lo remove.lo rename.lo \ +@USE_LIBTOOL_TRUE@rewind.lo rget.lo scanf.lo sccl.lo setbuf.lo \ +@USE_LIBTOOL_TRUE@setbuffer.lo setlinebuf.lo setvbuf.lo siprintf.lo \ +@USE_LIBTOOL_TRUE@siscanf.lo sniprintf.lo snprintf.lo sprintf.lo \ +@USE_LIBTOOL_TRUE@sscanf.lo stdio.lo tmpfile.lo tmpnam.lo ungetc.lo \ +@USE_LIBTOOL_TRUE@viprintf.lo viscanf.lo vprintf.lo vscanf.lo \ +@USE_LIBTOOL_TRUE@vsiprintf.lo vsiscanf.lo vsnprintf.lo vsniprintf.lo \ +@USE_LIBTOOL_TRUE@vsprintf.lo vsscanf.lo wbuf.lo wsetup.lo CFLAGS = @CFLAGS@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) diff --git a/newlib/libc/stdio/dprintf.c b/newlib/libc/stdio/dprintf.c deleted file mode 100644 index 6ebf12e8d..000000000 --- a/newlib/libc/stdio/dprintf.c +++ /dev/null @@ -1,129 +0,0 @@ -/* Copyright 2005 Shaun Jackman - * Permission to use, copy, modify, and distribute this software - * is freely granted, provided that this notice is preserved. - */ - -/* -FUNCTION -<<dprintf>>, <<vdprintf>>---print to a file descriptor - -INDEX - dprintf -INDEX - vdprintf - -ANSI_SYNOPSIS - #include <stdio.h> - #include <stdarg.h> - int dprintf(int <[fd]>, const char *<[format]>, ...); - int vdprintf(int <[fd]>, const char *<[format]>, va_list <[ap]>); - int _dprintf_r(struct _reent *<[ptr]>, int <[fd]>, - const char *<[format]>, ...); - int _vdprintf_r(struct _reent *<[ptr]>, int <[fd]>, - const char *<[format]>, va_list <[ap]>); - -TRAD_SYNOPSIS - #include <stdio.h> - #include <varargs.h> - - int dprintf(<[fd]>, <[format]> [, <[arg]>, ...]) - int <[fd]>; - char *<[format]>; - - int vdprintf(<[fd]>, <[fmt]>, <[list]>) - int <[fd]>; - char *<[fmt]>; - va_list <[list]>; - - int _dprintf_r(<[ptr]>, <[fd]>, <[format]> [, <[arg]>, ...]) - struct _reent *<[ptr]>; - int <[fd]>; - char *<[format]>; - - int _vdprintf_r(<[ptr]>, <[fd]>, <[fmt]>, <[list]>) - struct _reent *<[ptr]>; - int <[fd]>; - char *<[fmt]>; - va_list <[list]>; - -DESCRIPTION -<<dprintf>> and <<vdprintf>> allow printing a format, similarly to -<<printf>>, but write to a file descriptor instead of to a <<FILE>> -stream. - -The functions <<_dprintf_r>> and <<_vdprintf_r>> are simply -reentrant versions of the functions above. - -RETURNS -The return value and errors are exactly as for <<write>>, except that -<<errno>> may also be set to <<ENOMEM>> if the heap is exhausted. - -PORTABILITY -This function is originally a GNU extension in glibc and is not portable. - -Supporting OS subroutines required: <<sbrk>>, <<write>>. -*/ - -#include <_ansi.h> -#include <reent.h> -#include <stdio.h> -#include <unistd.h> -#ifdef _HAVE_STDC -#include <stdarg.h> -#else -#include <varargs.h> -#endif - -#ifdef _HAVE_STDC -int -_dprintf_r(struct _reent *ptr, int fd, _CONST char *format, ...) -#else -int -_dprintf_r(ptr, fd, format, va_alist) - struct _reent *ptr; - int fd; - char *format; - va_dcl -#endif -{ - va_list ap; - int n; - _REENT_SMALL_CHECK_INIT (ptr); -#ifdef _HAVE_STDC - va_start (ap, format); -#else - va_start (ap); -#endif - n = _vdprintf_r (ptr, fd, format, ap); - va_end (ap); - return n; -} - -#ifndef _REENT_ONLY - -#ifdef _HAVE_STDC -int -dprintf(int fd, _CONST char *format, ...) -#else -int -dprintf(fd, format, va_alist) - struct _reent *ptr; - int fd; - char *format; - va_dcl -#endif -{ - va_list ap; - int n; - _REENT_SMALL_CHECK_INIT (_REENT); -#ifdef _HAVE_STDC - va_start (ap, format); -#else - va_start (ap); -#endif - n = _vdprintf_r (_REENT, fd, format, ap); - va_end (ap); - return n; -} - -#endif /* ! _REENT_ONLY */ diff --git a/newlib/libc/stdio/fflush.c b/newlib/libc/stdio/fflush.c index 05084dde0..b417e5424 100644 --- a/newlib/libc/stdio/fflush.c +++ b/newlib/libc/stdio/fflush.c @@ -72,18 +72,8 @@ _DEFUN(fflush, (fp), _flockfile (fp); t = fp->_flags; - if ((t & __SWR) == 0) + if ((t & __SWR) == 0 || (p = fp->_bf._base) == NULL) { - /* For a read stream, an fflush causes the next seek to be - unoptimized (i.e. forces a system-level seek). This conforms - to the POSIX and SUSv3 standards. */ - fp->_flags |= __SNPT; - _funlockfile (fp); - return 0; - } - if ((p = fp->_bf._base) == NULL) - { - /* Nothing to flush. */ _funlockfile (fp); return 0; } diff --git a/newlib/libc/stdio/freopen.c b/newlib/libc/stdio/freopen.c index ae3444b1b..995100b27 100644 --- a/newlib/libc/stdio/freopen.c +++ b/newlib/libc/stdio/freopen.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1990, 2006 The Regents of the University of California. + * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted @@ -55,12 +55,6 @@ it). <[file]> and <[mode]> are used just as in <<fopen>>. -If <[file]> is <<NULL>>, the underlying stream is modified rather than -closed. The file cannot be given a more permissive access mode (for -example, a <[mode]> of "w" will fail on a read-only file descriptor), -but can change status such as append or binary mode. If modification -is not possible, failure occurs. - RETURNS If successful, the result is the same as the argument <[fp]>. If the file cannot be opened as specified, the result is <<NULL>>. @@ -76,7 +70,6 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, #include <reent.h> #include <time.h> #include <stdio.h> -#include <errno.h> #include <fcntl.h> #include <stdlib.h> #include <sys/lock.h> @@ -94,8 +87,7 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp), register FILE *fp) { register int f; - int flags, oflags; - int e = 0; + int flags, oflags, e; __sfp_lock_acquire (); @@ -125,60 +117,17 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp), { if (fp->_flags & __SWR) _CAST_VOID fflush (fp); - /* - * If close is NULL, closing is a no-op, hence pointless. - * If file is NULL, the file should not be closed. - */ - if (fp->_close != NULL && file != NULL) + /* if close is NULL, closing is a no-op, hence pointless */ + if (fp->_close != NULL) _CAST_VOID (*fp->_close) (fp->_cookie); } /* - * Now get a new descriptor to refer to the new file, or reuse the - * existing file descriptor if file is NULL. + * Now get a new descriptor to refer to the new file. */ - if (file != NULL) - { - f = _open_r (ptr, (char *) file, oflags, 0666); - e = ptr->_errno; - } - else - { -#ifdef HAVE_FCNTL - int oldflags; - /* - * Reuse the file descriptor, but only if the new access mode is - * equal or less permissive than the old. F_SETFL correctly - * ignores creation flags. - */ - f = fp->_file; - if ((oldflags = _fcntl_r (ptr, f, F_GETFL, 0)) == -1 - || ! ((oldflags & O_ACCMODE) == O_RDWR - || ((oldflags ^ oflags) & O_ACCMODE) == 0) - || _fcntl_r (ptr, f, F_SETFL, oflags) == -1) - f = -1; -#else - /* We cannot modify without fcntl support. */ - f = -1; -#endif - -#ifdef __SCLE - /* - * F_SETFL doesn't change textmode. Don't mess with modes of ttys. - */ - if (0 <= f && ! isatty (f) - && setmode (f, flags & (O_BINARY | O_TEXT)) == -1) - f = -1; -#endif - - if (f < 0) - { - e = EBADF; - if (fp->_close != NULL) - _CAST_VOID (*fp->_close) (fp->_cookie); - } - } + f = _open_r (ptr, (char *) file, oflags, 0666); + e = ptr->_errno; /* * Finish closing fp. Even if the open succeeded above, diff --git a/newlib/libc/stdio/fseek.c b/newlib/libc/stdio/fseek.c index 8b189ba17..2ad98551c 100644 --- a/newlib/libc/stdio/fseek.c +++ b/newlib/libc/stdio/fseek.c @@ -359,13 +359,6 @@ dumb: fp->_r = 0; /* fp->_w = 0; *//* unnecessary (I think...) */ fp->_flags &= ~__SEOF; - /* Reset no-optimization flag after successful seek. The - no-optimization flag may be set in the case of a read - stream that is flushed which by POSIX/SUSv3 standards, - means that a corresponding seek must not optimize. The - optimization is then allowed if no subsequent flush - is performed. */ - fp->_flags &= ~__SNPT; _funlockfile (fp); return 0; } diff --git a/newlib/libc/stdio/getdelim.c b/newlib/libc/stdio/getdelim.c index 0fdfb3add..dad8feeb2 100644 --- a/newlib/libc/stdio/getdelim.c +++ b/newlib/libc/stdio/getdelim.c @@ -1,7 +1,7 @@ /* Copyright 2002, Red Hat Inc. - all rights reserved */ /* FUNCTION -<<getdelim>>---read a line up to a specified line delimiter +<<getdelim>>---read a line up to a specified line delimeter INDEX getdelim @@ -21,16 +21,16 @@ TRAD_SYNOPSIS DESCRIPTION <<getdelim>> reads a file <[fp]> up to and possibly including a specified -delimiter <[delim]>. The line is read into a buffer pointed to +delimeter <[delim]>. The line is read into a buffer pointed to by <[bufptr]> and designated with size *<[n]>. If the buffer is not large enough, it will be dynamically grown by <<getdelim>>. As the buffer is grown, the pointer to the size <[n]> will be updated. RETURNS -<<getdelim>> returns <<-1>> if no characters were successfully read; +<<getdelim>> returns <<-1>> if no characters were successfully read, otherwise, it returns the number of bytes successfully read. -At end of file, the result is nonzero. +at end of file, the result is nonzero. PORTABILITY <<getdelim>> is a glibc extension. diff --git a/newlib/libc/stdio/getw.c b/newlib/libc/stdio/getw.c index 210c5939a..b5065bd53 100644 --- a/newlib/libc/stdio/getw.c +++ b/newlib/libc/stdio/getw.c @@ -37,15 +37,14 @@ to get the next word from the file or stream identified by <[fp]>. As a side effect, <<getw>> advances the file's current position indicator. -RETURNS -The next word (read as an <<int>>), unless there is no more -data or the host system reports a read error; in either of these +RETURNS The next word (read as an <<int>>), unless there is no more +data, or the host system reports a read error; in either of these situations, <<getw>> returns <<EOF>>. Since <<EOF>> is a valid <<int>>, you must use <<ferror>> or <<feof>> to distinguish these situations. PORTABILITY -<<getw>> is a remnant of K&R C; it is not part of any ISO C Standard. +<<getw>> is a remnant of K&R C, it is not part of any ISO C Standard. <<fread>> should be used instead. In fact, this implementation of <<getw>> is based upon <<fread>>. diff --git a/newlib/libc/stdio/putw.c b/newlib/libc/stdio/putw.c index 682015c0a..78406eeb4 100644 --- a/newlib/libc/stdio/putw.c +++ b/newlib/libc/stdio/putw.c @@ -37,11 +37,10 @@ DESCRIPTION to write a word to the file or stream identified by <[fp]>. As a side effect, <<putw>> advances the file's current position indicator. -RETURNS -Zero on success, <<EOF>> on failure. +RETURNS Zero on success, <<EOF>> on failure. PORTABILITY -<<putw>> is a remnant of K&R C; it is not part of any ISO C Standard. +<<putw>> is a remnant of K&R C, it is not part of any ISO C Standard. <<fwrite>> should be used instead. In fact, this implementation of <<putw>> is based upon <<fwrite>>. diff --git a/newlib/libc/stdio/siprintf.c b/newlib/libc/stdio/siprintf.c index 4e8e95aaa..18ba489b7 100644 --- a/newlib/libc/stdio/siprintf.c +++ b/newlib/libc/stdio/siprintf.c @@ -37,8 +37,7 @@ ANSI_SYNOPSIS int fiprintf(FILE *<[fd]>, const char *<[format]> [, <[arg]>, ...]); int siprintf(char *<[str]>, const char *<[format]> [, <[arg]>, ...]); int asiprintf(char **<[strp]>, const char *<[format]> [, <[arg]>, ...]); - int sniprintf(char *<[str]>, size_t <[size]>, const char *<[format]> - [, <[arg]>, ...]); + int sniprintf(char *<[str]>, size_t <[size]>, const char *<[format]> [, <[arg]>, ...]); TRAD_SYNOPSIS #include <stdio.h> diff --git a/newlib/libc/stdio/siscanf.c b/newlib/libc/stdio/siscanf.c index 694750dae..b87a5ea49 100644 --- a/newlib/libc/stdio/siscanf.c +++ b/newlib/libc/stdio/siscanf.c @@ -34,12 +34,10 @@ ANSI_SYNOPSIS int siscanf(const char *<[str]>, const char *<[format]> [, <[arg]>, ...]); - int _iscanf_r(struct _reent *<[ptr]>, const char *<[format]> + int _iscanf_r(struct _reent *<[ptr]>, const char *<[format]> [, <[arg]>, ...]); + int _fiscanf_r(struct _reent *<[ptr]>, FILE *<[fd]>, const char *<[format]> [, <[arg]>, ...]); + int _siscanf_r(struct _reent *<[ptr]>, const char *<[str]>, const char *<[format]> [, <[arg]>, ...]); - int _fiscanf_r(struct _reent *<[ptr]>, FILE *<[fd]>, const char *<[format]> - [, <[arg]>, ...]); - int _siscanf_r(struct _reent *<[ptr]>, const char *<[str]>, - const char *<[format]> [, <[arg]>, ...]); TRAD_SYNOPSIS diff --git a/newlib/libc/stdio/sprintf.c b/newlib/libc/stdio/sprintf.c index 346749a68..8ee530730 100644 --- a/newlib/libc/stdio/sprintf.c +++ b/newlib/libc/stdio/sprintf.c @@ -37,8 +37,7 @@ ANSI_SYNOPSIS int fprintf(FILE *<[fd]>, const char *<[format]> [, <[arg]>, ...]); int sprintf(char *<[str]>, const char *<[format]> [, <[arg]>, ...]); int asprintf(char **<[strp]>, const char *<[format]> [, <[arg]>, ...]); - int snprintf(char *<[str]>, size_t <[size]>, const char *<[format]> - [, <[arg]>, ...]); + int snprintf(char *<[str]>, size_t <[size]>, const char *<[format]> [, <[arg]>, ...]); TRAD_SYNOPSIS #include <stdio.h> diff --git a/newlib/libc/stdio/sscanf.c b/newlib/libc/stdio/sscanf.c index 5ad39d8b7..687f53edf 100644 --- a/newlib/libc/stdio/sscanf.c +++ b/newlib/libc/stdio/sscanf.c @@ -34,12 +34,10 @@ ANSI_SYNOPSIS int sscanf(const char *<[str]>, const char *<[format]> [, <[arg]>, ...]); - int _scanf_r(struct _reent *<[ptr]>, const char *<[format]> - [, <[arg]>, ...]); - int _fscanf_r(struct _reent *<[ptr]>, FILE *<[fd]>, const char *<[format]> - [, <[arg]>, ...]); - int _sscanf_r(struct _reent *<[ptr]>, const char *<[str]>, - const char *<[format]> [, <[arg]>, ...]); + int _scanf_r(struct _reent *<[ptr]>, const char *<[format]> [, <[arg]>, ...]); + int _fscanf_r(struct _reent *<[ptr]>, FILE *<[fd]>, const char *<[format]> [, <[arg]>, ...]); + int _sscanf_r(struct _reent *<[ptr]>, const char *<[str]>, const char *<[format]> + [, <[arg]>, ...]); TRAD_SYNOPSIS diff --git a/newlib/libc/stdio/stdio.tex b/newlib/libc/stdio/stdio.tex index 9c2ca0f5d..67be50374 100644 --- a/newlib/libc/stdio/stdio.tex +++ b/newlib/libc/stdio/stdio.tex @@ -25,7 +25,6 @@ structure. @menu * clearerr:: Clear file or stream error indicator -* dprintf:: Print to a file descriptor * fclose:: Close a file * fcloseall:: Close all files * feof:: Test for end of file @@ -84,9 +83,6 @@ structure. @include stdio/clearerr.def @page -@include stdio/dprintf.def - -@page @include stdio/fclose.def @page diff --git a/newlib/libc/stdio/vdprintf.c b/newlib/libc/stdio/vdprintf.c deleted file mode 100644 index acd193a13..000000000 --- a/newlib/libc/stdio/vdprintf.c +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright 2005 Shaun Jackman - * Permission to use, copy, modify, and distribute this software - * is freely granted, provided that this notice is preserved. - */ - -#include <_ansi.h> -#include <reent.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#ifdef _HAVE_STDC -#include <stdarg.h> -#else -#include <varargs.h> -#endif - -int -_DEFUN (_vdprintf_r, (ptr, fd, format, ap), - struct _reent *ptr _AND - int fd _AND - _CONST char *format _AND - va_list ap) -{ - char *p; - int n; - _REENT_SMALL_CHECK_INIT (ptr); - n = _vasprintf_r (ptr, &p, format, ap); - if (n == -1) return -1; - n = _write_r (ptr, fd, p, n); - _free_r (ptr, p); - return n; -} - -#ifndef _REENT_ONLY - -int -_DEFUN (vdprintf, (fd, format, ap), - int fd _AND - _CONST char *format _AND - va_list ap) -{ - _REENT_SMALL_CHECK_INIT (_REENT); - return _vdprintf_r (_REENT, fd, format, ap); -} - -#endif /* ! _REENT_ONLY */ diff --git a/newlib/libc/stdio/vfprintf.c b/newlib/libc/stdio/vfprintf.c index a8c1f9bca..c10fed8e9 100644 --- a/newlib/libc/stdio/vfprintf.c +++ b/newlib/libc/stdio/vfprintf.c @@ -54,19 +54,18 @@ ANSI_SYNOPSIS int vfprintf(FILE *<[fp]>, const char *<[fmt]>, va_list <[list]>); int vsprintf(char *<[str]>, const char *<[fmt]>, va_list <[list]>); int vasprintf(char **<[strp]>, const char *<[fmt]>, va_list <[list]>); - int vsnprintf(char *<[str]>, size_t <[size]>, const char *<[fmt]>, - va_list <[list]>); + int vsnprintf(char *<[str]>, size_t <[size]>, const char *<[fmt]>, va_list <[list]>); int _vprintf_r(struct _reent *<[reent]>, const char *<[fmt]>, va_list <[list]>); int _vfprintf_r(struct _reent *<[reent]>, FILE *<[fp]>, const char *<[fmt]>, va_list <[list]>); - int _vasprintf_r(struct _reent *<[reent]>, char **<[str]>, - const char *<[fmt]>, va_list <[list]>); - int _vsprintf_r(struct _reent *<[reent]>, char *<[str]>, - const char *<[fmt]>, va_list <[list]>); - int _vsnprintf_r(struct _reent *<[reent]>, char *<[str]>, size_t <[size]>, - const char *<[fmt]>, va_list <[list]>); + int _vasprintf_r(struct _reent *<[reent]>, char **<[str]>, const char *<[fmt]>, + va_list <[list]>); + int _vsprintf_r(struct _reent *<[reent]>, char *<[str]>, const char *<[fmt]>, + va_list <[list]>); + int _vsnprintf_r(struct _reent *<[reent]>, char *<[str]>, size_t <[size]>, const char *<[fmt]>, + va_list <[list]>); TRAD_SYNOPSIS #include <stdio.h> @@ -801,7 +800,6 @@ reswitch: switch (ch) { case 'e': case 'E': case 'f': - case 'F': case 'g': case 'G': if (prec == -1) { @@ -821,18 +819,12 @@ reswitch: switch (ch) { if (isinf (_fpvalue)) { if (_fpvalue < 0) sign = '-'; - if (ch == 'E' || ch == 'F' || ch == 'G') - cp = "INF"; - else - cp = "inf"; + cp = "Inf"; size = 3; break; } if (isnan (_fpvalue)) { - if (ch == 'E' || ch == 'F' || ch == 'G') - cp = "NAN"; - else - cp = "nan"; + cp = "NaN"; size = 3; break; } @@ -850,18 +842,12 @@ reswitch: switch (ch) { if (tmp == 2) { if (_fpvalue < 0) sign = '-'; - if (ch == 'E' || ch == 'F' || ch == 'G') - cp = "INF"; - else - cp = "inf"; + cp = "Inf"; size = 3; break; } if (tmp == 1) { - if (ch == 'E' || ch == 'F' || ch == 'G') - cp = "NAN"; - else - cp = "nan"; + cp = "NaN"; size = 3; break; } @@ -1274,11 +1260,7 @@ _DEFUN(cvt, (data, value, ndigits, flags, sign, decpt, ch, length), #ifdef _NO_LONGDBL union double_union tmp; #else - union - { - struct ldieee ieee; - _LONG_DOUBLE val; - } ld; + struct ldieee *ldptr; #endif if (ch == 'f') { @@ -1305,8 +1287,8 @@ _DEFUN(cvt, (data, value, ndigits, flags, sign, decpt, ch, length), digits = _dtoa_r (data, value, mode, ndigits, decpt, &dsgn, &rve); #else /* !_NO_LONGDBL */ - ld.val = value; - if (ld.ieee.sign) { /* this will check for < 0 and -0.0 */ + ldptr = (struct ldieee *)&value; + if (ldptr->sign) { /* this will check for < 0 and -0.0 */ value = -value; *sign = '-'; } else diff --git a/newlib/libc/stdio/vfscanf.c b/newlib/libc/stdio/vfscanf.c index 4788938c9..ae2581a3b 100644 --- a/newlib/libc/stdio/vfscanf.c +++ b/newlib/libc/stdio/vfscanf.c @@ -37,8 +37,8 @@ ANSI_SYNOPSIS va_list <[list]>); int _vfscanf_r(struct _reent *<[reent]>, FILE *<[fp]>, const char *<[fmt]>, va_list <[list]>); - int _vsscanf_r(struct _reent *<[reent]>, const char *<[str]>, - const char *<[fmt]>, va_list <[list]>); + int _vsscanf_r(struct _reent *<[reent]>, const char *<[str]>, const char *<[fmt]>, + va_list <[list]>); TRAD_SYNOPSIS #include <stdio.h> diff --git a/newlib/libc/stdio/viprintf.c b/newlib/libc/stdio/viprintf.c index cea96d3db..e70fa13f1 100644 --- a/newlib/libc/stdio/viprintf.c +++ b/newlib/libc/stdio/viprintf.c @@ -35,19 +35,18 @@ ANSI_SYNOPSIS int vfiprintf(FILE *<[fp]>, const char *<[fmt]>, va_list <[list]>); int vsiprintf(char *<[str]>, const char *<[fmt]>, va_list <[list]>); int vasiprintf(char **<[strp]>, const char *<[fmt]>, va_list <[list]>); - int vsniprintf(char *<[str]>, size_t <[size]>, const char *<[fmt]>, - va_list <[list]>); + int vsniprintf(char *<[str]>, size_t <[size]>, const char *<[fmt]>, va_list <[list]>); int _viprintf_r(struct _reent *<[reent]>, const char *<[fmt]>, va_list <[list]>); - int _vfiprintf_r(struct _reent *<[reent]>, FILE *<[fp]>, - const char *<[fmt]>, va_list <[list]>); - int _vasiprintf_r(struct _reent *<[reent]>, char **<[str]>, - const char *<[fmt]>, va_list <[list]>); - int _vsiprintf_r(struct _reent *<[reent]>, char *<[str]>, - const char *<[fmt]>, va_list <[list]>); - int _vsniprintf_r(struct _reent *<[reent]>, char *<[str]>, size_t <[size]>, - const char *<[fmt]>, va_list <[list]>); + int _vfiprintf_r(struct _reent *<[reent]>, FILE *<[fp]>, const char *<[fmt]>, + va_list <[list]>); + int _vasiprintf_r(struct _reent *<[reent]>, char **<[str]>, const char *<[fmt]>, + va_list <[list]>); + int _vsiprintf_r(struct _reent *<[reent]>, char *<[str]>, const char *<[fmt]>, + va_list <[list]>); + int _vsniprintf_r(struct _reent *<[reent]>, char *<[str]>, size_t <[size]>, const char *<[fmt]>, + va_list <[list]>); TRAD_SYNOPSIS #include <stdio.h> diff --git a/newlib/libc/stdio/viscanf.c b/newlib/libc/stdio/viscanf.c index f335f69ff..e5287acac 100644 --- a/newlib/libc/stdio/viscanf.c +++ b/newlib/libc/stdio/viscanf.c @@ -39,8 +39,8 @@ ANSI_SYNOPSIS va_list <[list]>); int _vfiscanf_r(struct _reent *<[reent]>, FILE *<[fp]>, const char *<[fmt]>, va_list <[list]>); - int _vsiscanf_r(struct _reent *<[reent]>, const char *<[str]>, - const char *<[fmt]>, va_list <[list]>); + int _vsiscanf_r(struct _reent *<[reent]>, const char *<[str]>, const char *<[fmt]>, + va_list <[list]>); TRAD_SYNOPSIS #include <stdio.h> diff --git a/newlib/libc/stdio/wsetup.c b/newlib/libc/stdio/wsetup.c index cf56c2abc..bc7299678 100644 --- a/newlib/libc/stdio/wsetup.c +++ b/newlib/libc/stdio/wsetup.c @@ -58,11 +58,9 @@ _DEFUN(__swsetup, (fp), /* * Make a buffer if necessary, then set _w. - * A string I/O file should not explicitly allocate a buffer - * unless asprintf is being used. */ - if (fp->_bf._base == NULL - && (!(fp->_flags & __SSTR) || (fp->_flags & __SMBF))) + /* NOT NEEDED FOR CYGNUS SPRINTF ONLY jpg */ + if (fp->_bf._base == NULL) __smakebuf (fp); if (fp->_flags & __SLBF) |