summaryrefslogtreecommitdiffstats
path: root/libio/stdio
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2008-06-01 00:03:21 +0000
committerpeter <peter@FreeBSD.org>2008-06-01 00:03:21 +0000
commita2be5f0c15218b0177d73b17d9bcb7589965d685 (patch)
treec9f0cd9c22378356a1716d32e13e70bc90f98b9c /libio/stdio
parent9e0f3cc19c9df1594c9cc36cfd8fddc83c52ad12 (diff)
downloadFreeBSD-src-a2be5f0c15218b0177d73b17d9bcb7589965d685.zip
FreeBSD-src-a2be5f0c15218b0177d73b17d9bcb7589965d685.tar.gz
Reorganize the gcc vendor import work area. This flattens out a bunch
of unnecessary path components that are relics of cvs2svn. (These are directory moves)
Diffstat (limited to 'libio/stdio')
-rw-r--r--libio/stdio/ChangeLog153
-rw-r--r--libio/stdio/Makefile.in35
-rw-r--r--libio/stdio/clearerr.c30
-rw-r--r--libio/stdio/clearerr_u.c28
-rw-r--r--libio/stdio/configure.in49
-rw-r--r--libio/stdio/fdopen.c9
-rw-r--r--libio/stdio/feof.c43
-rw-r--r--libio/stdio/feof_u.c37
-rw-r--r--libio/stdio/ferror.c43
-rw-r--r--libio/stdio/ferror_u.c37
-rw-r--r--libio/stdio/fgetc.c40
-rw-r--r--libio/stdio/fileno.c49
-rw-r--r--libio/stdio/fputc.c41
-rw-r--r--libio/stdio/fputc_u.c38
-rw-r--r--libio/stdio/freopen.c44
-rw-r--r--libio/stdio/fseek.c42
-rw-r--r--libio/stdio/getc.c48
-rw-r--r--libio/stdio/getc_u.c37
-rw-r--r--libio/stdio/getchar.c40
-rw-r--r--libio/stdio/getchar_u.c35
-rw-r--r--libio/stdio/getline.c13
-rw-r--r--libio/stdio/getw.c13
-rw-r--r--libio/stdio/obprintf.c168
-rw-r--r--libio/stdio/popen.c23
-rw-r--r--libio/stdio/putc.c42
-rw-r--r--libio/stdio/putc_u.c31
-rw-r--r--libio/stdio/putchar.c35
-rw-r--r--libio/stdio/putchar_u.c30
-rw-r--r--libio/stdio/putw.c15
-rw-r--r--libio/stdio/rewind.c38
-rw-r--r--libio/stdio/setbuf.c35
-rw-r--r--libio/stdio/setfileno.c17
-rw-r--r--libio/stdio/setlinebuf.c36
-rw-r--r--libio/stdio/snprintf.c51
-rw-r--r--libio/stdio/stdio.h219
-rw-r--r--libio/stdio/vasprintf.c72
-rw-r--r--libio/stdio/vfprintf.c35
-rw-r--r--libio/stdio/vfscanf.c36
-rw-r--r--libio/stdio/vprintf.c33
-rw-r--r--libio/stdio/vscanf.c41
-rw-r--r--libio/stdio/vsnprintf.c136
41 files changed, 1997 insertions, 0 deletions
diff --git a/libio/stdio/ChangeLog b/libio/stdio/ChangeLog
new file mode 100644
index 0000000..8ef9dcc
--- /dev/null
+++ b/libio/stdio/ChangeLog
@@ -0,0 +1,153 @@
+Fri Mar 16 12:46:19 GMT 2001 Bernd Schmidt (bernds@redhat.com)
+
+ * gcc-2.95.3 Released.
+
+Sun Oct 24 23:54:10 PDT 1999 Jeff Law (law@cygnus.com)
+
+ * gcc-2.95.2 Released.
+
+Mon Aug 16 01:29:24 PDT 1999 Jeff Law (law@cygnus.com)
+
+ * gcc-2.95.1 Released.
+
+Wed Jul 28 21:39:31 PDT 1999 Jeff Law (law@cygnus.com)
+
+ * gcc-2.95 Released.
+
+Sun Jul 25 23:40:51 PDT 1999 Jeff Law (law@cygnus.com)
+
+ * gcc-2.95 Released.
+
+1997-09-04 16:11 Ulrich Drepper <drepper@cygnus.com>
+
+ * Makefile.in (STDIO_OBJECTS): Lose feof.o and ferror.o. Add getc.o
+ and putc.o.
+ (stmp-libio, stmp-libiostream, stmp-io, stmp-streamlib): New rules.
+
+ (iostream.list): Depend upon stmp-stdio. Add the entries
+ from stdio.list to iostream.list.
+ (stmp-stdio): New name for what was the stdio/stdio.list rule.
+ All it now does is cd down into stdio and build stdio.list.
+
+ * clearerr.c: Add copyright and lock stream before use.
+ * feof.c: Likewise.
+ * ferror.c: Likewise.
+ * fgetc.c: Likewise.
+ * fputc.c: Likewise.
+ * freopen.c: Likewise.
+ * fseek.c: Likewise.
+ * getc.c: Likewise.
+ * getchar.c: Likewise.
+ * putc.c: Likewise.
+ * putchar.c: Likewise.
+ * rewind.c: Likewise.
+
+ * setbuf.c: Update copyright.
+ * setlinebuf.c: Likewise.
+ * vscanf.c: Likewise.
+
+ * fileno.c: Define alias fileno_unlocked. Update copyright.
+
+ * clearerr_u.c: New file. Implement clearerr_unlocked function.
+ * feof_u.c: New file. Implement feof_unlocked function.
+ * ferror_u.c: New file. Implement ferror_unlocked function.
+ * fputc_u.c: New file. Implement fputc_unlocked function.
+ * getc_u.c: New file. Implement getc_unclocked function.
+ * getchar_u.c: New file. Implement getchar_unclocked function.
+ * putc_u.c: New file. Implement putc_unclocked function.
+ * putchar_u.c: New file. Implement putchar_unclocked function.
+
+ * vsnprintf.c: Rewrite according to ISO C 9X draft.
+
+Thu May 1 11:03:45 1997 Brendan Kehoe <brendan@lisa.cygnus.com>
+
+ * stdio.h (TMP_MAX): Wrap it with #ifndef for now, since it can
+ get defined by <limits.h> (e.g., HP/UX and AIX).
+
+Wed Mar 12 08:51:37 1997 Gavin Koch <gavin@cygnus.com>
+
+ * stdio.h: Use _IO_va_list rather than _G_va_list.
+
+Wed Jun 14 21:41:50 1995 Jason Merrill <jason@python.cygnus.com>
+
+ * configure.in (LIBDIR): Set.
+ (MOSTLYCLEAN): Remove pic and stamp-picdir.
+ (stdio_objects): Also compile pic version.
+
+ * Makefile.in (STDIO_OBJECTS): Remove getdelim.o.
+
+Wed May 10 03:05:53 1995 Jason Merrill <jason@python.cygnus.com>
+
+ * vsnprintf.c (vsnprintf): Update to use _IO_JUMPS.
+
+ * Makefile.in (STDIO_OBJECTS): Fix typo.
+
+Tue Oct 18 17:15:09 1994 Per Bothner <bothner@kalessin.cygnus.com>
+
+ * getline.c, snprintf.c, vsnprintf.c: New files, providing
+ functionality of the GNU C library.
+ * Makefile.in (STDIO_OBJECTS), configure.in: Add new files.
+ * stdio.h: Add new functions.
+
+Fri Oct 14 15:56:27 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * stdio.h: Added vfscanf, vscanf, vsscanf, #ifndef __STRICT_ANSI__.
+
+Tue Aug 23 16:17:25 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * stdio.h: Added comment, at hjl's request.
+
+Sun Aug 7 13:28:12 1994 H.J. Lu (hjl@nynexst.com)
+
+ * stdio.h (getc, getchar, putc, putchar): New declarations.
+ Move macros after the declarations.
+
+Fri Aug 5 18:27:21 1994 H.J. Lu (hjl@nynexst.com)
+
+ * clearerr.c, rewind.c, setfileno.c:
+ Add CHECK_FILE(fp, ) and remove COERCE_FILE(fp).
+ * feof.c, ferror.c, fgetc.c, fileno.c, fputc.c, getw.c, putw.c,
+ vfscanf.c: Add CHECK_FILE(fp, EOF) and remove COERCE_FILE(fp).
+ * freopen.c: Add CHECK_FILE(fp, NULL) and remove COERCE_FILE(fp).
+ * fseek.c, vfprintf.c:
+ Add CHECK_FILE(fp, -1) and remove COERCE_FILE(fp).
+
+Fri May 20 13:11:58 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * stdio.h: Rename _ARGS macro to __P for better gnlibc and
+ BSD compatibility.
+
+Fri Nov 26 13:26:35 1993 Per Bothner (bothner@kalessin.cygnus.com)
+
+ Bunch of little changes, many from H.J. Lu <hjl@nynexst.com>.
+ * feof.c, setbuf.c, vprintf.c, vcanf.c: #include <stdio.h>,
+ for error checking.
+ * fileno.c: #include libioP.h, not just libio.h.
+ * fputc.c: Fix typo.
+ * fseek.c, rewind.c: Use #include "...", not <...> ,for local files.
+ * getc.c, getchar.c, putc.c, putchar.c: New files, providing
+ non-macro versions of the standard macros.
+ * getw.c, putw.c, setfileno.c, setlinebuf.c: New files.
+ * Makefile.in (STDIO_OBJECTS): Add new files.
+ * vfscanf.c: Add missing new 4th arg to _IO_vfscanf call.
+
+Thu Oct 14 16:12:07 1993 Karen Christiansen (karen@deneb.cygnus.com)
+
+ * configure.in: changed mv to mv -f
+
+Mon Oct 4 17:29:23 1993 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * configure.in (stdio_renames): Add fgetpos, fsetpos, gets,
+ perror, setbuffer, ungetc.
+ * clearerr.c, ferror.c, fgetc.c, fileno.c, fputc.c, freopen.c,
+ fseek.c, popen.c, rewind.c, setbuf.c: New files.
+ * Makefile.in (STDIO_OBJECTS): Add new files.
+ * stdio.h: Use _IO_XXX instead of _G_XXX many places.
+ #include <libio.h> instead of <_stdio.h>, to get useful defs.
+
+Fri Aug 20 00:28:28 1993 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * feof.c, vprintf.c, vscanf.c: Converted stub functions.
+ * configure.in (stdio_renamed): Removed feof.
+ Added sprintf sscanf vsscanf.
+ * ChangeLog.old: Copy of old libg++/iostream/stdio/ChangeLog.
diff --git a/libio/stdio/Makefile.in b/libio/stdio/Makefile.in
new file mode 100644
index 0000000..680c8a4
--- /dev/null
+++ b/libio/stdio/Makefile.in
@@ -0,0 +1,35 @@
+srcdir = .
+
+#### package, host, target, and site dependent Makefile fragments come in here.
+##
+
+# These are compiled from the corresponding ../ioFOO.c files.
+STDIO_RENAMED_OBJECTS = ... filled in by configure ...
+# These are the files that a libc would want.
+STDIO_OBJECTS = $(STDIO_RENAMED_OBJECTS) \
+ clearerr.o fdopen.o fgetc.o fileno.o \
+ fputc.o freopen.o fseek.o getchar.o getline.o getw.o \
+ popen.o putchar.o putw.o rewind.o \
+ setbuf.o setfileno.o setlinebuf.o snprintf.o \
+ vfprintf.o vfscanf.o vprintf.o vscanf.o vsnprintf.o
+
+CC_FOR_STDIO=$(CC)
+CINCLUDES = -I. -I$(srcdir) -I.. -I$(srcdir)/.. -D__USE_GNU
+
+nothing:
+
+stmp-libio: stdio.list stamp-io
+
+stamp-io:
+ $(AR) $(AR_FLAGS) ../libio.a $(STDIO_OBJECTS)
+ touch stmp-io
+
+stmp-libiostream: stdio.list stamp-streamlib
+
+stamp-streamlib:
+ $(AR) $(AR_FLAGS) ../libiostream.a $(STDIO_OBJECTS)
+ touch stmp-streamlib
+
+stdio.list: stamp-picdir $(STDIO_OBJECTS)
+ @echo "$(STDIO_OBJECTS)" >stdio.list
+
diff --git a/libio/stdio/clearerr.c b/libio/stdio/clearerr.c
new file mode 100644
index 0000000..4776250
--- /dev/null
+++ b/libio/stdio/clearerr.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include "libioP.h"
+#include "stdio.h"
+
+void
+clearerr (fp)
+ FILE *fp;
+{
+ CHECK_FILE (fp, /*nothing*/);
+ _IO_flockfile (fp);
+ _IO_clearerr (fp);
+ _IO_funlockfile (fp);
+}
diff --git a/libio/stdio/clearerr_u.c b/libio/stdio/clearerr_u.c
new file mode 100644
index 0000000..2a1ba70
--- /dev/null
+++ b/libio/stdio/clearerr_u.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include "libioP.h"
+#include "stdio.h"
+
+void
+clearerr_unlocked (fp)
+ FILE *fp;
+{
+ CHECK_FILE (fp, /*nothing*/);
+ _IO_clearerr (fp);
+}
diff --git a/libio/stdio/configure.in b/libio/stdio/configure.in
new file mode 100644
index 0000000..83cac17
--- /dev/null
+++ b/libio/stdio/configure.in
@@ -0,0 +1,49 @@
+# This file is a shell script fragment that supplies the information
+# necessary for a configure script to process the program in
+# this directory. For more information, look at ../configure.
+
+configdirs=
+srctrigger=stdio.h
+srcname="libio/stdio"
+package_makefile_frag=../Make.pack
+package_makefile_rules_frag=../Make.pack.r
+
+# per-host:
+
+# per-target:
+
+LIBDIR=yes
+TO_TOPDIR=../../
+ALL=nothing
+MOSTLYCLEAN='*.o pic stamp-picdir core stdio.list'
+(. ${srcdir}/../config.shared) >${package_makefile_frag} 2>${package_makefile_rules_frag}
+
+# post-target:
+
+# Certain files that are used to build a C library (such as fprintf.o)
+# are compled from the same sources as the ioXXX versions (such as ioprintf.c).
+# These lines add the appropriate rules.
+# NOTE: We assume a C compiler that where -o with -c works.
+# But these files are not built by default anyway ...
+
+# TODO: remove rename tmpfile tmpnam
+
+stdio_renames="fclose fflush fgetpos fgets fopen fprintf fputs fread \
+ fscanf fsetpos ftell fwrite getdelim gets perror printf puts \
+ scanf setbuffer setvbuf sprintf sscanf ungetc vsprintf vsscanf"
+stdio_objects=""
+
+for file in $stdio_renames ; do
+ cat >>Makefile <<EOF
+$file.o: \$(srcdir)/../io$file.c
+ if [ -n "\$(PICFLAG)" ]; then \\
+ \$(CC_FOR_STDIO) \$(CFLAGS) \$(CINCLUDES) \$(PICFLAG) -c \\
+ \$(srcdir)/../io$file.c -D_IO_$file=$file -o pic/$file.o; \\
+ fi
+ \$(CC_FOR_STDIO) \$(CFLAGS) \$(CINCLUDES) -c \\
+ \$(srcdir)/../io$file.c -D_IO_$file=$file -o $file.o
+EOF
+ stdio_objects="$stdio_objects $file.o"
+done
+sed -e "/STDIO_RENAMED_OBJECTS =/s/=.*/=${stdio_objects}/" <Makefile >tmp
+mv -f tmp Makefile
diff --git a/libio/stdio/fdopen.c b/libio/stdio/fdopen.c
new file mode 100644
index 0000000..83e026e
--- /dev/null
+++ b/libio/stdio/fdopen.c
@@ -0,0 +1,9 @@
+#include "libioP.h"
+
+_IO_FILE *
+fdopen (fd, mode)
+ int fd;
+ const char *mode;
+{
+ return _IO_fdopen (fd, mode);
+}
diff --git a/libio/stdio/feof.c b/libio/stdio/feof.c
new file mode 100644
index 0000000..d06de04
--- /dev/null
+++ b/libio/stdio/feof.c
@@ -0,0 +1,43 @@
+/* Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to
+ the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA.
+
+ As a special exception, if you link this library with files
+ compiled with a GNU compiler to produce an executable, this does
+ not cause the resulting executable to be covered by the GNU General
+ Public License. This exception does not however invalidate any
+ other reasons why the executable file might be covered by the GNU
+ General Public License. */
+
+#include "libioP.h"
+#include "stdio.h"
+
+int
+_IO_feof (fp)
+ _IO_FILE* fp;
+{
+ int result;
+ CHECK_FILE (fp, EOF);
+ _IO_flockfile (fp);
+ result = _IO_feof_unlocked (fp);
+ _IO_funlockfile (fp);
+ return result;
+}
+
+#ifdef weak_alias
+weak_alias (_IO_feof, feof)
+#endif
diff --git a/libio/stdio/feof_u.c b/libio/stdio/feof_u.c
new file mode 100644
index 0000000..4773599
--- /dev/null
+++ b/libio/stdio/feof_u.c
@@ -0,0 +1,37 @@
+/* Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to
+ the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA.
+
+ As a special exception, if you link this library with files
+ compiled with a GNU compiler to produce an executable, this does
+ not cause the resulting executable to be covered by the GNU General
+ Public License. This exception does not however invalidate any
+ other reasons why the executable file might be covered by the GNU
+ General Public License. */
+
+#include "libioP.h"
+#include "stdio.h"
+
+#undef feof_unlocked
+
+int
+feof_unlocked (fp)
+ _IO_FILE* fp;
+{
+ CHECK_FILE (fp, EOF);
+ return _IO_feof_unlocked (fp);
+}
diff --git a/libio/stdio/ferror.c b/libio/stdio/ferror.c
new file mode 100644
index 0000000..855627a
--- /dev/null
+++ b/libio/stdio/ferror.c
@@ -0,0 +1,43 @@
+/* Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to
+ the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA.
+
+ As a special exception, if you link this library with files
+ compiled with a GNU compiler to produce an executable, this does
+ not cause the resulting executable to be covered by the GNU General
+ Public License. This exception does not however invalidate any
+ other reasons why the executable file might be covered by the GNU
+ General Public License. */
+
+#include "libioP.h"
+#include "stdio.h"
+
+int
+_IO_ferror (fp)
+ _IO_FILE* fp;
+{
+ int result;
+ CHECK_FILE (fp, EOF);
+ _IO_flockfile (fp);
+ result = _IO_ferror_unlocked (fp);
+ _IO_funlockfile (fp);
+ return result;
+}
+
+#ifdef weak_alias
+weak_alias (_IO_ferror, ferror)
+#endif
diff --git a/libio/stdio/ferror_u.c b/libio/stdio/ferror_u.c
new file mode 100644
index 0000000..6e13e53
--- /dev/null
+++ b/libio/stdio/ferror_u.c
@@ -0,0 +1,37 @@
+/* Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to
+ the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA.
+
+ As a special exception, if you link this library with files
+ compiled with a GNU compiler to produce an executable, this does
+ not cause the resulting executable to be covered by the GNU General
+ Public License. This exception does not however invalidate any
+ other reasons why the executable file might be covered by the GNU
+ General Public License. */
+
+#include "libioP.h"
+#include "stdio.h"
+
+#undef ferror_unlocked
+
+int
+ferror_unlocked (fp)
+ _IO_FILE* fp;
+{
+ CHECK_FILE (fp, EOF);
+ return _IO_ferror_unlocked (fp);
+}
diff --git a/libio/stdio/fgetc.c b/libio/stdio/fgetc.c
new file mode 100644
index 0000000..174e60f
--- /dev/null
+++ b/libio/stdio/fgetc.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 1993, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to
+ the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA.
+
+ As a special exception, if you link this library with files
+ compiled with a GNU compiler to produce an executable, this does
+ not cause the resulting executable to be covered by the GNU General
+ Public License. This exception does not however invalidate any
+ other reasons why the executable file might be covered by the GNU
+ General Public License. */
+
+#include "libioP.h"
+#include "stdio.h"
+
+int
+fgetc (fp)
+ FILE *fp;
+{
+ int result;
+ CHECK_FILE (fp, EOF);
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
+ _IO_flockfile (fp);
+ result = _IO_getc_unlocked (fp);
+ _IO_cleanup_region_end (1);
+ return result;
+}
diff --git a/libio/stdio/fileno.c b/libio/stdio/fileno.c
new file mode 100644
index 0000000..7ff93e6
--- /dev/null
+++ b/libio/stdio/fileno.c
@@ -0,0 +1,49 @@
+/* Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to
+ the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA.
+
+ As a special exception, if you link this library with files
+ compiled with a GNU compiler to produce an executable, this does
+ not cause the resulting executable to be covered by the GNU General
+ Public License. This exception does not however invalidate any
+ other reasons why the executable file might be covered by the GNU
+ General Public License. */
+
+#include "libioP.h"
+#include "stdio.h"
+
+int
+fileno (fp)
+ _IO_FILE* fp;
+{
+ CHECK_FILE (fp, EOF);
+
+ if (!(fp->_flags & _IO_IS_FILEBUF))
+ return EOF;
+
+ return _IO_fileno (fp);
+}
+
+#ifdef _IO_MTSAFE_IO
+#ifdef weak_alias
+/* The fileno implementation for libio does not require locking because
+ it only accesses once a single variable and this is already atomic
+ (at least at thread level). */
+
+weak_alias (fileno, fileno_unlocked)
+#endif
+#endif
diff --git a/libio/stdio/fputc.c b/libio/stdio/fputc.c
new file mode 100644
index 0000000..22cdfab
--- /dev/null
+++ b/libio/stdio/fputc.c
@@ -0,0 +1,41 @@
+/* Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to
+ the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA.
+
+ As a special exception, if you link this library with files
+ compiled with a GNU compiler to produce an executable, this does
+ not cause the resulting executable to be covered by the GNU General
+ Public License. This exception does not however invalidate any
+ other reasons why the executable file might be covered by the GNU
+ General Public License. */
+
+#include "libioP.h"
+#include "stdio.h"
+
+int
+fputc (c, fp)
+ int c;
+ _IO_FILE *fp;
+{
+ int result;
+ CHECK_FILE (fp, EOF);
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
+ _IO_flockfile (fp);
+ result = _IO_putc_unlocked (c, fp);
+ _IO_cleanup_region_end (1);
+ return result;
+}
diff --git a/libio/stdio/fputc_u.c b/libio/stdio/fputc_u.c
new file mode 100644
index 0000000..48701e1
--- /dev/null
+++ b/libio/stdio/fputc_u.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to
+ the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA.
+
+ As a special exception, if you link this library with files
+ compiled with a GNU compiler to produce an executable, this does
+ not cause the resulting executable to be covered by the GNU General
+ Public License. This exception does not however invalidate any
+ other reasons why the executable file might be covered by the GNU
+ General Public License. */
+
+#include "libioP.h"
+#include "stdio.h"
+
+#undef fputc_unlocked
+
+int
+fputc_unlocked (c, fp)
+ int c;
+ _IO_FILE *fp;
+{
+ CHECK_FILE (fp, EOF);
+ return _IO_putc_unlocked (c, fp);
+}
diff --git a/libio/stdio/freopen.c b/libio/stdio/freopen.c
new file mode 100644
index 0000000..ff57d60
--- /dev/null
+++ b/libio/stdio/freopen.c
@@ -0,0 +1,44 @@
+/* Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to
+ the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA.
+
+ As a special exception, if you link this library with files
+ compiled with a GNU compiler to produce an executable, this does
+ not cause the resulting executable to be covered by the GNU General
+ Public License. This exception does not however invalidate any
+ other reasons why the executable file might be covered by the GNU
+ General Public License. */
+
+#include "libioP.h"
+#include "stdio.h"
+
+FILE*
+freopen (filename, mode, fp)
+ const char* filename;
+ const char* mode;
+ FILE* fp;
+{
+ FILE *result;
+ CHECK_FILE (fp, NULL);
+ if (!(fp->_flags & _IO_IS_FILEBUF))
+ return NULL;
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
+ _IO_flockfile (fp);
+ result = _IO_freopen (filename, mode, fp);
+ _IO_cleanup_region_end (1);
+ return result;
+}
diff --git a/libio/stdio/fseek.c b/libio/stdio/fseek.c
new file mode 100644
index 0000000..f2563d3
--- /dev/null
+++ b/libio/stdio/fseek.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to
+ the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA.
+
+ As a special exception, if you link this library with files
+ compiled with a GNU compiler to produce an executable, this does
+ not cause the resulting executable to be covered by the GNU General
+ Public License. This exception does not however invalidate any
+ other reasons why the executable file might be covered by the GNU
+ General Public License. */
+
+#include "libioP.h"
+#include "stdio.h"
+
+int
+fseek (fp, offset, whence)
+ _IO_FILE* fp;
+ long int offset;
+ int whence;
+{
+ int result;
+ CHECK_FILE (fp, -1);
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
+ _IO_flockfile (fp);
+ result = _IO_fseek (fp, offset, whence);
+ _IO_cleanup_region_end (1);
+ return result;
+}
diff --git a/libio/stdio/getc.c b/libio/stdio/getc.c
new file mode 100644
index 0000000..1dc53b5
--- /dev/null
+++ b/libio/stdio/getc.c
@@ -0,0 +1,48 @@
+/* Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to
+ the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA.
+
+ As a special exception, if you link this library with files
+ compiled with a GNU compiler to produce an executable, this does
+ not cause the resulting executable to be covered by the GNU General
+ Public License. This exception does not however invalidate any
+ other reasons why the executable file might be covered by the GNU
+ General Public License. */
+
+#include "libioP.h"
+#include "stdio.h"
+
+#undef _IO_getc
+
+int
+_IO_getc (fp)
+ FILE *fp;
+{
+ int result;
+ CHECK_FILE (fp, EOF);
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
+ _IO_flockfile (fp);
+ result = _IO_getc_unlocked (fp);
+ _IO_cleanup_region_end (1);
+ return result;
+}
+
+#undef getc
+
+#ifdef weak_alias
+weak_alias (_IO_getc, getc)
+#endif
diff --git a/libio/stdio/getc_u.c b/libio/stdio/getc_u.c
new file mode 100644
index 0000000..f074427
--- /dev/null
+++ b/libio/stdio/getc_u.c
@@ -0,0 +1,37 @@
+/* Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to
+ the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA.
+
+ As a special exception, if you link this library with files
+ compiled with a GNU compiler to produce an executable, this does
+ not cause the resulting executable to be covered by the GNU General
+ Public License. This exception does not however invalidate any
+ other reasons why the executable file might be covered by the GNU
+ General Public License. */
+
+#include "libioP.h"
+#include "stdio.h"
+
+#undef getc_unlocked
+
+int
+getc_unlocked (fp)
+ FILE *fp;
+{
+ CHECK_FILE (fp, EOF);
+ return _IO_getc_unlocked (fp);
+}
diff --git a/libio/stdio/getchar.c b/libio/stdio/getchar.c
new file mode 100644
index 0000000..93194b3
--- /dev/null
+++ b/libio/stdio/getchar.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to
+ the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA.
+
+ As a special exception, if you link this library with files
+ compiled with a GNU compiler to produce an executable, this does
+ not cause the resulting executable to be covered by the GNU General
+ Public License. This exception does not however invalidate any
+ other reasons why the executable file might be covered by the GNU
+ General Public License. */
+
+#include "libioP.h"
+#include "stdio.h"
+
+#undef getchar
+
+int
+getchar ()
+{
+ int result;
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, stdin);
+ _IO_flockfile (stdin);
+ result = _IO_getc_unlocked (stdin);
+ _IO_cleanup_region_end (1);
+ return result;
+}
diff --git a/libio/stdio/getchar_u.c b/libio/stdio/getchar_u.c
new file mode 100644
index 0000000..bfbe56b
--- /dev/null
+++ b/libio/stdio/getchar_u.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to
+ the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA.
+
+ As a special exception, if you link this library with files
+ compiled with a GNU compiler to produce an executable, this does
+ not cause the resulting executable to be covered by the GNU General
+ Public License. This exception does not however invalidate any
+ other reasons why the executable file might be covered by the GNU
+ General Public License. */
+
+#include "libioP.h"
+#include "stdio.h"
+
+#undef getchar_unlocked
+
+int
+getchar_unlocked ()
+{
+ return _IO_getc_unlocked (stdin);
+}
diff --git a/libio/stdio/getline.c b/libio/stdio/getline.c
new file mode 100644
index 0000000..6f4b677
--- /dev/null
+++ b/libio/stdio/getline.c
@@ -0,0 +1,13 @@
+#include "libioP.h"
+#include "stdio.h"
+
+/* NOTE: This geline function is different from _IO_getline. */
+
+_IO_ssize_t
+getline (lineptr, linelen, fp)
+ char** lineptr;
+ size_t* linelen;
+ FILE* fp;
+{
+ return _IO_getdelim (lineptr, linelen, '\n', fp);
+}
diff --git a/libio/stdio/getw.c b/libio/stdio/getw.c
new file mode 100644
index 0000000..1dfafbc
--- /dev/null
+++ b/libio/stdio/getw.c
@@ -0,0 +1,13 @@
+#include "libioP.h"
+#include "stdio.h"
+
+int
+getw(fp)
+ FILE *fp;
+{
+ int w;
+ _IO_size_t bytes_read;
+ CHECK_FILE(fp, EOF);
+ bytes_read = _IO_sgetn (fp, (char*)&w, sizeof(w));
+ return sizeof(w) == bytes_read ? w : EOF;
+}
diff --git a/libio/stdio/obprintf.c b/libio/stdio/obprintf.c
new file mode 100644
index 0000000..6b959e4
--- /dev/null
+++ b/libio/stdio/obprintf.c
@@ -0,0 +1,168 @@
+/* Print output of stream to given obstack.
+ Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+
+#ifdef __STDC__
+#include <stdlib.h>
+#endif
+#include "libioP.h"
+#include <string.h>
+#include <errno.h>
+#include <obstack.h>
+#include <stdarg.h>
+
+
+struct _IO_obstack_file
+{
+ struct _IO_FILE file;
+ const void *vtable;
+ struct obstack *obstack;
+};
+
+
+static int
+_IO_obstack_overflow (_IO_FILE *fp, int c)
+{
+ struct obstack *obstack = ((struct _IO_obstack_file *) fp)->obstack;
+
+ /* Make room for another character. This might as well allocate a
+ new chunk a memory and moves the old contents over. */
+ if (c != EOF)
+ obstack_1grow (obstack, c);
+
+ /* Setup the buffer pointers again. */
+ fp->_IO_write_base = obstack_base (obstack);
+ fp->_IO_write_ptr = obstack_next_free (obstack);
+ fp->_IO_write_end = fp->_IO_write_base + obstack_room (obstack);
+ /* Now allocate the rest of the current chunk. */
+ obstack_blank_fast (obstack, fp->_IO_write_end - fp->_IO_write_ptr);
+
+ return c;
+}
+
+
+static _IO_size_t
+_IO_obstack_xsputn (_IO_FILE *fp, const void *data, _IO_size_t n)
+{
+ struct obstack *obstack = ((struct _IO_obstack_file *) fp)->obstack;
+
+ if (fp->_IO_write_ptr + n > fp->_IO_write_end)
+ {
+ /* We need some more memory. First shrink the buffer to the
+ space we really currently need. */
+ obstack_blank (obstack, fp->_IO_write_ptr - fp->_IO_write_end);
+
+ /* Now grow for N bytes. */
+ obstack_blank (obstack, n);
+
+ /* Setup the buffer pointers again. */
+ fp->_IO_write_base = obstack_base (obstack);
+ fp->_IO_write_ptr = obstack_next_free (obstack);
+ fp->_IO_write_end = (fp->_IO_write_base + obstack_room (obstack));
+ /* Now allocate the rest of the current chunk. */
+ obstack_blank_fast (obstack, fp->_IO_write_end - fp->_IO_write_ptr);
+ }
+ else
+ {
+ memcpy (fp->_IO_write_ptr, data, n);
+ fp->_IO_write_ptr += n;
+ }
+
+ return n;
+}
+
+
+/* the jump table. */
+static struct _IO_jump_t _IO_obstack_jumps =
+{
+ JUMP_INIT_DUMMY,
+ JUMP_INIT(finish, NULL),
+ JUMP_INIT(overflow, _IO_obstack_overflow),
+ JUMP_INIT(underflow, NULL),
+ JUMP_INIT(uflow, NULL),
+ JUMP_INIT(pbackfail, NULL),
+ JUMP_INIT(xsputn, _IO_obstack_xsputn),
+ JUMP_INIT(xsgetn, NULL),
+ JUMP_INIT(seekoff, NULL),
+ JUMP_INIT(seekpos, NULL),
+ JUMP_INIT(setbuf, NULL),
+ JUMP_INIT(sync, NULL),
+ JUMP_INIT(doallocate, NULL),
+ JUMP_INIT(read, NULL),
+ JUMP_INIT(write, NULL),
+ JUMP_INIT(seek, NULL),
+ JUMP_INIT(close, NULL),
+ JUMP_INIT(stat, NULL)
+};
+
+
+int
+_IO_obstack_vprintf (struct obstack *obstack, const char *format, va_list args)
+{
+ struct obstack_FILE
+ {
+ struct _IO_obstack_file ofile;
+#ifdef _IO_MTSAFE_IO
+ _IO_lock_t lock;
+#endif
+ } new_f;
+ int result;
+
+#ifdef _IO_MTSAFE_IO
+ new_f.ofile.file._lock = &new_f.lock;
+#endif
+
+ _IO_init ((_IO_FILE *) &new_f.ofile, 0);
+ _IO_JUMPS (&new_f.ofile.file) = &_IO_obstack_jumps;
+ _IO_str_init_static (&new_f.ofile.file, obstack_base (obstack),
+ (obstack_object_size (obstack) +
+ obstack_room (obstack)), obstack_next_free (obstack));
+ /* Now allocate the rest of the current chunk. */
+ obstack_blank_fast (obstack,
+ (new_f.ofile.file._IO_write_end
+ - new_f.ofile.file._IO_write_ptr));
+ new_f.ofile.obstack = obstack;
+
+ result = _IO_vfprintf ((_IO_FILE *) &new_f, format, args);
+
+ /* Shrink the buffer to the space we really currently need. */
+ obstack_blank (obstack, (new_f.ofile.file._IO_write_ptr
+ - new_f.ofile.file._IO_write_end));
+
+ return result;
+}
+#ifdef weak_alias
+weak_alias (_IO_obstack_vprintf, obstack_vprintf)
+#endif
+
+
+int
+_IO_obstack_printf (struct obstack *obstack, const char *format, ...)
+{
+ int result;
+ va_list ap;
+ va_start (ap, format);
+ result = _IO_obstack_vprintf (obstack, format, ap);
+ va_end (ap);
+ return result;
+}
+#ifdef weak_alias
+weak_alias (_IO_obstack_printf, obstack_printf)
+#endif
diff --git a/libio/stdio/popen.c b/libio/stdio/popen.c
new file mode 100644
index 0000000..9f9f3f7
--- /dev/null
+++ b/libio/stdio/popen.c
@@ -0,0 +1,23 @@
+#include "libioP.h"
+#include "stdio.h"
+#include <errno.h>
+
+FILE *
+popen(command, mode)
+ const char *command; const char *mode;
+{
+ return _IO_popen(command, mode);
+}
+
+int
+pclose(fp)
+ FILE *fp;
+{
+#if 0
+ /* Does not actually test that stream was created by popen(). Instead,
+ it depends on the filebuf::sys_close() virtual to Do The Right Thing. */
+ if (fp is not a proc_file)
+ return -1;
+#endif
+ return _IO_fclose(fp);
+}
diff --git a/libio/stdio/putc.c b/libio/stdio/putc.c
new file mode 100644
index 0000000..3c35c36
--- /dev/null
+++ b/libio/stdio/putc.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 1991, 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include "libioP.h"
+#include "stdio.h"
+
+#undef _IO_putc
+
+int
+_IO_putc (c, fp)
+ int c;
+ _IO_FILE *fp;
+{
+ int result;
+ CHECK_FILE (fp, EOF);
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
+ _IO_flockfile (fp);
+ result = _IO_putc_unlocked (c, fp);
+ _IO_cleanup_region_end (1);
+ return result;
+}
+
+#undef putc
+
+#ifdef weak_alias
+weak_alias (_IO_putc, putc)
+#endif
diff --git a/libio/stdio/putc_u.c b/libio/stdio/putc_u.c
new file mode 100644
index 0000000..b4d94e8
--- /dev/null
+++ b/libio/stdio/putc_u.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1991, 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include "libioP.h"
+#include "stdio.h"
+
+#undef putc_unlocked
+
+int
+putc_unlocked (c, fp)
+ int c;
+ _IO_FILE *fp;
+{
+ CHECK_FILE (fp, EOF);
+ return _IO_putc_unlocked (c, fp);
+}
diff --git a/libio/stdio/putchar.c b/libio/stdio/putchar.c
new file mode 100644
index 0000000..1e1dd13
--- /dev/null
+++ b/libio/stdio/putchar.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 1991, 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include "libioP.h"
+#include "stdio.h"
+
+#undef putchar
+
+int
+putchar (c)
+ int c;
+{
+ int result;
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ _IO_stdout);
+ _IO_flockfile (_IO_stdout);
+ result = _IO_putc_unlocked (c, _IO_stdout);
+ _IO_cleanup_region_end (1);
+ return result;
+}
diff --git a/libio/stdio/putchar_u.c b/libio/stdio/putchar_u.c
new file mode 100644
index 0000000..f8f387a
--- /dev/null
+++ b/libio/stdio/putchar_u.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 1991, 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include "libioP.h"
+#include "stdio.h"
+
+#undef putchar_unlocked
+
+int
+putchar_unlocked (c)
+ int c;
+{
+ CHECK_FILE (stdout, EOF);
+ return _IO_putc_unlocked (c, stdout);
+}
diff --git a/libio/stdio/putw.c b/libio/stdio/putw.c
new file mode 100644
index 0000000..fd73261
--- /dev/null
+++ b/libio/stdio/putw.c
@@ -0,0 +1,15 @@
+#include "libioP.h"
+#include "stdio.h"
+
+#undef putw
+
+int
+putw(w, fp)
+ int w;
+ FILE *fp;
+{
+ _IO_size_t written;
+ CHECK_FILE(fp, EOF);
+ written = _IO_sputn(fp, (const char *)&w, sizeof(w));
+ return written == sizeof(w) ? 0 : EOF;
+}
diff --git a/libio/stdio/rewind.c b/libio/stdio/rewind.c
new file mode 100644
index 0000000..bce2757
--- /dev/null
+++ b/libio/stdio/rewind.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to
+ the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA.
+
+ As a special exception, if you link this library with files
+ compiled with a GNU compiler to produce an executable, this does
+ not cause the resulting executable to be covered by the GNU General
+ Public License. This exception does not however invalidate any
+ other reasons why the executable file might be covered by the GNU
+ General Public License. */
+
+#include "libioP.h"
+#include "stdio.h"
+
+void
+rewind (fp)
+ _IO_FILE *fp;
+{
+ CHECK_FILE (fp, );
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
+ _IO_flockfile (fp);
+ _IO_rewind (fp);
+ _IO_cleanup_region_end (1);
+}
diff --git a/libio/stdio/setbuf.c b/libio/stdio/setbuf.c
new file mode 100644
index 0000000..ac323a3
--- /dev/null
+++ b/libio/stdio/setbuf.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 1993, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to
+ the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA.
+
+ As a special exception, if you link this library with files
+ compiled with a GNU compiler to produce an executable, this does
+ not cause the resulting executable to be covered by the GNU General
+ Public License. This exception does not however invalidate any
+ other reasons why the executable file might be covered by the GNU
+ General Public License. */
+
+#include "libioP.h"
+#include "stdio.h"
+
+void
+setbuf (fp, buf)
+ _IO_FILE *fp;
+ char *buf;
+{
+ _IO_setbuffer (fp, buf, _IO_BUFSIZ);
+}
diff --git a/libio/stdio/setfileno.c b/libio/stdio/setfileno.c
new file mode 100644
index 0000000..f7ccc6f
--- /dev/null
+++ b/libio/stdio/setfileno.c
@@ -0,0 +1,17 @@
+/* Some known programs (xterm, pdksh?) non-portably change the _file
+ field of s struct _iobuf. This kludge allows the same "functionality".
+ This code is an undocumented feature for iostream/stdio. Use it at
+ your own risk. */
+
+#include "libioP.h"
+#include "stdio.h"
+
+void
+setfileno(fp, fd)
+ _IO_FILE* fp;
+ int fd;
+{
+ CHECK_FILE(fp, );
+ if ((fp->_flags & _IO_IS_FILEBUF) != 0)
+ fp->_fileno = fd;
+}
diff --git a/libio/stdio/setlinebuf.c b/libio/stdio/setlinebuf.c
new file mode 100644
index 0000000..e4e029f
--- /dev/null
+++ b/libio/stdio/setlinebuf.c
@@ -0,0 +1,36 @@
+/* Copyright (C) 1993, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to
+ the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA.
+
+ As a special exception, if you link this library with files
+ compiled with a GNU compiler to produce an executable, this does
+ not cause the resulting executable to be covered by the GNU General
+ Public License. This exception does not however invalidate any
+ other reasons why the executable file might be covered by the GNU
+ General Public License. */
+
+#include "libioP.h"
+#include "stdio.h"
+
+#undef setlinebuf
+
+void
+setlinebuf (stream)
+ _IO_FILE *stream;
+{
+ _IO_setvbuf (stream, NULL, 1, 0);
+}
diff --git a/libio/stdio/snprintf.c b/libio/stdio/snprintf.c
new file mode 100644
index 0000000..5c70a44
--- /dev/null
+++ b/libio/stdio/snprintf.c
@@ -0,0 +1,51 @@
+/*
+Copyright (C) 1994 Free Software Foundation
+
+This file is part of the GNU IO Library. This library is free
+software; you can redistribute it and/or modify it under the
+terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this library; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+As a special exception, if you link this library with files
+compiled with a GNU compiler to produce an executable, this does not cause
+the resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why
+the executable file might be covered by the GNU General Public License. */
+
+#include "libioP.h"
+
+#ifdef __STDC__
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+
+int
+snprintf
+#ifdef __STDC__
+ (char *string, _IO_size_t maxlen, const char *format, ...)
+#else
+(string, maxlen, format, va_alist)
+ char *string;
+ _IO_size_t maxlen;
+ char *format;
+ va_dcl
+#endif
+{
+ int ret;
+ va_list args;
+ _IO_va_start(args, format);
+ ret = vsnprintf(string, maxlen, format, args);
+ va_end(args);
+ return ret;
+}
diff --git a/libio/stdio/stdio.h b/libio/stdio/stdio.h
new file mode 100644
index 0000000..30065ac
--- /dev/null
+++ b/libio/stdio/stdio.h
@@ -0,0 +1,219 @@
+/* This is part of the iostream/stdio library, providing -*- C -*- I/O.
+ Define ANSI C stdio on top of C++ iostreams.
+ Copyright (C) 1991, 1994 Free Software Foundation
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+/*
+ * ANSI Standard: 4.9 INPUT/OUTPUT <stdio.h>
+ */
+
+#ifndef _STDIO_H
+#define _STDIO_H
+#define _STDIO_USES_IOSTREAM
+
+#include <libio.h>
+
+#ifndef NULL
+#ifdef __cplusplus
+#define NULL 0
+#else
+#define NULL (void*)0
+#endif
+#endif
+
+#ifndef EOF
+#define EOF (-1)
+#endif
+#ifndef BUFSIZ
+#define BUFSIZ 1024
+#endif
+
+#define _IOFBF 0 /* Fully buffered. */
+#define _IOLBF 1 /* Line buffered. */
+#define _IONBF 2 /* No buffering. */
+
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+
+ /* define size_t. Crud in case <sys/types.h> has defined it. */
+#if !defined(_SIZE_T) && !defined(_T_SIZE_) && !defined(_T_SIZE)
+#if !defined(__SIZE_T) && !defined(_SIZE_T_) && !defined(___int_size_t_h)
+#if !defined(_GCC_SIZE_T) && !defined(_SIZET_)
+#define _SIZE_T
+#define _T_SIZE_
+#define _T_SIZE
+#define __SIZE_T
+#define _SIZE_T_
+#define ___int_size_t_h
+#define _GCC_SIZE_T
+#define _SIZET_
+typedef _IO_size_t size_t;
+#endif
+#endif
+#endif
+
+typedef struct _IO_FILE FILE;
+typedef _IO_fpos_t fpos_t;
+
+#define FOPEN_MAX _G_FOPEN_MAX
+#define FILENAME_MAX _G_FILENAME_MAX
+#ifndef TMP_MAX
+#define TMP_MAX 999 /* Only limited by filename length */
+#endif
+
+#define L_ctermid 9
+#define L_cuserid 9
+#define P_tmpdir "/tmp"
+#define L_tmpnam 20
+
+/* For use by debuggers. These are linked in if printf or fprintf are used. */
+extern FILE *stdin, *stdout, *stderr; /* TODO */
+
+#define stdin _IO_stdin
+#define stdout _IO_stdout
+#define stderr _IO_stderr
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef __P
+#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
+#define __P(args) args
+#else
+#define __P(args) ()
+#endif
+#endif /*!__P*/
+
+extern void clearerr __P((FILE*));
+extern int fclose __P((FILE*));
+extern int feof __P((FILE*));
+extern int ferror __P((FILE*));
+extern int fflush __P((FILE*));
+extern int fgetc __P((FILE *));
+extern int fgetpos __P((FILE* fp, fpos_t *pos));
+extern char* fgets __P((char*, int, FILE*));
+extern FILE* fopen __P((const char*, const char*));
+extern int fprintf __P((FILE*, const char* format, ...));
+extern int fputc __P((int, FILE*));
+extern int fputs __P((const char *str, FILE *fp));
+extern size_t fread __P((void*, size_t, size_t, FILE*));
+extern FILE* freopen __P((const char*, const char*, FILE*));
+extern int fscanf __P((FILE *fp, const char* format, ...));
+extern int fseek __P((FILE* fp, long int offset, int whence));
+extern int fsetpos __P((FILE* fp, const fpos_t *pos));
+extern long int ftell __P((FILE* fp));
+extern size_t fwrite __P((const void*, size_t, size_t, FILE*));
+extern int getc __P((FILE *));
+extern int getchar __P((void));
+extern char* gets __P((char*));
+extern void perror __P((const char *));
+extern int printf __P((const char* format, ...));
+extern int putc __P((int, FILE *));
+extern int putchar __P((int));
+extern int puts __P((const char *str));
+extern int remove __P((const char*));
+extern int rename __P((const char* _old, const char* _new));
+extern void rewind __P((FILE*));
+extern int scanf __P((const char* format, ...));
+extern void setbuf __P((FILE*, char*));
+extern void setlinebuf __P((FILE*));
+extern void setbuffer __P((FILE*, char*, int));
+extern int setvbuf __P((FILE*, char*, int mode, size_t size));
+extern int sprintf __P((char*, const char* format, ...));
+extern int sscanf __P((const char* string, const char* format, ...));
+extern FILE* tmpfile __P((void));
+extern char* tmpnam __P((char*));
+extern int ungetc __P((int c, FILE* fp));
+extern int vfprintf __P((FILE *fp, char const *fmt0, _IO_va_list));
+extern int vprintf __P((char const *fmt, _IO_va_list));
+extern int vsprintf __P((char* string, const char* format, _IO_va_list));
+
+#ifndef __STRICT_ANSI__
+extern int vfscanf __P((FILE*, const char *, _IO_va_list));
+extern int vscanf __P((const char *, _IO_va_list));
+extern int vsscanf __P((const char *, const char *, _IO_va_list));
+#endif
+
+#if !defined(__STRICT_ANSI__) || defined(_POSIX_SOURCE)
+extern FILE *fdopen __P((int, const char *));
+extern int fileno __P((FILE*));
+extern FILE* popen __P((const char*, const char*));
+extern int pclose __P((FILE*));
+#endif
+
+#ifdef __USE_GNU
+extern _IO_ssize_t getdelim __P ((char **, size_t *, int, FILE*));
+extern _IO_ssize_t getline __P ((char **, size_t *, FILE *));
+
+extern int snprintf __P ((char *, size_t, const char *, ...));
+extern int vsnprintf __P ((char *, size_t, const char *, _IO_va_list));
+#endif
+
+extern int __underflow __P((struct _IO_FILE*));
+extern int __overflow __P((struct _IO_FILE*, int));
+
+/* Handle locking of streams. */
+#if defined _REENTRANT || defined _THREAD_SAFE
+extern void clearerr_locked __P ((FILE *));
+extern void clearerr_unlocked __P ((FILE *));
+extern int feof_locked __P ((FILE *));
+extern int feof_unlocked __P ((FILE *));
+extern int ferror_locked __P ((FILE*));
+extern int ferror_unlocked __P ((FILE*));
+extern int fileno_locked __P ((FILE *));
+extern int fileno_unlocked __P ((FILE *));
+extern void flockfile __P ((FILE *));
+extern void funlockfile __P ((FILE *));
+extern int ftrylockfile __P ((FILE *));
+extern int fclose_unlocked __P ((FILE *));
+extern int fflush_locked __P ((FILE *));
+extern int fflush_unlocked __P ((FILE *));
+extern size_t fread_unlocked __P ((void *, size_t, size_t, FILE *));
+extern size_t fwrite_unlocked __P ((const void *, size_t, size_t, FILE *));
+
+extern int fputc_locked __P ((int, FILE*));
+extern int fputc_unlocked __P ((int, FILE*));
+extern int getc_locked __P ((FILE *));
+extern int getc_unlocked __P ((FILE *));
+extern int getchar_locked __P ((void));
+extern int getchar_unlocked __P ((void));
+extern int putc_locked __P ((int, FILE *));
+extern int putc_unlocked __P ((int, FILE *));
+extern int putchar_locked __P ((int));
+extern int putchar_unlocked __P ((int));
+
+# define getc_unlocked(fp) _IO_getc_unlocked (fp)
+# define getc_locked(fp) _IO_getc (fp)
+# define getchar_unlocked() _IO_getc_unlocked (stdin)
+# define getchar_locked() _IO_getc (stdin)
+# define putchar_unlocked(c) _IO_putc_unlocked (c, stdout)
+# define putchar_locked(c) _IO_putc (c, stdout)
+#endif /* __USE_REENTRANT */
+
+#define getc(fp) _IO_getc(fp)
+#define putc(c, fp) _IO_putc(c, fp)
+#define putchar(c) _IO_putc(c, stdout)
+#define getchar() _IO_getc(stdin)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*!_STDIO_H*/
diff --git a/libio/stdio/vasprintf.c b/libio/stdio/vasprintf.c
new file mode 100644
index 0000000..15513d0
--- /dev/null
+++ b/libio/stdio/vasprintf.c
@@ -0,0 +1,72 @@
+/* Copyright (C) 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to
+ the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA.
+
+ As a special exception, if you link this library with files
+ compiled with a GNU compiler to produce an executable, this does
+ not cause the resulting executable to be covered by the GNU General
+ Public License. This exception does not however invalidate any
+ other reasons why the executable file might be covered by the GNU
+ General Public License. */
+
+#include <malloc.h>
+#include "libioP.h"
+#include "stdio.h"
+#include "strfile.h"
+
+int
+_IO_vasprintf (result_ptr, format, args)
+ char **result_ptr;
+ const char *format;
+ _IO_va_list args;
+{
+ /* Initial size of the buffer to be used. Will be doubled each time an
+ overflow occurs. */
+ const _IO_size_t init_string_size = 100;
+ char *string;
+ _IO_strfile sf;
+#ifdef _IO_MTSAFE_IO
+ _IO_lock_t lock;
+#endif
+ int ret;
+ string = (char *) malloc (init_string_size);
+ if (string == NULL)
+ return -1;
+#ifdef _IO_MTSAFE_IO
+ sf._sbf._f._lock = &lock;
+#endif
+ _IO_init ((_IO_FILE *) &sf, 0);
+ _IO_JUMPS ((_IO_FILE *) &sf) = &_IO_str_jumps;
+ _IO_str_init_static ((_IO_FILE *) &sf, string, init_string_size, string);
+ sf._sbf._f._flags &= ~_IO_USER_BUF;
+ sf._s._allocate_buffer = (_IO_alloc_type) malloc;
+ sf._s._free_buffer = (_IO_free_type) free;
+ ret = _IO_vfprintf ((_IO_FILE *) &sf, format, args);
+ if (ret < 0)
+ return ret;
+ *result_ptr = (char *) realloc (sf._sbf._f._IO_buf_base,
+ (sf._sbf._f._IO_write_ptr
+ - sf._sbf._f._IO_write_base) +1);
+ if (*result_ptr == NULL)
+ *result_ptr = sf._sbf._f._IO_buf_base;
+ (*result_ptr)[sf._sbf._f._IO_write_ptr-sf._sbf._f._IO_write_base] = '\0';
+ return ret;
+}
+
+#ifdef weak_alias
+weak_alias (_IO_vasprintf, vasprintf)
+#endif
diff --git a/libio/stdio/vfprintf.c b/libio/stdio/vfprintf.c
new file mode 100644
index 0000000..fca6209
--- /dev/null
+++ b/libio/stdio/vfprintf.c
@@ -0,0 +1,35 @@
+/*
+Copyright (C) 1993 Free Software Foundation
+
+This file is part of the GNU IO Library. This library is free
+software; you can redistribute it and/or modify it under the
+terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this library; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+As a special exception, if you link this library with files
+compiled with a GNU compiler to produce an executable, this does not cause
+the resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why
+the executable file might be covered by the GNU General Public License. */
+
+#include "libioP.h"
+
+int
+vfprintf(fp, format, args)
+ register _IO_FILE* fp;
+ char const *format;
+ _IO_va_list args;
+{
+ CHECK_FILE(fp, -1);
+ return _IO_vfprintf(fp, format, args);
+}
diff --git a/libio/stdio/vfscanf.c b/libio/stdio/vfscanf.c
new file mode 100644
index 0000000..1759ee5
--- /dev/null
+++ b/libio/stdio/vfscanf.c
@@ -0,0 +1,36 @@
+/*
+Copyright (C) 1993 Free Software Foundation
+
+This file is part of the GNU IO Library. This library is free
+software; you can redistribute it and/or modify it under the
+terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this library; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+As a special exception, if you link this library with files
+compiled with a GNU compiler to produce an executable, this does not cause
+the resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why
+the executable file might be covered by the GNU General Public License. */
+
+#include "libioP.h"
+#include "stdio.h"
+
+int
+vfscanf(fp, format, args)
+ register _IO_FILE* fp;
+ const char *format;
+ _IO_va_list args;
+{
+ CHECK_FILE(fp, EOF);
+ return _IO_vfscanf(fp, format, args, NULL);
+}
diff --git a/libio/stdio/vprintf.c b/libio/stdio/vprintf.c
new file mode 100644
index 0000000..784f0d9
--- /dev/null
+++ b/libio/stdio/vprintf.c
@@ -0,0 +1,33 @@
+/*
+Copyright (C) 1993 Free Software Foundation
+
+This file is part of the GNU IO Library. This library is free
+software; you can redistribute it and/or modify it under the
+terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this library; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+As a special exception, if you link this library with files
+compiled with a GNU compiler to produce an executable, this does not cause
+the resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why
+the executable file might be covered by the GNU General Public License. */
+
+#include "libioP.h"
+#include "stdio.h"
+
+int vprintf(format, args)
+ const char* format;
+ _IO_va_list args;
+{
+ return _IO_vfprintf(_IO_stdout, format, args);
+}
diff --git a/libio/stdio/vscanf.c b/libio/stdio/vscanf.c
new file mode 100644
index 0000000..8b92ae2
--- /dev/null
+++ b/libio/stdio/vscanf.c
@@ -0,0 +1,41 @@
+/* Copyright (C) 1993, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to
+ the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA.
+
+ As a special exception, if you link this library with files
+ compiled with a GNU compiler to produce an executable, this does
+ not cause the resulting executable to be covered by the GNU General
+ Public License. This exception does not however invalidate any
+ other reasons why the executable file might be covered by the GNU
+ General Public License. */
+
+#include "libioP.h"
+#include "stdio.h"
+
+#undef vscanf
+
+int
+_IO_vscanf (format, args)
+ const char *format;
+ _IO_va_list args;
+{
+ return _IO_vfscanf (_IO_stdin, format, args, NULL);
+}
+
+#ifdef weak_alias
+weak_alias (_IO_vscanf, vscanf)
+#endif
diff --git a/libio/stdio/vsnprintf.c b/libio/stdio/vsnprintf.c
new file mode 100644
index 0000000..3f35af2
--- /dev/null
+++ b/libio/stdio/vsnprintf.c
@@ -0,0 +1,136 @@
+/* Copyright (C) 1994, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to
+ the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA.
+
+ As a special exception, if you link this library with files
+ compiled with a GNU compiler to produce an executable, this does
+ not cause the resulting executable to be covered by the GNU General
+ Public License. This exception does not however invalidate any
+ other reasons why the executable file might be covered by the GNU
+ General Public License. */
+
+#include "libioP.h"
+#include "strfile.h"
+
+
+typedef struct
+{
+ _IO_strfile f;
+ /* This is used for the characters which do not fit in the buffer
+ provided by the user. */
+ char overflow_buf[64];
+} _IO_strnfile;
+
+
+static int _IO_strn_overflow __P ((_IO_FILE *fp, int c));
+
+static int
+_IO_strn_overflow (fp, c)
+ _IO_FILE *fp;
+ int c;
+{
+ /* When we come to here this means the user supplied buffer is
+ filled. But since we must return the number of characters which
+ would have been written in total we must provide a buffer for
+ further use. We can do this by writing on and on in the overflow
+ buffer in the _IO_strnfile structure. */
+ _IO_strnfile *snf = (_IO_strnfile *) fp;
+
+ if (fp->_IO_buf_base != snf->overflow_buf)
+ {
+ /* Terminate the string. We know that there is room for at
+ least one more character since we initialized the stream with
+ a size to make this possible. */
+ *fp->_IO_write_ptr = '\0';
+
+ _IO_setb (fp, snf->overflow_buf,
+ snf->overflow_buf + sizeof (snf->overflow_buf), 0);
+
+ fp->_IO_write_base = snf->overflow_buf;
+ fp->_IO_read_base = snf->overflow_buf;
+ fp->_IO_read_ptr = snf->overflow_buf;
+ fp->_IO_read_end = snf->overflow_buf + sizeof (snf->overflow_buf);
+ }
+
+ fp->_IO_write_ptr = snf->overflow_buf;
+ fp->_IO_write_end = snf->overflow_buf;
+
+ /* Since we are not really interested in storing the characters
+ which do not fit in the buffer we simply ignore it. */
+ return c;
+}
+
+
+static struct _IO_jump_t _IO_strn_jumps =
+{
+ JUMP_INIT_DUMMY,
+ JUMP_INIT(finish, _IO_str_finish),
+ JUMP_INIT(overflow, _IO_strn_overflow),
+ JUMP_INIT(underflow, _IO_str_underflow),
+ JUMP_INIT(uflow, _IO_default_uflow),
+ JUMP_INIT(pbackfail, _IO_str_pbackfail),
+ JUMP_INIT(xsputn, _IO_default_xsputn),
+ JUMP_INIT(xsgetn, _IO_default_xsgetn),
+ JUMP_INIT(seekoff, _IO_str_seekoff),
+ JUMP_INIT(seekpos, _IO_default_seekpos),
+ JUMP_INIT(setbuf, _IO_default_setbuf),
+ JUMP_INIT(sync, _IO_default_sync),
+ JUMP_INIT(doallocate, _IO_default_doallocate),
+ JUMP_INIT(read, _IO_default_read),
+ JUMP_INIT(write, _IO_default_write),
+ JUMP_INIT(seek, _IO_default_seek),
+ JUMP_INIT(close, _IO_default_close),
+ JUMP_INIT(stat, _IO_default_stat)
+};
+
+
+int
+_IO_vsnprintf (string, maxlen, format, args)
+ char *string;
+ _IO_size_t maxlen;
+ const char *format;
+ _IO_va_list args;
+{
+ _IO_strnfile sf;
+ int ret;
+#ifdef _IO_MTSAFE_IO
+ _IO_lock_t lock;
+ sf.f._sbf._f._lock = &lock;
+#endif
+
+ /* We need to handle the special case where MAXLEN is 0. Use the
+ overflow buffer right from the start. */
+ if (maxlen == 0)
+ {
+ string = sf.overflow_buf;
+ maxlen = sizeof (sf.overflow_buf);
+ }
+
+ _IO_init ((_IO_FILE *) &sf, 0);
+ _IO_JUMPS ((_IO_FILE *) &sf) = &_IO_strn_jumps;
+ _IO_str_init_static ((_IO_FILE *) &sf, string, maxlen - 1, string);
+ ret = _IO_vfprintf ((_IO_FILE *) &sf, format, args);
+
+ if (sf.f._sbf._f._IO_buf_base != sf.overflow_buf)
+ *sf.f._sbf._f._IO_write_ptr = '\0';
+ return ret;
+}
+
+#ifdef weak_alias
+weak_alias (_IO_vsnprintf, __vsnprintf)
+weak_alias (_IO_vsnprintf, vsnprintf)
+#endif
OpenPOWER on IntegriCloud