summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1997-08-20 03:53:21 +0000
committerUlrich Drepper <drepper@redhat.com>1997-08-20 03:53:21 +0000
commit40a55d2054ef9d9085c4e6b0157c5d30608736fc (patch)
tree7ccdbae13abe1988c2ce9af0f936daac639ba1b5
parentca34d7a7c77fa8dc823fd05439870e5a96610c5a (diff)
1997-08-20 05:30 Ulrich Drepper <drepper@cygnus.com> * catgets/catgets.c (catclose): Use __munmap instead of munmap. * catgets/gencat.c (read_input_file): Fix typo. * dirent/dirent.h: Make seekdir and telldir available for __USE_XOPEN. * elf/dl-load.c: Fix case of missing DT_RPATH in object which gets executed (e.g., when it is a static binary). * intl/bindtextdomain.c: Use strdup in glibc. Correct comment. * intl/dcgettext.c: Likewise. * intl/dgettext.c: Likewise. * intl/explodename.c: Likewise. * intl/finddomain.c: Likewise. * intl/gettext.c: Likewise. * intl/gettext.h: Likewise. * intl/hash-string.h: Likewise. * intl/l10nflist.c: Likewise. * intl/libintl.h: Likewise. * intl/loadinfo.h: Likewise. * intl/loadmsgcat.c: Likewise. * intl/localealias.c: Likewise. * intl/textdomain.c: Likewise. Unify libio sources with code in libg++. * libio/fcloseall.c: Update and reformat copyright. Protect use of weak_alias. Use _IO_* thread macros instead of __libc_*. * libio/feof.c: Likewise. * libio/feof_u.c: Likewise. * libio/ferror.c: Likewise. * libio/ferror_u.c: Likewise. * libio/fgetc.c: Likewise. * libio/filedoalloc.c: Likewise. * libio/fileno.c: Likewise. * libio/fileops.c: Likewise. * libio/fputc.c: Likewise. * libio/fputc_u.c: Likewise. * libio/freopen.c: Likewise. * libio/fseek.c: Likewise. * libio/genops.c: Likewise. * libio/getc.c: Likewise. * libio/getc_u.c: Likewise. * libio/getchar.c: Likewise. * libio/getchar_u.c: Likewise. * libio/iofclose.c: Likewise. * libio/iofdopen.c: Likewise. * libio/iofflush.c: Likewise. * libio/iofflush_u.c: Likewise. * libio/iofgetpos.c: Likewise. * libio/iofgets.c: Likewise. * libio/iofopen.c: Likewise. * libio/iofopncook.c: Likewise. * libio/iofprintf.c: Likewise. * libio/iofputs.c: Likewise. * libio/iofread.c: Likewise. * libio/iofsetpos.c: Likewise. * libio/ioftell.c: Likewise. * libio/iofwrite.c: Likewise. * libio/iogetdelim.c: Likewise. * libio/iogetline.c: Likewise. * libio/iogets.c: Likewise. * libio/iopadn.c: Likewise. * libio/iopopen.c: Likewise. * libio/ioputs.c: Likewise. * libio/ioseekoff.c: Likewise. * libio/ioseekpos.c: Likewise. * libio/iosetbuffer.c: Likewise. * libio/iosetvbuf.c: Likewise. * libio/iosprintf.c: Likewise. * libio/ioungetc.c: Likewise. * libio/iovdprintf.c: Likewise. * libio/iovsprintf.c: Likewise. * libio/iovsscanf.c: Likewise. * libio/libio.h: Likewise. * libio/libioP.h: Likewise. * libio/obprintf.c: Likewise. * libio/pclose.c: Likewise. * libio/peekc.c: Likewise. * libio/putc.c: Likewise. * libio/putchar.c: Likewise. * libio/rewind.c: Likewise. * libio/setbuf.c: Likewise. * libio/setlinebuf.c: Likewise. * libio/stdfiles.c: Likewise. * libio/stdio.c: Likewise. * libio/strfile.h: Likewise. * libio/strops.c: Likewise. * libio/vasprintf.c: Likewise. * libio/vscanf.c: Likewise. * libio/vsnprintf.c: Likewise. * manual/libc.texinfo: Add menu entries for chapter on message translation. * manual/locale.texi: Correct next entry in @node for new chapter. * manual/search.texi: Likewise for previous link. * manual/message.texi: New file. * manual/startup.texi: Document LC_ALL, LC_MESSAGES, NLSPATH, setenv, unsetenv, and clearenv. * manual/string.texi: Fix typos. Patch by Jim Meyering. * math/Makefile (test-longdouble-yes): Enable. We want long double tests now. Crusade against strcat. * nis/nss_nisplus/nisplus-publickey.c: Remove uses of strcat. * stdlib/canonicalize.c: Likewise. * posix/glob.h: Define __const if necessary. Use __const in all prototypes. * sysdeps/generic/stpcpy.c: Use K&R form to allow use in other GNU packages. * posix/wordexp.c: Completely reworked buffer handling for much better performance. Patch by Tim Waugh. * socket/sys/sochet.h (getpeername): Fix type of LEN parameter, it must be socklen_t. * sysdeps/libm-i387/e_remainder.S: Pretty print. * sysdeps/libm-i387/e_remainderf.S: Likewise. * sysdeps/libm-i387/e_remainderl.S: Pop extra value for FPU stack. * sysdeps/libm-i387/s_cexp.S: Little optimization. * sysdeps/libm-i387/s_cexpl.S: Likewise. * sysdep/libm-ieee754/s_csinhl.c: Include <fenv.h>. 1997-08-18 15:21 Ulrich Drepper <drepper@cygnus.com> * sysdeps/unix/sysv/linux/if_index.c (if_nameindex): Fix memory leak in cleanup code. 1997-08-17 Paul Eggert <eggert@twinsun.com> * tzset.c (__tzset_internal): Fix memory leak when the user specifies a TZ value that uses a default rule file. Do not assume US DST rules when the user specifies that there is no DST. 1997-08-10 19:17 Philip Blundell <Philip.Blundell@pobox.com> * inet/getnameinfo.c: Tidy up. * sysdeps/posix/getaddrinfo.c: Likewise. * sysdeps/unix/sysv/linux/if_index.c (if_nametoindex): Return 0 if using stub code. (if_indextoname): Use SIOGIFNAME ioctl if the kernel supports it. (if_nameindex): Use alloca() rather than malloc(); use SIOCGIFCOUNT ioctl if the kernel supports it. 1997-08-16 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/unix/sysv/linux/sys/mount.h: Remove the IS_* macros, they operate on internal kernel structures and have no place in a user header. 1997-08-16 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * Makerules (lib%.so): Depend on $(+preinit) and $(+postinit). (build-shlib): Filter them out of $^. 1997-08-15 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * elf/dl-error.c (_dl_signal_error): Fix error message. 1997-08-16 04:06 Ulrich Drepper <drepper@cygnus.com> * assert/assert.h [__USE_GNU]: Undefine assert_perror. Reported by Theodore C. Belding <Ted.Belding@umich.edu>. 1997-08-13 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * Makeconfig: Change object suffixes from *.[spgb]o to *.o[spgb] to avoid conflict with PO files. * Makerules: Likewise. * Rules: Likewise. * elf/Makefile: Likewise. * extra-lib.mk: Likewise. * gmon/Makefile: Likewise. * nis/Makefile: Likewise. * nss/Makefile: Likewise. * resolv/Makefile: Likewise. * rpm/Makefile: Likewise. * sunrpc/Makefile: Likewise. * sysdeps/sparc/elf/Makefile: Likewise. * sysdeps/sparc64/elf/Makefile: Likewise. * sysdeps/unix/sysv/linux/sparc/Makefile: Likewise. (ASFLAGS-.os): Renamed from as-FLAGS.os.
-rw-r--r--ChangeLog189
-rw-r--r--INSTALL4
-rw-r--r--Makeconfig42
-rw-r--r--Makerules20
-rw-r--r--Rules2
-rw-r--r--assert/assert.h8
-rw-r--r--catgets/catgets.c2
-rw-r--r--catgets/gencat.c2
-rw-r--r--dirent/dirent.h19
-rw-r--r--elf/Makefile16
-rw-r--r--elf/dl-error.c2
-rw-r--r--elf/dl-load.c115
-rw-r--r--extra-lib.mk2
-rw-r--r--gmon/Makefile2
-rw-r--r--inet/getnameinfo.c79
-rw-r--r--intl/bindtextdom.c58
-rw-r--r--intl/dcgettext.c11
-rw-r--r--intl/dgettext.c2
-rw-r--r--intl/explodename.c2
-rw-r--r--intl/finddomain.c8
-rw-r--r--intl/gettext.c2
-rw-r--r--intl/gettext.h2
-rw-r--r--intl/hash-string.h2
-rw-r--r--intl/l10nflist.c2
-rw-r--r--intl/libintl.h10
-rw-r--r--intl/loadinfo.h19
-rw-r--r--intl/loadmsgcat.c2
-rw-r--r--intl/localealias.c35
-rw-r--r--intl/textdomain.c5
-rw-r--r--libio/fcloseall.c42
-rw-r--r--libio/feof.c41
-rw-r--r--libio/feof_u.c38
-rw-r--r--libio/ferror.c41
-rw-r--r--libio/ferror_u.c38
-rw-r--r--libio/fgetc.c39
-rw-r--r--libio/filedoalloc.c57
-rw-r--r--libio/fileno.c49
-rw-r--r--libio/fileops.c384
-rw-r--r--libio/fputc.c39
-rw-r--r--libio/fputc_u.c39
-rw-r--r--libio/freopen.c39
-rw-r--r--libio/fseek.c39
-rw-r--r--libio/genops.c603
-rw-r--r--libio/getc.c51
-rw-r--r--libio/getc_u.c39
-rw-r--r--libio/getchar.c39
-rw-r--r--libio/getchar_u.c39
-rw-r--r--libio/iofclose.c51
-rw-r--r--libio/iofdopen.c47
-rw-r--r--libio/iofflush.c41
-rw-r--r--libio/iofflush_u.c41
-rw-r--r--libio/iofgetpos.c42
-rw-r--r--libio/iofgets.c45
-rw-r--r--libio/iofopen.c47
-rw-r--r--libio/iofopncook.c57
-rw-r--r--libio/iofprintf.c47
-rw-r--r--libio/iofputs.c39
-rw-r--r--libio/iofread.c41
-rw-r--r--libio/iofsetpos.c41
-rw-r--r--libio/ioftell.c41
-rw-r--r--libio/iofwrite.c47
-rw-r--r--libio/iogetdelim.c45
-rw-r--r--libio/iogetline.c62
-rw-r--r--libio/iogets.c43
-rw-r--r--libio/iopadn.c57
-rw-r--r--libio/iopopen.c110
-rw-r--r--libio/ioputs.c42
-rw-r--r--libio/ioseekoff.c54
-rw-r--r--libio/ioseekpos.c53
-rw-r--r--libio/iosetbuffer.c39
-rw-r--r--libio/iosetvbuf.c43
-rw-r--r--libio/iosprintf.c53
-rw-r--r--libio/ioungetc.c39
-rw-r--r--libio/iovdprintf.c42
-rw-r--r--libio/iovsprintf.c49
-rw-r--r--libio/iovsscanf.c51
-rw-r--r--libio/libio.h164
-rw-r--r--libio/libioP.h467
-rw-r--r--libio/obprintf.c6
-rw-r--r--libio/pclose.c29
-rw-r--r--libio/peekc.c45
-rw-r--r--libio/putc.c8
-rw-r--r--libio/putchar.c4
-rw-r--r--libio/rewind.c44
-rw-r--r--libio/setbuf.c38
-rw-r--r--libio/setlinebuf.c39
-rw-r--r--libio/stdfiles.c47
-rw-r--r--libio/stdio.c35
-rw-r--r--libio/strfile.h51
-rw-r--r--libio/strops.c125
-rw-r--r--libio/vasprintf.c52
-rw-r--r--libio/vscanf.c50
-rw-r--r--libio/vsnprintf.c59
-rw-r--r--manual/libc.texinfo8
-rw-r--r--manual/locale.texi2
-rw-r--r--manual/message.texi1185
-rw-r--r--manual/search.texi2
-rw-r--r--manual/startup.texi85
-rw-r--r--manual/string.texi4
-rw-r--r--math/Makefile4
-rw-r--r--nis/Makefile6
-rw-r--r--nis/nss_nisplus/nisplus-publickey.c75
-rw-r--r--nss/Makefile4
-rw-r--r--posix/glob.h60
-rw-r--r--posix/wordexp.c402
-rw-r--r--resolv/Makefile2
-rw-r--r--rpm/Makefile2
-rw-r--r--socket/sys/socket.h2
-rw-r--r--stdlib/canonicalize.c14
-rw-r--r--sunrpc/Makefile2
-rw-r--r--sysdeps/generic/stpcpy.c10
-rw-r--r--sysdeps/libm-i387/e_remainder.S2
-rw-r--r--sysdeps/libm-i387/e_remainderf.S2
-rw-r--r--sysdeps/libm-i387/e_remainderl.S1
-rw-r--r--sysdeps/libm-i387/s_cexp.S3
-rw-r--r--sysdeps/libm-i387/s_cexpl.S13
-rw-r--r--sysdeps/libm-ieee754/s_csinhl.c1
-rw-r--r--sysdeps/posix/getaddrinfo.c913
-rw-r--r--sysdeps/sparc/sparc32/elf/Makefile2
-rw-r--r--sysdeps/sparc/sparc64/elf/Makefile2
-rw-r--r--sysdeps/unix/sysv/linux/if_index.c107
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sparc32/Makefile2
-rw-r--r--sysdeps/unix/sysv/linux/sys/mount.h22
-rw-r--r--time/tzset.c9
124 files changed, 4896 insertions, 3044 deletions
diff --git a/ChangeLog b/ChangeLog
index bdcdeb974e..fc08e51511 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,192 @@
+1997-08-20 05:30 Ulrich Drepper <drepper@cygnus.com>
+
+ * catgets/catgets.c (catclose): Use __munmap instead of munmap.
+ * catgets/gencat.c (read_input_file): Fix typo.
+
+ * dirent/dirent.h: Make seekdir and telldir available for __USE_XOPEN.
+
+ * elf/dl-load.c: Fix case of missing DT_RPATH in object which gets
+ executed (e.g., when it is a static binary).
+
+ * intl/bindtextdomain.c: Use strdup in glibc. Correct comment.
+ * intl/dcgettext.c: Likewise.
+ * intl/dgettext.c: Likewise.
+ * intl/explodename.c: Likewise.
+ * intl/finddomain.c: Likewise.
+ * intl/gettext.c: Likewise.
+ * intl/gettext.h: Likewise.
+ * intl/hash-string.h: Likewise.
+ * intl/l10nflist.c: Likewise.
+ * intl/libintl.h: Likewise.
+ * intl/loadinfo.h: Likewise.
+ * intl/loadmsgcat.c: Likewise.
+ * intl/localealias.c: Likewise.
+ * intl/textdomain.c: Likewise.
+
+ Unify libio sources with code in libg++.
+ * libio/fcloseall.c: Update and reformat copyright. Protect use
+ of weak_alias. Use _IO_* thread macros instead of __libc_*.
+ * libio/feof.c: Likewise.
+ * libio/feof_u.c: Likewise.
+ * libio/ferror.c: Likewise.
+ * libio/ferror_u.c: Likewise.
+ * libio/fgetc.c: Likewise.
+ * libio/filedoalloc.c: Likewise.
+ * libio/fileno.c: Likewise.
+ * libio/fileops.c: Likewise.
+ * libio/fputc.c: Likewise.
+ * libio/fputc_u.c: Likewise.
+ * libio/freopen.c: Likewise.
+ * libio/fseek.c: Likewise.
+ * libio/genops.c: Likewise.
+ * libio/getc.c: Likewise.
+ * libio/getc_u.c: Likewise.
+ * libio/getchar.c: Likewise.
+ * libio/getchar_u.c: Likewise.
+ * libio/iofclose.c: Likewise.
+ * libio/iofdopen.c: Likewise.
+ * libio/iofflush.c: Likewise.
+ * libio/iofflush_u.c: Likewise.
+ * libio/iofgetpos.c: Likewise.
+ * libio/iofgets.c: Likewise.
+ * libio/iofopen.c: Likewise.
+ * libio/iofopncook.c: Likewise.
+ * libio/iofprintf.c: Likewise.
+ * libio/iofputs.c: Likewise.
+ * libio/iofread.c: Likewise.
+ * libio/iofsetpos.c: Likewise.
+ * libio/ioftell.c: Likewise.
+ * libio/iofwrite.c: Likewise.
+ * libio/iogetdelim.c: Likewise.
+ * libio/iogetline.c: Likewise.
+ * libio/iogets.c: Likewise.
+ * libio/iopadn.c: Likewise.
+ * libio/iopopen.c: Likewise.
+ * libio/ioputs.c: Likewise.
+ * libio/ioseekoff.c: Likewise.
+ * libio/ioseekpos.c: Likewise.
+ * libio/iosetbuffer.c: Likewise.
+ * libio/iosetvbuf.c: Likewise.
+ * libio/iosprintf.c: Likewise.
+ * libio/ioungetc.c: Likewise.
+ * libio/iovdprintf.c: Likewise.
+ * libio/iovsprintf.c: Likewise.
+ * libio/iovsscanf.c: Likewise.
+ * libio/libio.h: Likewise.
+ * libio/libioP.h: Likewise.
+ * libio/obprintf.c: Likewise.
+ * libio/pclose.c: Likewise.
+ * libio/peekc.c: Likewise.
+ * libio/putc.c: Likewise.
+ * libio/putchar.c: Likewise.
+ * libio/rewind.c: Likewise.
+ * libio/setbuf.c: Likewise.
+ * libio/setlinebuf.c: Likewise.
+ * libio/stdfiles.c: Likewise.
+ * libio/stdio.c: Likewise.
+ * libio/strfile.h: Likewise.
+ * libio/strops.c: Likewise.
+ * libio/vasprintf.c: Likewise.
+ * libio/vscanf.c: Likewise.
+ * libio/vsnprintf.c: Likewise.
+
+ * manual/libc.texinfo: Add menu entries for chapter on message
+ translation.
+ * manual/locale.texi: Correct next entry in @node for new chapter.
+ * manual/search.texi: Likewise for previous link.
+ * manual/message.texi: New file.
+ * manual/startup.texi: Document LC_ALL, LC_MESSAGES, NLSPATH,
+ setenv, unsetenv, and clearenv.
+ * manual/string.texi: Fix typos. Patch by Jim Meyering.
+
+ * math/Makefile (test-longdouble-yes): Enable. We want long double
+ tests now.
+
+ Crusade against strcat.
+ * nis/nss_nisplus/nisplus-publickey.c: Remove uses of strcat.
+ * stdlib/canonicalize.c: Likewise.
+
+ * posix/glob.h: Define __const if necessary. Use __const in all
+ prototypes.
+
+ * sysdeps/generic/stpcpy.c: Use K&R form to allow use in other
+ GNU packages.
+
+ * posix/wordexp.c: Completely reworked buffer handling for much
+ better performance. Patch by Tim Waugh.
+
+ * socket/sys/sochet.h (getpeername): Fix type of LEN parameter,
+ it must be socklen_t.
+
+ * sysdeps/libm-i387/e_remainder.S: Pretty print.
+ * sysdeps/libm-i387/e_remainderf.S: Likewise.
+ * sysdeps/libm-i387/e_remainderl.S: Pop extra value for FPU stack.
+ * sysdeps/libm-i387/s_cexp.S: Little optimization.
+ * sysdeps/libm-i387/s_cexpl.S: Likewise.
+ * sysdep/libm-ieee754/s_csinhl.c: Include <fenv.h>.
+
+1997-08-18 15:21 Ulrich Drepper <drepper@cygnus.com>
+
+ * sysdeps/unix/sysv/linux/if_index.c (if_nameindex): Fix memory leak
+ in cleanup code.
+
+1997-08-17 Paul Eggert <eggert@twinsun.com>
+
+ * tzset.c (__tzset_internal): Fix memory leak when the user
+ specifies a TZ value that uses a default rule file.
+ Do not assume US DST rules when the user specifies
+ that there is no DST.
+
+1997-08-10 19:17 Philip Blundell <Philip.Blundell@pobox.com>
+
+ * inet/getnameinfo.c: Tidy up.
+ * sysdeps/posix/getaddrinfo.c: Likewise.
+
+ * sysdeps/unix/sysv/linux/if_index.c (if_nametoindex): Return 0 if
+ using stub code.
+ (if_indextoname): Use SIOGIFNAME ioctl if the kernel supports it.
+ (if_nameindex): Use alloca() rather than malloc(); use
+ SIOCGIFCOUNT ioctl if the kernel supports it.
+
+1997-08-16 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * sysdeps/unix/sysv/linux/sys/mount.h: Remove the IS_* macros,
+ they operate on internal kernel structures and have no place in a
+ user header.
+
+1997-08-16 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * Makerules (lib%.so): Depend on $(+preinit) and $(+postinit).
+ (build-shlib): Filter them out of $^.
+
+1997-08-15 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * elf/dl-error.c (_dl_signal_error): Fix error message.
+
+1997-08-16 04:06 Ulrich Drepper <drepper@cygnus.com>
+
+ * assert/assert.h [__USE_GNU]: Undefine assert_perror.
+ Reported by Theodore C. Belding <Ted.Belding@umich.edu>.
+
+1997-08-13 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * Makeconfig: Change object suffixes from *.[spgb]o to *.o[spgb]
+ to avoid conflict with PO files.
+ * Makerules: Likewise.
+ * Rules: Likewise.
+ * elf/Makefile: Likewise.
+ * extra-lib.mk: Likewise.
+ * gmon/Makefile: Likewise.
+ * nis/Makefile: Likewise.
+ * nss/Makefile: Likewise.
+ * resolv/Makefile: Likewise.
+ * rpm/Makefile: Likewise.
+ * sunrpc/Makefile: Likewise.
+ * sysdeps/sparc/elf/Makefile: Likewise.
+ * sysdeps/sparc64/elf/Makefile: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/Makefile: Likewise.
+ (ASFLAGS-.os): Renamed from as-FLAGS.os.
+
1997-08-14 03:14 Ulrich Drepper <drepper@cygnus.com>
* elf/dl-minimal.c: Don't use relative #include paths.
diff --git a/INSTALL b/INSTALL
index 3c172a280b..9968b081b4 100644
--- a/INSTALL
+++ b/INSTALL
@@ -771,6 +771,10 @@ parts of the library were contributed or worked on by other people.
* The port to Linux/m68k (`m68k-ANYTHING-linux') was contributed by
Andreas Schwab.
+ * The ports to Linux/ARM (`arm-ANYTHING-linuxaout') and ARM standalone
+ (`arm-ANYTHING-none'), as well as parts of the IPv6 support code, were
+ contributed by Philip Blundell.
+
* Richard Henderson contributed the ELF dynamic linking code and
other support for the Alpha processor.
diff --git a/Makeconfig b/Makeconfig
index 37839bc972..e1103c5ce1 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -530,41 +530,41 @@ endif
# to pass different flags for each flavor.
libtypes = $(foreach o,$(object-suffixes),$(libtype$o))
object-suffixes := .o
-all-object-suffixes := .o .so .po .go .bo
+all-object-suffixes := .o .os .op .og .ob
libtype.o := lib%.a
ifeq (yes,$(build-shared))
# Under --enable-shared, we will build a shared library of PIC objects.
-# The PIC object files are named foo.so.
-object-suffixes += .so
-CPPFLAGS-.so = -DPIC
-CFLAGS-.so = -fPIC -fno-common
-libtype.so := lib%_pic.a
+# The PIC object files are named foo.os.
+object-suffixes += .os
+CPPFLAGS-.os = -DPIC
+CFLAGS-.os = -fPIC -fno-common
+libtype.os := lib%_pic.a
endif
ifeq (yes,$(build-profile))
# Under --enable-profile, we will build a static library of profiled objects.
-# The profiled object files are named foo.po.
-object-suffixes += .po
-CPPFLAGS-.po = -DPROF
-CFLAGS-.po = -pg
-libtype.po = lib%_p.a
+# The profiled object files are named foo.op.
+object-suffixes += .op
+CPPFLAGS-.op = -DPROF
+CFLAGS-.op = -pg
+libtype.op = lib%_p.a
endif
ifeq (yes,$(build-omitfp))
# Under --enable-omitfp, we build an the library optimized without
# debugging information using -fomit-frame-pointer, and build an extra
-# library with debugging information. The debuggable objects are named foo.go.
-object-suffixes += .go
-CFLAGS-.go = -g
+# library with debugging information. The debuggable objects are named foo.og.
+object-suffixes += .og
+CFLAGS-.og = -g
CFLAGS-.o = -g0 -O99 -fomit-frame-pointer
-CFLAGS-.so += $(CFLAGS-.o)
-libtype.go = lib%_g.a
+CFLAGS-.os += $(CFLAGS-.o)
+libtype.og = lib%_g.a
endif
ifeq (yes,$(build-bounded))
# Under --enable-bounded, we build the library with `-fbounded-pointers -g'
-# to runtime bounds checking. The bounded-pointer objects are named foo.bo.
-object-suffixes += .bo
-CPPFLAGS-.bo = -DBOUNDED_POINTERS
-CFLAGS-.bo = -g -fbounded-pointers
-libtype.bo = lib%_b.a
+# to runtime bounds checking. The bounded-pointer objects are named foo.ob.
+object-suffixes += .ob
+CPPFLAGS-.ob = -DBOUNDED_POINTERS
+CFLAGS-.ob = -g -fbounded-pointers
+libtype.ob = lib%_b.a
endif
diff --git a/Makerules b/Makerules
index b9cdc5e424..8f35b716d5 100644
--- a/Makerules
+++ b/Makerules
@@ -344,7 +344,8 @@ endif
# build shared libraries in place from the installed *_pic.a files.
# $(LDLIBS-%.so) may contain -l switches to generate run-time dependencies
# on other shared objects.
-lib%.so: lib%_pic.a; $(build-shlib)
+lib%.so: lib%_pic.a $(+preinit) $(+postinit)
+ $(build-shlib)
ifeq ($(have-no-whole-archive),yes)
no-whole-archive = -Wl,--no-whole-archive
@@ -352,10 +353,10 @@ else
no-whole-archive =
endif
-interp-obj = $(common-objpfx)interp.so
-$(interp-obj): $(common-objpfx)%.so: $(..)%.c
+interp-obj = $(common-objpfx)interp.os
+$(interp-obj): $(common-objpfx)%.os: $(..)%.c
$(compile-command.c)
-common-generated += interp.so
+common-generated += interp.os
CFLAGS-interp.c = -D'RUNTIME_LINKER="$(slibdir)/$(rtld-installed-name)"'
$(common-objpfx)libc.so: $(interp-obj)
@@ -367,7 +368,8 @@ $(LINK.o) -shared -o $@ $(sysdep-LDFLAGS) $(config-LDFLAGS) \
-Wl,-soname=lib$(libprefix)$(@F:lib%.so=%).so$($(@F)-version) \
$(LDFLAGS.so) $(LDFLAGS-$(@F:lib%.so=%).so) \
-L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link) \
- -Wl,--whole-archive $(filter-out $($(@F:.so=)-map),$^) \
+ -Wl,--whole-archive \
+ $(filter-out $($(@F:.so=)-map) $(+preinit) $(+postinit),$^) \
$(no-whole-archive) $(LDLIBS-$(@F:lib%.so=%).so)
endef
@@ -382,9 +384,9 @@ LDFLAGS-c.so += -e __libc_main
# We have a versioning file for libc.so.
libc-map = $(..)libc.map
# Use our own special initializer and finalizer files for libc.so.
-$(common-objpfx)libc.so: $(elfobjdir)/soinit.so \
+$(common-objpfx)libc.so: $(elfobjdir)/soinit.os \
$(common-objpfx)libc_pic.a \
- $(elfobjdir)/sofini.so $(elfobjdir)/ld.so \
+ $(elfobjdir)/sofini.os $(elfobjdir)/ld.so \
$(libc-map)
$(build-shlib)
ifdef libc.so-version
@@ -428,11 +430,11 @@ endif
ifeq ($(build-programs),yes)
+depfiles := $(strip $(sources:.c=.d) \
- $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.so=.o))) \
+ $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \
$(addsuffix .d,$(others) $(tests) $(test-srcs)))
else
+depfiles := $(strip $(sources:.c=.d) \
- $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.so=.o))) \
+ $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \
$(addsuffix .d,$(tests) $(test-srcs)))
endif
+depfiles := $(addprefix $(objpfx),\
diff --git a/Rules b/Rules
index 001d9e1e90..e74b6367c7 100644
--- a/Rules
+++ b/Rules
@@ -166,7 +166,7 @@ endif
ifdef static-only-routines
# These routines are to be omitted from the shared library object,
# so we replace the PIC objects for them with the empty object file.
-$(static-only-routines:%=$(objpfx)%.so): %.so: $(common-objpfx)empty.o
+$(static-only-routines:%=$(objpfx)%.os): %.os: $(common-objpfx)empty.o
rm -f $@
ln $< $@
endif
diff --git a/assert/assert.h b/assert/assert.h
index 3f0d6a3ac1..3f0b55f866 100644
--- a/assert/assert.h
+++ b/assert/assert.h
@@ -22,8 +22,12 @@
#ifdef _ASSERT_H
-#undef _ASSERT_H
-#undef assert
+# undef _ASSERT_H
+# undef assert
+
+# ifdef __USE_GNU
+# undef assert_perror
+# endif
#endif /* assert.h */
diff --git a/catgets/catgets.c b/catgets/catgets.c
index 9228f970d6..4c6997e567 100644
--- a/catgets/catgets.c
+++ b/catgets/catgets.c
@@ -164,7 +164,7 @@ catclose (nl_catd catalog_desc)
catalog = (__nl_catd) catalog_desc;
if (catalog->status == mmapped)
- munmap ((void *) catalog->file_ptr, catalog->file_size);
+ __munmap ((void *) catalog->file_ptr, catalog->file_size);
else if (catalog->status == malloced)
free ((void *) catalog->file_ptr);
else if (catalog->status != closed && catalog->status != nonexisting)
diff --git a/catgets/gencat.c b/catgets/gencat.c
index bee101eb74..9ce962c3c9 100644
--- a/catgets/gencat.c
+++ b/catgets/gencat.c
@@ -332,7 +332,7 @@ read_input_file (struct catalog *current, const char *fname)
/* This is a comment line. Do nothing. */;
else if (strncmp (&this_line[1], "set", 3) == 0)
{
- int cnt = sizeof ("cnt");
+ int cnt = sizeof ("set");
int set_number;
const char *symbol = NULL;
while (isspace (this_line[cnt]))
diff --git a/dirent/dirent.h b/dirent/dirent.h
index a9a9a39e97..a9b7a7474d 100644
--- a/dirent/dirent.h
+++ b/dirent/dirent.h
@@ -131,6 +131,16 @@ extern int readdir_r __P ((DIR *__dirp, struct dirent *__entry,
/* Rewind DIRP to the beginning of the directory. */
extern void rewinddir __P ((DIR *__dirp));
+#if defined __USE_BSD || defined __USE_MISC || defined __USE_XOPEN
+# include <bits/types.h>
+
+/* Seek to position POS on DIRP. */
+extern void seekdir __P ((DIR *__dirp, __off_t __pos));
+
+/* Return the current position of DIRP. */
+extern __off_t telldir __P ((DIR *__dirp));
+#endif
+
#if defined __USE_BSD || defined __USE_MISC
/* Return the file descriptor used by DIRP. */
@@ -152,16 +162,9 @@ extern int dirfd __P ((DIR *__dirp));
# endif
# endif
-# include <bits/types.h>
# define __need_size_t
# include <stddef.h>
-/* Seek to position POS on DIRP. */
-extern void seekdir __P ((DIR *__dirp, __off_t __pos));
-
-/* Return the current position of DIRP. */
-extern __off_t telldir __P ((DIR *__dirp));
-
/* Scan the directory DIR, calling SELECTOR on each directory entry.
Entries for which SELECT returns nonzero are individually malloc'd,
sorted using qsort with CMP, and collected in a malloc'd array in
@@ -178,7 +181,7 @@ extern int alphasort __P ((__const __ptr_t, __const __ptr_t));
# ifdef __USE_GNU
/* Function to compare two `struct dirent's by name & version. */
extern int versionsort __P ((__const __ptr_t, __const __ptr_t));
-#endif
+# endif
/* Read directory entries from FD into BUF, reading at most NBYTES.
Reading starts at offset *BASEP, and *BASEP is updated with the new
diff --git a/elf/Makefile b/elf/Makefile
index f8dc9d0ef2..fb85b85e3c 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -30,7 +30,7 @@ dl-routines = $(addprefix dl-,load cache lookup object reloc deps \
runtime error init fini debug misc \
version profile)
# But they are absent from the shared libc, because that code is in ld.so.
-elide-routines.so = $(dl-routines) dl-support enbl-secure
+elide-routines.os = $(dl-routines) dl-support enbl-secure
# ld.so uses those routines, plus some special stuff for being the program
# interpreter and operating independent of libc.
@@ -54,8 +54,8 @@ all: # Make this the default target; it will be defined in Rules.
include ../Makeconfig
ifeq (yes,$(build-shared))
-extra-objs = $(rtld-routines:=.so) soinit.so sofini.so eval.so
-generated = librtld.so dl-allobjs.so trusted-dirs.h rtldtbl.h
+extra-objs = $(rtld-routines:=.os) soinit.os sofini.os eval.os
+generated = librtld.os dl-allobjs.os trusted-dirs.h rtldtbl.h
install-others = $(inst_slibdir)/$(rtld-installed-name)
install-bin = ldd
endif
@@ -85,11 +85,11 @@ endif
# Command to link into a larger single relocatable object.
reloc-link = $(LINK.o) -nostdlib -nostartfiles -r -o $@
-$(objpfx)dl-allobjs.so: $(rtld-routines:%=$(objpfx)%.so)
+$(objpfx)dl-allobjs.os: $(rtld-routines:%=$(objpfx)%.os)
$(reloc-link) $^
# Link together the dynamic linker into a single relocatable object.
-$(objpfx)librtld.so: $(objpfx)dl-allobjs.so $(common-objpfx)libc_pic.a
+$(objpfx)librtld.os: $(objpfx)dl-allobjs.os $(common-objpfx)libc_pic.a
$(reloc-link) '-Wl,-(' $^ -lgcc '-Wl,-)'
# Do we need a linker script?
@@ -107,7 +107,7 @@ $(objpfx)rtld-ldscript: $(rtld-ldscript-in) $(rtld-parms)
-e 's#@@rtld-entry@@#$(rtld-entry)#' \
-e 's#@@rtld-base@@#$(rtld-base)#' $< >$@
-$(objpfx)ld.so: $(objpfx)librtld.so $(objpfx)rtld-ldscript
+$(objpfx)ld.so: $(objpfx)librtld.os $(objpfx)rtld-ldscript
$(rtld-link) -Wl,-soname=$(rtld-installed-name)
define rtld-link
@@ -116,7 +116,7 @@ $(LINK.o) -nostdlib -nostartfiles -shared -o $@ \
$(filter-out $(objpfx)rtld-ldscript,$^)
endef
else
-$(objpfx)ld.so: $(objpfx)librtld.so
+$(objpfx)ld.so: $(objpfx)librtld.os
$(rtld-link) -Wl,-soname=$(rtld-installed-name)
define rtld-link
@@ -186,4 +186,4 @@ endif
# muwahaha
LDFLAGS-dl.so = -Wl,-dynamic-linker,$(slibdir)/$(rtld-installed-name)
-$(objpfx)libdl.so: $(objpfx)eval.so
+$(objpfx)libdl.so: $(objpfx)eval.os
diff --git a/elf/dl-error.c b/elf/dl-error.c
index 7ee803ad9b..72af85985d 100644
--- a/elf/dl-error.c
+++ b/elf/dl-error.c
@@ -75,7 +75,7 @@ _dl_signal_error (int errcode,
/* Lossage while resolving the program's own symbols is always fatal. */
extern char **_dl_argv; /* Set in rtld.c at startup. */
_dl_sysdep_fatal (_dl_argv[0] ?: "<program name unknown>",
- ": error in loading shared libraries",
+ ": error in loading shared libraries: ",
objname ?: "", objname ? ": " : "",
errstring, errcode ? ": " : "",
errcode ? strerror (errcode) : "", "\n", NULL);
diff --git a/elf/dl-load.c b/elf/dl-load.c
index f0af29292a..ce3bd9fb94 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -94,6 +94,11 @@ size_t _dl_pagesize;
extern const char *_dl_platform;
extern size_t _dl_platformlen;
+/* This is a fake list to store the RPATH information for static
+ binaries. */
+static struct r_search_path_elem **fake_path_list;
+
+
/* Local version of `strdup' function. */
static inline char *
local_strdup (const char *s)
@@ -308,6 +313,12 @@ decompose_rpath (const char *rpath, size_t additional_room)
void
_dl_init_paths (void)
{
+ static const char *trusted_dirs[] =
+ {
+#include "trusted-dirs.h"
+ NULL
+ };
+
struct r_search_path_elem **pelem;
/* We have in `search_path' the information about the RPATH of the
@@ -333,53 +344,72 @@ _dl_init_paths (void)
nllp = 0;
l = _dl_loaded;
- if (l && l->l_type != lt_loaded && l->l_info[DT_RPATH])
+ if (l != NULL)
{
- /* Allocate room for the search path and fill in information from
- RPATH. */
- l->l_rpath_dirs =
- decompose_rpath ((const char *) (l->l_addr
- + l->l_info[DT_STRTAB]->d_un.d_ptr
- + l->l_info[DT_RPATH]->d_un.d_val),
- nllp);
+ if (l->l_type != lt_loaded && l->l_info[DT_RPATH])
+ {
+ /* Allocate room for the search path and fill in information
+ from RPATH. */
+ l->l_rpath_dirs =
+ decompose_rpath ((const char *)
+ (l->l_addr + l->l_info[DT_STRTAB]->d_un.d_ptr
+ + l->l_info[DT_RPATH]->d_un.d_val),
+ nllp);
+ }
+ else
+ {
+ /* If we have no LD_LIBRARY_PATH and no RPATH we must tell
+ this somehow to prevent we look this up again and again. */
+ if (nllp == 0)
+ l->l_rpath_dirs = (struct r_search_path_elem **) -1l;
+ else
+ {
+ l->l_rpath_dirs = (struct r_search_path_elem **)
+ malloc ((nllp + 1) * sizeof (*l->l_rpath_dirs));
+ if (l->l_rpath_dirs == NULL)
+ _dl_signal_error (ENOMEM, NULL,
+ "cannot create cache for search path");
+ l->l_rpath_dirs[0] = NULL;
+ }
+ }
+
+ /* We don't need to search the list of fake entries which is searched
+ when no dynamic objects were loaded at this time. */
+ fake_path_list = NULL;
+
+ if (nllp > 0)
+ {
+ char *copy = strdupa (llp);
+
+ /* Decompose the LD_LIBRARY_PATH and fill in the result.
+ First search for the next place to enter elements. */
+ struct r_search_path_elem **result = l->l_rpath_dirs;
+ while (*result != NULL)
+ ++result;
+
+ /* We need to take care that the LD_LIBRARY_PATH environment
+ variable can contain a semicolon. */
+ (void) fillin_rpath (copy, result, ":;",
+ __libc_enable_secure ? trusted_dirs : NULL);
+ }
}
else
{
- /* If we have no LD_LIBRARY_PATH and no RPATH we must tell this
- somehow to prevent we look this up again and again. */
+ /* This is a statically linked program but we still have to
+ take care for the LD_LIBRARY_PATH environment variable. We
+ use a fake link_map entry. This will only contain the
+ l_rpath_dirs information. */
+
if (nllp == 0)
- l->l_rpath_dirs = (struct r_search_path_elem **) -1l;
+ fake_path_list = NULL;
else
{
- l->l_rpath_dirs =
- (struct r_search_path_elem **) malloc ((nllp + 1)
- * sizeof (*l->l_rpath_dirs));
- if (l->l_rpath_dirs == NULL)
- _dl_signal_error (ENOMEM, NULL,
- "cannot create cache for search path");
- l->l_rpath_dirs[0] = NULL;
- }
- }
+ fake_path_list = (struct r_search_path_elem **)
+ malloc ((nllp + 1) * sizeof (struct r_search_path_elem *));
- if (nllp > 0)
- {
- static const char *trusted_dirs[] =
- {
-#include "trusted-dirs.h"
- NULL
- };
- char *copy = strdupa (llp);
-
- /* Decompose the LD_LIBRARY_PATH and fill in the result.
- First search for the next place to enter elements. */
- struct r_search_path_elem **result = l->l_rpath_dirs;
- while (*result != NULL)
- ++result;
-
- /* We need to take care that the LD_LIBRARY_PATH environement
- variable can contain a semicolon. */
- (void) fillin_rpath (copy, result, ":;",
- __libc_enable_secure ? trusted_dirs : NULL);
+ (void) fillin_rpath (local_strdup (llp), fake_path_list, ":;",
+ __libc_enable_secure ? trusted_dirs : NULL);
+ }
}
/* Now set up the rest of the rtld_search_dirs. */
@@ -871,7 +901,7 @@ _dl_map_object (struct link_map *loader, const char *name, int type,
/* Look for this name among those already loaded. */
for (l = _dl_loaded; l; l = l->l_next)
- if (_dl_name_match_p (name, l) ||
+ if (l->l_opencount > 0 && _dl_name_match_p (name, l) ||
/* If the requested name matches the soname of a loaded object,
use that object. */
(l->l_info[DT_SONAME] &&
@@ -923,6 +953,11 @@ _dl_map_object (struct link_map *loader, const char *name, int type,
&& l->l_rpath_dirs != (struct r_search_path_elem **) -1l)
fd = open_path (name, namelen, l->l_rpath_dirs, &realname);
+ /* This is used if a static binary uses dynamic loading and there
+ is a LD_LIBRARY_PATH given. */
+ if (fd == -1 && fake_path_list != NULL)
+ fd = open_path (name, namelen, fake_path_list, &realname);
+
if (fd == -1)
{
/* Check the list of libraries in the file /etc/ld.so.cache,
diff --git a/extra-lib.mk b/extra-lib.mk
index ad9f28cc65..793dc09c38 100644
--- a/extra-lib.mk
+++ b/extra-lib.mk
@@ -36,7 +36,7 @@ endif
# The linked shared library is never a dependent of lib-noranlib,
# because linking it will depend on libc.so already being built.
-ifneq (,$(filter .so,$(object-suffixes-$(lib))))
+ifneq (,$(filter .os,$(object-suffixes-$(lib))))
others: $(objpfx)$(lib).so$($(lib).so-version)
endif
diff --git a/gmon/Makefile b/gmon/Makefile
index 4f8108f82d..a07fe731eb 100644
--- a/gmon/Makefile
+++ b/gmon/Makefile
@@ -40,6 +40,6 @@ ifeq (,$(filter profil,$(unix-syscalls)))
noprof += profil
endif
-$(noprof:%=$(objpfx)%.po): %.po: %.o
+$(noprof:%=$(objpfx)%.op): %.op: %.o
rm -f $@
ln $< $@
diff --git a/inet/getnameinfo.c b/inet/getnameinfo.c
index f090f0b32e..2bba606ec7 100644
--- a/inet/getnameinfo.c
+++ b/inet/getnameinfo.c
@@ -42,19 +42,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/* This software is Copyright 1996 by Craig Metz, All Rights Reserved. */
-#define INET6 1
-#define LOCAL 1
-#define HOSTTABLE 0
-#define RESOLVER 1
-
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
-#if LOCAL
#include <sys/un.h>
#include <sys/utsname.h>
-#endif /* LOCAL */
#include <netdb.h>
#include <errno.h>
#include <string.h>
@@ -64,20 +57,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <bits/libc-lock.h>
#include <arpa/inet.h>
-#ifndef AF_LOCAL
-# define AF_LOCAL AF_UNIX
-#endif /* AF_LOCAL */
-
-#if HOSTTABLE
-struct hostent *_addr2hostname_hosts (const char *, int, int);
-#endif /* HOSTTABLE */
-
#ifndef min
# define min(x,y) (((x) > (y)) ? (y) : (x))
#endif /* min */
-static const char *
+static char *
nrl_domainname (void)
{
static char *domain = NULL;
@@ -92,7 +77,7 @@ nrl_domainname (void)
{
char *c;
struct hostent *h, th;
- int tmpbuflen = 1024;
+ size_t tmpbuflen = 1024;
char *tmpbuf = alloca (tmpbuflen);
int herror;
@@ -194,27 +179,12 @@ getnameinfo (const struct sockaddr *sa, size_t addrlen, char *host,
switch(sa->sa_family)
{
case AF_INET:
-#if INET6
case AF_INET6:
-#endif /* INET6 */
if (!(flags & NI_NUMERICHOST))
{
struct hostent *h = NULL;
-#if HOSTTABLE
-# if INET6
- if (sa->sa_family == AF_INET6)
- h = _addr2hostname_hosts ((void *) &(((struct sockaddr_in6 *) sa)->sin6_addr),
- sizeof(struct in6_addr), AF_INET6);
- else
-# endif /* INET6 */
- h = _addr2hostname_hosts ((void *)& (((struct sockaddr_in *) sa)->sin_addr),
- sizeof(struct in_addr), AF_INET);
-#endif /* HOSTTABLE */
-
-#if RESOLVER
if (h == NULL)
{
-#if INET6
if (sa->sa_family == AF_INET6)
{
while (__gethostbyaddr_r ((void *) &(((struct sockaddr_in6 *) sa)->sin6_addr),
@@ -232,7 +202,8 @@ getnameinfo (const struct sockaddr *sa, size_t addrlen, char *host,
else
{
__set_h_errno (herrno);
- goto fail;
+ __set_errno (serrno);
+ return -1;
}
}
else
@@ -243,7 +214,6 @@ getnameinfo (const struct sockaddr *sa, size_t addrlen, char *host,
}
else
{
-#endif /* INET6 */
while (__gethostbyaddr_r ((void *) &(((struct sockaddr_in *)sa)->sin_addr),
sizeof(struct in_addr), AF_INET,
&th, tmpbuf, tmpbuflen,
@@ -261,13 +231,12 @@ getnameinfo (const struct sockaddr *sa, size_t addrlen, char *host,
}
}
}
-#endif /* RESOLVER */
if (h)
{
if (flags & NI_NOFQDN)
{
- const char *c;
+ char *c;
if ((c = nrl_domainname ()) && (c = strstr(h->h_name, c))
&& (c != h->h_name) && (*(--c) == '.'))
{
@@ -282,7 +251,10 @@ getnameinfo (const struct sockaddr *sa, size_t addrlen, char *host,
}
if (flags & NI_NAMEREQD)
- goto fail;
+ {
+ __set_errno (serrno);
+ return -1;
+ }
else
{
const char *c;
@@ -297,12 +269,14 @@ getnameinfo (const struct sockaddr *sa, size_t addrlen, char *host,
(void *) &(((struct sockaddr_in *) sa)->sin_addr),
host, hostlen);
- if (!c)
- goto fail;
+ if (c == NULL)
+ {
+ __set_errno (serrno);
+ return -1;
+ }
}
break;
-#if LOCAL
case AF_LOCAL:
if (!(flags & NI_NUMERICHOST))
{
@@ -316,11 +290,13 @@ getnameinfo (const struct sockaddr *sa, size_t addrlen, char *host,
};
if (flags & NI_NAMEREQD)
- goto fail;
+ {
+ __set_errno (serrno);
+ return -1;
+ }
strncpy (host, "localhost", hostlen);
break;
-#endif /* LOCAL */
default:
return -1;
@@ -330,9 +306,7 @@ getnameinfo (const struct sockaddr *sa, size_t addrlen, char *host,
switch(sa->sa_family)
{
case AF_INET:
-#if INET6
case AF_INET6:
-#endif /* INET6 */
if (!(flags & NI_NUMERICSERV))
{
struct servent *s, ts;
@@ -345,10 +319,13 @@ getnameinfo (const struct sockaddr *sa, size_t addrlen, char *host,
if (errno == ERANGE)
{
tmpbuflen *= 2;
- tmpbuf = __alloca(tmpbuflen);
+ tmpbuf = __alloca (tmpbuflen);
}
else
- goto fail;
+ {
+ __set_errno (serrno);
+ return -1;
+ }
}
else
{
@@ -357,7 +334,7 @@ getnameinfo (const struct sockaddr *sa, size_t addrlen, char *host,
}
if (s)
{
- strncpy(serv, s->s_name, servlen);
+ strncpy (serv, s->s_name, servlen);
break;
}
}
@@ -365,11 +342,9 @@ getnameinfo (const struct sockaddr *sa, size_t addrlen, char *host,
ntohs (((struct sockaddr_in *) sa)->sin_port));
break;
-#if LOCAL
case AF_LOCAL:
strncpy (serv, ((struct sockaddr_un *) sa)->sun_path, servlen);
break;
-#endif /* LOCAL */
}
if (host && (hostlen > 0))
@@ -378,8 +353,4 @@ getnameinfo (const struct sockaddr *sa, size_t addrlen, char *host,
serv[servlen-1] = 0;
errno = serrno;
return 0;
-
-fail:
- errno = serrno;
- return -1;
-};
+}
diff --git a/intl/bindtextdom.c b/intl/bindtextdom.c
index b8f22b6c5d..0540d1e162 100644
--- a/intl/bindtextdom.c
+++ b/intl/bindtextdom.c
@@ -2,7 +2,7 @@
Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library. Its master source is NOT part of
- the C library, however. The master source lives in /gd/gnu/lib.
+ the C library, however.
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
@@ -65,6 +65,7 @@ extern struct binding *_nl_domain_bindings;
prefix. So we have to make a difference here. */
#ifdef _LIBC
# define BINDTEXTDOMAIN __bindtextdomain
+# define strdup(str) __strdup (str)
#else
# define BINDTEXTDOMAIN bindtextdomain__
#endif
@@ -102,25 +103,36 @@ BINDTEXTDOMAIN (domainname, dirname)
if (binding != NULL)
{
- /* The domain is already bound. Replace the old binding. */
- char *new_dirname;
-
- if (strcmp (dirname, _nl_default_dirname) == 0)
- new_dirname = (char *) _nl_default_dirname;
- else
+ /* The domain is already bound. If the new value and the old
+ one are equal we simply do nothing. Otherwise replace the
+ old binding. */
+ if (strcmp (dirname, binding->dirname) != 0)
{
- size_t len = strlen (dirname) + 1;
- new_dirname = (char *) malloc (len);
- if (new_dirname == NULL)
- return NULL;
+ char *new_dirname;
+
+ if (strcmp (dirname, _nl_default_dirname) == 0)
+ new_dirname = (char *) _nl_default_dirname;
+ else
+ {
+#if defined _LIBC || defined HAVE_STRDUP
+ new_dirname = strdup (dirname);
+ if (new_dirname == NULL)
+ return NULL;
+#else
+ size_t len = strlen (dirname) + 1;
+ new_dirname = (char *) malloc (len);
+ if (new_dirname == NULL)
+ return NULL;
- memcpy (new_dirname, dirname, len);
- }
+ memcpy (new_dirname, dirname, len);
+#endif
+ }
- if (strcmp (binding->dirname, _nl_default_dirname) != 0)
- free (binding->dirname);
+ if (binding->dirname != _nl_default_dirname)
+ free (binding->dirname);
- binding->dirname = new_dirname;
+ binding->dirname = new_dirname;
+ }
}
else
{
@@ -132,21 +144,33 @@ BINDTEXTDOMAIN (domainname, dirname)
if (new_binding == NULL)
return NULL;
+#if defined _LIBC || defined HAVE_STRDUP
+ new_binding->domainname = strdup (domainname);
+ if (new_binding->domainname == NULL)
+ return NULL;
+#else
len = strlen (domainname) + 1;
new_binding->domainname = (char *) malloc (len);
if (new_binding->domainname == NULL)
- return NULL;
+ return NULL;
memcpy (new_binding->domainname, domainname, len);
+#endif
if (strcmp (dirname, _nl_default_dirname) == 0)
new_binding->dirname = (char *) _nl_default_dirname;
else
{
+#if defined _LIBC || defined HAVE_STRDUP
+ new_binding->dirname = strdup (dirname);
+ if (new_binding->dirname == NULL)
+ return NULL;
+#else
len = strlen (dirname) + 1;
new_binding->dirname = (char *) malloc (len);
if (new_binding->dirname == NULL)
return NULL;
memcpy (new_binding->dirname, dirname, len);
+#endif
}
/* Now enqueue it. */
diff --git a/intl/dcgettext.c b/intl/dcgettext.c
index 152acef9a1..c7540053b2 100644
--- a/intl/dcgettext.c
+++ b/intl/dcgettext.c
@@ -2,7 +2,7 @@
Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library. Its master source is NOT part of
- the C library, however. The master source lives in /gd/gnu/lib.
+ the C library, however.
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
@@ -298,10 +298,6 @@ DCGETTEXT (domainname, msgid, category)
return (char *) msgid;
}
- /* We don't want libintl.a to depend on any other library. So
- we avoid the non-standard function stpcpy. In GNU C Library
- this function is available, though. Also allow the symbol
- HAVE_STPCPY to be defined. */
stpcpy (stpcpy (strchr (dirname, '\0'), "/"), binding->dirname);
}
@@ -312,10 +308,7 @@ DCGETTEXT (domainname, msgid, category)
xdomainname = (char *) alloca (strlen (categoryname)
+ strlen (domainname) + 5);
ADD_BLOCK (block_list, xdomainname);
- /* We don't want libintl.a to depend on any other library. So we
- avoid the non-standard function stpcpy. In GNU C Library this
- function is available, though. Also allow the symbol HAVE_STPCPY
- to be defined. */
+
stpcpy (stpcpy (stpcpy (stpcpy (xdomainname, categoryname), "/"),
domainname),
".mo");
diff --git a/intl/dgettext.c b/intl/dgettext.c
index b63e083162..f7899579f7 100644
--- a/intl/dgettext.c
+++ b/intl/dgettext.c
@@ -2,7 +2,7 @@
Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library. Its master source is NOT part of
- the C library, however. The master source lives in /gd/gnu/lib.
+ the C library, however.
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
diff --git a/intl/explodename.c b/intl/explodename.c
index e938ff234b..ce5b06b288 100644
--- a/intl/explodename.c
+++ b/intl/explodename.c
@@ -2,7 +2,7 @@
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
This file is part of the GNU C Library. Its master source is NOT part of
- the C library, however. The master source lives in /gd/gnu/lib.
+ the C library, however.
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
diff --git a/intl/finddomain.c b/intl/finddomain.c
index 27163a6f66..c1ab68bfed 100644
--- a/intl/finddomain.c
+++ b/intl/finddomain.c
@@ -3,7 +3,7 @@
Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
This file is part of the GNU C Library. Its master source is NOT part of
- the C library, however. The master source lives in /gd/gnu/lib.
+ the C library, however.
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
@@ -146,12 +146,18 @@ _nl_find_domain (dirname, locale, domainname)
alias_value = _nl_expand_alias (locale);
if (alias_value != NULL)
{
+#if defined _LIBC || defined HAVE_STRDUP
+ locale = strdup (alias_value);
+ if (locale == NULL)
+ return NULL;
+#else
size_t len = strlen (alias_value) + 1;
locale = (char *) malloc (len);
if (locale == NULL)
return NULL;
memcpy (locale, alias_value, len);
+#endif
}
/* Now we determine the single parts of the locale name. First
diff --git a/intl/gettext.c b/intl/gettext.c
index a08bd11d8a..d4687ceb24 100644
--- a/intl/gettext.c
+++ b/intl/gettext.c
@@ -2,7 +2,7 @@
Copyright (C) 1995, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library. Its master source is NOT part of
- the C library, however. The master source lives in /gd/gnu/lib.
+ the C library, however.
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
diff --git a/intl/gettext.h b/intl/gettext.h
index 8d5c121234..804b219ee2 100644
--- a/intl/gettext.h
+++ b/intl/gettext.h
@@ -2,7 +2,7 @@
Copyright (C) 1995, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library. Its master source is NOT part of
- the C library, however. The master source lives in /gd/gnu/lib.
+ the C library, however.
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
diff --git a/intl/hash-string.h b/intl/hash-string.h
index 7212eb0254..8b675c10e4 100644
--- a/intl/hash-string.h
+++ b/intl/hash-string.h
@@ -2,7 +2,7 @@
Copyright (C) 1995, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library. Its master source is NOT part of
- the C library, however. The master source lives in /gd/gnu/lib.
+ the C library, however.
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
diff --git a/intl/l10nflist.c b/intl/l10nflist.c
index bda2105ac7..640b932b01 100644
--- a/intl/l10nflist.c
+++ b/intl/l10nflist.c
@@ -2,7 +2,7 @@
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
This file is part of the GNU C Library. Its master source is NOT part of
- the C library, however. The master source lives in /gd/gnu/lib.
+ the C library, however.
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
diff --git a/intl/libintl.h b/intl/libintl.h
index 86b44650e8..2c8e8a49eb 100644
--- a/intl/libintl.h
+++ b/intl/libintl.h
@@ -1,10 +1,10 @@
-/* libintl.h -- Message catalogs for internationalization.
- Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+/* Message catalogs for internationalization.
+ Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
This file is derived from the file libgettext.h in the GNU gettext package.
This file is part of the GNU C Library. Its master source is NOT part of
- the C library, however. The master source lives in /gd/gnu/lib.
+ the C library, however.
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
@@ -71,8 +71,8 @@ extern char *__bindtextdomain __P ((__const char *__domainname,
#if defined __OPTIMIZE__
/* We need NULL for `gettext'. */
-#define __need_NULL
-#include <stddef.h>
+# define __need_NULL
+# include <stddef.h>
/* We need LC_MESSAGES for `dgettext'. */
# include <locale.h>
diff --git a/intl/loadinfo.h b/intl/loadinfo.h
index c67c2eb2e8..274066764c 100644
--- a/intl/loadinfo.h
+++ b/intl/loadinfo.h
@@ -1,3 +1,22 @@
+/* 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. */
+
#ifndef PARAMS
# if __STDC__
# define PARAMS(args) args
diff --git a/intl/loadmsgcat.c b/intl/loadmsgcat.c
index 3fe8f69cdd..f4352d00eb 100644
--- a/intl/loadmsgcat.c
+++ b/intl/loadmsgcat.c
@@ -2,7 +2,7 @@
Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library. Its master source is NOT part of
- the C library, however. The master source lives in /gd/gnu/lib.
+ the C library, however.
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
diff --git a/intl/localealias.c b/intl/localealias.c
index 4547873414..99fcfa511f 100644
--- a/intl/localealias.c
+++ b/intl/localealias.c
@@ -2,7 +2,7 @@
Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library. Its master source is NOT part of
- the C library, however. The master source lives in /gd/gnu/lib.
+ the C library, however.
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
@@ -82,6 +82,12 @@ void free ();
because some ANSI C functions will require linking with this object
file and the name space must not be polluted. */
# define strcasecmp __strcasecmp
+# define strdup __strdup
+
+/* We need locking here since we can be called from different palces. */
+# include <libc-lock.h>
+
+__libc_lock_define_initialized (static, lock);
#endif
@@ -146,8 +152,13 @@ _nl_expand_alias (name)
{
static const char *locale_alias_path = LOCALE_ALIAS_PATH;
struct alias_map *retval;
+ const char *result = NULL;
size_t added;
+#ifdef _LIBC
+ __libc_lock_lock (lock);
+#endif
+
do
{
struct alias_map item;
@@ -165,7 +176,10 @@ _nl_expand_alias (name)
/* We really found an alias. Return the value. */
if (retval != NULL)
- return retval->value;
+ {
+ result = retval->value;
+ break;
+ }
/* Perhaps we can find another alias file. */
added = 0;
@@ -186,7 +200,11 @@ _nl_expand_alias (name)
}
while (added != 0);
- return NULL;
+#ifdef _LIBC
+ __libc_lock_unlock (lock);
+#endif
+
+ return result;
}
@@ -274,7 +292,15 @@ read_alias_file (fname, fname_len)
if (nmap >= maxmap)
extend_alias_table ();
- /* We cannot depend on strdup available in the libc. Sigh! */
+#if defined _LIBC || defined HAVE_STRDUP
+ map[nmap].alias = strdup (alias);
+ map[nmap].value = strdup (value);
+ if (map[nmap].alias == NULL || map[nmap].value == NULL)
+ {
+ FREE_BLOCKS (block_list);
+ return added;
+ }
+#else
len = strlen (alias) + 1;
tp = (char *) malloc (len);
if (tp == NULL)
@@ -294,6 +320,7 @@ read_alias_file (fname, fname_len)
}
memcpy (tp, value, len);
map[nmap].value = tp;
+#endif
++nmap;
++added;
diff --git a/intl/textdomain.c b/intl/textdomain.c
index bad9d166c0..116419dd12 100644
--- a/intl/textdomain.c
+++ b/intl/textdomain.c
@@ -57,6 +57,7 @@ extern const char *_nl_current_default_domain;
prefix. So we have to make a difference here. */
#ifdef _LIBC
# define TEXTDOMAIN __textdomain
+# define strdup(str) __strdup (str)
#else
# define TEXTDOMAIN textdomain__
#endif
@@ -85,11 +86,15 @@ TEXTDOMAIN (domainname)
/* If the following malloc fails `_nl_current_default_domain'
will be NULL. This value will be returned and so signals we
are out of core. */
+#if defined _LIBC || defined HAVE_STRDUP
+ _nl_current_default_domain = strdup (domainname);
+#else
size_t len = strlen (domainname) + 1;
char *cp = (char *) malloc (len);
if (cp != NULL)
memcpy (cp, domainname, len);
_nl_current_default_domain = cp;
+#endif
}
if (old != _nl_default_default_domain)
diff --git a/libio/fcloseall.c b/libio/fcloseall.c
index 05693f3b61..cd01655450 100644
--- a/libio/fcloseall.c
+++ b/libio/fcloseall.c
@@ -1,26 +1,27 @@
-/*
-Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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>
@@ -32,4 +33,7 @@ __fcloseall ()
_IO_cleanup ();
return 0;
}
+
+#ifdef weak_alias
weak_alias (__fcloseall, fcloseall)
+#endif
diff --git a/libio/feof.c b/libio/feof.c
index 23674704d6..d06de044fb 100644
--- a/libio/feof.c
+++ b/libio/feof.c
@@ -1,25 +1,27 @@
-/* Copyright (C) 1993, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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"
@@ -35,4 +37,7 @@ _IO_feof (fp)
_IO_funlockfile (fp);
return result;
}
+
+#ifdef weak_alias
weak_alias (_IO_feof, feof)
+#endif
diff --git a/libio/feof_u.c b/libio/feof_u.c
index 6ed8b7d4fe..4773599012 100644
--- a/libio/feof_u.c
+++ b/libio/feof_u.c
@@ -1,25 +1,27 @@
-/* Copyright (C) 1993, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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"
diff --git a/libio/ferror.c b/libio/ferror.c
index b9ed64587c..855627ade6 100644
--- a/libio/ferror.c
+++ b/libio/ferror.c
@@ -1,25 +1,27 @@
-/* Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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"
@@ -35,4 +37,7 @@ _IO_ferror (fp)
_IO_funlockfile (fp);
return result;
}
+
+#ifdef weak_alias
weak_alias (_IO_ferror, ferror)
+#endif
diff --git a/libio/ferror_u.c b/libio/ferror_u.c
index df550d9d4d..6e13e53ddc 100644
--- a/libio/ferror_u.c
+++ b/libio/ferror_u.c
@@ -1,25 +1,27 @@
-/* Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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"
diff --git a/libio/fgetc.c b/libio/fgetc.c
index 25bfed5596..174e60fa3f 100644
--- a/libio/fgetc.c
+++ b/libio/fgetc.c
@@ -1,26 +1,27 @@
-/*
-Copyright (C) 1993, 1995 Free Software Foundation
+/* Copyright (C) 1993, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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"
diff --git a/libio/filedoalloc.c b/libio/filedoalloc.c
index 836c56b63b..f1b781e8a0 100644
--- a/libio/filedoalloc.c
+++ b/libio/filedoalloc.c
@@ -1,26 +1,27 @@
-/*
-Copyright (C) 1993 Free Software Foundation
+/* Copyright (C) 1993, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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. */
/*
* Copyright (c) 1990 The Regents of the University of California.
@@ -66,12 +67,12 @@ the executable file might be covered by the GNU General Public License. */
*/
int
-DEFUN(_IO_file_doallocate, (fp),
- register _IO_FILE *fp)
+_IO_file_doallocate (fp)
+ _IO_FILE *fp;
{
- register _IO_size_t size;
+ _IO_size_t size;
int couldbetty;
- register char *p;
+ char *p;
struct stat st;
#ifndef _LIBC
@@ -80,7 +81,7 @@ DEFUN(_IO_file_doallocate, (fp),
on exit. We call it from _IO_file_doallocate, since that is likely
to get called by any program that does buffered I/O. */
if (_IO_cleanup_registration_needed)
- (*_IO_cleanup_registration_needed)();
+ (*_IO_cleanup_registration_needed) ();
#endif
if (fp->_fileno < 0 || _IO_SYSSTAT (fp, &st) < 0)
@@ -94,16 +95,16 @@ DEFUN(_IO_file_doallocate, (fp),
}
else
{
- couldbetty = S_ISCHR(st.st_mode);
+ couldbetty = S_ISCHR (st.st_mode);
#if _IO_HAVE_ST_BLKSIZE
size = st.st_blksize <= 0 ? _IO_BUFSIZ : st.st_blksize;
#else
size = _IO_BUFSIZ;
#endif
}
- ALLOC_BUF(p, size, EOF);
- _IO_setb(fp, p, p+size, 1);
- if (couldbetty && isatty(fp->_fileno))
+ ALLOC_BUF (p, size, EOF);
+ _IO_setb (fp, p, p + size, 1);
+ if (couldbetty && isatty (fp->_fileno))
fp->_flags |= _IO_LINE_BUF;
return 1;
}
diff --git a/libio/fileno.c b/libio/fileno.c
index 269ecb875a..7ff93e6a81 100644
--- a/libio/fileno.c
+++ b/libio/fileno.c
@@ -1,26 +1,27 @@
-/*
-Copyright (C) 1993, 1995, 1996 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. */
+/* 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"
@@ -38,9 +39,11 @@ 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/fileops.c b/libio/fileops.c
index afba972693..b3a3a24651 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -1,28 +1,29 @@
-/*
-Copyright (C) 1993, 1995 Free Software Foundation
+/* Copyright (C) 1993, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
+ Written by Per Bothner <bothner@cygnus.com>.
-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 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.
+ 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.
+ 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. */
+ 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. */
-/* written by Per Bothner (bothner@cygnus.com) */
#ifndef _POSIX_SOURCE
# define _POSIX_SOURCE
@@ -97,8 +98,8 @@ extern int errno;
void
-DEFUN(_IO_file_init, (fp),
- register _IO_FILE *fp)
+_IO_file_init (fp)
+ _IO_FILE *fp;
{
/* POSIX.1 allows another file handle to be used to change the position
of our file descriptor. Hence we actually don't know the actual
@@ -111,11 +112,11 @@ DEFUN(_IO_file_init, (fp),
}
int
-DEFUN(_IO_file_close_it, (fp),
- register _IO_FILE* fp)
+_IO_file_close_it (fp)
+ _IO_FILE *fp;
{
int write_status, close_status;
- if (!_IO_file_is_open(fp))
+ if (!_IO_file_is_open (fp))
return EOF;
write_status = _IO_do_flush (fp);
@@ -125,11 +126,11 @@ DEFUN(_IO_file_close_it, (fp),
close_status = _IO_SYSCLOSE (fp);
/* Free buffer. */
- _IO_setb(fp, NULL, NULL, 0);
- _IO_setg(fp, NULL, NULL, NULL);
- _IO_setp(fp, NULL, NULL);
+ _IO_setb (fp, NULL, NULL, 0);
+ _IO_setg (fp, NULL, NULL, NULL);
+ _IO_setp (fp, NULL, NULL);
- _IO_un_link(fp);
+ _IO_un_link (fp);
fp->_flags = _IO_MAGIC|CLOSED_FILEBUF_FLAGS;
fp->_fileno = EOF;
fp->_offset = _IO_pos_BAD;
@@ -138,68 +139,74 @@ DEFUN(_IO_file_close_it, (fp),
}
void
-DEFUN(_IO_file_finish, (fp, dummy),
- register _IO_FILE* fp AND int dummy)
+_IO_file_finish (fp, dummy)
+ _IO_FILE *fp;
+ int dummy;
{
- if (_IO_file_is_open(fp))
+ if (_IO_file_is_open (fp))
{
_IO_do_flush (fp);
if (!(fp->_flags & _IO_DELETE_DONT_CLOSE))
_IO_SYSCLOSE (fp);
}
- _IO_default_finish(fp, 0);
+ _IO_default_finish (fp, 0);
}
_IO_FILE *
-DEFUN(_IO_file_fopen, (fp, filename, mode),
- register _IO_FILE *fp AND const char *filename AND const char *mode)
+_IO_file_fopen (fp, filename, mode)
+ _IO_FILE *fp;
+ const char *filename;
+ const char *mode;
{
int oflags = 0, omode;
int read_write, fdesc;
int oprot = 0666;
if (_IO_file_is_open (fp))
return 0;
- switch (*mode++) {
- case 'r':
- omode = O_RDONLY;
- read_write = _IO_NO_WRITES;
- break;
- case 'w':
- omode = O_WRONLY;
- oflags = O_CREAT|O_TRUNC;
- read_write = _IO_NO_READS;
- break;
- case 'a':
- omode = O_WRONLY;
- oflags = O_CREAT|O_APPEND;
- read_write = _IO_NO_READS|_IO_IS_APPENDING;
- break;
- default:
- __set_errno (EINVAL);
- return NULL;
- }
- if (mode[0] == '+' || (mode[0] == 'b' && mode[1] == '+')) {
- omode = O_RDWR;
- read_write &= _IO_IS_APPENDING;
- }
- fdesc = open(filename, omode|oflags, oprot);
+ switch (*mode++)
+ {
+ case 'r':
+ omode = O_RDONLY;
+ read_write = _IO_NO_WRITES;
+ break;
+ case 'w':
+ omode = O_WRONLY;
+ oflags = O_CREAT|O_TRUNC;
+ read_write = _IO_NO_READS;
+ break;
+ case 'a':
+ omode = O_WRONLY;
+ oflags = O_CREAT|O_APPEND;
+ read_write = _IO_NO_READS|_IO_IS_APPENDING;
+ break;
+ default:
+ __set_errno (EINVAL);
+ return NULL;
+ }
+ if (mode[0] == '+' || (mode[0] == 'b' && mode[1] == '+'))
+ {
+ omode = O_RDWR;
+ read_write &= _IO_IS_APPENDING;
+ }
+ fdesc = open (filename, omode|oflags, oprot);
if (fdesc < 0)
return NULL;
fp->_fileno = fdesc;
- _IO_mask_flags(fp, read_write,_IO_NO_READS+_IO_NO_WRITES+_IO_IS_APPENDING);
+ _IO_mask_flags (fp, read_write,_IO_NO_READS+_IO_NO_WRITES+_IO_IS_APPENDING);
if (read_write & _IO_IS_APPENDING)
if (_IO_SEEKOFF (fp, (_IO_off_t)0, _IO_seek_end, _IOS_INPUT|_IOS_OUTPUT)
== _IO_pos_BAD && errno != ESPIPE)
return NULL;
- _IO_link_in(fp);
+ _IO_link_in (fp);
return fp;
}
-_IO_FILE*
-DEFUN(_IO_file_attach, (fp, fd),
- _IO_FILE *fp AND int fd)
+_IO_FILE *
+_IO_file_attach (fp, fd)
+ _IO_FILE *fp;
+ int fd;
{
- if (_IO_file_is_open(fp))
+ if (_IO_file_is_open (fp))
return NULL;
fp->_fileno = fd;
fp->_flags &= ~(_IO_NO_READS+_IO_NO_WRITES);
@@ -213,16 +220,18 @@ DEFUN(_IO_file_attach, (fp, fd),
return fp;
}
-_IO_FILE*
-DEFUN(_IO_file_setbuf, (fp, p, len),
- register _IO_FILE *fp AND char* p AND _IO_ssize_t len)
+_IO_FILE *
+_IO_file_setbuf (fp, p, len)
+ _IO_FILE *fp;
+ char *p;
+ _IO_ssize_t len;
{
- if (_IO_default_setbuf(fp, p, len) == NULL)
- return NULL;
+ if (_IO_default_setbuf (fp, p, len) == NULL)
+ return NULL;
fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_write_end
= fp->_IO_buf_base;
- _IO_setg(fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base);
+ _IO_setg (fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base);
return fp;
}
@@ -231,8 +240,10 @@ DEFUN(_IO_file_setbuf, (fp, p, len),
Then mark FP as having empty buffers. */
int
-DEFUN(_IO_do_write, (fp, data, to_do),
- register _IO_FILE *fp AND const char* data AND _IO_size_t to_do)
+_IO_do_write (fp, data, to_do)
+ _IO_FILE *fp;
+ const char *data;
+ _IO_size_t to_do;
{
_IO_size_t count;
if (to_do == 0)
@@ -247,24 +258,24 @@ DEFUN(_IO_do_write, (fp, data, to_do),
else if (fp->_IO_read_end != fp->_IO_write_base)
{
_IO_pos_t new_pos
- = _IO_SYSSEEK(fp, fp->_IO_write_base - fp->_IO_read_end, 1);
+ = _IO_SYSSEEK (fp, fp->_IO_write_base - fp->_IO_read_end, 1);
if (new_pos == _IO_pos_BAD)
return EOF;
fp->_offset = new_pos;
}
count = _IO_SYSWRITE (fp, data, to_do);
if (fp->_cur_column)
- fp->_cur_column = _IO_adjust_column(fp->_cur_column - 1, data, to_do) + 1;
- _IO_setg(fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base);
+ fp->_cur_column = _IO_adjust_column (fp->_cur_column - 1, data, to_do) + 1;
+ _IO_setg (fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base);
fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_buf_base;
- fp->_IO_write_end = (fp->_flags & (_IO_LINE_BUF+_IO_UNBUFFERED)) ? fp->_IO_buf_base
- : fp->_IO_buf_end;
+ fp->_IO_write_end = ((fp->_flags & (_IO_LINE_BUF+_IO_UNBUFFERED))
+ ? fp->_IO_buf_base : fp->_IO_buf_end);
return count != to_do ? EOF : 0;
}
int
-DEFUN(_IO_file_underflow, (fp),
- register _IO_FILE *fp)
+_IO_file_underflow (fp)
+ _IO_FILE *fp;
{
_IO_ssize_t count;
#if 0
@@ -279,17 +290,17 @@ DEFUN(_IO_file_underflow, (fp),
return EOF;
}
if (fp->_IO_read_ptr < fp->_IO_read_end)
- return *(unsigned char*)fp->_IO_read_ptr;
+ return *(unsigned char *) fp->_IO_read_ptr;
if (fp->_IO_buf_base == NULL)
- _IO_doallocbuf(fp);
+ _IO_doallocbuf (fp);
/* Flush all line buffered files before reading. */
/* FIXME This can/should be moved to genops ?? */
if (fp->_flags & (_IO_LINE_BUF|_IO_UNBUFFERED))
- _IO_flush_all_linebuffered();
+ _IO_flush_all_linebuffered ();
- _IO_switch_to_get_mode(fp);
+ _IO_switch_to_get_mode (fp);
/* This is very tricky. We have to adjust those
pointers before we call _IO_SYSREAD () since
@@ -313,13 +324,14 @@ DEFUN(_IO_file_underflow, (fp),
if (count == 0)
return EOF;
if (fp->_offset != _IO_pos_BAD)
- _IO_pos_adjust(fp->_offset, count);
- return *(unsigned char*)fp->_IO_read_ptr;
+ _IO_pos_adjust (fp->_offset, count);
+ return *(unsigned char *) fp->_IO_read_ptr;
}
int
-DEFUN(_IO_file_overflow, (f, ch),
- register _IO_FILE* f AND int ch)
+_IO_file_overflow (f, ch)
+ _IO_FILE *f;
+ int ch;
{
if (f->_flags & _IO_NO_WRITES) /* SET ERROR */
{
@@ -333,7 +345,7 @@ DEFUN(_IO_file_overflow, (f, ch),
/* Allocate a buffer if needed. */
if (f->_IO_write_base == 0)
{
- _IO_doallocbuf(f);
+ _IO_doallocbuf (f);
_IO_setg (f, f->_IO_buf_base, f->_IO_buf_base, f->_IO_buf_base);
}
/* Otherwise must be currently reading.
@@ -355,21 +367,21 @@ DEFUN(_IO_file_overflow, (f, ch),
f->_flags |= _IO_CURRENTLY_PUTTING;
}
if (ch == EOF)
- return _IO_do_flush(f);
+ return _IO_do_flush (f);
if (f->_IO_write_ptr == f->_IO_buf_end ) /* Buffer is really full */
- if (_IO_do_flush(f) == EOF)
+ if (_IO_do_flush (f) == EOF)
return EOF;
*f->_IO_write_ptr++ = ch;
if ((f->_flags & _IO_UNBUFFERED)
|| ((f->_flags & _IO_LINE_BUF) && ch == '\n'))
- if (_IO_do_flush(f) == EOF)
+ if (_IO_do_flush (f) == EOF)
return EOF;
- return (unsigned char)ch;
+ return (unsigned char) ch;
}
int
-DEFUN(_IO_file_sync, (fp),
- register _IO_FILE* fp)
+_IO_file_sync (fp)
+ _IO_FILE *fp;
{
_IO_size_t delta;
/* char* ptr = cur_ptr(); */
@@ -379,11 +391,11 @@ DEFUN(_IO_file_sync, (fp),
if (delta != 0)
{
#ifdef TODO
- if (_IO_in_backup(fp))
- delta -= eGptr() - Gbase();
+ if (_IO_in_backup (fp))
+ delta -= eGptr () - Gbase ();
#endif
_IO_off_t new_pos = _IO_SYSSEEK (fp, delta, 1);
- if (new_pos != (_IO_off_t)EOF)
+ if (new_pos != (_IO_off_t) EOF)
fp->_IO_read_end = fp->_IO_read_ptr;
#ifdef ESPIPE
else if (errno == ESPIPE)
@@ -399,8 +411,11 @@ DEFUN(_IO_file_sync, (fp),
}
_IO_pos_t
-DEFUN(_IO_file_seekoff, (fp, offset, dir, mode),
- register _IO_FILE *fp AND _IO_off_t offset AND int dir AND int mode)
+_IO_file_seekoff (fp, offset, dir, mode)
+ _IO_FILE *fp;
+ _IO_off_t offset;
+ int dir;
+ int mode;
{
_IO_pos_t result;
_IO_off_t delta, new_offset;
@@ -421,14 +436,15 @@ DEFUN(_IO_file_seekoff, (fp, offset, dir, mode),
end up flushing when we close(), it doesn't make much difference.)
FIXME: simulate mem-papped files. */
- if (fp->_IO_write_ptr > fp->_IO_write_base || _IO_in_put_mode(fp))
- if (_IO_switch_to_get_mode(fp)) return EOF;
+ if (fp->_IO_write_ptr > fp->_IO_write_base || _IO_in_put_mode (fp))
+ if (_IO_switch_to_get_mode (fp))
+ return EOF;
if (fp->_IO_buf_base == NULL)
{
- _IO_doallocbuf(fp);
- _IO_setp(fp, fp->_IO_buf_base, fp->_IO_buf_base);
- _IO_setg(fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base);
+ _IO_doallocbuf (fp);
+ _IO_setp (fp, fp->_IO_buf_base, fp->_IO_buf_base);
+ _IO_setg (fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base);
}
switch (dir)
@@ -439,7 +455,7 @@ DEFUN(_IO_file_seekoff, (fp, offset, dir, mode),
if (fp->_offset == _IO_pos_BAD)
goto dumb;
/* Make offset absolute, assuming current pointer is file_ptr(). */
- offset += _IO_pos_as_off(fp->_offset);
+ offset += _IO_pos_as_off (fp->_offset);
dir = _IO_seek_set;
break;
@@ -448,7 +464,7 @@ DEFUN(_IO_file_seekoff, (fp, offset, dir, mode),
case _IO_seek_end:
{
struct stat st;
- if (_IO_SYSSTAT (fp, &st) == 0 && S_ISREG(st.st_mode))
+ if (_IO_SYSSTAT (fp, &st) == 0 && S_ISREG (st.st_mode))
{
offset += st.st_size;
dir = _IO_seek_set;
@@ -464,46 +480,46 @@ DEFUN(_IO_file_seekoff, (fp, offset, dir, mode),
&& !_IO_in_backup (fp))
{
/* Offset relative to start of main get area. */
- _IO_pos_t rel_offset = offset - fp->_offset
- + (fp->_IO_read_end - fp->_IO_read_base);
+ _IO_pos_t rel_offset = (offset - fp->_offset
+ + (fp->_IO_read_end - fp->_IO_read_base));
if (rel_offset >= 0)
{
#if 0
- if (_IO_in_backup(fp))
- _IO_switch_to_main_get_area(fp);
+ if (_IO_in_backup (fp))
+ _IO_switch_to_main_get_area (fp);
#endif
if (rel_offset <= fp->_IO_read_end - fp->_IO_read_base)
{
- _IO_setg(fp, fp->_IO_buf_base, fp->_IO_buf_base + rel_offset,
- fp->_IO_read_end);
- _IO_setp(fp, fp->_IO_buf_base, fp->_IO_buf_base);
+ _IO_setg (fp, fp->_IO_buf_base, fp->_IO_buf_base + rel_offset,
+ fp->_IO_read_end);
+ _IO_setp (fp, fp->_IO_buf_base, fp->_IO_buf_base);
return offset;
}
#ifdef TODO
/* If we have streammarkers, seek forward by reading ahead. */
- if (_IO_have_markers(fp))
+ if (_IO_have_markers (fp))
{
int to_skip = rel_offset
- (fp->_IO_read_ptr - fp->_IO_read_base);
- if (ignore(to_skip) != to_skip)
+ if (ignore (to_skip) != to_skip)
goto dumb;
return offset;
}
#endif
}
#ifdef TODO
- if (rel_offset < 0 && rel_offset >= Bbase() - Bptr())
+ if (rel_offset < 0 && rel_offset >= Bbase () - Bptr ())
{
- if (!_IO_in_backup(fp))
- _IO_switch_to_backup_area(fp);
- gbump(fp->_IO_read_end + rel_offset - fp->_IO_read_ptr);
+ if (!_IO_in_backup (fp))
+ _IO_switch_to_backup_area (fp);
+ gbump (fp->_IO_read_end + rel_offset - fp->_IO_read_ptr);
return offset;
}
#endif
}
#ifdef TODO
- _IO_unsave_markers(fp);
+ _IO_unsave_markers (fp);
#endif
if (fp->_flags & _IO_NO_READS)
@@ -535,30 +551,33 @@ DEFUN(_IO_file_seekoff, (fp, offset, dir, mode),
goto dumb;
}
}
- _IO_setg(fp, fp->_IO_buf_base, fp->_IO_buf_base+delta, fp->_IO_buf_base+count);
- _IO_setp(fp, fp->_IO_buf_base, fp->_IO_buf_base);
+ _IO_setg (fp, fp->_IO_buf_base, fp->_IO_buf_base + delta,
+ fp->_IO_buf_base + count);
+ _IO_setp (fp, fp->_IO_buf_base, fp->_IO_buf_base);
fp->_offset = result + count;
- _IO_mask_flags(fp, 0, _IO_EOF_SEEN);
+ _IO_mask_flags (fp, 0, _IO_EOF_SEEN);
return offset;
dumb:
- _IO_unsave_markers(fp);
+ _IO_unsave_markers (fp);
result = _IO_SYSSEEK (fp, offset, dir);
if (result != EOF)
- _IO_mask_flags(fp, 0, _IO_EOF_SEEN);
+ _IO_mask_flags (fp, 0, _IO_EOF_SEEN);
fp->_offset = result;
- _IO_setg(fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base);
- _IO_setp(fp, fp->_IO_buf_base, fp->_IO_buf_base);
+ _IO_setg (fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base);
+ _IO_setp (fp, fp->_IO_buf_base, fp->_IO_buf_base);
return result;
}
_IO_ssize_t
-DEFUN(_IO_file_read, (fp, buf, size),
- register _IO_FILE* fp AND void* buf AND _IO_ssize_t size)
+_IO_file_read (fp, buf, size)
+ _IO_FILE *fp;
+ void *buf;
+ _IO_ssize_t size;
{
for (;;)
{
- _IO_ssize_t count = _IO_read(fp->_fileno, buf, size);
+ _IO_ssize_t count = _IO_read (fp->_fileno, buf, size);
#if 0 && defined EINTR
/* We must not do this optimization since POSIX.1 explicitly
requests that the stream operations must return with the
@@ -572,34 +591,39 @@ DEFUN(_IO_file_read, (fp, buf, size),
}
_IO_pos_t
-DEFUN(_IO_file_seek, (fp, offset, dir),
- _IO_FILE *fp AND _IO_off_t offset AND int dir)
+_IO_file_seek (fp, offset, dir)
+ _IO_FILE *fp;
+ _IO_off_t offset;
+ int dir;
{
- return _IO_lseek(fp->_fileno, offset, dir);
+ return _IO_lseek (fp->_fileno, offset, dir);
}
int
-DEFUN(_IO_file_stat, (fp, st),
- _IO_FILE *fp AND void* st)
+_IO_file_stat (fp, st)
+ _IO_FILE *fp;
+ void *st;
{
- return _IO_fstat(fp->_fileno, (struct stat*)st);
+ return _IO_fstat (fp->_fileno, (struct stat *) st);
}
int
-DEFUN(_IO_file_close, (fp),
- _IO_FILE* fp)
+_IO_file_close (fp)
+ _IO_FILE *fp;
{
- return _IO_close(fp->_fileno);
+ return _IO_close (fp->_fileno);
}
_IO_ssize_t
-DEFUN(_IO_file_write, (f, data, n),
- register _IO_FILE* f AND const void* data AND _IO_ssize_t n)
+_IO_file_write (f, data, n)
+ _IO_FILE *f;
+ const void *data;
+ _IO_ssize_t n;
{
_IO_ssize_t to_do = n;
while (to_do > 0)
{
- _IO_ssize_t count = _IO_write(f->_fileno, data, to_do);
+ _IO_ssize_t count = _IO_write (f->_fileno, data, to_do);
if (count == EOF)
{
#if 0 && defined EINTR
@@ -617,7 +641,7 @@ DEFUN(_IO_file_write, (f, data, n),
}
}
to_do -= count;
- data = (void*)((char*)data + count);
+ data = (void *) ((char *) data + count);
}
n -= to_do;
if (f->_offset >= 0)
@@ -626,10 +650,12 @@ DEFUN(_IO_file_write, (f, data, n),
}
_IO_size_t
-DEFUN(_IO_file_xsputn, (f, data, n),
- _IO_FILE *f AND const void *data AND _IO_size_t n)
+_IO_file_xsputn (f, data, n)
+ _IO_FILE *f;
+ const void *data;
+ _IO_size_t n;
{
- register const char *s = (char*) data;
+ register const char *s = (char *) data;
_IO_size_t to_do = n;
int must_flush = 0;
_IO_size_t count;
@@ -646,14 +672,16 @@ DEFUN(_IO_file_xsputn, (f, data, n),
{
count = f->_IO_buf_end - f->_IO_write_ptr;
if (count >= n)
- { register const char *p;
+ {
+ register const char *p;
for (p = s + n; p > s; )
{
- if (*--p == '\n') {
- count = p - s + 1;
- must_flush = 1;
- break;
- }
+ if (*--p == '\n')
+ {
+ count = p - s + 1;
+ must_flush = 1;
+ break;
+ }
}
}
}
@@ -662,23 +690,26 @@ DEFUN(_IO_file_xsputn, (f, data, n),
{
if (count > to_do)
count = to_do;
- if (count > 20) {
- memcpy(f->_IO_write_ptr, s, count);
- s += count;
- }
+ if (count > 20)
+ {
+ memcpy (f->_IO_write_ptr, s, count);
+ s += count;
+ }
else
{
register char *p = f->_IO_write_ptr;
- register int i = (int)count;
- while (--i >= 0) *p++ = *s++;
+ register int i = (int) count;
+ while (--i >= 0)
+ *p++ = *s++;
}
f->_IO_write_ptr += count;
to_do -= count;
}
if (to_do + must_flush > 0)
- { _IO_size_t block_size, dont_write;
+ {
+ _IO_size_t block_size, dont_write;
/* Next flush the (full) buffer. */
- if (__overflow(f, EOF) == EOF)
+ if (__overflow (f, EOF) == EOF)
return n - to_do;
/* Try to maintain alignment: write a whole number of blocks.
@@ -687,7 +718,7 @@ DEFUN(_IO_file_xsputn, (f, data, n),
dont_write = block_size >= 128 ? to_do % block_size : 0;
count = to_do - dont_write;
- if (_IO_do_write(f, s, count) == EOF)
+ if (_IO_do_write (f, s, count) == EOF)
return n - to_do;
to_do = dont_write;
@@ -695,7 +726,7 @@ DEFUN(_IO_file_xsputn, (f, data, n),
buffer, but it's somewhat messier for line-buffered files,
so we let _IO_default_xsputn handle the general case. */
if (dont_write)
- to_do -= _IO_default_xsputn(f, s+count, dont_write);
+ to_do -= _IO_default_xsputn (f, s+count, dont_write);
}
return n - to_do;
}
@@ -703,21 +734,24 @@ DEFUN(_IO_file_xsputn, (f, data, n),
#if 0
/* Work in progress */
_IO_size_t
-DEFUN(_IO_file_xsgetn, (fp, data, n),
- _IO_FILE *fp AND void *data AND _IO_size_t n)
+_IO_file_xsgetn (fp, data, n)
+ _IO_FILE *fp;
+ void *data;
+ _IO_size_t n;
{
register _IO_size_t more = n;
register char *s = data;
for (;;)
{
- _IO_ssize_t count = fp->_IO_read_end - fp->_IO_read_ptr; /* Data available. */
+ /* Data available. */
+ _IO_ssize_t count = fp->_IO_read_end - fp->_IO_read_ptr;
if (count > 0)
{
if (count > more)
count = more;
if (count > 20)
{
- memcpy(s, fp->_IO_read_ptr, count);
+ memcpy (s, fp->_IO_read_ptr, count);
s += count;
fp->_IO_read_ptr += count;
}
@@ -726,8 +760,9 @@ DEFUN(_IO_file_xsgetn, (fp, data, n),
else
{
register char *p = fp->_IO_read_ptr;
- register int i = (int)count;
- while (--i >= 0) *s++ = *p++;
+ register int i = (int) count;
+ while (--i >= 0)
+ *s++ = *p++;
fp->_IO_read_ptr = p;
}
more -= count;
@@ -742,11 +777,11 @@ DEFUN(_IO_file_xsgetn, (fp, data, n),
/* If we're reading a lot of data, don't bother allocating
a buffer. But if we're only reading a bit, perhaps we should ??*/
if (count <= 512 && fp->_IO_buf_base == NULL)
- _IO_doallocbuf(fp);
+ _IO_doallocbuf (fp);
if (fp->_flags & (_IO_LINE_BUF|_IO_UNBUFFERED))
- _IO_flush_all_linebuffered();
+ _IO_flush_all_linebuffered ();
- _IO_switch_to_get_mode(fp); ???;
+ _IO_switch_to_get_mode (fp); ???;
count = _IO_SYSREAD (fp, s, more);
if (count <= 0)
{
@@ -760,14 +795,15 @@ DEFUN(_IO_file_xsgetn, (fp, data, n),
more -= count;
}
#endif
- if (more == 0 || __underflow(fp) == EOF)
+ if (more == 0 || __underflow (fp) == EOF)
break;
}
return n - more;
}
#endif
-struct _IO_jump_t _IO_file_jumps = {
+struct _IO_jump_t _IO_file_jumps =
+{
JUMP_INIT_DUMMY,
JUMP_INIT(finish, _IO_file_finish),
JUMP_INIT(overflow, _IO_file_overflow),
diff --git a/libio/fputc.c b/libio/fputc.c
index e1f10f1b20..22cdfab9a8 100644
--- a/libio/fputc.c
+++ b/libio/fputc.c
@@ -1,26 +1,27 @@
-/*
-Copyright (C) 1993, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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"
diff --git a/libio/fputc_u.c b/libio/fputc_u.c
index bc2cc2efb6..48701e1d6c 100644
--- a/libio/fputc_u.c
+++ b/libio/fputc_u.c
@@ -1,26 +1,27 @@
-/*
-Copyright (C) 1993, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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"
diff --git a/libio/freopen.c b/libio/freopen.c
index bb0c59788f..ff57d6033d 100644
--- a/libio/freopen.c
+++ b/libio/freopen.c
@@ -1,26 +1,27 @@
-/*
-Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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"
diff --git a/libio/fseek.c b/libio/fseek.c
index 3d4e4925b9..f2563d33f2 100644
--- a/libio/fseek.c
+++ b/libio/fseek.c
@@ -1,26 +1,27 @@
-/*
-Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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"
diff --git a/libio/genops.c b/libio/genops.c
index c08598686d..de9c826b9f 100644
--- a/libio/genops.c
+++ b/libio/genops.c
@@ -1,26 +1,27 @@
-/*
-Copyright (C) 1993, 1995 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. */
+/* 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. */
/* Generic or default I/O operations. */
@@ -31,41 +32,46 @@ the executable file might be covered by the GNU General Public License. */
#include <string.h>
void
-DEFUN(_IO_un_link, (fp),
- _IO_FILE *fp)
-{
- if (fp->_flags & _IO_LINKED) {
- _IO_FILE **f;
- for (f = &_IO_list_all; *f != NULL; f = &(*f)->_chain) {
- if (*f == fp) {
- *f = fp->_chain;
- break;
- }
+_IO_un_link (fp)
+ _IO_FILE *fp;
+{
+ if (fp->_flags & _IO_LINKED)
+ {
+ _IO_FILE **f;
+ for (f = &_IO_list_all; *f != NULL; f = &(*f)->_chain)
+ {
+ if (*f == fp)
+ {
+ *f = fp->_chain;
+ break;
+ }
+ }
+ fp->_flags &= ~_IO_LINKED;
}
- fp->_flags &= ~_IO_LINKED;
- }
}
void
-DEFUN(_IO_link_in, (fp),
- _IO_FILE *fp)
+_IO_link_in (fp)
+ _IO_FILE *fp;
{
- if ((fp->_flags & _IO_LINKED) == 0) {
+ if ((fp->_flags & _IO_LINKED) == 0)
+ {
fp->_flags |= _IO_LINKED;
fp->_chain = _IO_list_all;
_IO_list_all = fp;
- }
+ }
}
/* Return minimum _pos markers
Assumes the current get area is the main get area. */
+static _IO_size_t _IO_least_marker __P ((_IO_FILE *fp));
-_IO_size_t
-DEFUN(_IO_least_marker, (fp),
- register _IO_FILE *fp)
+static _IO_size_t
+_IO_least_marker (fp)
+ _IO_FILE *fp;
{
_IO_ssize_t least_so_far = fp->_IO_read_end - fp->_IO_read_base;
- register struct _IO_marker *mark;
+ struct _IO_marker *mark;
for (mark = fp->_markers; mark != NULL; mark = mark->_next)
if (mark->_pos < least_so_far)
least_so_far = mark->_pos;
@@ -75,41 +81,51 @@ DEFUN(_IO_least_marker, (fp),
/* Switch current get area from backup buffer to (start of) main get area. */
void
-DEFUN(_IO_switch_to_main_get_area, (fp),
- _IO_FILE *fp)
+_IO_switch_to_main_get_area (fp)
+ _IO_FILE *fp;
{
char *tmp;
fp->_flags &= ~_IO_IN_BACKUP;
/* Swap _IO_read_end and _IO_save_end. */
- tmp = fp->_IO_read_end; fp->_IO_read_end= fp->_IO_save_end; fp->_IO_save_end= tmp;
+ tmp = fp->_IO_read_end;
+ fp->_IO_read_end = fp->_IO_save_end;
+ fp->_IO_save_end= tmp;
/* Swap _IO_read_base and _IO_save_base. */
- tmp = fp->_IO_read_base; fp->_IO_read_base = fp->_IO_save_base; fp->_IO_save_base = tmp;
+ tmp = fp->_IO_read_base;
+ fp->_IO_read_base = fp->_IO_save_base;
+ fp->_IO_save_base = tmp;
+
fp->_IO_read_ptr = fp->_IO_read_base;
}
/* Switch current get area from main get area to (end of) backup area. */
void
-DEFUN(_IO_switch_to_backup_area, (fp),
- register _IO_FILE *fp)
+_IO_switch_to_backup_area (fp)
+ _IO_FILE *fp;
{
char *tmp;
fp->_flags |= _IO_IN_BACKUP;
/* Swap _IO_read_end and _IO_save_end. */
- tmp = fp->_IO_read_end; fp->_IO_read_end = fp->_IO_save_end; fp->_IO_save_end = tmp;
+ tmp = fp->_IO_read_end;
+ fp->_IO_read_end = fp->_IO_save_end;
+ fp->_IO_save_end = tmp;
/* Swap _gbase and _IO_save_base. */
- tmp = fp->_IO_read_base; fp->_IO_read_base = fp->_IO_save_base; fp->_IO_save_base = tmp;
+ tmp = fp->_IO_read_base;
+ fp->_IO_read_base = fp->_IO_save_base;
+ fp->_IO_save_base = tmp;
+
fp->_IO_read_ptr = fp->_IO_read_end;
}
int
-DEFUN(_IO_switch_to_get_mode, (fp),
- register _IO_FILE *fp)
+_IO_switch_to_get_mode (fp)
+ _IO_FILE *fp;
{
if (fp->_IO_write_ptr > fp->_IO_write_base)
if (_IO_OVERFLOW (fp, EOF) == EOF)
return EOF;
- if (_IO_in_backup(fp))
+ if (_IO_in_backup (fp))
fp->_IO_read_base = fp->_IO_backup_base;
else
{
@@ -126,11 +142,11 @@ DEFUN(_IO_switch_to_get_mode, (fp),
}
void
-DEFUN(_IO_free_backup_area, (fp),
- register _IO_FILE *fp)
+_IO_free_backup_area (fp)
+ _IO_FILE *fp;
{
if (_IO_in_backup (fp))
- _IO_switch_to_main_get_area(fp); /* Just in case. */
+ _IO_switch_to_main_get_area (fp); /* Just in case. */
free (fp->_IO_save_base);
fp->_IO_save_base = NULL;
fp->_IO_save_end = NULL;
@@ -139,13 +155,14 @@ DEFUN(_IO_free_backup_area, (fp),
#if 0
int
-DEFUN(_IO_switch_to_put_mode, (fp),
- register _IO_FILE *fp)
+_IO_switch_to_put_mode (fp)
+ _IO_FILE *fp;
{
fp->_IO_write_base = fp->_IO_read_ptr;
fp->_IO_write_ptr = fp->_IO_read_ptr;
/* Following is wrong if line- or un-buffered? */
- fp->_IO_write_end = fp->_flags & _IO_IN_BACKUP ? fp->_IO_read_end : fp->_IO_buf_end;
+ fp->_IO_write_end = (fp->_flags & _IO_IN_BACKUP
+ ? fp->_IO_read_end : fp->_IO_buf_end);
fp->_IO_read_ptr = fp->_IO_read_end;
fp->_IO_read_base = fp->_IO_read_end;
@@ -156,18 +173,21 @@ DEFUN(_IO_switch_to_put_mode, (fp),
#endif
int
-DEFUN(__overflow, (f, ch),
- _IO_FILE *f AND int ch)
+__overflow (f, ch)
+ _IO_FILE *f;
+ int ch;
{
return _IO_OVERFLOW (f, ch);
}
-static int
-DEFUN(save_for_backup, (fp),
- _IO_FILE *fp)
+static int save_for_backup __P ((_IO_FILE *fp));
+
+ static int
+save_for_backup (fp)
+ _IO_FILE *fp;
{
/* Append [_IO_read_base.._IO_read_end] to backup area. */
- int least_mark = _IO_least_marker(fp);
+ int least_mark = _IO_least_marker (fp);
/* needed_size is how much space we need in the backup area. */
int needed_size = (fp->_IO_read_end - fp->_IO_read_base) - least_mark;
int current_Bsize = fp->_IO_save_end - fp->_IO_save_base;
@@ -178,22 +198,22 @@ DEFUN(save_for_backup, (fp),
{
char *new_buffer;
avail = 100;
- new_buffer = (char*)malloc(avail+needed_size);
+ new_buffer = (char *) malloc (avail + needed_size);
if (new_buffer == NULL)
return EOF; /* FIXME */
if (least_mark < 0)
{
- memcpy(new_buffer + avail,
- fp->_IO_save_end + least_mark,
- -least_mark);
- memcpy(new_buffer +avail - least_mark,
- fp->_IO_read_base,
- fp->_IO_read_end - fp->_IO_read_base);
+ memcpy (new_buffer + avail,
+ fp->_IO_save_end + least_mark,
+ -least_mark);
+ memcpy (new_buffer + avail - least_mark,
+ fp->_IO_read_base,
+ fp->_IO_read_end - fp->_IO_read_base);
}
else
- memcpy(new_buffer + avail,
- fp->_IO_read_base + least_mark,
- needed_size);
+ memcpy (new_buffer + avail,
+ fp->_IO_read_base + least_mark,
+ needed_size);
if (fp->_IO_save_base)
free (fp->_IO_save_base);
fp->_IO_save_base = new_buffer;
@@ -204,17 +224,17 @@ DEFUN(save_for_backup, (fp),
avail = current_Bsize - needed_size;
if (least_mark < 0)
{
- memmove(fp->_IO_save_base + avail,
- fp->_IO_save_end + least_mark,
- -least_mark);
- memcpy(fp->_IO_save_base + avail - least_mark,
- fp->_IO_read_base,
- fp->_IO_read_end - fp->_IO_read_base);
+ memmove (fp->_IO_save_base + avail,
+ fp->_IO_save_end + least_mark,
+ -least_mark);
+ memcpy (fp->_IO_save_base + avail - least_mark,
+ fp->_IO_read_base,
+ fp->_IO_read_end - fp->_IO_read_base);
}
else if (needed_size > 0)
- memcpy(fp->_IO_save_base + avail,
- fp->_IO_read_base + least_mark,
- needed_size);
+ memcpy (fp->_IO_save_base + avail,
+ fp->_IO_read_base + least_mark,
+ needed_size);
}
/* FIXME: Dubious arithmetic if pointers are NULL */
fp->_IO_backup_base = fp->_IO_save_base + avail;
@@ -226,59 +246,64 @@ DEFUN(save_for_backup, (fp),
}
int
-DEFUN(__underflow, (fp),
- _IO_FILE *fp)
+__underflow (fp)
+ _IO_FILE *fp;
{
- if (_IO_in_put_mode(fp))
- if (_IO_switch_to_get_mode(fp) == EOF) return EOF;
+ if (_IO_in_put_mode (fp))
+ if (_IO_switch_to_get_mode (fp) == EOF)
+ return EOF;
if (fp->_IO_read_ptr < fp->_IO_read_end)
- return *(unsigned char*)fp->_IO_read_ptr;
- if (_IO_in_backup(fp))
+ return *(unsigned char *) fp->_IO_read_ptr;
+ if (_IO_in_backup (fp))
{
- _IO_switch_to_main_get_area(fp);
+ _IO_switch_to_main_get_area (fp);
if (fp->_IO_read_ptr < fp->_IO_read_end)
return *fp->_IO_read_ptr;
}
- if (_IO_have_markers(fp))
+ if (_IO_have_markers (fp))
{
if (save_for_backup (fp))
return EOF;
}
- else if (_IO_have_backup(fp))
- _IO_free_backup_area(fp);
+ else if (_IO_have_backup (fp))
+ _IO_free_backup_area (fp);
return _IO_UNDERFLOW (fp);
}
int
-DEFUN(__uflow, (fp),
- _IO_FILE *fp)
+__uflow (fp)
+ _IO_FILE *fp;
{
- if (_IO_in_put_mode(fp))
- if (_IO_switch_to_get_mode(fp) == EOF) return EOF;
+ if (_IO_in_put_mode (fp))
+ if (_IO_switch_to_get_mode (fp) == EOF)
+ return EOF;
if (fp->_IO_read_ptr < fp->_IO_read_end)
- return *(unsigned char*)fp->_IO_read_ptr++;
- if (_IO_in_backup(fp))
+ return *(unsigned char *) fp->_IO_read_ptr++;
+ if (_IO_in_backup (fp))
{
- _IO_switch_to_main_get_area(fp);
+ _IO_switch_to_main_get_area (fp);
if (fp->_IO_read_ptr < fp->_IO_read_end)
return *fp->_IO_read_ptr++;
}
- if (_IO_have_markers(fp))
+ if (_IO_have_markers (fp))
{
if (save_for_backup (fp))
return EOF;
}
- else if (_IO_have_backup(fp))
- _IO_free_backup_area(fp);
+ else if (_IO_have_backup (fp))
+ _IO_free_backup_area (fp);
return _IO_UFLOW (fp);
}
void
-DEFUN(_IO_setb, (f, b, eb, a),
- _IO_FILE *f AND char *b AND char *eb AND int a)
+_IO_setb (f, b, eb, a)
+ _IO_FILE *f;
+ char *b;
+ char *eb;
+ int a;
{
if (f->_IO_buf_base && !(f->_flags & _IO_USER_BUF))
- FREE_BUF(f->_IO_buf_base, _IO_blen (f));
+ FREE_BUF (f->_IO_buf_base, _IO_blen (f));
f->_IO_buf_base = b;
f->_IO_buf_end = eb;
if (a)
@@ -288,52 +313,55 @@ DEFUN(_IO_setb, (f, b, eb, a),
}
void
-DEFUN(_IO_doallocbuf, (fp),
- register _IO_FILE *fp)
+_IO_doallocbuf (fp)
+ _IO_FILE *fp;
{
if (fp->_IO_buf_base)
return;
if (!(fp->_flags & _IO_UNBUFFERED))
if (_IO_DOALLOCATE (fp) != EOF)
return;
- _IO_setb(fp, fp->_shortbuf, fp->_shortbuf+1, 0);
+ _IO_setb (fp, fp->_shortbuf, fp->_shortbuf+1, 0);
}
int
-DEFUN(_IO_default_underflow, (fp),
- _IO_FILE *fp)
+_IO_default_underflow (fp)
+ _IO_FILE *fp;
{
return EOF;
}
int
-DEFUN(_IO_default_uflow, (fp),
- _IO_FILE *fp)
+_IO_default_uflow (fp)
+ _IO_FILE *fp;
{
int ch = _IO_UNDERFLOW (fp);
if (ch == EOF)
return EOF;
- return *(unsigned char*)fp->_IO_read_ptr++;
+ return *(unsigned char *) fp->_IO_read_ptr++;
}
_IO_size_t
-DEFUN(_IO_default_xsputn, (f, data, n),
- register _IO_FILE *f AND const void *data AND _IO_size_t n)
+_IO_default_xsputn (f, data, n)
+ _IO_FILE *f;
+ const void *data;
+ _IO_size_t n;
{
- register const char *s = (char*) data;
- register _IO_size_t more = n;
+ const char *s = (char *) data;
+ _IO_size_t more = n;
if (more <= 0)
return 0;
for (;;)
{
- _IO_ssize_t count = f->_IO_write_end - f->_IO_write_ptr; /* Space available. */
+ /* Space available. */
+ _IO_ssize_t count = f->_IO_write_end - f->_IO_write_ptr;
if (count > 0)
{
if ((_IO_size_t) count > more)
count = more;
if (count > 20)
{
- memcpy(f->_IO_write_ptr, s, count);
+ memcpy (f->_IO_write_ptr, s, count);
s += count;
f->_IO_write_ptr += count;
}
@@ -341,14 +369,15 @@ DEFUN(_IO_default_xsputn, (f, data, n),
count = 0;
else
{
- register char *p = f->_IO_write_ptr;
- register _IO_ssize_t i;
- for (i = count; --i >= 0; ) *p++ = *s++;
+ char *p = f->_IO_write_ptr;
+ _IO_ssize_t i;
+ for (i = count; --i >= 0; )
+ *p++ = *s++;
f->_IO_write_ptr = p;
}
more -= count;
}
- if (more == 0 || __overflow(f, (unsigned char)*s++) == EOF)
+ if (more == 0 || __overflow (f, (unsigned char) *s++) == EOF)
break;
more--;
}
@@ -356,29 +385,34 @@ DEFUN(_IO_default_xsputn, (f, data, n),
}
_IO_size_t
-DEFUN(_IO_sgetn, (fp, data, n),
- _IO_FILE *fp AND void *data AND _IO_size_t n)
+_IO_sgetn (fp, data, n)
+ _IO_FILE *fp;
+ void *data;
+ _IO_size_t n;
{
/* FIXME handle putback buffer here! */
return _IO_XSGETN (fp, data, n);
}
_IO_size_t
-DEFUN(_IO_default_xsgetn, (fp, data, n),
- _IO_FILE *fp AND void *data AND _IO_size_t n)
+_IO_default_xsgetn (fp, data, n)
+ _IO_FILE *fp;
+ void *data;
+ _IO_size_t n;
{
- register _IO_size_t more = n;
- register char *s = (char*) data;
+ _IO_size_t more = n;
+ char *s = (char*) data;
for (;;)
{
- _IO_ssize_t count = fp->_IO_read_end - fp->_IO_read_ptr; /* Data available. */
+ /* Data available. */
+ _IO_ssize_t count = fp->_IO_read_end - fp->_IO_read_ptr;
if (count > 0)
{
if ((_IO_size_t) count > more)
count = more;
if (count > 20)
{
- memcpy(s, fp->_IO_read_ptr, count);
+ memcpy (s, fp->_IO_read_ptr, count);
s += count;
fp->_IO_read_ptr += count;
}
@@ -386,41 +420,47 @@ DEFUN(_IO_default_xsgetn, (fp, data, n),
count = 0;
else
{
- register char *p = fp->_IO_read_ptr;
- register int i = (int)count;
- while (--i >= 0) *s++ = *p++;
+ char *p = fp->_IO_read_ptr;
+ int i = (int) count;
+ while (--i >= 0)
+ *s++ = *p++;
fp->_IO_read_ptr = p;
}
more -= count;
}
- if (more == 0 || __underflow(fp) == EOF)
+ if (more == 0 || __underflow (fp) == EOF)
break;
}
return n - more;
}
+#if 0
+/* Seems not to be needed. --drepper */
int
-DEFUN(_IO_sync, (fp),
- register _IO_FILE *fp)
+_IO_sync (fp)
+ _IO_FILE *fp;
{
return 0;
}
+#endif
-_IO_FILE*
-DEFUN(_IO_default_setbuf, (fp, p, len),
- register _IO_FILE *fp AND char* p AND _IO_ssize_t len)
+_IO_FILE *
+_IO_default_setbuf (fp, p, len)
+ _IO_FILE *fp;
+ char *p;
+ _IO_ssize_t len;
{
if (_IO_SYNC (fp) == EOF)
return NULL;
if (p == NULL || len == 0)
{
fp->_flags |= _IO_UNBUFFERED;
- _IO_setb(fp, fp->_shortbuf, fp->_shortbuf+1, 0);
+ _IO_setb (fp, fp->_shortbuf, fp->_shortbuf+1, 0);
}
else
{
fp->_flags &= ~_IO_UNBUFFERED;
- _IO_setb(fp, p, p+len, 0);
+ _IO_setb (fp, p, p+len, 0);
}
fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_write_end = 0;
fp->_IO_read_base = fp->_IO_read_ptr = fp->_IO_read_end = 0;
@@ -428,26 +468,29 @@ DEFUN(_IO_default_setbuf, (fp, p, len),
}
_IO_pos_t
-DEFUN(_IO_default_seekpos, (fp, pos, mode),
- _IO_FILE *fp AND _IO_pos_t pos AND int mode)
+_IO_default_seekpos (fp, pos, mode)
+ _IO_FILE *fp;
+ _IO_pos_t pos;
+ int mode;
{
- return _IO_SEEKOFF (fp, _IO_pos_as_off(pos), 0, mode);
+ return _IO_SEEKOFF (fp, _IO_pos_as_off (pos), 0, mode);
}
int
-DEFUN(_IO_default_doallocate, (fp),
- _IO_FILE *fp)
+_IO_default_doallocate (fp)
+ _IO_FILE *fp;
{
char *buf;
- ALLOC_BUF(buf, _IO_BUFSIZ, EOF);
- _IO_setb(fp, buf, buf+_IO_BUFSIZ, 1);
+ ALLOC_BUF (buf, _IO_BUFSIZ, EOF);
+ _IO_setb (fp, buf, buf+_IO_BUFSIZ, 1);
return 1;
}
void
-DEFUN(_IO_init, (fp, flags),
- register _IO_FILE *fp AND int flags)
+_IO_init (fp, flags)
+ _IO_FILE *fp;
+ int flags;
{
fp->_flags = _IO_MAGIC|flags;
fp->_IO_buf_base = NULL;
@@ -471,8 +514,8 @@ DEFUN(_IO_init, (fp, flags),
}
int
-DEFUN(_IO_default_sync, (fp),
- _IO_FILE *fp)
+_IO_default_sync (fp)
+ _IO_FILE *fp;
{
return 0;
}
@@ -481,13 +524,14 @@ DEFUN(_IO_default_sync, (fp),
current implementation, this function can get called twice! */
void
-DEFUN(_IO_default_finish, (fp, dummy),
- _IO_FILE *fp AND int dummy)
+_IO_default_finish (fp, dummy)
+ _IO_FILE *fp;
+ int dummy;
{
struct _IO_marker *mark;
if (fp->_IO_buf_base && !(fp->_flags & _IO_USER_BUF))
{
- FREE_BUF(fp->_IO_buf_base, _IO_blen (fp));
+ FREE_BUF (fp->_IO_buf_base, _IO_blen (fp));
fp->_IO_buf_base = fp->_IO_buf_end = NULL;
}
@@ -504,19 +548,23 @@ DEFUN(_IO_default_finish, (fp, dummy),
_IO_lock_fini (*fp->_lock);
#endif
- _IO_un_link(fp);
+ _IO_un_link (fp);
}
_IO_pos_t
-DEFUN(_IO_default_seekoff, (fp, offset, dir, mode),
- register _IO_FILE *fp AND _IO_off_t offset AND int dir AND int mode)
+_IO_default_seekoff (fp, offset, dir, mode)
+ _IO_FILE *fp;
+ _IO_off_t offset;
+ int dir;
+ int mode;
{
return _IO_pos_BAD;
}
int
-DEFUN(_IO_sputbackc, (fp, c),
- register _IO_FILE *fp AND int c)
+_IO_sputbackc (fp, c)
+ _IO_FILE *fp;
+ int c;
{
int result;
@@ -524,7 +572,7 @@ DEFUN(_IO_sputbackc, (fp, c),
&& (unsigned char)fp->_IO_read_ptr[-1] == (unsigned char)c)
{
fp->_IO_read_ptr--;
- result = (unsigned char)c;
+ result = (unsigned char) c;
}
else
result = _IO_PBACKFAIL (fp, c);
@@ -536,15 +584,15 @@ DEFUN(_IO_sputbackc, (fp, c),
}
int
-DEFUN(_IO_sungetc, (fp),
- register _IO_FILE *fp)
+_IO_sungetc (fp)
+ _IO_FILE *fp;
{
int result;
if (fp->_IO_read_ptr > fp->_IO_read_base)
{
fp->_IO_read_ptr--;
- result = (unsigned char)*fp->_IO_read_ptr;
+ result = (unsigned char) *fp->_IO_read_ptr;
}
else
result = _IO_PBACKFAIL (fp, EOF);
@@ -556,9 +604,12 @@ DEFUN(_IO_sungetc, (fp),
}
#if 0 /* Work in progress */
+/* Seems not to be needed. */
+#if 0
void
-DEFUN(_IO_set_column, (fp, c),
- register _IO_FILE *fp AND int c)
+_IO_set_column (fp, c)
+ _IO_FILE *fp;
+ int c;
{
if (c == -1)
fp->_column = -1;
@@ -567,39 +618,46 @@ DEFUN(_IO_set_column, (fp, c),
}
#else
int
-DEFUN(_IO_set_column, (fp, i),
- register _IO_FILE *fp AND int i)
+_IO_set_column (fp, i)
+ _IO_FILE *fp;
+ int i;
{
- fp->_cur_column = i+1;
+ fp->_cur_column = i + 1;
return 0;
}
#endif
+#endif
unsigned
-DEFUN(_IO_adjust_column, (start, line, count),
- unsigned start AND const char *line AND int count)
+_IO_adjust_column (start, line, count)
+ unsigned start;
+ const char *line;
+ int count;
{
- register const char *ptr = line + count;
+ const char *ptr = line + count;
while (ptr > line)
if (*--ptr == '\n')
return line + count - ptr - 1;
return start + count;
}
+#if 0
+/* Seems not to be needed. --drepper */
int
-DEFUN(_IO_get_column, (fp),
- register _IO_FILE *fp)
+_IO_get_column (fp)
+ _IO_FILE *fp;
{
if (fp->_cur_column)
- return _IO_adjust_column(fp->_cur_column - 1,
+ return _IO_adjust_column (fp->_cur_column - 1,
fp->_IO_write_base,
fp->_IO_write_ptr - fp->_IO_write_base);
return -1;
}
+#endif
int
-DEFUN_VOID(_IO_flush_all)
+_IO_flush_all ()
{
int result = 0;
_IO_FILE *fp;
@@ -611,7 +669,7 @@ DEFUN_VOID(_IO_flush_all)
}
void
-DEFUN_VOID(_IO_flush_all_linebuffered)
+_IO_flush_all_linebuffered ()
{
_IO_FILE *fp;
for (fp = _IO_list_all; fp != NULL; fp = fp->_chain)
@@ -619,8 +677,10 @@ DEFUN_VOID(_IO_flush_all_linebuffered)
_IO_OVERFLOW (fp, EOF);
}
-void
-DEFUN_VOID(_IO_unbuffer_all)
+static void _IO_unbuffer_all __P ((void));
+
+static void
+_IO_unbuffer_all ()
{
_IO_FILE *fp;
for (fp = _IO_list_all; fp != NULL; fp = fp->_chain)
@@ -629,7 +689,7 @@ DEFUN_VOID(_IO_unbuffer_all)
}
void
-DEFUN_VOID(_IO_cleanup)
+_IO_cleanup ()
{
_IO_flush_all ();
@@ -644,13 +704,14 @@ DEFUN_VOID(_IO_cleanup)
}
void
-DEFUN(_IO_init_marker, (marker, fp),
- struct _IO_marker *marker AND _IO_FILE *fp)
+_IO_init_marker (marker, fp)
+ struct _IO_marker *marker;
+ _IO_FILE *fp;
{
marker->_sbuf = fp;
- if (_IO_in_put_mode(fp))
- _IO_switch_to_get_mode(fp);
- if (_IO_in_backup(fp))
+ if (_IO_in_put_mode (fp))
+ _IO_switch_to_get_mode (fp);
+ if (_IO_in_backup (fp))
marker->_pos = fp->_IO_read_ptr - fp->_IO_read_end;
else
marker->_pos = fp->_IO_read_ptr - fp->_IO_read_base;
@@ -661,11 +722,11 @@ DEFUN(_IO_init_marker, (marker, fp),
}
void
-DEFUN(_IO_remove_marker, (marker),
- register struct _IO_marker *marker)
+_IO_remove_marker (marker)
+ struct _IO_marker *marker;
{
/* Unlink from sb's chain. */
- register struct _IO_marker **ptr = &marker->_sbuf->_markers;
+ struct _IO_marker **ptr = &marker->_sbuf->_markers;
for (; ; ptr = &(*ptr)->_next)
{
if (*ptr == NULL)
@@ -685,21 +746,22 @@ DEFUN(_IO_remove_marker, (marker),
#define BAD_DELTA EOF
int
-DEFUN(_IO_marker_difference, (mark1, mark2),
- struct _IO_marker *mark1 AND struct _IO_marker *mark2)
+_IO_marker_difference (mark1, mark2)
+ struct _IO_marker *mark1;
+ struct _IO_marker *mark2;
{
return mark1->_pos - mark2->_pos;
}
/* Return difference between MARK and current position of MARK's stream. */
int
-DEFUN(_IO_marker_delta, (mark),
- struct _IO_marker *mark)
+_IO_marker_delta (mark)
+ struct _IO_marker *mark;
{
int cur_pos;
if (mark->_sbuf == NULL)
return BAD_DELTA;
- if (_IO_in_backup(mark->_sbuf))
+ if (_IO_in_backup (mark->_sbuf))
cur_pos = mark->_sbuf->_IO_read_ptr - mark->_sbuf->_IO_read_end;
else
cur_pos = mark->_sbuf->_IO_read_ptr - mark->_sbuf->_IO_read_base;
@@ -707,135 +769,150 @@ DEFUN(_IO_marker_delta, (mark),
}
int
-DEFUN(_IO_seekmark, (fp, mark, delta),
- _IO_FILE *fp AND struct _IO_marker *mark AND int delta)
+_IO_seekmark (fp, mark, delta)
+ _IO_FILE *fp;
+ struct _IO_marker *mark;
+ int delta;
{
if (mark->_sbuf != fp)
return EOF;
if (mark->_pos >= 0)
{
- if (_IO_in_backup(fp))
- _IO_switch_to_main_get_area(fp);
+ if (_IO_in_backup (fp))
+ _IO_switch_to_main_get_area (fp);
fp->_IO_read_ptr = fp->_IO_read_base + mark->_pos;
}
else
{
- if (!_IO_in_backup(fp))
- _IO_switch_to_backup_area(fp);
+ if (!_IO_in_backup (fp))
+ _IO_switch_to_backup_area (fp);
fp->_IO_read_ptr = fp->_IO_read_end + mark->_pos;
}
return 0;
}
void
-DEFUN(_IO_unsave_markers, (fp),
- register _IO_FILE *fp)
+_IO_unsave_markers (fp)
+ _IO_FILE *fp;
{
- register struct _IO_marker *mark = fp->_markers;
+ struct _IO_marker *mark = fp->_markers;
if (mark)
{
#ifdef TODO
- streampos offset = seekoff(0, ios::cur, ios::in);
+ streampos offset = seekoff (0, ios::cur, ios::in);
if (offset != EOF)
{
- offset += eGptr() - Gbase();
+ offset += eGptr () - Gbase ();
for ( ; mark != NULL; mark = mark->_next)
- mark->set_streampos(mark->_pos + offset);
+ mark->set_streampos (mark->_pos + offset);
}
else
{
for ( ; mark != NULL; mark = mark->_next)
- mark->set_streampos(EOF);
+ mark->set_streampos (EOF);
}
#endif
fp->_markers = 0;
}
- if (_IO_have_backup(fp))
- _IO_free_backup_area(fp);
+ if (_IO_have_backup (fp))
+ _IO_free_backup_area (fp);
}
+#if 0
+/* Seems not to be needed. --drepper */
int
-DEFUN(_IO_nobackup_pbackfail, (fp, c),
- register _IO_FILE *fp AND int c)
+_IO_nobackup_pbackfail (fp, c)
+ _IO_FILE *fp;
+ int c;
{
if (fp->_IO_read_ptr > fp->_IO_read_base)
fp->_IO_read_ptr--;
if (c != EOF && *fp->_IO_read_ptr != c)
*fp->_IO_read_ptr = c;
- return (unsigned char)c;
+ return (unsigned char) c;
}
+#endif
int
-DEFUN(_IO_default_pbackfail, (fp, c),
- register _IO_FILE *fp AND int c)
+_IO_default_pbackfail (fp, c)
+ _IO_FILE *fp;
+ int c;
{
if (fp->_IO_read_ptr <= fp->_IO_read_base)
- {
- /* Need to handle a filebuf in write mode (switch to read mode). FIXME!*/
- if (_IO_have_backup(fp) && !_IO_in_backup(fp))
- _IO_switch_to_backup_area(fp);
-
- if (!_IO_have_backup(fp))
- {
- /* No backup buffer: allocate one. */
- /* Use nshort buffer, if unused? (probably not) FIXME */
- int backup_size = 128;
- char *bbuf = (char*)malloc(backup_size);
- if (bbuf == NULL)
- return EOF;
- fp->_IO_save_base = bbuf;
- fp->_IO_save_end = fp->_IO_save_base + backup_size;
- fp->_IO_backup_base = fp->_IO_save_end;
- _IO_switch_to_backup_area(fp);
- }
- else if (fp->_IO_read_ptr <= fp->_IO_read_base)
- {
- /* Increase size of existing backup buffer. */
- _IO_size_t new_size;
- _IO_size_t old_size = fp->_IO_read_end - fp->_IO_read_base;
- char *new_buf;
- new_size = 2 * old_size;
- new_buf = (char*)malloc(new_size);
- if (new_buf == NULL)
- return EOF;
- memcpy(new_buf+(new_size-old_size), fp->_IO_read_base, old_size);
- free (fp->_IO_read_base);
- _IO_setg(fp,
- new_buf, new_buf+(new_size-old_size), new_buf+new_size);
- fp->_IO_backup_base = fp->_IO_read_ptr;
- }
- }
- fp->_IO_read_ptr--;
+ {
+ /* Need to handle a filebuf in write mode (switch to read mode). FIXME!*/
+ if (_IO_have_backup (fp) && !_IO_in_backup (fp))
+ _IO_switch_to_backup_area (fp);
+
+ if (!_IO_have_backup (fp))
+ {
+ /* No backup buffer: allocate one. */
+ /* Use nshort buffer, if unused? (probably not) FIXME */
+ int backup_size = 128;
+ char *bbuf = (char *) malloc (backup_size);
+ if (bbuf == NULL)
+ return EOF;
+ fp->_IO_save_base = bbuf;
+ fp->_IO_save_end = fp->_IO_save_base + backup_size;
+ fp->_IO_backup_base = fp->_IO_save_end;
+ _IO_switch_to_backup_area (fp);
+ }
+ else if (fp->_IO_read_ptr <= fp->_IO_read_base)
+ {
+ /* Increase size of existing backup buffer. */
+ _IO_size_t new_size;
+ _IO_size_t old_size = fp->_IO_read_end - fp->_IO_read_base;
+ char *new_buf;
+ new_size = 2 * old_size;
+ new_buf = (char *) malloc (new_size);
+ if (new_buf == NULL)
+ return EOF;
+ memcpy (new_buf + (new_size - old_size), fp->_IO_read_base,
+ old_size);
+ free (fp->_IO_read_base);
+ _IO_setg (fp, new_buf, new_buf + (new_size - old_size),
+ new_buf + new_size);
+ fp->_IO_backup_base = fp->_IO_read_ptr;
+ }
+ }
+ --fp->_IO_read_ptr;
if (c != EOF && *fp->_IO_read_ptr != c)
*fp->_IO_read_ptr = c;
- return (unsigned char)*fp->_IO_read_ptr;
+ return (unsigned char) *fp->_IO_read_ptr;
}
_IO_pos_t
-DEFUN(_IO_default_seek, (fp, offset, dir),
- _IO_FILE *fp AND _IO_off_t offset AND int dir)
+_IO_default_seek (fp, offset, dir)
+ _IO_FILE *fp;
+ _IO_off_t offset;
+ int dir;
{
return _IO_pos_BAD;
}
int
-DEFUN(_IO_default_stat, (fp, st),
- _IO_FILE *fp AND void* st)
+_IO_default_stat (fp, st)
+ _IO_FILE *fp;
+ void* st;
{
return EOF;
}
_IO_ssize_t
-DEFUN(_IO_default_read, (fp, data, n),
- register _IO_FILE* fp AND void* data AND _IO_ssize_t n)
+_IO_default_read (fp, data, n)
+ _IO_FILE* fp;
+ void *data;
+ _IO_ssize_t n;
{
return -1;
}
_IO_ssize_t
-DEFUN(_IO_default_write, (fp, data, n),
- register _IO_FILE* fp AND const void* data AND _IO_ssize_t n)
+_IO_default_write (fp, data, n)
+ _IO_FILE *fp;
+ const void *data;
+ _IO_ssize_t n;
{
return 0;
}
@@ -851,7 +928,7 @@ DEFUN(_IO_default_write, (fp, data, n),
#else
struct __io_defs {
__io_defs() { }
- ~__io_defs() { _IO_cleanup(); }
+ ~__io_defs() { _IO_cleanup (); }
};
__io_defs io_defs__;
#endif
diff --git a/libio/getc.c b/libio/getc.c
index d3e89fcc27..1dc53b5ed6 100644
--- a/libio/getc.c
+++ b/libio/getc.c
@@ -1,26 +1,27 @@
-/*
-Copyright (C) 1993, 1995, 1996 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. */
+/* 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"
@@ -39,5 +40,9 @@ _IO_getc (fp)
_IO_cleanup_region_end (1);
return result;
}
+
#undef getc
+
+#ifdef weak_alias
weak_alias (_IO_getc, getc)
+#endif
diff --git a/libio/getc_u.c b/libio/getc_u.c
index 569e063b1f..f074427446 100644
--- a/libio/getc_u.c
+++ b/libio/getc_u.c
@@ -1,26 +1,27 @@
-/*
-Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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"
diff --git a/libio/getchar.c b/libio/getchar.c
index 25eb2b10ae..93194b3912 100644
--- a/libio/getchar.c
+++ b/libio/getchar.c
@@ -1,26 +1,27 @@
-/*
-Copyright (C) 1993, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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"
diff --git a/libio/getchar_u.c b/libio/getchar_u.c
index 337f693709..bfbe56b30c 100644
--- a/libio/getchar_u.c
+++ b/libio/getchar_u.c
@@ -1,26 +1,27 @@
-/*
-Copyright (C) 1993, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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"
diff --git a/libio/iofclose.c b/libio/iofclose.c
index 67fadbed2d..35f4a8b569 100644
--- a/libio/iofclose.c
+++ b/libio/iofclose.c
@@ -1,26 +1,27 @@
-/*
-Copyright (C) 1993, 1995 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. */
+/* 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"
#ifdef __STDC__
@@ -29,7 +30,7 @@ the executable file might be covered by the GNU General Public License. */
int
_IO_fclose (fp)
- register _IO_FILE *fp;
+ _IO_FILE *fp;
{
int status;
@@ -52,4 +53,6 @@ _IO_fclose (fp)
return status;
}
+#ifdef weak_alias
weak_alias (_IO_fclose, fclose)
+#endif
diff --git a/libio/iofdopen.c b/libio/iofdopen.c
index 4ec9a1cbce..841e7032b8 100644
--- a/libio/iofdopen.c
+++ b/libio/iofdopen.c
@@ -1,26 +1,27 @@
-/*
-Copyright (C) 1993, 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. */
+/* Copyright (C) 1993, 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. */
#ifdef __STDC__
#include <stdlib.h>
diff --git a/libio/iofflush.c b/libio/iofflush.c
index 082988875f..540c99d535 100644
--- a/libio/iofflush.c
+++ b/libio/iofflush.c
@@ -1,33 +1,34 @@
-/*
-Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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_fflush (fp)
- register _IO_FILE *fp;
+ _IO_FILE *fp;
{
if (fp == NULL)
return _IO_flush_all ();
diff --git a/libio/iofflush_u.c b/libio/iofflush_u.c
index b8af7101a1..b46ae4a3f9 100644
--- a/libio/iofflush_u.c
+++ b/libio/iofflush_u.c
@@ -1,33 +1,34 @@
-/*
-Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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
fflush_unlocked (fp)
- register _IO_FILE *fp;
+ _IO_FILE *fp;
{
if (fp == NULL)
return _IO_flush_all ();
diff --git a/libio/iofgetpos.c b/libio/iofgetpos.c
index 9682af96ae..08a3c20e86 100644
--- a/libio/iofgetpos.c
+++ b/libio/iofgetpos.c
@@ -1,30 +1,30 @@
-/*
-Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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 <errno.h>
-/* ANSI explicitly requires setting errno to a positive value on failure. */
int
_IO_fgetpos (fp, posp)
@@ -39,6 +39,8 @@ _IO_fgetpos (fp, posp)
_IO_cleanup_region_end (1);
if (pos == _IO_pos_BAD)
{
+ /* ANSI explicitly requires setting errno to a positive value on
+ failure. */
#ifdef EIO
if (errno == 0)
__set_errno (EIO);
diff --git a/libio/iofgets.c b/libio/iofgets.c
index c8ec289bd1..74754d5d1e 100644
--- a/libio/iofgets.c
+++ b/libio/iofgets.c
@@ -1,35 +1,36 @@
-/*
-Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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>
-char*
+char *
_IO_fgets (buf, n, fp)
- char* buf;
+ char *buf;
int n;
- _IO_FILE* fp;
+ _IO_FILE *fp;
{
_IO_size_t count;
char *result;
diff --git a/libio/iofopen.c b/libio/iofopen.c
index acf034cd22..1dbeccb81a 100644
--- a/libio/iofopen.c
+++ b/libio/iofopen.c
@@ -1,26 +1,27 @@
-/*
-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. */
+/* 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"
#ifdef __STDC__
diff --git a/libio/iofopncook.c b/libio/iofopncook.c
index 718205e073..9bf29e71ae 100644
--- a/libio/iofopncook.c
+++ b/libio/iofopncook.c
@@ -1,26 +1,27 @@
-/*
-Copyright (C) 1993, 1995 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. */
+/* 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>
@@ -39,8 +40,8 @@ static int _IO_cookie_close __P ((_IO_FILE* fp));
static _IO_ssize_t
_IO_cookie_read (fp, buf, size)
- register _IO_FILE* fp;
- void* buf;
+ _IO_FILE *fp;
+ void *buf;
_IO_ssize_t size;
{
struct _IO_cookie_file *cfile = (struct _IO_cookie_file *) fp;
@@ -53,8 +54,8 @@ _IO_cookie_read (fp, buf, size)
static _IO_ssize_t
_IO_cookie_write (fp, buf, size)
- register _IO_FILE* fp;
- const void* buf;
+ _IO_FILE *fp;
+ const void *buf;
_IO_ssize_t size;
{
struct _IO_cookie_file *cfile = (struct _IO_cookie_file *) fp;
@@ -88,7 +89,7 @@ _IO_cookie_seek (fp, offset, dir)
static int
_IO_cookie_close (fp)
- _IO_FILE* fp;
+ _IO_FILE *fp;
{
struct _IO_cookie_file *cfile = (struct _IO_cookie_file *) fp;
diff --git a/libio/iofprintf.c b/libio/iofprintf.c
index 74e28263b5..4dc9d3f661 100644
--- a/libio/iofprintf.c
+++ b/libio/iofprintf.c
@@ -1,26 +1,27 @@
-/*
-Copyright (C) 1993 Free Software Foundation
+/* Copyright (C) 1993, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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"
@@ -31,11 +32,13 @@ the executable file might be covered by the GNU General Public License. */
#endif
int
-_IO_fprintf
#ifdef __STDC__
- (_IO_FILE *fp, const char* format, ...)
+_IO_fprintf (_IO_FILE *fp, const char* format, ...)
#else
-(fp, format, va_alist) _IO_FILE *fp; char *format; va_dcl
+_IO_fprintf (fp, format, va_alist)
+ _IO_FILE *fp;
+ char *format;
+ va_dcl
#endif
{
int ret;
diff --git a/libio/iofputs.c b/libio/iofputs.c
index 7c76ac6336..1a329bbe26 100644
--- a/libio/iofputs.c
+++ b/libio/iofputs.c
@@ -1,26 +1,27 @@
-/*
-Copyright (C) 1993, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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 <string.h>
diff --git a/libio/iofread.c b/libio/iofread.c
index ad7e4845a8..c83d2b638c 100644
--- a/libio/iofread.c
+++ b/libio/iofread.c
@@ -1,26 +1,27 @@
-/*
-Copyright (C) 1993, 1995 Free Software Foundation
+/* Copyright (C) 1993, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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"
@@ -29,7 +30,7 @@ _IO_fread (buf, size, count, fp)
void *buf;
_IO_size_t size;
_IO_size_t count;
- _IO_FILE* fp;
+ _IO_FILE *fp;
{
_IO_size_t bytes_requested = size*count;
_IO_size_t bytes_read;
diff --git a/libio/iofsetpos.c b/libio/iofsetpos.c
index 2f71d79708..a8d816f5a3 100644
--- a/libio/iofsetpos.c
+++ b/libio/iofsetpos.c
@@ -1,33 +1,34 @@
-/*
-Copyright (C) 1993, 1995 Free Software Foundation
+/* Copyright (C) 1993, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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 <errno.h>
int
_IO_fsetpos (fp, posp)
- _IO_FILE* fp;
+ _IO_FILE *fp;
const _IO_fpos_t *posp;
{
int result;
diff --git a/libio/ioftell.c b/libio/ioftell.c
index 37156bb22c..d8a1ce1d24 100644
--- a/libio/ioftell.c
+++ b/libio/ioftell.c
@@ -1,26 +1,27 @@
-/*
-Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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 <errno.h>
@@ -28,7 +29,7 @@ the executable file might be covered by the GNU General Public License. */
long int
_IO_ftell (fp)
- _IO_FILE* fp;
+ _IO_FILE *fp;
{
_IO_pos_t pos;
CHECK_FILE (fp, -1L);
diff --git a/libio/iofwrite.c b/libio/iofwrite.c
index 3f098e078e..5bc525ffc7 100644
--- a/libio/iofwrite.c
+++ b/libio/iofwrite.c
@@ -1,37 +1,38 @@
-/*
-Copyright (C) 1993, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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"
_IO_size_t
_IO_fwrite (buf, size, count, fp)
- const void* buf;
+ const void *buf;
_IO_size_t size;
_IO_size_t count;
_IO_FILE *fp;
{
- _IO_size_t request = size*count;
+ _IO_size_t request = size * count;
_IO_size_t written;
CHECK_FILE (fp, 0);
if (request == 0)
@@ -41,11 +42,11 @@ _IO_fwrite (buf, size, count, fp)
written = _IO_sputn (fp, (const char *) buf, request);
_IO_cleanup_region_end (1);
/* Many traditional implementations return 0 if size==0 && count > 0,
- but ANSI seems to require us to return count in this case. */
+ but ANSI requires us to return count in this case. */
if (written == request)
return count;
else
- return written/size;
+ return written / size;
}
#ifdef weak_alias
diff --git a/libio/iogetdelim.c b/libio/iogetdelim.c
index 8e87511c12..50918b3e8d 100644
--- a/libio/iogetdelim.c
+++ b/libio/iogetdelim.c
@@ -1,26 +1,27 @@
-/*
-Copyright (C) 1994, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1994, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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. */
#ifdef __STDC__
#include <stdlib.h>
@@ -39,11 +40,11 @@ _IO_ssize_t
_IO_getdelim (lineptr, n, delimiter, fp)
char **lineptr;
_IO_size_t *n;
- int delimiter;
- _IO_FILE *fp;
+ int delimiter;
+ _IO_FILE *fp;
{
int result;
- register _IO_ssize_t cur_len = 0;
+ _IO_ssize_t cur_len = 0;
_IO_ssize_t len;
if (lineptr == NULL || n == NULL)
diff --git a/libio/iogetline.c b/libio/iogetline.c
index a72707196b..bd1a7431f3 100644
--- a/libio/iogetline.c
+++ b/libio/iogetline.c
@@ -1,26 +1,27 @@
-/*
-Copyright (C) 1993 Free Software Foundation
+/* Copyright (C) 1993, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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 GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ 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. */
+ 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 <string.h>
@@ -34,38 +35,41 @@ the executable file might be covered by the GNU General Public License. */
If extract_delim > 0, insert delim in output. */
_IO_size_t
-DEFUN(_IO_getline, (fp, buf, n, delim, extract_delim),
- _IO_FILE *fp AND char* buf AND _IO_size_t n
- AND int delim AND int extract_delim)
+_IO_getline (fp, buf, n, delim, extract_delim)
+ _IO_FILE *fp;
+ char *buf;
+ _IO_size_t n;
+ int delim;
+ int extract_delim;
{
- register char *ptr = buf;
+ char *ptr = buf;
do
{
_IO_ssize_t len = fp->_IO_read_end - fp->_IO_read_ptr;
char *t;
if (len <= 0)
- if (__underflow(fp) == EOF)
+ if (__underflow (fp) == EOF)
break;
else
len = fp->_IO_read_end - fp->_IO_read_ptr;
if ((_IO_size_t) len >= n)
len = n;
- t = (char*)memchr((void*)fp->_IO_read_ptr, delim, len);
+ t = (char *) memchr ((void *) fp->_IO_read_ptr, delim, len);
if (t != NULL)
{
_IO_size_t old_len = ptr-buf;
len = t - fp->_IO_read_ptr;
if (extract_delim >= 0)
{
- t++;
+ ++t;
if (extract_delim > 0)
- len++;
+ ++len;
}
- memcpy((void*)ptr, (void*)fp->_IO_read_ptr, len);
+ memcpy ((void *) ptr, (void *) fp->_IO_read_ptr, len);
fp->_IO_read_ptr = t;
return old_len + len;
}
- memcpy((void*)ptr, (void*)fp->_IO_read_ptr, len);
+ memcpy ((void *) ptr, (void *) fp->_IO_read_ptr, len);
fp->_IO_read_ptr += len;
ptr += len;
n -= len;
diff --git a/libio/iogets.c b/libio/iogets.c
index ed078763c4..9e88ca1037 100644
--- a/libio/iogets.c
+++ b/libio/iogets.c
@@ -1,33 +1,34 @@
-/*
-Copyright (C) 1993, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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 <limits.h>
char*
_IO_gets (buf)
- char* buf;
+ char *buf;
{
_IO_size_t count;
int ch;
@@ -46,7 +47,7 @@ _IO_gets (buf)
count = 0;
else
{
- buf[0] = (char)ch;
+ buf[0] = (char) ch;
count = _IO_getline (_IO_stdin, buf + 1, INT_MAX, '\n', 0) + 1;
if (_IO_stdin->_IO_file_flags & _IO_ERR_SEEN)
{
diff --git a/libio/iopadn.c b/libio/iopadn.c
index be2c2a6767..087715b349 100644
--- a/libio/iopadn.c
+++ b/libio/iopadn.c
@@ -1,26 +1,27 @@
-/*
-Copyright (C) 1993 Free Software Foundation
+/* Copyright (C) 1993, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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 GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ 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. */
+ 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"
@@ -31,13 +32,16 @@ static char const zeroes[PADSIZE] =
{'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'};
_IO_ssize_t
-DEFUN(_IO_padn, (fp, pad, count),
- _IO_FILE *fp AND int pad AND _IO_ssize_t count)
+_IO_padn (fp, pad, count)
+ _IO_FILE *fp;
+ int pad;
+ _IO_ssize_t count;
{
char padbuf[PADSIZE];
const char *padptr;
- register int i;
- _IO_size_t written = 0, w;
+ int i;
+ _IO_size_t written = 0;
+ _IO_size_t w;
if (pad == ' ')
padptr = blanks;
@@ -45,12 +49,13 @@ DEFUN(_IO_padn, (fp, pad, count),
padptr = zeroes;
else
{
- for (i = PADSIZE; --i >= 0; ) padbuf[i] = pad;
+ for (i = PADSIZE; --i >= 0; )
+ padbuf[i] = pad;
padptr = padbuf;
}
for (i = count; i >= PADSIZE; i -= PADSIZE)
{
- w = _IO_sputn(fp, padptr, PADSIZE);
+ w = _IO_sputn (fp, padptr, PADSIZE);
written += w;
if (w != PADSIZE)
return written;
@@ -58,7 +63,7 @@ DEFUN(_IO_padn, (fp, pad, count),
if (i > 0)
{
- w = _IO_sputn(fp, padptr, i);
+ w = _IO_sputn (fp, padptr, i);
written += w;
}
return written;
diff --git a/libio/iopopen.c b/libio/iopopen.c
index 0768321281..434008609f 100644
--- a/libio/iopopen.c
+++ b/libio/iopopen.c
@@ -1,28 +1,28 @@
-/*
-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. */
-
-/* written by Per Bothner (bothner@cygnus.com) */
+/* Copyright (C) 1993, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
+ Written by Per Bothner <bothner@cygnus.com>.
+
+ 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. */
#ifndef _POSIX_SOURCE
# define _POSIX_SOURCE
@@ -80,17 +80,19 @@ typedef struct _IO_proc_file _IO_proc_file;
static struct _IO_proc_file *proc_file_chain = NULL;
_IO_FILE *
-DEFUN(_IO_proc_open, (fp, command, mode),
- _IO_FILE* fp AND const char *command AND const char *mode)
+_IO_proc_open (fp, command, mode)
+ _IO_FILE *fp;
+ const char *command;
+ const char *mode;
{
#if _IO_HAVE_SYS_WAIT
volatile int read_or_write;
volatile int parent_end, child_end;
int pipe_fds[2];
_IO_pid_t child_pid;
- if (_IO_file_is_open(fp))
+ if (_IO_file_is_open (fp))
return NULL;
- if (_IO_pipe(pipe_fds) < 0)
+ if (_IO_pipe (pipe_fds) < 0)
return NULL;
if (mode[0] == 'r')
{
@@ -104,17 +106,17 @@ DEFUN(_IO_proc_open, (fp, command, mode),
child_end = pipe_fds[0];
read_or_write = _IO_NO_READS;
}
- ((_IO_proc_file*)fp)->pid = child_pid = _IO_fork();
+ ((_IO_proc_file *) fp)->pid = child_pid = _IO_fork ();
if (child_pid == 0)
{
int child_std_end = mode[0] == 'r' ? 1 : 0;
- _IO_close(parent_end);
+ _IO_close (parent_end);
if (child_end != child_std_end)
{
- _IO_dup2(child_end, child_std_end);
- _IO_close(child_end);
+ _IO_dup2 (child_end, child_std_end);
+ _IO_close (child_end);
}
- /* Posix.2: "popen() shall ensure that any streams from previous
+ /* POSIX.2: "popen() shall ensure that any streams from previous
popen() calls that remain open in the parent process are closed
in the new child process." */
while (proc_file_chain)
@@ -123,20 +125,20 @@ DEFUN(_IO_proc_open, (fp, command, mode),
proc_file_chain = proc_file_chain->next;
}
- _IO_execl("/bin/sh", "sh", "-c", command, (char *) 0);
- _IO__exit(127);
+ _IO_execl ("/bin/sh", "sh", "-c", command, (char *) 0);
+ _IO__exit (127);
}
- _IO_close(child_end);
+ _IO_close (child_end);
if (child_pid < 0)
{
- _IO_close(parent_end);
+ _IO_close (parent_end);
return NULL;
}
- _IO_fileno(fp) = parent_end;
+ _IO_fileno (fp) = parent_end;
/* Link into proc_file_chain. */
- ((_IO_proc_file*)fp)->next = proc_file_chain;
- proc_file_chain = (_IO_proc_file*)fp;
+ ((_IO_proc_file *) fp)->next = proc_file_chain;
+ proc_file_chain = (_IO_proc_file *) fp;
_IO_mask_flags (fp, read_or_write, _IO_NO_READS|_IO_NO_WRITES);
return fp;
@@ -146,8 +148,9 @@ DEFUN(_IO_proc_open, (fp, command, mode),
}
_IO_FILE *
-DEFUN(_IO_popen, (command, mode),
- const char *command AND const char *mode)
+_IO_popen (command, mode)
+ const char *command;
+ const char *mode;
{
struct locked_FILE
{
@@ -165,11 +168,11 @@ DEFUN(_IO_popen, (command, mode),
new_f->fpx.file.file._lock = &new_f->lock;
#endif
fp = (_IO_FILE*)&new_f->fpx;
- _IO_init(fp, 0);
- _IO_JUMPS(fp) = &_IO_proc_jumps;
- _IO_file_init(fp);
+ _IO_init (fp, 0);
+ _IO_JUMPS (fp) = &_IO_proc_jumps;
+ _IO_file_init (fp);
#if !_IO_UNIFIED_JUMPTABLES
- ((struct _IO_FILE_plus*)fp)->vtable = NULL;
+ ((struct _IO_FILE_plus *) fp)->vtable = NULL;
#endif
if (_IO_proc_open (fp, command, mode) != NULL)
return fp;
@@ -182,8 +185,8 @@ strong_alias (_IO_popen, popen);
#endif
int
-DEFUN(_IO_proc_close, (fp),
- _IO_FILE *fp)
+_IO_proc_close (fp)
+ _IO_FILE *fp;
{
/* This is not name-space clean. FIXME! */
#if _IO_HAVE_SYS_WAIT
@@ -195,7 +198,7 @@ DEFUN(_IO_proc_close, (fp),
/* Unlink from proc_file_chain. */
for ( ; *ptr != NULL; ptr = &(*ptr)->next)
{
- if (*ptr == (_IO_proc_file*)fp)
+ if (*ptr == (_IO_proc_file *) fp)
{
*ptr = (*ptr)->next;
status = 0;
@@ -203,7 +206,7 @@ DEFUN(_IO_proc_close, (fp),
}
}
- if (status < 0 || _IO_close(_IO_fileno(fp)) < 0)
+ if (status < 0 || _IO_close (_IO_fileno(fp)) < 0)
return -1;
/* POSIX.2 Rationale: "Some historical implementations either block
or ignore the signals SIGINT, SIGQUIT, and SIGHUP while waiting
@@ -211,8 +214,9 @@ DEFUN(_IO_proc_close, (fp),
described in POSIX.2, such implementations are not conforming." */
do
{
- wait_pid = _IO_waitpid (((_IO_proc_file*)fp)->pid, &wstatus, 0);
- } while (wait_pid == -1 && errno == EINTR);
+ wait_pid = _IO_waitpid (((_IO_proc_file *) fp)->pid, &wstatus, 0);
+ }
+ while (wait_pid == -1 && errno == EINTR);
if (wait_pid == -1)
return -1;
return wstatus;
diff --git a/libio/ioputs.c b/libio/ioputs.c
index fcc296a45c..ab5e6aaa4c 100644
--- a/libio/ioputs.c
+++ b/libio/ioputs.c
@@ -1,37 +1,39 @@
-/* Copyright (C) 1993, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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 <string.h>
int
_IO_puts (str)
- const char *str;
+ const char *str;
{
int result;
_IO_size_t len = strlen (str);
_IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
- _IO_stdout);
+ _IO_stdout);
_IO_flockfile (_IO_stdout);
if (_IO_sputn (_IO_stdout, str, len) == len
&& _IO_putc_unlocked ('\n', _IO_stdout) != EOF)
diff --git a/libio/ioseekoff.c b/libio/ioseekoff.c
index 80720e5180..8c642165f6 100644
--- a/libio/ioseekoff.c
+++ b/libio/ioseekoff.c
@@ -1,32 +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. */
+/* 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>
_IO_pos_t
-DEFUN(_IO_seekoff, (fp, offset, dir, mode),
- _IO_FILE* fp AND _IO_off_t offset AND int dir AND int mode)
+_IO_seekoff (fp, offset, dir, mode)
+ _IO_FILE *fp;
+ _IO_off_t offset;
+ int dir;
+ int mode;
{
/* If we have a backup buffer, get rid of it, since the __seekoff
callback may not know to do the right thing about it.
diff --git a/libio/ioseekpos.c b/libio/ioseekpos.c
index dfb3b16d9b..1ae88fb848 100644
--- a/libio/ioseekpos.c
+++ b/libio/ioseekpos.c
@@ -1,32 +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. */
+/* 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>
_IO_pos_t
-DEFUN(_IO_seekpos, (fp, pos, mode),
- _IO_FILE* fp AND _IO_pos_t pos AND int mode)
+_IO_seekpos (fp, pos, mode)
+ _IO_FILE *fp;
+ _IO_pos_t pos;
+ int mode;
{
/* If we have a backup buffer, get rid of it, since the __seekoff
callback may not know to do the right thing about it.
diff --git a/libio/iosetbuffer.c b/libio/iosetbuffer.c
index 8921887985..f140a9ad04 100644
--- a/libio/iosetbuffer.c
+++ b/libio/iosetbuffer.c
@@ -1,26 +1,27 @@
-/*
-Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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"
diff --git a/libio/iosetvbuf.c b/libio/iosetvbuf.c
index 3e105f3b79..65eeea51a6 100644
--- a/libio/iosetvbuf.c
+++ b/libio/iosetvbuf.c
@@ -1,26 +1,27 @@
-/*
-Copyright (C) 1993, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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"
@@ -30,8 +31,8 @@ the executable file might be covered by the GNU General Public License. */
int
_IO_setvbuf (fp, buf, mode, size)
- _IO_FILE* fp;
- char* buf;
+ _IO_FILE *fp;
+ char *buf;
int mode;
_IO_size_t size;
{
diff --git a/libio/iosprintf.c b/libio/iosprintf.c
index b873eb4455..704a6dbd72 100644
--- a/libio/iosprintf.c
+++ b/libio/iosprintf.c
@@ -1,26 +1,27 @@
-/*
-Copyright (C) 1993 Free Software Foundation
+/* Copyright (C) 1993, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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"
@@ -31,17 +32,19 @@ the executable file might be covered by the GNU General Public License. */
#endif
int
-_IO_sprintf
#ifdef __STDC__
- (char *string, const char* format, ...)
+_IO_sprintf (char *string, const char* format, ...)
#else
-(string, format, va_alist) char *string; char *format; va_dcl
+_IO_sprintf (string, format, va_alist)
+ char *string;
+ char *format;
+ va_dcl
#endif
{
int ret;
va_list args;
- _IO_va_start(args, format);
- ret = _IO_vsprintf(string, format, args);
- va_end(args);
+ _IO_va_start (args, format);
+ ret = _IO_vsprintf (string, format, args);
+ va_end (args);
return ret;
}
diff --git a/libio/ioungetc.c b/libio/ioungetc.c
index 866cba642d..07f38e747b 100644
--- a/libio/ioungetc.c
+++ b/libio/ioungetc.c
@@ -1,26 +1,27 @@
-/*
-Copyright (C) 1993, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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"
diff --git a/libio/iovdprintf.c b/libio/iovdprintf.c
index b4b1cc337c..a24d3b535e 100644
--- a/libio/iovdprintf.c
+++ b/libio/iovdprintf.c
@@ -1,26 +1,27 @@
-/*
-Copyright (C) 1995 Free Software Foundation
+/* Copyright (C) 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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 "libio.h"
@@ -63,4 +64,7 @@ _IO_vdprintf (d, format, arg)
return done;
}
+
+#ifdef weak_alias
weak_alias (_IO_vdprintf, vdprintf)
+#endif
diff --git a/libio/iovsprintf.c b/libio/iovsprintf.c
index 25bae66d93..34919588ce 100644
--- a/libio/iovsprintf.c
+++ b/libio/iovsprintf.c
@@ -1,26 +1,27 @@
-/*
-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. */
+/* 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 "strfile.h"
@@ -29,7 +30,7 @@ int
_IO_vsprintf (string, format, args)
char *string;
const char *format;
- _IO_va_list args;
+ _IO_va_list args;
{
_IO_strfile sf;
#ifdef _IO_MTSAFE_IO
diff --git a/libio/iovsscanf.c b/libio/iovsscanf.c
index e9376fe03d..21600f53ef 100644
--- a/libio/iovsscanf.c
+++ b/libio/iovsscanf.c
@@ -1,33 +1,36 @@
-/*
-Copyright (C) 1993 Free Software Foundation
+/* Copyright (C) 1993, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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"
int
-DEFUN(_IO_vsscanf, (string, format, args),
- const char *string AND const char *format AND _IO_va_list args)
+_IO_vsscanf (string, format, args)
+ const char *string;
+ const char *format;
+ _IO_va_list args;
{
int ret;
_IO_strfile sf;
@@ -35,12 +38,12 @@ DEFUN(_IO_vsscanf, (string, format, args),
_IO_lock_t lock;
sf._sbf._f._lock = &lock;
#endif
- _IO_init(&sf._sbf._f, 0);
- _IO_JUMPS(&sf._sbf._f) = &_IO_str_jumps;
+ _IO_init (&sf._sbf._f, 0);
+ _IO_JUMPS (&sf._sbf._f) = &_IO_str_jumps;
_IO_str_init_static (&sf._sbf._f, (char*)string, 0, NULL);
_IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, &sf);
_IO_flockfile (&sf._sbf._f);
- ret = _IO_vfscanf(&sf._sbf._f, format, args, NULL);
+ ret = _IO_vfscanf (&sf._sbf._f, format, args, NULL);
_IO_cleanup_region_end (1);
return ret;
}
diff --git a/libio/libio.h b/libio/libio.h
index 88bd0ae576..03b2afdf28 100644
--- a/libio/libio.h
+++ b/libio/libio.h
@@ -1,28 +1,28 @@
-/*
-Copyright (C) 1991, 1992, 1993, 1994, 1995 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. */
-
-/* This is part of the iostream library. Written by Per Bothner. */
+/* Copyright (C) 1991, 92, 93, 94, 95, 97 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
+ Written by Per Bothner <bothner@cygnus.com>.
+
+ 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. */
#ifndef _IO_STDIO_H
#define _IO_STDIO_H
@@ -43,56 +43,56 @@ the executable file might be covered by the GNU General Public License. */
#ifdef _G_NEED_STDARG_H
/* This define avoids name pollution if we're using GNU stdarg.h */
-#define __need___va_list
-#include <stdarg.h>
-#ifdef __GNUC_VA_LIST
-#undef _IO_va_list
-#define _IO_va_list __gnuc_va_list
-#endif /* __GNUC_VA_LIST */
+# define __need___va_list
+# include <stdarg.h>
+# ifdef __GNUC_VA_LIST
+# undef _IO_va_list
+# define _IO_va_list __gnuc_va_list
+# endif /* __GNUC_VA_LIST */
#endif
#ifndef __P
-#if _G_HAVE_SYS_CDEFS
-#include <sys/cdefs.h>
-#else
-#ifdef __STDC__
-#define __P(protos) protos
-#else
-#define __P(protos) ()
-#endif
-#endif
+# if _G_HAVE_SYS_CDEFS
+# include <sys/cdefs.h>
+# else
+# ifdef __STDC__
+# define __P(protos) protos
+# else
+# define __P(protos) ()
+# endif
+# endif
#endif /*!__P*/
/* For backward compatibility */
#ifndef _PARAMS
-#define _PARAMS(protos) __P(protos)
+# define _PARAMS(protos) __P(protos)
#endif /*!_PARAMS*/
#ifndef __STDC__
-#define const
+# define const
#endif
#define _IO_UNIFIED_JUMPTABLES 1
#if 0
-#ifdef _IO_NEED_STDARG_H
-#include <stdarg.h>
-#endif
+# ifdef _IO_NEED_STDARG_H
+# include <stdarg.h>
+# endif
#endif
#ifndef EOF
-#define EOF (-1)
+# define EOF (-1)
#endif
#ifndef NULL
-#if defined __GNUG__ && \
+# if defined __GNUG__ && \
(__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
-#define NULL (__null)
-#else
-#if !defined(__cplusplus)
-#define NULL ((void*)0)
-#else
-#define NULL (0)
-#endif
-#endif
+# define NULL (__null)
+# else
+# if !defined(__cplusplus)
+# define NULL ((void*)0)
+# else
+# define NULL (0)
+# endif
+# endif
#endif
#define _IOS_INPUT 1
@@ -153,7 +153,7 @@ struct _IO_jump_t; struct _IO_FILE;
/* Handle lock. */
#ifdef _IO_MTSAFE_IO
-#include <bits/stdio-lock.h>
+# include <bits/stdio-lock.h>
#else
typedef void _IO_lock_t;
#endif
@@ -239,7 +239,8 @@ typedef struct
} _IO_cookie_io_functions_t;
/* Special file type for fopencookie function. */
-struct _IO_cookie_file {
+struct _IO_cookie_file
+{
struct _IO_FILE file;
const void *vtable;
void *cookie;
@@ -251,22 +252,22 @@ struct _IO_cookie_file {
extern "C" {
#endif
-extern int __underflow __P((_IO_FILE*));
-extern int __uflow __P((_IO_FILE*));
-extern int __overflow __P((_IO_FILE*, int));
+extern int __underflow __P ((_IO_FILE *));
+extern int __uflow __P ((_IO_FILE *));
+extern int __overflow __P ((_IO_FILE *, int));
#define _IO_getc_unlocked(_fp) \
- ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end ? __uflow(_fp) \
- : *(unsigned char*)(_fp)->_IO_read_ptr++)
+ ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end ? __uflow (_fp) \
+ : *(unsigned char *) (_fp)->_IO_read_ptr++)
#define _IO_peekc_unlocked(_fp) \
((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end \
- && __underflow(_fp) == EOF ? EOF \
- : *(unsigned char*)(_fp)->_IO_read_ptr)
+ && __underflow (_fp) == EOF ? EOF \
+ : *(unsigned char *) (_fp)->_IO_read_ptr)
#define _IO_putc_unlocked(_ch, _fp) \
(((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end) \
- ? __overflow(_fp, (unsigned char)(_ch)) \
- : (unsigned char)(*(_fp)->_IO_write_ptr++ = (_ch)))
+ ? __overflow (_fp, (unsigned char) (_ch)) \
+ : (unsigned char) (*(_fp)->_IO_write_ptr++ = (_ch)))
#define _IO_feof_unlocked(__fp) (((__fp)->_flags & _IO_EOF_SEEN) != 0)
#define _IO_ferror_unlocked(__fp) (((__fp)->_flags & _IO_ERR_SEEN) != 0)
@@ -294,32 +295,17 @@ extern int _IO_ftrylockfile __P ((_IO_FILE *));
# define _IO_cleanup_region_end(_Doit) /**/
#endif /* !_IO_MTSAFE_IO */
-/* XXX Should we allow a symbol to be defined which selects the efficient
- implementation when the user is really sure no threaded functions ever
- will be used? */
-#if 1
-# define _IO_getc(_fp) _IO_getc (_fp)
-# define _IO_peekc(_fp) _IO_peekc_locked (_fp)
-# define _IO_putc(_ch, _fp) _IO_putc (_ch, _fp)
-# define _IO_feof(_fp) _IO_feof (_fp)
-# define _IO_ferror(_fp) _IO_ferror (_fp)
-#else
-# define _IO_getc(_fp) _IO_getc_unlocked (_fp)
-# define _IO_peekc(_fp) _IO_peekc_unlocked (_fp)
-# define _IO_putc(_ch, _fp) _IO_putc_unlocked (_ch, _fp)
-# define _IO_feof(_fp) _IO_feof_unlocked (_fp)
-# define _IO_ferror(_fp) _IO_ferror_unlocked (_fp)
-#endif
+#define _IO_peekc(_fp) _IO_peekc_locked (_fp)
-extern int _IO_vfscanf __P((_IO_FILE*, const char*, _IO_va_list, int*));
-extern int _IO_vfprintf __P((_IO_FILE*, const char*, _IO_va_list));
-extern _IO_ssize_t _IO_padn __P((_IO_FILE *, int, _IO_ssize_t));
-extern _IO_size_t _IO_sgetn __P((_IO_FILE *, void*, _IO_size_t));
+extern int _IO_vfscanf __P ((_IO_FILE *, const char *, _IO_va_list, int *));
+extern int _IO_vfprintf __P ((_IO_FILE *, const char *, _IO_va_list));
+extern _IO_ssize_t _IO_padn __P ((_IO_FILE *, int, _IO_ssize_t));
+extern _IO_size_t _IO_sgetn __P ((_IO_FILE *, void *, _IO_size_t));
-extern _IO_fpos_t _IO_seekoff __P((_IO_FILE*, _IO_off_t, int, int));
-extern _IO_fpos_t _IO_seekpos __P((_IO_FILE*, _IO_fpos_t, int));
+extern _IO_fpos_t _IO_seekoff __P ((_IO_FILE *, _IO_off_t, int, int));
+extern _IO_fpos_t _IO_seekpos __P ((_IO_FILE *, _IO_fpos_t, int));
-extern void _IO_free_backup_area __P((_IO_FILE*));
+extern void _IO_free_backup_area __P ((_IO_FILE *));
#ifdef __cplusplus
}
diff --git a/libio/libioP.h b/libio/libioP.h
index 7d033e02ee..1880e0bbde 100644
--- a/libio/libioP.h
+++ b/libio/libioP.h
@@ -1,57 +1,34 @@
-/*
-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. */
+/* 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 <errno.h>
-#ifndef errno
-extern int errno;
-#endif
#include <bits/libc-lock.h>
#include "iolibio.h"
-#if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(__cplusplus)
-/* All known AIX compilers implement these things (but don't always
- define __STDC__). The RISC/OS MIPS compiler defines these things
- in SVR4 mode, but does not define __STDC__. */
-
-#define AND ,
-#define DEFUN(name, arglist, args) name(args)
-#define DEFUN_VOID(name) name(void)
-
-#else /* Not ANSI C. */
-
-#define AND ;
-#ifndef const /* some systems define it in header files for non-ansi mode */
-#define const
-#endif
-#define DEFUN(name, arglist, args) name arglist args;
-#define DEFUN_VOID(name) name()
-#endif /* ANSI C. */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
+__BEGIN_DECLS
#define _IO_seek_set 0
#define _IO_seek_cur 1
@@ -78,103 +55,104 @@ extern "C" {
* object being acted on (i.e. the 'this' parameter).
*/
-#define _IO_JUMPS(THIS) ((struct _IO_FILE_plus*)(THIS))->vtable
+#define _IO_JUMPS(THIS) ((struct _IO_FILE_plus *) (THIS))->vtable
#ifdef _G_USING_THUNKS
-#define JUMP_FIELD(TYPE, NAME) TYPE NAME
-#define JUMP0(FUNC, THIS) _IO_JUMPS(THIS)->FUNC(THIS)
-#define JUMP1(FUNC, THIS, X1) _IO_JUMPS(THIS)->FUNC(THIS, X1)
-#define JUMP2(FUNC, THIS, X1, X2) _IO_JUMPS(THIS)->FUNC(THIS, X1, X2)
-#define JUMP3(FUNC, THIS, X1,X2,X3) _IO_JUMPS(THIS)->FUNC(THIS, X1,X2, X3)
-#define JUMP_INIT(NAME, VALUE) VALUE
-#define JUMP_INIT_DUMMY JUMP_INIT(dummy, 0), JUMP_INIT(dummy2, 0)
+# define JUMP_FIELD(TYPE, NAME) TYPE NAME
+# define JUMP0(FUNC, THIS) _IO_JUMPS(THIS)->FUNC (THIS)
+# define JUMP1(FUNC, THIS, X1) _IO_JUMPS(THIS)->FUNC (THIS, X1)
+# define JUMP2(FUNC, THIS, X1, X2) _IO_JUMPS(THIS)->FUNC (THIS, X1, X2)
+# define JUMP3(FUNC, THIS, X1,X2,X3) _IO_JUMPS(THIS)->FUNC (THIS, X1,X2, X3)
+# define JUMP_INIT(NAME, VALUE) VALUE
+# define JUMP_INIT_DUMMY JUMP_INIT(dummy, 0), JUMP_INIT (dummy2, 0)
#else
/* These macros will change when we re-implement vtables to use "thunks"! */
-#define JUMP_FIELD(TYPE, NAME) struct { short delta1, delta2; TYPE pfn; } NAME
-#define JUMP0(FUNC, THIS) _IO_JUMPS(THIS)->FUNC.pfn(THIS)
-#define JUMP1(FUNC, THIS, X1) _IO_JUMPS(THIS)->FUNC.pfn(THIS, X1)
-#define JUMP2(FUNC, THIS, X1, X2) _IO_JUMPS(THIS)->FUNC.pfn(THIS, X1, X2)
-#define JUMP3(FUNC, THIS, X1,X2,X3) _IO_JUMPS(THIS)->FUNC.pfn(THIS, X1,X2, X3)
-#define JUMP_INIT(NAME, VALUE) {0, 0, VALUE}
-#define JUMP_INIT_DUMMY JUMP_INIT(dummy, 0)
+# define JUMP_FIELD(TYPE, NAME) struct { short delta1, delta2; TYPE pfn; } NAME
+# define JUMP0(FUNC, THIS) _IO_JUMPS(THIS)->FUNC.pfn (THIS)
+# define JUMP1(FUNC, THIS, X1) _IO_JUMPS(THIS)->FUNC.pfn (THIS, X1)
+# define JUMP2(FUNC, THIS, X1, X2) _IO_JUMPS(THIS)->FUNC.pfn (THIS, X1, X2)
+# define JUMP3(FUNC, THIS, X1,X2,X3) _IO_JUMPS(THIS)->FUNC.pfn (THIS, X1,X2,X3)
+# define JUMP_INIT(NAME, VALUE) {0, 0, VALUE}
+# define JUMP_INIT_DUMMY JUMP_INIT(dummy, 0)
#endif
/* The 'finish' function does any final cleaning up of an _IO_FILE object.
It does not delete (free) it, but does everything else to finalize it/
It matches the streambuf::~streambuf virtual destructor. */
-typedef void (*_IO_finish_t) __P((_IO_FILE*, int)); /* finalize */
-#define _IO_FINISH(FP) JUMP1(__finish, FP, 0)
+typedef void (*_IO_finish_t) __P ((_IO_FILE *, int)); /* finalize */
+#define _IO_FINISH(FP) JUMP1 (__finish, FP, 0)
/* The 'overflow' hook flushes the buffer.
The second argument is a character, or EOF.
It matches the streambuf::overflow virtual function. */
-typedef int (*_IO_overflow_t) __P((_IO_FILE*, int));
-#define _IO_OVERFLOW(FP, CH) JUMP1(__overflow, FP, CH)
+typedef int (*_IO_overflow_t) __P ((_IO_FILE *, int));
+#define _IO_OVERFLOW(FP, CH) JUMP1 (__overflow, FP, CH)
/* The 'underflow' hook tries to fills the get buffer.
It returns the next character (as an unsigned char) or EOF. The next
character remains in the get buffer, and the get position is not changed.
It matches the streambuf::underflow virtual function. */
-typedef int (*_IO_underflow_t) __P((_IO_FILE*));
-#define _IO_UNDERFLOW(FP) JUMP0(__underflow, FP)
+typedef int (*_IO_underflow_t) __P ((_IO_FILE *));
+#define _IO_UNDERFLOW(FP) JUMP0 (__underflow, FP)
/* The 'uflow' hook returns the next character in the input stream
(cast to unsigned char), and increments the read position;
EOF is returned on failure.
It matches the streambuf::uflow virtual function, which is not in the
cfront implementation, but was added to C++ by the ANSI/ISO committee. */
-#define _IO_UFLOW(FP) JUMP0(__uflow, FP)
+#define _IO_UFLOW(FP) JUMP0 (__uflow, FP)
/* The 'pbackfail' hook handles backing up.
It matches the streambuf::pbackfail virtual function. */
-typedef int (*_IO_pbackfail_t) __P((_IO_FILE*, int));
-#define _IO_PBACKFAIL(FP, CH) JUMP1(__pbackfail, FP, CH)
+typedef int (*_IO_pbackfail_t) __P ((_IO_FILE *, int));
+#define _IO_PBACKFAIL(FP, CH) JUMP1 (__pbackfail, FP, CH)
/* The 'xsputn' hook writes upto N characters from buffer DATA.
Returns the number of character actually written.
It matches the streambuf::xsputn virtual function. */
-typedef _IO_size_t (*_IO_xsputn_t)
- __P((_IO_FILE *FP, const void *DATA, _IO_size_t N));
-#define _IO_XSPUTN(FP, DATA, N) JUMP2(__xsputn, FP, DATA, N)
+typedef _IO_size_t (*_IO_xsputn_t) __P ((_IO_FILE *FP, const void *DATA,
+ _IO_size_t N));
+#define _IO_XSPUTN(FP, DATA, N) JUMP2 (__xsputn, FP, DATA, N)
/* The 'xsgetn' hook reads upto N characters into buffer DATA.
Returns the number of character actually read.
It matches the streambuf::xsgetn virtual function. */
-typedef _IO_size_t (*_IO_xsgetn_t) __P((_IO_FILE*FP, void*DATA, _IO_size_t N));
-#define _IO_XSGETN(FP, DATA, N) JUMP2(__xsgetn, FP, DATA, N)
+typedef _IO_size_t (*_IO_xsgetn_t) __P ((_IO_FILE *FP, void *DATA,
+ _IO_size_t N));
+#define _IO_XSGETN(FP, DATA, N) JUMP2 (__xsgetn, FP, DATA, N)
/* The 'seekoff' hook moves the stream position to a new position
relative to the start of the file (if DIR==0), the current position
(MODE==1), or the end of the file (MODE==2).
It matches the streambuf::seekoff virtual function.
It is also used for the ANSI fseek function. */
-typedef _IO_fpos_t (*_IO_seekoff_t)
- __P((_IO_FILE* FP, _IO_off_t OFF, int DIR, int MODE));
-#define _IO_SEEKOFF(FP, OFF, DIR, MODE) JUMP3(__seekoff, FP, OFF, DIR, MODE)
+typedef _IO_fpos_t (*_IO_seekoff_t) __P ((_IO_FILE *FP, _IO_off_t OFF,
+ int DIR, int MODE));
+#define _IO_SEEKOFF(FP, OFF, DIR, MODE) JUMP3 (__seekoff, FP, OFF, DIR, MODE)
/* The 'seekpos' hook also moves the stream position,
but to an absolute position given by a fpos_t (seekpos).
It matches the streambuf::seekpos virtual function.
It is also used for the ANSI fgetpos and fsetpos functions. */
/* The _IO_seek_cur and _IO_seek_end options are not allowed. */
-typedef _IO_fpos_t (*_IO_seekpos_t) __P((_IO_FILE*, _IO_fpos_t, int));
-#define _IO_SEEKPOS(FP, POS, FLAGS) JUMP2(__seekpos, FP, POS, FLAGS)
+typedef _IO_fpos_t (*_IO_seekpos_t) __P ((_IO_FILE *, _IO_fpos_t, int));
+#define _IO_SEEKPOS(FP, POS, FLAGS) JUMP2 (__seekpos, FP, POS, FLAGS)
/* The 'setbuf' hook gives a buffer to the file.
It matches the streambuf::setbuf virtual function. */
-typedef _IO_FILE* (*_IO_setbuf_t) __P((_IO_FILE*, char *, _IO_ssize_t));
-#define _IO_SETBUF(FP, BUFFER, LENGTH) JUMP2(__setbuf, FP, BUFFER, LENGTH)
+typedef _IO_FILE* (*_IO_setbuf_t) __P ((_IO_FILE *, char *, _IO_ssize_t));
+#define _IO_SETBUF(FP, BUFFER, LENGTH) JUMP2 (__setbuf, FP, BUFFER, LENGTH)
/* The 'sync' hook attempts to synchronize the internal data structures
of the file with the external state.
It matches the streambuf::sync virtual function. */
-typedef int (*_IO_sync_t) __P((_IO_FILE*));
-#define _IO_SYNC(FP) JUMP0(__sync, FP)
+typedef int (*_IO_sync_t) __P ((_IO_FILE *));
+#define _IO_SYNC(FP) JUMP0 (__sync, FP)
/* The 'doallocate' hook is used to tell the file to allocate a buffer.
It matches the streambuf::doallocate virtual function, which is not
in the ANSI/ISO C++ standard, but is part traditional implementations. */
-typedef int (*_IO_doallocate_t) __P((_IO_FILE*));
-#define _IO_DOALLOCATE(FP) JUMP0(__doallocate, FP)
+typedef int (*_IO_doallocate_t) __P ((_IO_FILE *));
+#define _IO_DOALLOCATE(FP) JUMP0 (__doallocate, FP)
/* The following four hooks (sysread, syswrite, sysclose, sysseek, and
sysstat) are low-level hooks specific to this implementation.
@@ -191,42 +169,43 @@ typedef int (*_IO_doallocate_t) __P((_IO_FILE*));
an existing buffer. It generalizes the Unix read(2) function.
It matches the streambuf::sys_read virtual function, which is
specific to this implementation. */
-typedef _IO_ssize_t (*_IO_read_t) __P((_IO_FILE*, void*, _IO_ssize_t));
-#define _IO_SYSREAD(FP, DATA, LEN) JUMP2(__read, FP, DATA, LEN)
+typedef _IO_ssize_t (*_IO_read_t) __P ((_IO_FILE *, void *, _IO_ssize_t));
+#define _IO_SYSREAD(FP, DATA, LEN) JUMP2 (__read, FP, DATA, LEN)
/* The 'syswrite' hook is used to write data from an existing buffer
to an external file. It generalizes the Unix write(2) function.
It matches the streambuf::sys_write virtual function, which is
specific to this implementation. */
-typedef _IO_ssize_t (*_IO_write_t) __P((_IO_FILE*,const void*,_IO_ssize_t));
-#define _IO_SYSWRITE(FP, DATA, LEN) JUMP2(__write, FP, DATA, LEN)
+typedef _IO_ssize_t (*_IO_write_t) __P ((_IO_FILE *,const void *,_IO_ssize_t));
+#define _IO_SYSWRITE(FP, DATA, LEN) JUMP2 (__write, FP, DATA, LEN)
/* The 'sysseek' hook is used to re-position an external file.
It generalizes the Unix lseek(2) function.
It matches the streambuf::sys_seek virtual function, which is
specific to this implementation. */
-typedef _IO_fpos_t (*_IO_seek_t) __P((_IO_FILE*, _IO_off_t, int));
-#define _IO_SYSSEEK(FP, OFFSET, MODE) JUMP2(__seek, FP, OFFSET, MODE)
+typedef _IO_fpos_t (*_IO_seek_t) __P ((_IO_FILE *, _IO_off_t, int));
+#define _IO_SYSSEEK(FP, OFFSET, MODE) JUMP2 (__seek, FP, OFFSET, MODE)
/* The 'sysclose' hook is used to finalize (close, finish up) an
external file. It generalizes the Unix close(2) function.
It matches the streambuf::sys_close virtual function, which is
specific to this implementation. */
-typedef int (*_IO_close_t) __P((_IO_FILE*)); /* finalize */
-#define _IO_SYSCLOSE(FP) JUMP0(__close, FP)
+typedef int (*_IO_close_t) __P ((_IO_FILE *)); /* finalize */
+#define _IO_SYSCLOSE(FP) JUMP0 (__close, FP)
/* The 'sysstat' hook is used to get information about an external file
into a struct stat buffer. It generalizes the Unix fstat(2) call.
It matches the streambuf::sys_stat virtual function, which is
specific to this implementation. */
-typedef int (*_IO_stat_t) __P((_IO_FILE*, void*));
-#define _IO_SYSSTAT(FP, BUF) JUMP1(__stat, FP, BUF)
+typedef int (*_IO_stat_t) __P ((_IO_FILE *, void *));
+#define _IO_SYSSTAT(FP, BUF) JUMP1 (__stat, FP, BUF)
#define _IO_CHAR_TYPE char /* unsigned char ? */
#define _IO_INT_TYPE int
-struct _IO_jump_t {
+struct _IO_jump_t
+{
JUMP_FIELD(_G_size_t, __dummy);
#ifdef _G_USING_THUNKS
JUMP_FIELD(_G_size_t, __dummy2);
@@ -260,63 +239,69 @@ struct _IO_jump_t {
This is for compatibility with C++ streambuf; the word can
be used to smash to a pointer to a virtual function table. */
-struct _IO_FILE_plus {
+struct _IO_FILE_plus
+{
_IO_FILE file;
const struct _IO_jump_t *vtable;
};
/* Generic functions */
-extern _IO_fpos_t _IO_seekoff __P((_IO_FILE*, _IO_off_t, int, int));
-extern _IO_fpos_t _IO_seekpos __P((_IO_FILE*, _IO_fpos_t, int));
-
-extern int _IO_switch_to_get_mode __P((_IO_FILE*));
-extern void _IO_init __P((_IO_FILE*, int));
-extern int _IO_sputbackc __P((_IO_FILE*, int));
-extern int _IO_sungetc __P((_IO_FILE*));
-extern void _IO_un_link __P((_IO_FILE*));
-extern void _IO_link_in __P((_IO_FILE *));
-extern void _IO_doallocbuf __P((_IO_FILE*));
-extern void _IO_unsave_markers __P((_IO_FILE*));
-extern void _IO_setb __P((_IO_FILE*, char*, char*, int));
-extern unsigned _IO_adjust_column __P((unsigned, const char *, int));
-#define _IO_sputn(__fp, __s, __n) _IO_XSPUTN(__fp, __s, __n)
+extern _IO_fpos_t _IO_seekoff __P ((_IO_FILE *, _IO_off_t, int, int));
+extern _IO_fpos_t _IO_seekpos __P ((_IO_FILE *, _IO_fpos_t, int));
+
+extern void _IO_switch_to_main_get_area __P ((_IO_FILE *));
+extern void _IO_switch_to_backup_area __P ((_IO_FILE *));
+extern int _IO_switch_to_get_mode __P ((_IO_FILE *));
+extern void _IO_init __P ((_IO_FILE *, int));
+extern int _IO_sputbackc __P ((_IO_FILE *, int));
+extern int _IO_sungetc __P ((_IO_FILE *));
+extern void _IO_un_link __P ((_IO_FILE *));
+extern void _IO_link_in __P ((_IO_FILE *));
+extern void _IO_doallocbuf __P ((_IO_FILE *));
+extern void _IO_unsave_markers __P ((_IO_FILE *));
+extern void _IO_setb __P ((_IO_FILE *, char *, char *, int));
+extern unsigned _IO_adjust_column __P ((unsigned, const char *, int));
+#define _IO_sputn(__fp, __s, __n) _IO_XSPUTN (__fp, __s, __n)
/* Marker-related function. */
-extern void _IO_init_marker __P((struct _IO_marker *, _IO_FILE *));
-extern void _IO_remove_marker __P((struct _IO_marker*));
-extern int _IO_marker_difference __P((struct _IO_marker *, struct _IO_marker *));
-extern int _IO_marker_delta __P((struct _IO_marker *));
-extern int _IO_seekmark __P((_IO_FILE *, struct _IO_marker *, int));
+extern void _IO_init_marker __P ((struct _IO_marker *, _IO_FILE *));
+extern void _IO_remove_marker __P ((struct _IO_marker *));
+extern int _IO_marker_difference __P ((struct _IO_marker *,
+ struct _IO_marker *));
+extern int _IO_marker_delta __P ((struct _IO_marker *));
+extern int _IO_seekmark __P ((_IO_FILE *, struct _IO_marker *, int));
/* Default jumptable functions. */
-extern int _IO_default_underflow __P((_IO_FILE*));
-extern int _IO_default_uflow __P((_IO_FILE*));
-extern int _IO_default_doallocate __P((_IO_FILE*));
-extern void _IO_default_finish __P((_IO_FILE *, int));
-extern int _IO_default_pbackfail __P((_IO_FILE*, int));
-extern _IO_FILE* _IO_default_setbuf __P((_IO_FILE *, char*, _IO_ssize_t));
-extern _IO_size_t _IO_default_xsputn __P((_IO_FILE *, const void*, _IO_size_t));
-extern _IO_size_t _IO_default_xsgetn __P((_IO_FILE *, void*, _IO_size_t));
-extern _IO_fpos_t _IO_default_seekoff __P((_IO_FILE*, _IO_off_t, int, int));
-extern _IO_fpos_t _IO_default_seekpos __P((_IO_FILE*, _IO_fpos_t, int));
-extern _IO_ssize_t _IO_default_write __P((_IO_FILE*,const void*,_IO_ssize_t));
-extern _IO_ssize_t _IO_default_read __P((_IO_FILE*, void*, _IO_ssize_t));
-extern int _IO_default_stat __P((_IO_FILE*, void*));
-extern _IO_fpos_t _IO_default_seek __P((_IO_FILE*, _IO_off_t, int));
-extern int _IO_default_sync __P((_IO_FILE*));
-#define _IO_default_close ((_IO_close_t)_IO_default_sync)
+extern int _IO_default_underflow __P ((_IO_FILE *));
+extern int _IO_default_uflow __P ((_IO_FILE *));
+extern int _IO_default_doallocate __P ((_IO_FILE *));
+extern void _IO_default_finish __P ((_IO_FILE *, int));
+extern int _IO_default_pbackfail __P ((_IO_FILE *, int));
+extern _IO_FILE* _IO_default_setbuf __P ((_IO_FILE *, char *, _IO_ssize_t));
+extern _IO_size_t _IO_default_xsputn __P ((_IO_FILE *, const void *,
+ _IO_size_t));
+extern _IO_size_t _IO_default_xsgetn __P ((_IO_FILE *, void *, _IO_size_t));
+extern _IO_fpos_t _IO_default_seekoff __P ((_IO_FILE *, _IO_off_t, int, int));
+extern _IO_fpos_t _IO_default_seekpos __P ((_IO_FILE *, _IO_fpos_t, int));
+extern _IO_ssize_t _IO_default_write __P ((_IO_FILE *, const void *,
+ _IO_ssize_t));
+extern _IO_ssize_t _IO_default_read __P ((_IO_FILE *, void *, _IO_ssize_t));
+extern int _IO_default_stat __P ((_IO_FILE *, void *));
+extern _IO_fpos_t _IO_default_seek __P ((_IO_FILE *, _IO_off_t, int));
+extern int _IO_default_sync __P ((_IO_FILE *));
+#define _IO_default_close ((_IO_close_t) _IO_default_sync)
extern struct _IO_jump_t _IO_file_jumps;
extern struct _IO_jump_t _IO_streambuf_jumps;
extern struct _IO_jump_t _IO_proc_jumps;
extern struct _IO_jump_t _IO_str_jumps;
-extern int _IO_do_write __P((_IO_FILE*, const char*, _IO_size_t));
-extern int _IO_flush_all __P((void));
-extern void _IO_cleanup __P((void));
-extern void _IO_flush_all_linebuffered __P((void));
+extern int _IO_do_write __P ((_IO_FILE *, const char *, _IO_size_t));
+extern int _IO_flush_all __P ((void));
+extern void _IO_cleanup __P ((void));
+extern void _IO_flush_all_linebuffered __P ((void));
#define _IO_do_flush(_f) \
_IO_do_write(_f, (_f)->_IO_write_base, \
@@ -335,40 +320,41 @@ extern void _IO_flush_all_linebuffered __P((void));
/* Jumptable functions for files. */
-extern int _IO_file_doallocate __P((_IO_FILE*));
-extern _IO_FILE* _IO_file_setbuf __P((_IO_FILE *, char*, _IO_ssize_t));
-extern _IO_fpos_t _IO_file_seekoff __P((_IO_FILE*, _IO_off_t, int, int));
-extern _IO_size_t _IO_file_xsputn __P((_IO_FILE*,const void*,_IO_size_t));
-extern int _IO_file_stat __P((_IO_FILE*, void*));
-extern int _IO_file_close __P((_IO_FILE*));
-extern int _IO_file_underflow __P((_IO_FILE *));
-extern int _IO_file_overflow __P((_IO_FILE *, int));
+extern int _IO_file_doallocate __P ((_IO_FILE *));
+extern _IO_FILE* _IO_file_setbuf __P ((_IO_FILE *, char *, _IO_ssize_t));
+extern _IO_fpos_t _IO_file_seekoff __P ((_IO_FILE *, _IO_off_t, int, int));
+extern _IO_size_t _IO_file_xsputn __P ((_IO_FILE *, const void *, _IO_size_t));
+extern int _IO_file_stat __P ((_IO_FILE *, void *));
+extern int _IO_file_close __P ((_IO_FILE *));
+extern int _IO_file_underflow __P ((_IO_FILE *));
+extern int _IO_file_overflow __P ((_IO_FILE *, int));
#define _IO_file_is_open(__fp) ((__fp)->_fileno >= 0)
-extern void _IO_file_init __P((_IO_FILE*));
-extern _IO_FILE* _IO_file_attach __P((_IO_FILE*, int));
-extern _IO_FILE* _IO_file_fopen __P((_IO_FILE*, const char*, const char*));
-extern _IO_ssize_t _IO_file_write __P((_IO_FILE*,const void*,_IO_ssize_t));
-extern _IO_ssize_t _IO_file_read __P((_IO_FILE*, void*, _IO_ssize_t));
-extern int _IO_file_sync __P((_IO_FILE*));
-extern int _IO_file_close_it __P((_IO_FILE*));
-extern _IO_fpos_t _IO_file_seek __P((_IO_FILE *, _IO_off_t, int));
-extern void _IO_file_finish __P((_IO_FILE*, int));
+extern void _IO_file_init __P ((_IO_FILE *));
+extern _IO_FILE* _IO_file_attach __P ((_IO_FILE *, int));
+extern _IO_FILE* _IO_file_fopen __P ((_IO_FILE *, const char *, const char *));
+extern _IO_ssize_t _IO_file_write __P ((_IO_FILE *, const void *,
+ _IO_ssize_t));
+extern _IO_ssize_t _IO_file_read __P ((_IO_FILE *, void *, _IO_ssize_t));
+extern int _IO_file_sync __P ((_IO_FILE *));
+extern int _IO_file_close_it __P ((_IO_FILE *));
+extern _IO_fpos_t _IO_file_seek __P ((_IO_FILE *, _IO_off_t, int));
+extern void _IO_file_finish __P ((_IO_FILE *, int));
/* Jumptable functions for proc_files. */
-extern _IO_FILE* _IO_proc_open __P((_IO_FILE*, const char*, const char *));
-extern int _IO_proc_close __P((_IO_FILE*));
+extern _IO_FILE* _IO_proc_open __P ((_IO_FILE *, const char *, const char *));
+extern int _IO_proc_close __P ((_IO_FILE *));
/* Jumptable functions for strfiles. */
-extern int _IO_str_underflow __P((_IO_FILE*));
-extern int _IO_str_overflow __P((_IO_FILE *, int));
-extern int _IO_str_pbackfail __P((_IO_FILE*, int));
-extern _IO_fpos_t _IO_str_seekoff __P((_IO_FILE*,_IO_off_t,int,int));
-extern void _IO_str_finish __P ((_IO_FILE*, int));
+extern int _IO_str_underflow __P ((_IO_FILE *));
+extern int _IO_str_overflow __P ((_IO_FILE *, int));
+extern int _IO_str_pbackfail __P ((_IO_FILE *, int));
+extern _IO_fpos_t _IO_str_seekoff __P ((_IO_FILE *, _IO_off_t, int, int));
+extern void _IO_str_finish __P ((_IO_FILE *, int));
/* Other strfile functions */
-extern void _IO_str_init_static __P((_IO_FILE *, char*, int, char*));
-extern void _IO_str_init_readonly __P((_IO_FILE *, const char*, int));
-extern _IO_ssize_t _IO_str_count __P ((_IO_FILE*));
+extern void _IO_str_init_static __P ((_IO_FILE *, char *, int, char *));
+extern void _IO_str_init_readonly __P ((_IO_FILE *, const char *, int));
+extern _IO_ssize_t _IO_str_count __P ((_IO_FILE *));
extern int _IO_vasprintf __P ((char **result_ptr, __const char *format,
_IO_va_list args));
@@ -377,66 +363,66 @@ extern int _IO_vsnprintf __P ((char *string, _IO_size_t maxlen,
__const char *format, _IO_va_list args));
-extern _IO_size_t _IO_getline __P((_IO_FILE*,char*,_IO_size_t,int,int));
-extern _IO_ssize_t _IO_getdelim __P((char**, _IO_size_t*, int, _IO_FILE*));
-extern double _IO_strtod __P((const char *, char **));
-extern char * _IO_dtoa __P((double __d, int __mode, int __ndigits,
- int *__decpt, int *__sign, char **__rve));
-extern int _IO_outfloat __P((double __value, _IO_FILE *__sb, int __type,
- int __width, int __precision, int __flags,
- int __sign_mode, int __fill));
+extern _IO_size_t _IO_getline __P ((_IO_FILE *,char *, _IO_size_t, int, int));
+extern _IO_ssize_t _IO_getdelim __P ((char **, _IO_size_t *, int, _IO_FILE *));
+extern double _IO_strtod __P ((const char *, char **));
+extern char *_IO_dtoa __P ((double __d, int __mode, int __ndigits,
+ int *__decpt, int *__sign, char **__rve));
+extern int _IO_outfloat __P ((double __value, _IO_FILE *__sb, int __type,
+ int __width, int __precision, int __flags,
+ int __sign_mode, int __fill));
extern _IO_FILE *_IO_list_all;
extern void (*_IO_cleanup_registration_needed) __P ((void));
#ifndef EOF
-#define EOF (-1)
+# define EOF (-1)
#endif
#ifndef NULL
-#if defined __GNUG__ && \
+# if defined __GNUG__ && \
(__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
-#define NULL (__null)
-#else
-#if !defined(__cplusplus)
-#define NULL ((void*)0)
-#else
-#define NULL (0)
-#endif
-#endif
+# define NULL (__null)
+# else
+# if !defined(__cplusplus)
+# define NULL ((void*)0)
+# else
+# define NULL (0)
+# endif
+# endif
#endif
#if _G_HAVE_MMAP
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-#include <sys/param.h>
+# include <unistd.h>
+# include <fcntl.h>
+# include <sys/mman.h>
+# include <sys/param.h>
-#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
-#define MAP_ANONYMOUS MAP_ANON
-#endif
+# if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
+# define MAP_ANONYMOUS MAP_ANON
+# endif
-#if !defined(MAP_ANONYMOUS) || !defined(EXEC_PAGESIZE)
-#undef _G_HAVE_MMAP
-#define _G_HAVE_MMAP 0
-#endif
+# if !defined(MAP_ANONYMOUS) || !defined(EXEC_PAGESIZE)
+# undef _G_HAVE_MMAP
+# define _G_HAVE_MMAP 0
+# endif
#endif /* _G_HAVE_MMAP */
#if _G_HAVE_MMAP
-#ifdef _LIBC
+# ifdef _LIBC
/* When using this code in the GNU libc we must not pollute the name space. */
-#define mmap __mmap
-#define munmap __munmap
-#endif
+# define mmap __mmap
+# define munmap __munmap
+# endif
-#define ROUND_TO_PAGE(_S) \
+# define ROUND_TO_PAGE(_S) \
(((_S) + EXEC_PAGESIZE - 1) & ~(EXEC_PAGESIZE - 1))
-#define FREE_BUF(_B, _S) \
+# define FREE_BUF(_B, _S) \
munmap ((_B), ROUND_TO_PAGE (_S))
-#define ALLOC_BUF(_B, _S, _R) \
+# define ALLOC_BUF(_B, _S, _R) \
do { \
(_B) = (char *) mmap (0, ROUND_TO_PAGE (_S), \
PROT_READ | PROT_WRITE, \
@@ -447,9 +433,9 @@ extern void (*_IO_cleanup_registration_needed) __P ((void));
#else /* _G_HAVE_MMAP */
-#define FREE_BUF(_B, _S) \
+# define FREE_BUF(_B, _S) \
free(_B)
-#define ALLOC_BUF(_B, _S, _R) \
+# define ALLOC_BUF(_B, _S, _R) \
do { \
(_B) = (char*)malloc(_S); \
if ((_B) == NULL) \
@@ -459,15 +445,15 @@ extern void (*_IO_cleanup_registration_needed) __P ((void));
#endif /* _G_HAVE_MMAP */
#ifndef OS_FSTAT
-#define OS_FSTAT fstat
+# define OS_FSTAT fstat
#endif
struct stat;
-extern _IO_ssize_t _IO_read __P((int, void*, _IO_size_t));
-extern _IO_ssize_t _IO_write __P((int, const void*, _IO_size_t));
-extern _IO_off_t _IO_lseek __P((int, _IO_off_t, int));
-extern int _IO_close __P((int));
-extern int _IO_fstat __P((int, struct stat *));
-extern int _IO_vscanf __P((const char *, _IO_va_list));
+extern _IO_ssize_t _IO_read __P ((int, void *, _IO_size_t));
+extern _IO_ssize_t _IO_write __P ((int, const void *, _IO_size_t));
+extern _IO_off_t _IO_lseek __P ((int, _IO_off_t, int));
+extern int _IO_close __P ((int));
+extern int _IO_fstat __P ((int, struct stat *));
+extern int _IO_vscanf __P ((const char *, _IO_va_list));
/* Operations on _IO_fpos_t.
Normally, these are trivial, but we provide hooks for configurations
@@ -476,34 +462,32 @@ extern int _IO_vscanf __P((const char *, _IO_va_list));
/* _IO_pos_BAD is an _IO_fpos_t value indicating error, unknown, or EOF. */
#ifndef _IO_pos_BAD
-#define _IO_pos_BAD ((_IO_fpos_t)(-1))
+# define _IO_pos_BAD ((_IO_fpos_t) -1)
#endif
/* _IO_pos_as_off converts an _IO_fpos_t value to an _IO_off_t value. */
#ifndef _IO_pos_as_off
-#define _IO_pos_as_off(__pos) ((_IO_off_t)(__pos))
+# define _IO_pos_as_off(__pos) ((_IO_off_t) (__pos))
#endif
/* _IO_pos_adjust adjust an _IO_fpos_t by some number of bytes. */
#ifndef _IO_pos_adjust
-#define _IO_pos_adjust(__pos, __delta) ((__pos) += (__delta))
+# define _IO_pos_adjust(__pos, __delta) ((__pos) += (__delta))
#endif
/* _IO_pos_0 is an _IO_fpos_t value indicating beginning of file. */
#ifndef _IO_pos_0
-#define _IO_pos_0 ((_IO_fpos_t)0)
+# define _IO_pos_0 ((_IO_fpos_t) 0)
#endif
-#ifdef __cplusplus
-}
-#endif
+__END_DECLS
#ifdef _IO_MTSAFE_IO
/* check following! */
-#define FILEBUF_LITERAL(CHAIN, FLAGS, FD) \
+# define FILEBUF_LITERAL(CHAIN, FLAGS, FD) \
{ _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CHAIN, FD, \
0, 0, 0, 0, { 0 }, &_IO_stdfile_##FD##_lock }
#else
/* check following! */
-#define FILEBUF_LITERAL(CHAIN, FLAGS, FD) \
+# define FILEBUF_LITERAL(CHAIN, FLAGS, FD) \
{ _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CHAIN, FD }
#endif
@@ -511,57 +495,56 @@ extern int _IO_vscanf __P((const char *, _IO_va_list));
/* VTABLE_LABEL defines NAME as of the CLASS class.
CNLENGTH is strlen(#CLASS). */
#ifdef __GNUC__
-#if _G_VTABLE_LABEL_HAS_LENGTH
-#define VTABLE_LABEL(NAME, CLASS, CNLENGTH) \
+# if _G_VTABLE_LABEL_HAS_LENGTH
+# define VTABLE_LABEL(NAME, CLASS, CNLENGTH) \
extern char NAME[] asm (_G_VTABLE_LABEL_PREFIX #CNLENGTH #CLASS);
-#else
-#define VTABLE_LABEL(NAME, CLASS, CNLENGTH) \
+# else
+# define VTABLE_LABEL(NAME, CLASS, CNLENGTH) \
extern char NAME[] asm (_G_VTABLE_LABEL_PREFIX #CLASS);
-#endif
+# endif
#endif /* __GNUC__ */
#if !defined(builtinbuf_vtable) && defined(__cplusplus)
-#ifdef __GNUC__
+# ifdef __GNUC__
VTABLE_LABEL(builtinbuf_vtable, builtinbuf, 10)
-#else
-#if _G_VTABLE_LABEL_HAS_LENGTH
-#define builtinbuf_vtable _G_VTABLE_LABEL_PREFIX_ID##10builtinbuf
-#else
-#define builtinbuf_vtable _G_VTABLE_LABEL_PREFIX_ID##builtinbuf
-#endif
-#endif
+# else
+# if _G_VTABLE_LABEL_HAS_LENGTH
+# define builtinbuf_vtable _G_VTABLE_LABEL_PREFIX_ID##10builtinbuf
+# else
+# define builtinbuf_vtable _G_VTABLE_LABEL_PREFIX_ID##builtinbuf
+# endif
+# endif
#endif /* !defined(builtinbuf_vtable) && defined(__cplusplus) */
#if defined(__STDC__) || defined(__cplusplus)
-#define _IO_va_start(args, last) va_start(args, last)
+# define _IO_va_start(args, last) va_start(args, last)
#else
-#define _IO_va_start(args, last) va_start(args)
+# define _IO_va_start(args, last) va_start(args)
#endif
extern struct _IO_fake_stdiobuf _IO_stdin_buf, _IO_stdout_buf, _IO_stderr_buf;
#if 1
-#define COERCE_FILE(FILE) /* Nothing */
+# define COERCE_FILE(FILE) /* Nothing */
#else
/* This is part of the kludge for binary compatibility with old stdio. */
-#define COERCE_FILE(FILE) \
+# define COERCE_FILE(FILE) \
(((FILE)->_IO_file_flags & _IO_MAGIC_MASK) == _OLD_MAGIC_MASK \
&& (FILE) = *(FILE**)&((int*)fp)[1])
#endif
#ifdef EINVAL
-#define MAYBE_SET_EINVAL __set_errno (EINVAL)
+# define MAYBE_SET_EINVAL __set_errno (EINVAL)
#else
-#define MAYBE_SET_EINVAL /* nothing */
+# define MAYBE_SET_EINVAL /* nothing */
#endif
#ifdef IO_DEBUG
-#define CHECK_FILE(FILE,RET) \
+# define CHECK_FILE(FILE, RET) \
if ((FILE) == NULL) { MAYBE_SET_EINVAL; return RET; } \
else { COERCE_FILE(FILE); \
if (((FILE)->_IO_file_flags & _IO_MAGIC_MASK) != _IO_MAGIC) \
{ MAYBE_SET_EINVAL; return RET; }}
#else
-#define CHECK_FILE(FILE,RET) \
- COERCE_FILE(FILE)
+# define CHECK_FILE(FILE, RET) COERCE_FILE (FILE)
#endif
diff --git a/libio/obprintf.c b/libio/obprintf.c
index bd629f1ee0..6b959e455a 100644
--- a/libio/obprintf.c
+++ b/libio/obprintf.c
@@ -1,5 +1,5 @@
/* Print output of stream to given obstack.
- Copyright (C) 1996 Free Software Foundation, Inc.
+ 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.
@@ -148,7 +148,9 @@ _IO_obstack_vprintf (struct obstack *obstack, const char *format, va_list args)
return result;
}
+#ifdef weak_alias
weak_alias (_IO_obstack_vprintf, obstack_vprintf)
+#endif
int
@@ -161,4 +163,6 @@ _IO_obstack_printf (struct obstack *obstack, const char *format, ...)
va_end (ap);
return result;
}
+#ifdef weak_alias
weak_alias (_IO_obstack_printf, obstack_printf)
+#endif
diff --git a/libio/pclose.c b/libio/pclose.c
index e5d7c0c9c9..0640d47599 100644
--- a/libio/pclose.c
+++ b/libio/pclose.c
@@ -1,9 +1,34 @@
+/* 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"
#include <errno.h>
int
-pclose(fp)
+pclose (fp)
FILE *fp;
{
#if 0
@@ -12,5 +37,5 @@ pclose(fp)
if (fp is not a proc_file)
return -1;
#endif
- return _IO_fclose(fp);
+ return _IO_fclose (fp);
}
diff --git a/libio/peekc.c b/libio/peekc.c
index 2b0a812868..0b3b5140c2 100644
--- a/libio/peekc.c
+++ b/libio/peekc.c
@@ -1,26 +1,27 @@
-/*
-Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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"
@@ -29,13 +30,13 @@ the executable file might be covered by the GNU General Public License. */
int
_IO_peekc_locked (fp)
- FILE *fp;
+ _IO_FILE *fp;
{
int result;
CHECK_FILE (fp, EOF);
- __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
result = _IO_peekc_unlocked (fp);
- __libc_cleanup_region_end (1);
+ _IO_cleanup_region_end (1);
return result;
}
diff --git a/libio/putc.c b/libio/putc.c
index 6d84f24995..3c35c365f0 100644
--- a/libio/putc.c
+++ b/libio/putc.c
@@ -28,11 +28,15 @@ _IO_putc (c, fp)
{
int result;
CHECK_FILE (fp, EOF);
- __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
result = _IO_putc_unlocked (c, fp);
- __libc_cleanup_region_end (1);
+ _IO_cleanup_region_end (1);
return result;
}
+
#undef putc
+
+#ifdef weak_alias
weak_alias (_IO_putc, putc)
+#endif
diff --git a/libio/putchar.c b/libio/putchar.c
index b8a41ebf76..1e1dd13762 100644
--- a/libio/putchar.c
+++ b/libio/putchar.c
@@ -26,10 +26,10 @@ putchar (c)
int c;
{
int result;
- __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
_IO_stdout);
_IO_flockfile (_IO_stdout);
result = _IO_putc_unlocked (c, _IO_stdout);
- __libc_cleanup_region_end (1);
+ _IO_cleanup_region_end (1);
return result;
}
diff --git a/libio/rewind.c b/libio/rewind.c
index 2af2dd84d3..bce27575fd 100644
--- a/libio/rewind.c
+++ b/libio/rewind.c
@@ -1,36 +1,38 @@
-/* Copyright (C) 1993, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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;
+ _IO_FILE *fp;
{
CHECK_FILE (fp, );
- __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
_IO_rewind (fp);
- __libc_cleanup_region_end (1);
+ _IO_cleanup_region_end (1);
}
diff --git a/libio/setbuf.c b/libio/setbuf.c
index f3518aadad..ac323a31b5 100644
--- a/libio/setbuf.c
+++ b/libio/setbuf.c
@@ -1,25 +1,27 @@
-/* Copyright (C) 1993 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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"
diff --git a/libio/setlinebuf.c b/libio/setlinebuf.c
index b456d5846c..e4e029faea 100644
--- a/libio/setlinebuf.c
+++ b/libio/setlinebuf.c
@@ -1,26 +1,27 @@
-/*
-Copyright (C) 1993 Free Software Foundation
+/* Copyright (C) 1993, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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"
diff --git a/libio/stdfiles.c b/libio/stdfiles.c
index 7c6f789912..8453e33c34 100644
--- a/libio/stdfiles.c
+++ b/libio/stdfiles.c
@@ -1,26 +1,27 @@
-/*
-Copyright (C) 1993, 1994, 1996, 1997 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. */
+/* Copyright (C) 1993, 1994, 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. */
/* This file provides definitions of _IO_stdin, _IO_stdout, and _IO_stderr
diff --git a/libio/stdio.c b/libio/stdio.c
index cd56dba307..27c298c184 100644
--- a/libio/stdio.c
+++ b/libio/stdio.c
@@ -1,12 +1,37 @@
+/* Copyright (C) 1993, 1994, 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"
-/* Define non-macro versions of stdin/stdout/stderr,
- * for use by debuggers. */
+/* Define non-macro versions of stdin/stdout/stderr, for use by
+ debuggers. */
#undef stdin
#undef stdout
#undef stderr
-FILE* stdin = &_IO_stdin_.file;
-FILE* stdout = &_IO_stdout_.file;
-FILE* stderr = &_IO_stderr_.file;
+FILE *stdin = &_IO_stdin_.file;
+FILE *stdout = &_IO_stdout_.file;
+FILE *stderr = &_IO_stderr_.file;
diff --git a/libio/strfile.h b/libio/strfile.h
index 76044f8927..a0e47021f6 100644
--- a/libio/strfile.h
+++ b/libio/strfile.h
@@ -1,34 +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. */
+/* 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 <libio.h>
#ifdef TODO
Merge into libio.h ?
#endif
-typedef void *(*_IO_alloc_type) __P((_IO_size_t));
-typedef void (*_IO_free_type) __P((void*));
+typedef void *(*_IO_alloc_type) __P ((_IO_size_t));
+typedef void (*_IO_free_type) __P ((void*));
struct _IO_str_fields
{
diff --git a/libio/strops.c b/libio/strops.c
index afc293bd7d..f7c22627e7 100644
--- a/libio/strops.c
+++ b/libio/strops.c
@@ -1,26 +1,27 @@
-/*
-Copyright (C) 1993 Free Software Foundation
+/* Copyright (C) 1993, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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 "strfile.h"
#include "libioP.h"
@@ -59,11 +60,14 @@ the executable file might be covered by the GNU General Public License. */
#endif
void
-DEFUN(_IO_str_init_static, (fp, ptr, size, pstart),
- _IO_FILE *fp AND char *ptr AND int size AND char *pstart)
+_IO_str_init_static (fp, ptr, size, pstart)
+ _IO_FILE *fp;
+ char *ptr;
+ int size;
+ char *pstart;
{
if (size == 0)
- size = strlen(ptr);
+ size = strlen (ptr);
else if (size < 0)
{
/* If size is negative 'the characters are assumed to
@@ -80,7 +84,7 @@ DEFUN(_IO_str_init_static, (fp, ptr, size, pstart),
size += s;
}
}
- _IO_setb(fp, ptr, ptr+size, 0);
+ _IO_setb (fp, ptr, ptr + size, 0);
fp->_IO_write_base = ptr;
fp->_IO_read_base = ptr;
@@ -98,20 +102,23 @@ DEFUN(_IO_str_init_static, (fp, ptr, size, pstart),
fp->_IO_read_end = ptr+size;
}
/* A null _allocate_buffer function flags the strfile as being static. */
- (((_IO_strfile*)(fp))->_s._allocate_buffer) = (_IO_alloc_type)0;
+ (((_IO_strfile *) fp)->_s._allocate_buffer) = (_IO_alloc_type)0;
}
void
-DEFUN(_IO_str_init_readonly, (fp, ptr, size),
- _IO_FILE *fp AND const char *ptr AND int size)
+_IO_str_init_readonly (fp, ptr, size)
+ _IO_FILE *fp;
+ const char *ptr;
+ int size;
{
- _IO_str_init_static (fp, (char*)ptr, size, NULL);
+ _IO_str_init_static (fp, (char *) ptr, size, NULL);
fp->_IO_file_flags |= _IO_NO_WRITES;
}
int
-DEFUN(_IO_str_overflow, (fp, c),
- register _IO_FILE* fp AND int c)
+_IO_str_overflow (fp, c)
+ _IO_FILE *fp;
+ int c;
{
int flush_only = c == EOF;
_IO_size_t pos;
@@ -124,7 +131,7 @@ DEFUN(_IO_str_overflow, (fp, c),
fp->_IO_read_ptr = fp->_IO_read_end;
}
pos = fp->_IO_write_ptr - fp->_IO_write_base;
- if (pos >= (_IO_size_t) (_IO_blen(fp) + flush_only))
+ if (pos >= (_IO_size_t) (_IO_blen (fp) + flush_only))
{
if (fp->_flags & _IO_USER_BUF) /* not allowed to enlarge */
return EOF;
@@ -132,9 +139,9 @@ DEFUN(_IO_str_overflow, (fp, c),
{
char *new_buf;
char *old_buf = fp->_IO_buf_base;
- _IO_size_t new_size = 2 * _IO_blen(fp) + 100;
+ _IO_size_t new_size = 2 * _IO_blen (fp) + 100;
new_buf
- = (char*)(*((_IO_strfile*)fp)->_s._allocate_buffer)(new_size);
+ = (char *) (*((_IO_strfile *) fp)->_s._allocate_buffer) (new_size);
if (new_buf == NULL)
{
/* __ferror(fp) = 1; */
@@ -142,16 +149,16 @@ DEFUN(_IO_str_overflow, (fp, c),
}
if (fp->_IO_buf_base)
{
- memcpy(new_buf, old_buf, _IO_blen(fp));
- (*((_IO_strfile*)fp)->_s._free_buffer)(fp->_IO_buf_base);
+ memcpy (new_buf, old_buf, _IO_blen (fp));
+ (*((_IO_strfile *) fp)->_s._free_buffer) (fp->_IO_buf_base);
/* Make sure _IO_setb won't try to delete _IO_buf_base. */
fp->_IO_buf_base = NULL;
}
#if 0
if (lenp == &LEN(fp)) /* use '\0'-filling */
- memset(new_buf + pos, 0, blen() - pos);
+ memset (new_buf + pos, 0, blen() - pos);
#endif
- _IO_setb(fp, new_buf, new_buf + new_size, 1);
+ _IO_setb (fp, new_buf, new_buf + new_size, 1);
fp->_IO_read_base = new_buf + (fp->_IO_read_base - old_buf);
fp->_IO_read_ptr = new_buf + (fp->_IO_read_ptr - old_buf);
fp->_IO_read_end = new_buf + (fp->_IO_read_end - old_buf);
@@ -170,8 +177,8 @@ DEFUN(_IO_str_overflow, (fp, c),
}
int
-DEFUN(_IO_str_underflow, (fp),
- register _IO_FILE* fp)
+_IO_str_underflow (fp)
+ _IO_FILE *fp;
{
if (fp->_IO_write_ptr > fp->_IO_read_end)
fp->_IO_read_end = fp->_IO_write_ptr;
@@ -190,19 +197,22 @@ DEFUN(_IO_str_underflow, (fp),
/* The size of the valid part of the buffer. */
_IO_ssize_t
-DEFUN(_IO_str_count, (fp),
- register _IO_FILE *fp)
+_IO_str_count (fp)
+ _IO_FILE *fp;
{
- return (fp->_IO_write_end > fp->_IO_read_end ? fp->_IO_write_end
- : fp->_IO_read_end)
- - fp->_IO_read_base;
+ return ((fp->_IO_write_end > fp->_IO_read_end
+ ? fp->_IO_write_end : fp->_IO_read_end)
+ - fp->_IO_read_base);
}
_IO_pos_t
-DEFUN(_IO_str_seekoff, (fp, offset, dir, mode),
- register _IO_FILE *fp AND _IO_off_t offset AND int dir AND int mode)
+_IO_str_seekoff (fp, offset, dir, mode)
+ _IO_FILE *fp;
+ _IO_off_t offset;
+ int dir;
+ int mode;
{
- _IO_ssize_t cur_size = _IO_str_count(fp);
+ _IO_ssize_t cur_size = _IO_str_count (fp);
_IO_pos_t new_pos = EOF;
/* Move the get pointer, if requested. */
@@ -219,7 +229,7 @@ DEFUN(_IO_str_seekoff, (fp, offset, dir, mode),
default: /* case _IO_seek_set: */
break;
}
- if (offset < 0 || (_IO_ssize_t)offset > cur_size)
+ if (offset < 0 || (_IO_ssize_t) offset > cur_size)
return EOF;
fp->_IO_read_ptr = fp->_IO_read_base + offset;
fp->_IO_read_end = fp->_IO_read_base + cur_size;
@@ -240,7 +250,7 @@ DEFUN(_IO_str_seekoff, (fp, offset, dir, mode),
default: /* case _IO_seek_set: */
break;
}
- if (offset < 0 || (_IO_ssize_t)offset > cur_size)
+ if (offset < 0 || (_IO_ssize_t) offset > cur_size)
return EOF;
fp->_IO_write_ptr = fp->_IO_write_base + offset;
new_pos = offset;
@@ -249,26 +259,29 @@ DEFUN(_IO_str_seekoff, (fp, offset, dir, mode),
}
int
-DEFUN(_IO_str_pbackfail, (fp, c),
- register _IO_FILE *fp AND int c)
+_IO_str_pbackfail (fp, c)
+ _IO_FILE *fp;
+ int c;
{
if ((fp->_flags & _IO_NO_WRITES) && c != EOF)
return EOF;
- return _IO_default_pbackfail(fp, c);
+ return _IO_default_pbackfail (fp, c);
}
void
-DEFUN (_IO_str_finish, (fp, dummy),
- register _IO_FILE* fp AND int dummy)
+_IO_str_finish (fp, dummy)
+ _IO_FILE *fp;
+ int dummy;
{
if (fp->_IO_buf_base && !(fp->_flags & _IO_USER_BUF))
- (((_IO_strfile*)fp)->_s._free_buffer)(fp->_IO_buf_base);
+ (((_IO_strfile *) fp)->_s._free_buffer) (fp->_IO_buf_base);
fp->_IO_buf_base = NULL;
- _IO_default_finish(fp, 0);
+ _IO_default_finish (fp, 0);
}
-struct _IO_jump_t _IO_str_jumps = {
+struct _IO_jump_t _IO_str_jumps =
+{
JUMP_INIT_DUMMY,
JUMP_INIT(finish, _IO_str_finish),
JUMP_INIT(overflow, _IO_str_overflow),
diff --git a/libio/vasprintf.c b/libio/vasprintf.c
index 02289407f4..15513d0fca 100644
--- a/libio/vasprintf.c
+++ b/libio/vasprintf.c
@@ -1,26 +1,27 @@
-/*
-Copyright (C) 1995 Free Software Foundation
+/* Copyright (C) 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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 GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ 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. */
+ 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"
@@ -42,19 +43,19 @@ _IO_vasprintf (result_ptr, format, args)
_IO_lock_t lock;
#endif
int ret;
- string = malloc (init_string_size);
+ 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);
+ _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);
+ ret = _IO_vfprintf ((_IO_FILE *) &sf, format, args);
if (ret < 0)
return ret;
*result_ptr = (char *) realloc (sf._sbf._f._IO_buf_base,
@@ -65,4 +66,7 @@ _IO_vasprintf (result_ptr, format, args)
(*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/vscanf.c b/libio/vscanf.c
index f905cff5a3..8b92ae270e 100644
--- a/libio/vscanf.c
+++ b/libio/vscanf.c
@@ -1,26 +1,27 @@
-/*
-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. */
+/* 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"
@@ -34,4 +35,7 @@ _IO_vscanf (format, args)
{
return _IO_vfscanf (_IO_stdin, format, args, NULL);
}
+
+#ifdef weak_alias
weak_alias (_IO_vscanf, vscanf)
+#endif
diff --git a/libio/vsnprintf.c b/libio/vsnprintf.c
index 5ada74215c..3f35af299a 100644
--- a/libio/vsnprintf.c
+++ b/libio/vsnprintf.c
@@ -1,26 +1,27 @@
-/*
-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. */
+/* 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"
@@ -35,8 +36,12 @@ typedef struct
} _IO_strnfile;
+static int _IO_strn_overflow __P ((_IO_FILE *fp, int c));
+
static int
-_IO_strn_overflow (_IO_FILE* fp, int c)
+_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
@@ -70,7 +75,8 @@ _IO_strn_overflow (_IO_FILE* fp, int c)
}
-static struct _IO_jump_t _IO_strn_jumps = {
+static struct _IO_jump_t _IO_strn_jumps =
+{
JUMP_INIT_DUMMY,
JUMP_INIT(finish, _IO_str_finish),
JUMP_INIT(overflow, _IO_strn_overflow),
@@ -123,5 +129,8 @@ _IO_vsnprintf (string, maxlen, format, args)
*sf.f._sbf._f._IO_write_ptr = '\0';
return ret;
}
+
+#ifdef weak_alias
weak_alias (_IO_vsnprintf, __vsnprintf)
weak_alias (_IO_vsnprintf, vsnprintf)
+#endif
diff --git a/manual/libc.texinfo b/manual/libc.texinfo
index cb1769fec7..6a936fdbe4 100644
--- a/manual/libc.texinfo
+++ b/manual/libc.texinfo
@@ -122,6 +122,8 @@ of the GNU C Library.
* Extended Characters:: Support for extended character sets.
* Locales:: The country and language can affect
the behavior of library functions.
+* Message Translation:: How to make the program speak the users
+ language.
* Searching and Sorting:: General searching and sorting functions.
* Pattern Matching:: Matching wildcards and regular expressions,
and shell-style ``word expansion''.
@@ -314,6 +316,11 @@ Locales and Internationalization
* Standard Locales:: Locale names available on all systems.
* Numeric Formatting:: How to format numbers for the chosen locale.
+Message Translation
+
+* Message catalogs a la X/Open:: The @code{catgets} family of functions.
+* The Uniforum approach:: The @code{gettext} family of functions.
+
Searching and Sorting
* Comparison Functions:: Defining how to compare two objects.
@@ -975,6 +982,7 @@ Porting the GNU C Library
@include time.texi
@include mbyte.texi
@include locale.texi
+@include message.texi
@include setjmp.texi
@include signal.texi
@include startup.texi
diff --git a/manual/locale.texi b/manual/locale.texi
index 1866c66fb7..dfc9117176 100644
--- a/manual/locale.texi
+++ b/manual/locale.texi
@@ -1,4 +1,4 @@
-@node Locales, Searching and Sorting, Extended Characters, Top
+@node Locales, Message Translation, Extended Characters, Top
@chapter Locales and Internationalization
Different countries and cultures have varying conventions for how to
diff --git a/manual/message.texi b/manual/message.texi
new file mode 100644
index 0000000000..7640e21acf
--- /dev/null
+++ b/manual/message.texi
@@ -0,0 +1,1185 @@
+@node Message Translation
+@chapter Message Translation
+
+The program's interface with the human should be designed in a way to
+ease the human the task. One of the possibilities is to use messages in
+whatever language the user prefers.
+
+Printing messages in different languages can be implemented in different
+ways. One could add all the different languages in the source code and
+add among the variants every time a message has to be printed. This is
+certainly no good solution since extending the set of languages is
+difficult (the code must be changed) and the code itself can become
+really big with dozens of message sets.
+
+A better solution is to keep the message sets for each language are kept
+in separate files which are loaded at runtime depending on the language
+selection of the user.
+
+The GNU C Library provides two different sets of functions to support
+message translation. The problem is that neither of the interfaces is
+officially defined by the POSIX standard. The @code{catgets} family of
+functions is defined in the X/Open standard but this is drived from
+industry decisions and therefore not necessarily is based on reasinable
+decisions.
+
+As mentioned above the message catalog handling provides easy
+extendibility by using external data files which contain the message
+translations. I.e., these files contain for each of the messages used
+in the program a translation for the appropriate language. So the tasks
+of the message handling functions functions are
+
+@itemize @bullet
+@item
+locate the external data file with the appropriate translations.
+@item
+load the data and make it possible to address the messages
+@item
+map a given key to the translated message
+@end itemize
+
+The two approaches mainly differ in the implementation of this last
+step. The design decisions made for this influences the whole rest.
+
+@menu
+* Message catalogs a la X/Open:: The @code{catgets} family of functions.
+* The Uniforum approach:: The @code{gettext} family of functions.
+@end menu
+
+
+@node Message catalogs a la X/Open
+@section X/Open Message Catalog Handling
+
+The @code{catgets} functions are based on the simple scheme:
+
+@quotation
+Associate every message to translate in the source code with a unique
+identifier. To retrieve a message from a catalog file solely the
+identifier is used.
+@end quotation
+
+This means for the author of the program that s/he will have to make
+sure the meaning of the identifier in the program code and in the
+message catalogs are always the same.
+
+Before a message can be translated the catalog file must be located.
+The user of the program must be able to guide the responsible function
+to find whatever catalog the user wants. This is separated from what
+the programmer had in mind.
+
+All the types, constants and funtions for the @code{catgets} functions
+are defined/declared in the @file{nl_types.h} header file.
+
+@menu
+* The catgets Functions:: The @code{catgets} function family.
+* The message catalog files:: Format of the message catalog files.
+* The gencat program:: How to generate message catalogs files which
+ can be used by the functions.
+* Common Usage:: How to use the @code{catgets} interface.
+@end menu
+
+
+@node The catgets Functions
+@subsection The @code{catgets} function family
+
+@comment nl_types.h
+@comment X/Open
+@deftypefun nl_catd catopen (const char *@var{cat_name}, int @var{flag})
+The @code{catgets} function tries to locate the message data file names
+@var{cat_name} and loads it when found. The return value is of an
+opaque type and can be used in calls to the other functions to refer to
+this loaded catalog.
+
+The return value is @code{(nl_catd) -1} in case the function failed and
+no catalog was loaded. The global variable @var{errno} contains a code
+for the error causing the failure. But even if the function call
+succeeded this does not mean that all messages can be translated.
+
+Locating the catalog file must happen in a way which lets the user of
+the program influence the decision. It is up to the user to decide
+about the language to use and sometimes it is useful to use alternate
+catalog files. All this can be specified by the user by setting some
+enviroment variables.
+
+The first problem is to find out where all the message catalogs are
+stored. Every program could have its own place to keep all the
+different files but usually the catalog files are grouped by languages
+and the catalogs for all programs are kept in the same place.
+
+@cindex NLSPATH environment variable
+To tell the @code{catopen} function where the catalog for the program
+can be found the user can set the environment variable @code{NLSPATH} to
+a value which describes her/his choice. Since this value must be usable
+for different languages and locales it cannot be a simple string.
+Instead it is a format string (similar to @code{printf}'s). An example
+is
+
+@smallexample
+/usr/share/locale/%L/%N:/usr/share/locale/%L/LC_MESSAGES/%N
+@end smallexample
+
+First one can see that more than one directory can be specified (with
+the usual syntax of separating them by colons). The next things to
+observe are the format string, @code{%L} and @code{%N} in this case.
+The @code{catopen} function knows about several of them and the
+replacement for all of them is of course different.
+
+@table @code
+@item %N
+This format element is substituted with the name of the catalog file.
+This is the value of the @var{cat_name} argument given to
+@code{catgets}.
+
+@item %L
+This format element is substituted with the name of the currently
+selected locale for translating messages. How this is determined is
+explained below.
+
+@item %l
+(This is the lowercase ell.) This format element is substituted with the
+language element of the locale name. The string decsribing the selected
+locale is expected to have the form
+@code{@var{lang}[_@var{terr}[.@var{codeset}]]} and this format uses the
+first part @var{lang}.
+
+@item %t
+This format element is substituted by the territory part @var{terr} of
+the name of the currently selected locale. See the explanation of the
+format above.
+
+@item %c
+This format element is substituted by the codeset part @var{codeset} of
+the name of the currently selected locale. See the explanation of the
+format above.
+
+@item %%
+Since @code{%} is used in a meta character there must be a way to
+express the @code{%} character in the result itself. Using @code{%%}
+does this just like it works for @code{printf}.
+@end table
+
+
+Using @code{NLSPATH} allows to specify arbitrary directories to be
+searched for message catalogs while still allowing different languages
+to be used. If the @code{NLSPATH} environment variable is not set the
+default value is
+
+@smallexample
+@var{prefix}/share/locale/%L/%N:@var{prefix}/share/locale/%L/LC_MESSAGES/%N
+@end smallexample
+
+@noindent
+where @var{prefix} is given to @code{configure} while installing the GNU
+C Library (this value is in many cases @code{/usr} or the empty string).
+
+The remaining problem is to decide which must be used. The value
+decides about the substitution of the format elements mentioned above.
+First of all the user can specify a path in the message catalog name
+(i.e., the name contains a slash character). In this situation the
+@code{NLSPATH} environment variable is not used. The catalog must exist
+as specified in the program, perhaps relative to the current working
+directory. This situation in not desirable and catalogs names never
+should be written this way. Beside this, this behaviour is not portable
+to all other platforms providing the @code{catgets} interface.
+
+@cindex LC_ALL environment variable
+@cindex LC_MESSAGES environment variable
+@cindex LANG environment variable
+Otherwise the values of environment variables from the standard
+environemtn are examined (@pxref{Standard Environment}). Which
+variables are examined is decided by the @var{flag} parameter of
+@code{catopen}. If the value is @code{NL_CAT_LOCALE} (which is defined
+in @file{nl_types.h}) then the @code{catopen} function examines the
+environment variable @code{LC_ALL}, @code{LC_MESSAGES}, and @code{LANG}
+in this order. The first variable which is set in the current
+environment will be used.
+
+If @var{flag} is zero only the @code{LANG} environment variable is
+examined. This is a left-over from the early days of this function
+where the other environment variable were not known.
+
+In any case the environment variable should have a value of the form
+@code{@var{lang}[_@var{terr}[.@var{codeset}]]} as explained above. If
+no environment variable is set the @code{"C"} locale is used which
+prevents any translation.
+
+The return value of the function is in any case a valid string. Either
+it is a translation from a message catalog or it is the same as the
+@var{string} parameter. So a piece of code to decide whether a
+translation actually happened must look like this:
+
+@smallexample
+@{
+ char *trans = catgets (desc, set, msg, input_string);
+ if (trans == input_string)
+ @{
+ /* Something went wrong. */
+ @}
+@}
+@end smallexample
+
+@noindent
+When an error occured the global variable @var{errno} is set to
+
+@table @var
+@item EBADF
+The catalog does not exist.
+@item ENOMSG
+The set/message touple does not name an existing element in the
+message catalog.
+@end table
+
+While it sometimes can be useful to test for errors programs normally
+will avoid any test. If the translation is not available it is no big
+problem if the original, untranslated message is printed. Either the
+user understands this as well or s/he will look for the reason why the
+messages are not translated.
+@end deftypefun
+
+Please note that the currently selected locale does not depend on a call
+to the @code{setlocale} function. It is not necessary that the locale
+data files for this locale exist and calling @code{setlocale} succeeds.
+The @code{catopen} function directly reads the values of the environment
+variables.
+
+
+@deftypefun {char *} catgets (nl_catd @var{catalog_desc}, int @var{set}, int @var{message}, const char *@var{string})
+The function @code{catgets} has to be used to access the massage catalog
+previously opened using the @code{catopen} function. The
+@var{catalog_desc} parameter must be a value previously returned by
+@code{catopen}.
+
+The next two parameters, @var{set} and @var{message}, reflect the
+internal organization of the message catalog files. This will be
+explained in detail below. For now it is interesting to know that a
+catalog can consists of several set and the messages in each thread are
+individually numbered using numbers. Neither the set number nor the
+message number must be consecutive. They can be arbitrarily chosen.
+But each message (unless equal to another one) must have its own unique
+pair of set and message number.
+
+Since it is not guaranteed that the message catalog for the language
+selected by the user exists the last parameter @var{string} helps to
+handle this case gracefully. If no matching string can be found
+@var{string} is returned. This means for the programmer that
+
+@itemize @bullet
+@item
+the @var{string} parameters should contain reasonable text (this also
+helps to understand the program seems otherwise there would be no hint
+on the string which is expected to be returned.
+@item
+all @var{string} arguments should be written in the same language.
+@end itemize
+@end deftypefun
+
+It is somewhat uncomfortable to write a program using the @code{catgets}
+functions if no supporting functionality is available. Since each
+set/message number touple must be unique the programmer must keep lists
+of the messages at the same time the code is written. And the work
+between several people working on the same project must be coordinated.
+In @ref{Common Usage} we will see some how these problems can be relaxed
+a bit.
+
+@deftypefun int catclose (nl_catd @var{catalog_desc})
+The @code{catclose} function can be used to free the resources
+associated with a message catalog which previously was opened by a call
+to @code{catopen}. If the resources can be successfully freed the
+function returns @code{0}. Otherwise it return @code{@minus{}1} and the
+global variable @var{errno} is set. Errors can occur if the catalog
+descriptor @var{catalog_desc} is not valid in which case @var{errno} is
+set to @code{EBADF}.
+@end deftypefun
+
+
+@node The message catalog files
+@subsection Format of the message catalog files
+
+The only reasonable way the translate all the messages of a function and
+store the result in a message catalog file which can be read by the
+@code{catopen} function is to write all the message text to the
+translator and let her/him translate them all. I.e., we must have a
+file with entries which associate the set/message touple with a specific
+translation. This file format is specified in the X/Open standard and
+is as follows:
+
+@itemize @bullet
+@item
+Lines containing only whitespace characters or empty lines are ignored.
+
+@item
+Lines which contain as the first non-whitespace character a @code{$}
+followed by a whitespace character are comment and are also ignored.
+
+@item
+If a line contains as the first non-whitespace characters the sequence
+@code{$set} followed by a whitespace character an additional argument
+is required to follow. This argument can either be:
+
+@itemize @minus
+@item
+a number. In this case the value of this number determines the set
+to which the following messages are added.
+
+@item
+an identifier consisting of alphanumeric characters plus the underscore
+character. In this case the set get automatically a number assigned.
+This value is one added to the largest set number which so far appeared.
+
+How to use the symbolic names is explained in section @ref{Common Usage}.
+
+It is an error if a symbol name appears more than once. All following
+messages are placed in a set with this number.
+@end itemize
+
+@item
+If a line contains as the first non-whitespace characters the sequence
+@code{$delset} followed by a whitespace character an additional argument
+is required to follow. This argument can either be:
+
+@itemize @minus
+@item
+a number. In this case the value of this number determines the set
+which will be deleted.
+
+@item
+an identifier consisting of alphanumeric characters plus the underscore
+character. This symbolic identifier must match a name for a set which
+previously was defined. It is an error if the name is unknown.
+@end itemize
+
+In both cases all messages in the specified set will be removed. They
+will not appear in the output. But if this set is later again selected
+with a @code{$set} command again messages could be added and these
+messages will appear in the output.
+
+@item
+If a line contains after leading whitespaces the sequence
+@code{$quote}, the quoting character used for this input file is
+changed to the first non-whitespace character following the
+@code{$quote}. If no non-whitespace character is present before the
+line ends quoting is disable.
+
+By default no quoting character is used. In this mode strings are
+terminated with the first unescaped line break. If there is a
+@code{$quote} sequence present newline need not be escaped. Instead a
+string is terminated with the first unescaped appearence of the quote
+character.
+
+A common usage of this feature would be to set the quote character to
+@code{"}. Then any appearence of the @code{"} in the strings must
+be escaped using the backslash (i.e., @code{\"} must be written).
+
+@item
+Any other line must start with a number or an alphanumeric identifier
+(with the underscore character included). The following characters
+(starting at the first non-whitespace character) will form the string
+which gets associated with the currently selected set and the message
+number represented by the number and identifier respectively.
+
+If the start of the line is a number the message number is obvious. It
+is an error if the same message number already appeared for this set.
+
+If the leading token was an identifier the message number gets
+automatically assigned. The value is the current maximum messages
+number for this set plus one. It is an error if the identifier was
+already used for a message in this set. It is ok to reuse the
+identifier for a message in another thread. How to use the symbolic
+identifiers will be explained below (@pxref{Common Usage}). There is
+one limitation with the identifier: it must not be @code{Set}. The
+reason will be explained below.
+
+Please note that you must use a quoting character if a message contains
+leading whitespace. Since one cannot guarantee this never happens it is
+probably a good idea to always use quoting.
+
+The text of the messages can contain escape characters. The usual bunch
+of characters known from the @w{ISO C} language are recognized
+(@code{\n}, @code{\t}, @code{\v}, @code{\b}, @code{\r}, @code{\f},
+@code{\\}, and @code{\@var{nnn}}, where @var{nnn} is the octal coding of
+a character code).
+@end itemize
+
+@strong{Important:} The handling of identifiers instead of numbers for
+the set and messages is a GNU extension. Systems strictly following the
+X/Open specification do not have this feature. An example for a message
+catalog file is this:
+
+@smallexample
+$ This is a leading comment.
+$quote "
+
+$set SetOne
+1 Message with ID 1.
+two " Message with ID \"two\", which gets the value 2 assigned"
+
+$set SetTwo
+$ Since the last set got the nubmer 1 assigned this set has number 2.
+4000 "The numbers can be arbitrary, they need not start at one."
+@end smallexample
+
+This small example shows various aspects:
+@itemize @bullet
+@item
+Lines 1 and 9 are comments since they start with @code{$} followed by
+a whitespace.
+@item
+The quoting character is set to @code{"}. Otherwise the quotes in the
+message definition would have to be left away and in this case the
+message with the identifier @code{two} would loose its leading whitespace.
+@item
+Mixing numbered messages with message having symbolic names is no
+problem and the numering happens automatically.
+@end itemize
+
+
+While this file format is pretty easy it is not the best possible for
+use in a running program. The @code{catopen} function would have to
+parser the file and handle syntactic errors gracefully. This is not so
+easy and the whole process is pretty slow. Therefore the @code{catgets}
+functions expect the data in another more compact and ready-to-use file
+format. There is a special programm @code{gencat} which is explained in
+detail in the next section.
+
+Files in this other format are not human readable. To be easy to use by
+programs it is a binary file. But the format is byte order independent
+so translation files can be shared by systems of arbitrary architecture
+(as long as they use the GNU C Library).
+
+Details about the binary file format are not important to know since
+these files are always created by the @code{gencat} program. The
+sources of the GNU C Library also provide the sources for the
+@code{gencat} program and so the interested reader can look throught
+these source files to learn about the file format.
+
+
+@node The gencat program
+@subsection Generate Message Catalogs files
+
+@cindex gencat
+The @code{gencat} program is specified in the X/Open standard and the
+GNU implementation follows this specification and so allows to process
+all correctly formed input files. Additionally some extension are
+implemented which help to work in a more reasonable way with the the
+@code{catgets} functions.
+
+The @code{gencat} program can be invoked in two ways:
+
+@example
+`gencat [@var{Option}]@dots{} [@var{Output-File} [@var{Input-File}]@dots{}]`
+@end example
+
+This is the interface defined in the X/Open standard. If no
+@var{Input-File} parameter is given input will be read from standard
+input. Multiple input files will be read as if they are concatenated.
+If @var{Output-File} is also missing, the output will be written to
+standard output. To provide the interface one is used from other
+programs a second interface is provided.
+
+@smallexample
+`gencat [@var{Option}]@dots{} -o @var{Output-File} [@var{Input-File}]@dots{}`
+@end smallexample
+
+The option @samp{-o} is used to specify the output file and all file
+arguments are used as input files.
+
+Beside this one can use @file{-} or @file{/dev/stdin} for
+@var{Input-File} to denote the standard input. Corresponding one can
+use @file{-} and @file{/dev/stdout} for @var{Output-File} to denote
+standard output. Using @file{-} as a file name is allowed in X/Open
+while using the device names is a GNU extension.
+
+The @code{gencat} program works by concatenating all input files and
+then @strong{merge} the resulting collection of message sets with a
+possiblity existing output file. This is done by removing all messages
+with set/message number touples matching any of the generated messages
+from the output file and then adding all the new messages. To
+regenerate a catalog file while ignoring the old contents therefore
+requires to remove the output file if it exists. If the output is
+written to standard output no merging takes place.
+
+@noindent
+The following table shows the options understood by the @code{gencat}
+program. The X/Open standard does not specify any option for the
+program so all of these are GNU extensions.
+
+@table @samp
+@item -V
+@itemx --version
+Print the version information and exit.
+@item -h
+@itemx --help
+Print a usage message listing all available options, then exit successfully.
+@item --new
+Do never merge the new messages from the input files with the old content
+of the output files. The old content of the output file is discarded.
+@item -H
+@itemx --header=name
+This option is used to emit the symbolic names given to sets and
+messages in the input files for use in the program. Details about how
+to use this are given in the next section. The @var{name} parameter to
+this option specifies the name of the output file. It will contain a
+number of C preprocessor @code{#define}s to associate a name with a
+number.
+
+Please note that the generated file only contains the symbols from the
+input files. If the output is merged with the previous content of the
+output file the possibly existing symbols from the file(s) which
+generated the old output files are not in the generated header file.
+@end table
+
+
+@node Common Usage
+@subsection How to use the @code{catgets} interface
+
+The @code{catgets} functions can be used in two different ways. By
+following slavishly the X/Open specs and not relying on the extension
+and by using the GNU extensions. We will take a look at the former
+method first to understand the benefits of extensions.
+
+@subsubsection Not using symbolic symbolic names
+
+Since the X/Open format of the message catalog files does not allow
+symbol names we have to work with numbers all the time. When we start
+writing a program we have to replace all appearences of translatable
+strings with someting like
+
+@smallexample
+catgets (catdesc, set, msg, "string")
+@end smallexample
+
+@noindent
+@var{catgets} is retrieved from a call to @code{catopen} which is
+normally done once at the program start. The @code{"string"} is the
+string we want to translate. The problems start with the set and
+message numbers.
+
+In a bigger program several programmers usually work at the same time on
+the program and so coordinating the number allocation is crucial.
+Though no two different strings must be indexed by the same touple of
+numbers it is highly desireable to reuse the numbers for equal strings
+with equal translations (please note that there might be strings which
+are equal in one language but have different translations due to
+difference contexts).
+
+The allocation process can be relaxed a bit by different set numbers for
+different parts of the program. So the number of developers who have to
+coordinate the allocation can be reduced. But still lists must be keep
+track of the allocation and errors can easily happen. These errors
+cannot be discovered by the compiler or the @code{catgets} functions.
+Only the user of the program might see wrong messages printed. In the
+worst cases the messages are so irritating that they cannot be
+recognized as wrong. Think about the translations for @code{"true"} and
+@code{"false"} being exchanged. This could result in a desaster.
+
+
+@subsubsection Using symbolic names
+
+The problems mentioned in the last section derive from the fact that:
+
+@enumerate
+@item
+the numbers are allocated once and due to the possibly frequent use of
+them it is difficult to change a number later.
+@item
+the numbers do not allow to guess anything about the string and
+therefore collisions can easily happen.
+@end enumerate
+
+By constantly using symbolic names and by providing a method which maps
+the string content to a symbolic name (however this will happen) one can
+prevent both problems above. The cost of this is that the programmer
+has to write a complete message catalog file while s/he is writing the
+program itself.
+
+This is necessary since the symbolic names must be mapped to numbers
+before the program sources can be compiled. In the last section it was
+described how to generate a header containing the mapping of the names.
+E.g., for the example message file given in the last section we could
+call the @code{gencat} program as follow (assume @file{ex.msg} contains
+the sources).
+
+@smallexample
+gencat -H ex.h -o ex.cat ex.msg
+@end smallexample
+
+@noindent
+This generates a header file with the following content:
+
+@smallexample
+#define SetTwoSet 0x2 /* u.msg:8 */
+
+#define SetOneSet 0x1 /* u.msg:4 */
+#define SetOnetwo 0x2 /* u.msg:6 */
+@end smallexample
+
+As can be seen the various symbols given in the source file are mangled
+to generate unique identifiers and these identifiers get numbers
+assigned. Reading the source file and knowing about the rules will
+allow to predict the content of the header file (it is deterministic)
+but this is not necessary. The @code{gencat} program can take care for
+everything. All the programmer has to do is to put the generated header
+file in the dependency list of the source files of her/his project and
+to add a rules to regenerate the header of any of the input files
+change.
+
+One word about the symbol mangling. Every symbol consists of two parts:
+the name of the message set plus the name of the message or the special
+string @code{Set}. So @code{SetOnetwo} means this macro can be used to
+access the translation with identifier @code{two} in the message set
+@code{SetOne}.
+
+The other names denote the names of the message sets. The special
+string @code{Set} is used in the place of the message identifier.
+
+If in the code the second string of the set @code{SetOne} is used the C
+code should look like this:
+
+@smallexample
+catgets (catdesc, SetOneSet, SetOnetwo,
+ " Message with ID \"two\", which gets the value 2 assigned")
+@end smallexample
+
+Writing the function this way will allow to change the message number
+and even the set number without requiring any change in the C source
+code. (The text of the string is normally not the same; this is only
+for this example.)
+
+
+@subsubsection How does to this allow to develop
+
+To illustrate the usual way to work with the symbolic version numbers
+here is a little example. Assume we want to write the very complex and
+famous greeting program. We start by writing the code as usual:
+
+@smallexample
+#include <stdio.h>
+int
+main (void)
+@{
+ printf ("Hello, world!\n");
+ return 0;
+@}
+@end smallexample
+
+Now we want to internationalize the message and therefore replace the
+message with whatever the user wants.
+
+@smallexample
+#include <nl_types.h>
+#include <stdio.h>
+#include "msgnrs.h"
+int
+main (void)
+@{
+ nl_catd catdesc = catopen ("hello.cat", NL_CAT_LOCALE);
+ printf (catgets (catdesc, SetMainSet, SetMainHello, "Hello, world!\n"));
+ catclose (catdesc);
+ return 0;
+@}
+@end smallexample
+
+We see how the catalog object is opened and the returned descriptor used
+in the other function calls. It is not really necessary to check for
+failure of any of the functions since even in these situations the
+functions will behave reasonable. They simply will be return a
+translation.
+
+What remains unspecified here are the constants @code{SetMainSet} and
+@code{SetMainHello}. These are the symbolic names describing the
+message. To get the actual definitions which match the information in
+the catalog file we have to create the message catalog source file and
+process it using the @code{gencat} program.
+
+@smallexample
+$ Messages for the famous greeting program.
+$quote "
+
+$set Main
+Hello "Hallo, Welt!\n"
+@end smallexample
+
+Now we can start building the program (assume the message catalog source
+file is named @file{hello.msg} and the program source file @file{hello.c}):
+
+@smallexample
+@cartouche
+% gencat -H msgnrs.h -o hello.cat hello.msg
+% cat msgnrs.h
+#define MainSet 0x1 /* hello.msg:4 */
+#define MainHello 0x1 /* hello.msg:5 */
+% gcc -o hello hello.c -I.
+% cp hello.cat /usr/share/locale/de/LC_MESSAGES
+% echo $LC_ALL
+de
+% ./hello
+Hallo, Welt!
+%
+@end cartouche
+@end smallexample
+
+The call of the @code{gencat} program creates the missing header file
+@file{msgnrs.h} as well as the message catalog binary. The former is
+used in the compilation of @file{hello.c} while the later is placed in a
+directory in which the @code{catopen} function will try to locate it.
+Please check the @code{LC_ALL} environment variable and the default path
+for @code{catopen} presented in the description above.
+
+
+@node The Uniforum approach
+@section The Uniforum approach to Message Translation
+
+Sun Microsystems tried to standardize a different approach to message
+translation in the Uniforum group. There never was a real standard
+defined but still the interface was used in Sun's operation systems.
+Since this approach fits better in the development process of free
+software it is also used throughout the GNU package and the GNU
+@file{gettext} package provides support for this outside the GNU C
+Library.
+
+The code of the @file{libintl} from GNU @file{gettext} is the same as
+the code in the GNU C Library. So the documentation in the GNU
+@file{gettext} manual is also valid for the functionality here. The
+following text will describe the library functions in detail. But the
+numerous helper programs are not described in this manual. Instead
+people should read the GNU @file{gettext} manual
+(@pxref{Top,,GNU gettext utilities,gettext,Native Language Support Library and Tools}).
+We will only give a short overview.
+
+Though the @code{catgets} functions are available by default on more
+systems the @code{gettext} interface is at least as portable as the
+former. The GNU @file{gettext} package can be used wherever the
+functions are not available.
+
+
+@menu
+* Message catalogs with gettext:: The @code{gettext} family of functions.
+* Helper programs for gettext:: Programs to handle message catalogs
+ for @code{gettext}.
+@end menu
+
+
+@node Message catalogs with gettext
+@subsection The @code{gettext} family of functions
+
+The paradigms underlying the @code{gettext} approach to message
+translations is different from that of the @code{catgets} functions the
+basic functionally is equivalent. There are functions of the following
+categories:
+
+@menu
+* Translation with gettext:: What has to be done to translate a message.
+* Locating gettext catalog:: How to determine which catalog to be used.
+* Using gettextized software:: The possibilities of the user to influence
+ the way @code{gettext} works.
+@end menu
+
+@node Translation with gettext
+@subsubsection What has to be done to translate a message?
+
+The @code{gettext} functions have a very simple interface. The most
+basic function just takes the string which shall be translated as the
+argument and it returns the translation. This is fundamentally
+different from the @code{catgets} approach where an extra key is
+necessary and the original string is only used for the error case.
+
+If the string which has to be translated is the only argument this of
+course means the string itself is the key. I.e., the translation will
+be selected based on the original string. The message catalogs must
+therefore contain the original strings plus one translation for any such
+string. The task of the @code{gettext} function is it to compare the
+argument string with the available strings in the catalog and return the
+appropriate translation. Of course this process is optimized so that
+this process is not more expensive than an access using an atomic key
+like in @code{catgets}.
+
+The @code{gettext} approach has some advantages but also some
+disadvantages. Please see the GNU @file{gettext} manual for a detailed
+discussion of the pros and cons.
+
+All the definitions and declarations for @code{gettext} can be found in
+the @file{libintl.h} header file. On systems where these functions are
+not part of the C library they can be found in a separate library named
+@file{libintl.a} (or accordingly different for shared libraries).
+
+@deftypefun {char *} gettext (const char *@var{msgid})
+The @code{gettext} function searches the currently selected message
+catalogs for a string which is equal to @var{msgid}. If there is such a
+string available it is returned. Otherwise the argument string
+@var{msgid} is returned.
+
+Please note that all though the return value is @code{char *} the
+returned string must not be changed. This broken type results from the
+history of the function and does not reflect the way the function should
+be used.
+
+Please note that above we wrote ``message catalogs'' (plural). This is
+a speciality of the GNU implementation of these functions and we will
+say more about this in section @xref{Locating gettext catalog} when we
+talk about the ways message catalogs are selected.
+
+The @code{gettext} function does not modify the value of the global
+@var{errno} variable. This is necessary to make it possible to write
+something like
+
+@smallexample
+ printf (gettext ("Operation failed: %m\n"));
+@end smallexample
+
+Here the @var{errno} value is used in the @code{printf} function while
+processing the @code{%m} format element and if the @code{gettext}
+function would change this value (it is called before @code{printf} is
+called) we wouls get a wrong message.
+
+So there is no easy way to detect a missing message catalog beside
+comparing the argument string with the result. But it is normally the
+task of the user to react on missing catalogs. The program cannot guess
+when a message catalog is really necessary since for a user who s peaks
+the language the program was developed in does not need any translation.
+@end deftypefun
+
+The remaining two functions to access the message catalog add some
+functionality to select a message catalog which is not the default one.
+This is important if parts of the program are developed independently.
+Every part can have its own message catalog and all of them can be used
+at the same time. The C library itself is an example: internally it
+uses the @code{gettext} functions but since it must not depend on a
+currently selected default message catalog it must specify all ambiguous
+information.
+
+@deftypefun {char *} dgettext (const char *@var{domainname}, const char *@var{msgid})
+The @code{dgettext} functions acts just like the @code{gettext}
+function. It only takes an additional first argument @var{domainname}
+which guides the selection of the message catalogs which are searched
+for the translation. If the @var{domainname} parameter is the null
+pointer the @code{dgettext} function is exactly equivalent to
+@code{gettext} since the default value for the domain name is used.
+
+As for @code{gettext} the return value type is @code{char *} which is an
+anachronism. The returned string must never be modfied.
+@end deftypefun
+
+@deftypefun {char *} dcgettext (const char *@var{domainname}, const char *@var{msgid}, int @var{category})
+The @code{dcgettext} adds another argument to those which
+@code{dgettext} takes. This argument @var{category} specifies the last
+piece of information needed to localize the message catalog. I.e., the
+domain name and the locale category exactly specify which message
+catalog has to be used (relative to a given directory, see below).
+
+The @code{dgettext} function can be expressed in terms of
+@code{dcgettext} by using
+
+@smallexample
+dcgettext (domain, string, LC_MESSAGES)
+@end smallexample
+
+@noindent
+instead of
+
+@smallexample
+dgettext (domain, string)
+@end smallexample
+
+This also shows which values are expected for the third parameter. One
+has to use the available selectors for the categories available in
+@file{locale.h}. Normally the available values are @code{LC_CTYPE},
+@code{LC_COLLATE}, @code{LC_MESSAGES}, @code{LC_MONETARY},
+@code{LC_NUMERIC}, and @code{LC_TIME}. Please note that @code{LC_ALL}
+must not be used and even though the names might suggest this, there is
+no relation to the environments variables of this name.
+
+The @code{dcgettext} function is only implemented for compatibility with
+other systems which have @code{gettext} functions. There is not really
+any situation where it is necessary (or useful) to use a different value
+but @code{LC_MESSAGES} in for the @var{category} parameter. We are
+dealing with messages here and any other choice can only be irritating.
+
+As for @code{gettext} the return value type is @code{char *} which is an
+anachronism. The returned string must never be modfied.
+@end deftypefun
+
+When using the three functions above in a program it is a frequent case
+that the @var{msgid} argument is a constant string. So it is worth to
+optimize this case. Thinking shortly about this one will realize that
+as long as no new message catalog is loaded the translation of a message
+will not change. I.e., the algorithm to determine the translation is
+deterministic.
+
+Exactly this is what the optimizations implemented in the
+@file{libintl.h} header will use. Whenver a program is compiler with
+the GNU C compiler, optimization is selected and the @var{msgid}
+argument to @code{gettext}, @code{dgettext} or @code{dcgettext} is a
+constant string the actual function call will only be done the first
+time the message is used and then always only if any new message catalog
+was loaded and so the result of the translation lookup might be
+different. See the @file{libintl.h} header file for details. For the
+user it is only important to know that the result is always the same,
+independent of the compiler or compiler options in use.
+
+
+@node Locating gettext catalog
+@subsubsection How to determine which catalog to be used
+
+The functions to retrieve the translations for a given mesage have a
+remarkable simple interface. But to provide the user of the program
+still the opportunity to select exactly the translation s/he wants and
+also to provide the programmer the possibility to influence the way to
+locate the search for catalogs files there is a quite complicated
+underlying mechanism which controls all this. The code is complicated
+the use is easy.
+
+Basically we have two different tasks to perform which can also be
+performed by the @code{catgets} functions:
+
+@enumerate
+@item
+Locate the set of message catalogs. There are a number of files for
+different languages and which all belong to the package. Usually they
+are all stored in the filesystem below a certain directory.
+
+There can be arbitrary many packages installed and they can follow
+different guidelines for the placement of their files.
+
+@item
+Relative to the location specified by the package the actual translation
+files must be searched, based on the wishes of the user. I.e., for each
+language the user selects the program should be able to locate the
+appropriate file.
+@end enumerate
+
+This is the functionality required by the specifications for
+@code{gettext} and this is also what the @code{catgets} functions are
+able to do. But there are some problems unresolved:
+
+@itemize @bullet
+@item
+The language to be used can be specified in several different ways.
+There is no generally accepted standard for this and the user always
+expects the program understand what s/he means. E.g., to select the
+German translation one could write @code{de}, @code{german}, or
+@code{deutsch} and the program should always react the same.
+
+@item
+Sometimes the specification of the user is too detailed. If s/he, e.g.,
+specifies @code{de_DE.ISO-8859-1} which means German, spoken in Germany,
+coded using the @w{ISO 8859-1} character set there is the possibility
+that a message catalog matching this exactly is not available. But
+there could be a catalog matching @code{de} and if the character set
+used on the machine is always @w{ISO 8859-1} there is no reason why this
+later message catalog should not be used. (We call this @dfn{message
+inheritance}.)
+
+@item
+If a catalog for a wanted language is not available it is not always the
+second best choice to fall back on the language of the developer and
+simply not translate any message. Instead a user might be better able
+to read the messages in another language and so the user of the program
+should be able to define an precedence order of languages.
+@end itemize
+
+We can devide the configuration actions in two parts: the one is
+performed by the programmer, the other by the user. We will start with
+the functions the programmer can use since the user configuration will
+be based on this.
+
+As the functions described in the last sections already mention separate
+sets of messages can be selected by a @dfn{domain name}. This is a
+simple string which should be unique for each program part with uses a
+separate domain. It is possible to use in one program arbitrary many
+domains at the same time. E.g., the GNU C Library itself uses a domain
+named @code{libc} while the program using the C Library could use a
+domain named @code{foo}. The important point is that at any time
+exactly one domain is active. This is controlled with the following
+function.
+
+@deftypefun {char *} textdomain (const char *@var{domainname})
+The @code{textdomain} function sets the default domain, which is used in
+all future @code{gettext} calls, to @var{domainname}. Please note that
+@code{dgettext} and @code{dcgettext} calls are not influenced if the
+@var{domainname} parameter of these functions is not the null pointer.
+
+Before the first call to @code{textdomain} the default domain is
+@code{messages}. This is the name specified in the fpsecification of
+the @code{gettext} API. This name is as good as any other name. No
+program should ever really use a domain with this name since this can
+only lead to problems.
+
+The function returns the value which is from now on taken as the default
+domain. If the system went out of memory the returned value is
+@code{NULL} and the global variable @var{errno} is set to @code{ENOMEM}.
+Despite the return value type being @code{char *} the return string must
+not be changed. It is allocated internally by the @code{textdomain}
+function.
+
+If the @var{domainname} parameter is the null pointer no new default
+domain is set. Instead the currently selected default domain is
+returned.
+
+If the @var{domainname} parameter is the empty string the default domain
+is reset to its initial value, the domain with the name @code{messages}.
+This possibility is questionable to use since the domain @code{messages}
+really never should be used.
+@end deftypefun
+
+@deftypefun {char *} bindtextdomain (const char *@var{domainname}, const char *@var{dirname})
+The @code{bindtextdomain} function can be used to specify the directly
+which contains the message catalogs for domain @var{domainname} for the
+different languages. To be correct, this is the directory where the
+hierachy of directories is expected. Details are explained below.
+
+For the programmer it is important to note that the translations which
+come with the program have be placed in a directory hierachy starting
+at, say, @file{/foo/bar}. Then the program should make a
+@code{bindtextdomain} call to bind the domain for the current program to
+this directory. So it is made sure the catalogs are found. A correctly
+running program does not depend on the user setting an environment
+variable.
+
+The @code{bindtextdomain} function can be used several times and if the
+@var{domainname} argument is different the previously boundd domains
+will not be overwritten.
+
+If the @var{dirname} parameter is the null pointer @code{bindtextdomain}
+returns the currently selected directory for the domain with the name
+@var{domainname}.
+
+the @code{bindtextdomain} function returns a pointer to a string
+containing the name of the selected directory name. The string is
+allocated internally in the function and must not be changed by the
+user. If the system went out of core during the execution of
+@code{bindtextdomain} the return value is @code{NULL} and the global
+variable @var{errno} is set accordingly.
+@end deftypefun
+
+
+@node Using gettextized software
+@subsubsection User influence on @code{gettext}
+
+The last sections described what the programmer can do to
+internationalize the messages of the program. But it is finally up to
+the user to select the message s/he wants to see. S/He must understand
+them.
+
+The POSIX locale model uses the environment variables @code{LC_COLLATE},
+@code{LC_CTYPE}, @code{LC_MESSAGES}, @code{LC_MONETARY}, @code{NUMERIC},
+and @code{LC_TIME} to select the locale which is to be used. This way
+the user can influence lots of functions. As we mentioned above the
+@code{gettext} functions also take advantage of this.
+
+To understand how this happens it is necessary to take a look at the
+various components of the filename which gets computed to locate a
+message catalog. It is composed as follows:
+
+@smallexample
+@var{dir_name}/@var{locale}/LC_@var{category}/@var{domain_name}.mo
+@end smallexample
+
+The default value for @var{dir_name} is system specific. It is computed
+from the value given as the prefix while configuring the C library.
+This value normally is @file{/usr} or @file{/}. For the former the
+complete @var{dir_name} is:
+
+@smallexample
+/usr/share/locale
+@end smallexample
+
+We can use @file{/usr/share} since the @file{.mo} files containing the
+message catalogs are system independent, all systems can use the same
+files. If the program executed the @code{bindtextdomain} function for
+the message domain that is currently handled the @code{dir_name}
+component is the exactly the value which was given to the function as
+the second parameter. I.e., @code{bindtextdomain} allows to overwrite
+the only system depdendent and fixed value to make it possible to
+address file everywhere in the filesystem.
+
+The @var{category} is the name of the locale category which was selected
+in the program code. For @code{gettext} and @code{dgettext} this is
+always @code{LC_MESSAGES}, for @code{dcgettext} this is selected by the
+value of the third parameter. As said above it should be avoided to
+ever use a category other than @code{LC_MESSAGES}.
+
+The @var{locale} component is computed based on the category used. Just
+like for the @code{setlocale} function here comes the user selection
+into the play. Some environment variables are examined in a fixed order
+and the first environment variable set determines the return value of
+the lookup process. In detail, for the category @code{LC_xxx} the
+following variables in this order are examined:
+
+@table @code
+@item LANGUAGE
+@item LC_ALL
+@item LC_xxx
+@item LANG
+@end table
+
+This looks very familiar. With the exception of the @code{LANGUAGE}
+environment variable this is exactly the lookup order the
+@code{setlocale} function uses. But why introducing the @code{LANGUAGE}
+variable?
+
+The reason is that the syntax of the values these variables can have is
+different to what is expected by the @code{setlocale} function. If we
+would set @code{LC_ALL} to a value following the extended syntax that
+would mean the @code{setlocale} function will never be able to use the
+value of this variable as well. An additional variable removes this
+problem plus we can select the language independently of the locale
+setting which sometimes is useful.
+
+While for the @code{LC_xxx} variables the value should consist of
+exactly one specification of a locale the @code{LANGUAGE} variable's
+value can consist of a colon separated list of locale names. The
+attentive reader will realize that this is the way we manage to
+implement one of our additional demands above: we want to be able to
+specify an ordered list of language.
+
+Back to the constructed filename we have only one component missing.
+The @var{domain_name} part is the name which was either registered using
+the @code{textdomain} function or which was given to @code{dgettext} or
+@code{dcgettext} as the first parameter. Now it becomes obvious that a
+good choice for the domain name in the program code is a string which is
+closely related to the program/package name. E.g., for the GNU C
+Library the domain name is @code{libc}.
+
+@noindent
+A limit piece of example code should show how the programmer is supposed
+to work:
+
+@smallexample
+@{
+ textdomain ("test-package");
+ bindtextdomain ("test-package", "/usr/local/share/locale");
+ puts (gettext ("Hello, world!");
+@}
+@end smallexample
+
+At the program start the default domain is @code{messages}. The
+@code{textdomain} call changes this to @code{test-package}. The
+@code{bindtextdomain} call specifies that the message catalogs for the
+domain @code{test-package} can be found below the directory
+@file{/usr/local/share/locale}.
+
+If now the user set in her/his environment the variable @code{LANGUAGE}
+to @code{de} the @code{gettext} function will try to use the
+translations from the file
+
+@smallexample
+/usr/local/share/locale/de/LC_MESSAGES/test-package.mo
+@end smallexample
+
+From the above descriptions it should be clear which component of this
+filename is determined fromby which source.
+
+@c Describe:
+@c * message inheritence
+@c * locale aliasing
+@c * character set dependence
+
+
+@node Helper programs for gettext
+@subsection Programs to handle message catalogs for @code{gettext}
+
+@c Describe:
+@c * msgfmt
+@c * xgettext
+@c Mention:
+@c * other programs from GNU gettext
diff --git a/manual/search.texi b/manual/search.texi
index 26a8f82131..abb93bb5a8 100644
--- a/manual/search.texi
+++ b/manual/search.texi
@@ -1,4 +1,4 @@
-@node Searching and Sorting, Pattern Matching, Locales, Top
+@node Searching and Sorting, Pattern Matching, Message Translation, Top
@chapter Searching and Sorting
This chapter describes functions for searching and sorting arrays of
diff --git a/manual/startup.texi b/manual/startup.texi
index e61a755456..fab74edbef 100644
--- a/manual/startup.texi
+++ b/manual/startup.texi
@@ -278,9 +278,9 @@ character, since this is assumed to terminate the string.
@menu
* Environment Access:: How to get and set the values of
- environment variables.
+ environment variables.
* Standard Environment:: These environment variables have
- standard interpretations.
+ standard interpretations.
@end menu
@node Environment Access
@@ -290,7 +290,9 @@ character, since this is assumed to terminate the string.
The value of an environment variable can be accessed with the
@code{getenv} function. This is declared in the header file
-@file{stdlib.h}.
+@file{stdlib.h}. All of the following functions can be safely used in
+multi-threaded programs. It is made sure that concurrent modifications
+to the environment do not lead to errors.
@pindex stdlib.h
@comment stdlib.h
@@ -314,11 +316,62 @@ definition is added to the environment. Otherwise, the @var{string} is
interpreted as the name of an environment variable, and any definition
for this variable in the environment is removed.
-The GNU library provides this function for compatibility with SVID; it
-may not be available in other systems.
+This function is part of the extended Unix interface. Since it was also
+available in old SVID libraries you should define either
+@var{_XOPEN_SOURCE} or @var{_SVID_SOURCE} before including any header.
+@end deftypefun
+
+
+@comment stdlib.h
+@comment BSD
+@deftypefun int setenv (const char *@var{name}, const char *@var{value}, int @var{replace})
+The @code{setenv} function can be used to add a new definition to the
+environment. The entry with the name @var{name} is replaced by the
+value @samp{@var{name}=@var{value}}. Please note that this is also true
+if @var{value} is the empty string. A null pointer for the @var{value}
+parameter is illegal. If the environment already contains an entry with
+key @var{name} the @var{replace} parameter controls the action. If
+replace is zero, nothing happens. otherwise the old entry is replaced
+by the new one.
+
+Please note that you cannot remove an entry completely using this function.
+
+This function is part of the BSD library. The GNU C Library provides
+this function for compatibility but it may not be available on other
+systems.
+@end deftypefun
+
+@comment stdlib.h
+@comment BSD
+@deftypefun void unsetenv (const char *@var{name})
+Using this function one can remove an entry completely from the
+environment. If the environment contains an entry with the key
+@var{name} this whole entry is removed. A call to this function is
+equivalent to a call to @code{putenv} when the @var{value} part of the
+string is empty.
+
+This function is part of the BSD library. The GNU C Library provides
+this function for compatibility but it may not be available on other
+systems.
+@end deftypefun
+
+There is one more function to modify the whole environment. This
+function is said to be used in the POSIX.9 (POSIX bindings for Fortran
+77) and so one should expect it did made it into POSIX.1. But this
+never happened. But we still provide this function as a GNU extension
+to enable writing standard compliant Fortran environments.
+
+@comment stdlib.h
+@comment GNU
+@deftypefun int clearenv (void)
+The @code{clearenv} function removes all entries from the environment.
+Using @code{putenv} and @code{setenv} new entries can be added again
+later.
+
+If the function is successful it returns @code{0}. Otherwise the return
+value is nonzero.
@end deftypefun
-@c !!! BSD function setenv
You can deal directly with the underlying representation of environment
objects to add more variables to the environment (for example, to
@@ -444,6 +497,14 @@ attribute category environment variables, or for the @code{LANG}
environment variable.
@end ignore
+@item LC_ALL
+@cindex LC_ALL environment variable
+
+If this environment variable is set it overrides the selection for all
+the locales done using the other @code{LC_*} environment variables. The
+value of the other @code{LC_*} environment variables is simply ignored
+in this case.
+
@item LC_COLLATE
@cindex LC_COLLATE environment variable
@@ -455,6 +516,12 @@ This specifies what locale to use for string sorting.
This specifies what locale to use for character sets and character
classification.
+@item LC_MESSAGES
+@cindex LC_MESSAGES environment variable
+
+This specifies what locale to use for printing messages and to parse
+reponses.
+
@item LC_MONETARY
@cindex LC_MONETARY environment variable
@@ -470,6 +537,12 @@ This specifies what locale to use for formatting numbers.
This specifies what locale to use for formatting date/time values.
+@item NLSPATH
+@cindex NLSPATH environment variable
+
+This specifies the directories in which the @code{catopen} function
+looks for message translation catalogs.
+
@item _POSIX_OPTION_ORDER
@cindex _POSIX_OPTION_ORDER environment variable.
diff --git a/manual/string.texi b/manual/string.texi
index 46101ded99..07ed35b8ab 100644
--- a/manual/string.texi
+++ b/manual/string.texi
@@ -365,7 +365,7 @@ string has the same limitations as any block of memory allocated using
@code{alloca}.
For obvious reasons @code{strdupa} is implemented only as a macro. I.e.,
-you cannot get the address of this function. Despite this limitations
+you cannot get the address of this function. Despite this limitation
it is a useful function. The following code shows a situation where
using @code{malloc} would be a lot more expensive.
@@ -374,7 +374,7 @@ using @code{malloc} would be a lot more expensive.
@end smallexample
Please note that calling @code{strtok} using @var{path} directly is
-illegal.
+invalid.
This function is only available if GNU CC is used.
@end deftypefun
diff --git a/math/Makefile b/math/Makefile
index 44b4e7de3e..3b1ff4332b 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -80,9 +80,7 @@ tests = test-float test-double $(test-longdouble-$(long-double-fcts)) \
test-ifloat test-idouble test-matherr test-fenv
# We do the `long double' tests only if this data type is available and
# distrinct from `double'.
-#
-# XXX This test is disabled for now since the functions are too buggy.
-#test-longdouble-yes = test-ldouble test-ildoubl
+test-longdouble-yes = test-ldouble test-ildoubl
CFLAGS-test-float.c = -fno-inline
CFLAGS-test-double.c = -fno-inline
diff --git a/nis/Makefile b/nis/Makefile
index e7dd50c1d9..9b72429f8f 100644
--- a/nis/Makefile
+++ b/nis/Makefile
@@ -55,15 +55,15 @@ libnsl-routines = yp_xdr ypclnt ypupdate_xdr \
libnsl-map = libnsl.map
libnss_compat-routines := $(addprefix compat-,grp pwd spwd) nisplus-parser
-libnss_compat-inhibit-o = $(filter-out .so,$(object-suffixes))
+libnss_compat-inhibit-o = $(filter-out .os,$(object-suffixes))
libnss_compat-map := libnss_compat.map
libnss_nis-routines := $(addprefix nis-,$(databases))
-libnss_nis-inhibit-o = $(filter-out .so,$(object-suffixes))
+libnss_nis-inhibit-o = $(filter-out .os,$(object-suffixes))
libnss_nis-map := libnss_nis.map
libnss_nisplus-routines := $(addprefix nisplus-,$(databases)) nisplus-parser
-libnss_nisplus-inhibit-o = $(filter-out .so,$(object-suffixes))
+libnss_nisplus-inhibit-o = $(filter-out .os,$(object-suffixes))
libnss_nisplus-map := libnss_nisplus.map
include ../Rules
diff --git a/nis/nss_nisplus/nisplus-publickey.c b/nis/nss_nisplus/nisplus-publickey.c
index 554da95754..99ec2a08ec 100644
--- a/nis/nss_nisplus/nisplus-publickey.c
+++ b/nis/nss_nisplus/nisplus-publickey.c
@@ -39,6 +39,7 @@ _nss_nisplus_getpublickey (const char *netname, char *pkey)
nis_result *res;
enum nss_status retval;
char buf[NIS_MAXNAMELEN+2];
+ size_t slen;
char *domain, *cptr;
int len;
@@ -55,12 +56,15 @@ _nss_nisplus_getpublickey (const char *netname, char *pkey)
return NSS_STATUS_UNAVAIL;
domain++;
- snprintf (buf, NIS_MAXNAMELEN,
- "[auth_name=%s,auth_type=DES],cred.org_dir.%s",
- netname, domain);
+ slen = snprintf (buf, NIS_MAXNAMELEN,
+ "[auth_name=%s,auth_type=DES],cred.org_dir.%s",
+ netname, domain);
- if (buf[strlen (buf)-1] != '.')
- strcat (buf, ".");
+ if (buf[slen - 1] != '.')
+ {
+ buf[slen++] = '.';
+ buf[slen] = '\0';
+ }
res = nis_list (buf, USE_DGRAM+NO_AUTHINFO+FOLLOW_LINKS+FOLLOW_PATH,
NULL, NULL);
@@ -107,6 +111,7 @@ _nss_nisplus_getsecretkey (const char *netname, char *skey, char *passwd)
nis_result *res;
enum nss_status retval;
char buf[NIS_MAXNAMELEN+2];
+ size_t slen;
char *domain, *cptr;
int len;
@@ -123,12 +128,15 @@ _nss_nisplus_getsecretkey (const char *netname, char *skey, char *passwd)
return NSS_STATUS_UNAVAIL;
domain++;
- snprintf (buf, NIS_MAXNAMELEN,
- "[auth_name=%s,auth_type=DES],cred.org_dir.%s",
- netname, domain);
+ slen = snprintf (buf, NIS_MAXNAMELEN,
+ "[auth_name=%s,auth_type=DES],cred.org_dir.%s",
+ netname, domain);
- if (buf[strlen(buf)-1] != '.')
- strcat(buf, ".");
+ if (buf[slen - 1] != '.')
+ {
+ buf[slen++] = '.';
+ buf[slen] = '\0';
+ }
res = nis_list (buf, USE_DGRAM+NO_AUTHINFO+FOLLOW_LINKS+FOLLOW_PATH,
NULL, NULL);
@@ -187,7 +195,7 @@ parse_grp_str (const char *s, gid_t *gidp, int *gidlenp, gid_t *gidlist)
if (!s || (!isdigit (*s)))
{
- syslog (LOG_ERR, "netname2user: missing group id list in '%s'.", s);
+ syslog (LOG_ERR, _("netname2user: missing group id list in '%s'."), s);
return NSS_STATUS_NOTFOUND;
}
@@ -212,6 +220,7 @@ _nss_nisplus_netname2user (char netname[MAXNETNAMELEN + 1], uid_t *uidp,
char *domain;
nis_result *res;
char sname[NIS_MAXNAMELEN+1]; /* search criteria + table name */
+ size_t slen;
char principal[NIS_MAXNAMELEN+1];
int len;
@@ -227,11 +236,15 @@ _nss_nisplus_netname2user (char netname[MAXNETNAMELEN + 1], uid_t *uidp,
(size_t) NIS_MAXNAMELEN)
return NSS_STATUS_UNAVAIL;
- snprintf (sname, NIS_MAXNAMELEN,
- "[auth_name=%s,auth_type=DES],cred.org_dir.%s",
- netname, domain);
- if (sname[strlen (sname) - 1] != '.')
- strcat(sname, ".");
+ slen = snprintf (sname, NIS_MAXNAMELEN,
+ "[auth_name=%s,auth_type=DES],cred.org_dir.%s",
+ netname, domain);
+
+ if (sname[slen - 1] != '.')
+ {
+ sname[slen++] = '.';
+ sname[slen] = '\0';
+ }
/* must use authenticated call here */
/* XXX but we cant, for now. XXX */
@@ -250,12 +263,12 @@ _nss_nisplus_netname2user (char netname[MAXNETNAMELEN + 1], uid_t *uidp,
return NSS_STATUS_NOTFOUND;
case NIS_S_NOTFOUND:
case NIS_TRYAGAIN:
- syslog (LOG_ERR, "netname2user: (nis+ lookup): %s\n",
+ syslog (LOG_ERR, _("netname2user: (nis+ lookup): %s\n"),
nis_sperrno (res->status));
nis_freeresult (res);
return NSS_STATUS_TRYAGAIN;
default:
- syslog (LOG_ERR, "netname2user: (nis+ lookup): %s\n",
+ syslog (LOG_ERR, _("netname2user: (nis+ lookup): %s\n"),
nis_sperrno (res->status));
nis_freeresult (res);
return NSS_STATUS_UNAVAIL;
@@ -286,17 +299,21 @@ _nss_nisplus_netname2user (char netname[MAXNETNAMELEN + 1], uid_t *uidp,
* LOCAL entry in **local** cred table.
*/
domain = nis_local_directory ();
- if ((strlen (principal)+strlen (domain)+45) >
- (size_t) NIS_MAXNAMELEN)
+ if ((strlen (principal) + strlen (domain) + 45) > (size_t) NIS_MAXNAMELEN)
{
syslog (LOG_ERR, _("netname2user: principal name '%s' too long"),
principal);
return NSS_STATUS_UNAVAIL;
}
- sprintf (sname, "[cname=%s,auth_type=LOCAL],cred.org_dir.%s",
- principal, domain);
- if (sname[strlen(sname) - 1] != '.')
- strcat(sname, ".");
+
+ slen = sprintf (sname, "[cname=%s,auth_type=LOCAL],cred.org_dir.%s",
+ principal, domain);
+
+ if (sname[slen - 1] != '.')
+ {
+ sname[slen++] = '.';
+ sname[slen] = '\0';
+ }
/* must use authenticated call here */
/* XXX but we cant, for now. XXX */
@@ -312,7 +329,7 @@ _nss_nisplus_netname2user (char netname[MAXNETNAMELEN + 1], uid_t *uidp,
return NSS_STATUS_NOTFOUND;
case NIS_S_NOTFOUND:
case NIS_TRYAGAIN:
- syslog (LOG_ERR, "netname2user: (nis+ lookup): %s\n",
+ syslog (LOG_ERR, _("netname2user: (nis+ lookup): %s\n"),
nis_sperrno (res->status));
nis_freeresult (res);
return NSS_STATUS_TRYAGAIN;
@@ -320,7 +337,7 @@ _nss_nisplus_netname2user (char netname[MAXNETNAMELEN + 1], uid_t *uidp,
case NIS_S_SUCCESS:
break; /* go and do something useful */
default:
- syslog (LOG_ERR, "netname2user: (nis+ lookup): %s\n",
+ syslog (LOG_ERR, _("netname2user: (nis+ lookup): %s\n"),
nis_sperrno (res->status));
nis_freeresult (res);
return NSS_STATUS_UNAVAIL;
@@ -333,9 +350,9 @@ _nss_nisplus_netname2user (char netname[MAXNETNAMELEN + 1], uid_t *uidp,
* Something wrong with cred table.
* Warn user and continue.
*/
- syslog(LOG_ALERT,
- _("netname2user: LOCAL entry for %s in directory %s not unique"),
- netname, domain);
+ syslog (LOG_ALERT,
+ _("netname2user: LOCAL entry for %s in directory %s not unique"),
+ netname, domain);
}
/* Fetch the uid */
*uidp = atoi (ENTRY_VAL (res->objects.objects_val, 2));
diff --git a/nss/Makefile b/nss/Makefile
index 90e5521d5b..fae12eb652 100644
--- a/nss/Makefile
+++ b/nss/Makefile
@@ -62,8 +62,8 @@ distribute += db-XXX.c
ifneq ($(build-static-nss),yes)
-libnss_files-inhibit-o = $(filter-out .so,$(object-suffixes))
-libnss_db-inhibit-o = $(filter-out .so,$(object-suffixes))
+libnss_files-inhibit-o = $(filter-out .os,$(object-suffixes))
+libnss_db-inhibit-o = $(filter-out .os,$(object-suffixes))
endif
diff --git a/posix/glob.h b/posix/glob.h
index 515514a4c2..713117bd7e 100644
--- a/posix/glob.h
+++ b/posix/glob.h
@@ -1,8 +1,5 @@
/* Copyright (C) 1991, 1992, 1995, 1996, 1997 Free Software Foundation, Inc.
- This file is part of the GNU C Library. Its master source is NOT part of
- the C library, however. The master source lives in /gd/gnu/lib.
-
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
@@ -27,17 +24,21 @@ extern "C"
#endif
#undef __ptr_t
-#if (defined (__cplusplus) || (defined (__STDC__) && __STDC__) \
- || defined (WINDOWS32))
-#undef __P
-#define __P(protos) protos
-#define __ptr_t void *
+#if (defined __cplusplus || (defined __STDC__ && __STDC__) \
+ || defined WINDOWS32)
+# undef __P
+# define __P(protos) protos
+# define __ptr_t void *
+# if !defined __GNUC__ || __GNUC__ < 2
+# undef __const
+# define __const const
+# endif
#else /* Not C++ or ANSI C. */
-#undef __P
-#define __P(protos) ()
-#undef const
-#define const
-#define __ptr_t char *
+# undef __P
+# define __P(protos) ()
+# undef __const
+# define __const
+# define __ptr_t char *
#endif /* C++ or ANSI C. */
/* Bits set in the FLAGS argument to `glob'. */
@@ -49,17 +50,22 @@ extern "C"
#define GLOB_APPEND (1 << 5)/* Append to results of a previous call. */
#define GLOB_NOESCAPE (1 << 6)/* Backslashes don't quote metacharacters. */
#define GLOB_PERIOD (1 << 7)/* Leading `.' can be matched by metachars. */
-#define __GLOB_FLAGS (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \
+
+#if (!defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 2 || defined _BSD_SOURCE \
+ || defined _GNU_SOURCE)
+# define GLOB_MAGCHAR (1 << 8)/* Set in gl_flags if any metachars seen. */
+# define GLOB_ALTDIRFUNC (1 << 9)/* Use gl_opendir et al functions. */
+# define GLOB_BRACE (1 << 10)/* Expand "{a,b}" to "a" "b". */
+# define GLOB_NOMAGIC (1 << 11)/* If no magic chars, return the pattern. */
+# define GLOB_TILDE (1 <<12)/* Expand ~user and ~ to home directories. */
+# define __GLOB_FLAGS (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \
GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND| \
GLOB_PERIOD|GLOB_ALTDIRFUNC|GLOB_BRACE| \
GLOB_NOMAGIC|GLOB_TILDE)
-
-#if !defined (_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 2 || defined (_BSD_SOURCE) || defined (_GNU_SOURCE)
-#define GLOB_MAGCHAR (1 << 8)/* Set in gl_flags if any metachars seen. */
-#define GLOB_ALTDIRFUNC (1 << 9)/* Use gl_opendir et al functions. */
-#define GLOB_BRACE (1 << 10)/* Expand "{a,b}" to "a" "b". */
-#define GLOB_NOMAGIC (1 << 11)/* If no magic chars, return the pattern. */
-#define GLOB_TILDE (1 <<12)/* Expand ~user and ~ to home directories. */
+#else
+# define __GLOB_FLAGS (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \
+ GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND| \
+ GLOB_PERIOD)
#endif
/* Error returns from `glob'. */
@@ -74,7 +80,7 @@ extern "C"
#endif
/* Structure describing a globbing run. */
-#if !defined (_AMIGA) && !defined (VMS) /* Buggy compiler. */
+#if !defined _AMIGA && !defined VMS /* Buggy compiler. */
struct stat;
#endif
typedef struct
@@ -88,9 +94,9 @@ typedef struct
are used instead of the normal file access functions. */
void (*gl_closedir) __P ((void *));
struct dirent *(*gl_readdir) __P ((void *));
- __ptr_t (*gl_opendir) __P ((const char *));
- int (*gl_lstat) __P ((const char *, struct stat *));
- int (*gl_stat) __P ((const char *, struct stat *));
+ __ptr_t (*gl_opendir) __P ((__const char *));
+ int (*gl_lstat) __P ((__const char *, struct stat *));
+ int (*gl_stat) __P ((__const char *, struct stat *));
} glob_t;
/* Do glob searching for PATTERN, placing results in PGLOB.
@@ -101,8 +107,8 @@ typedef struct
`glob' returns GLOB_ABEND; if it returns zero, the error is ignored.
If memory cannot be allocated for PGLOB, GLOB_NOSPACE is returned.
Otherwise, `glob' returns zero. */
-extern int glob __P ((const char *__pattern, int __flags,
- int (*__errfunc) __P ((const char *, int)),
+extern int glob __P ((__const char *__pattern, int __flags,
+ int (*__errfunc) __P ((__const char *, int)),
glob_t *__pglob));
/* Free storage allocated in PGLOB by a previous `glob' call. */
diff --git a/posix/wordexp.c b/posix/wordexp.c
index 2f6f0815d5..e89f30d628 100644
--- a/posix/wordexp.c
+++ b/posix/wordexp.c
@@ -21,7 +21,6 @@
#include <wordexp.h>
#include <signal.h>
#include <stdlib.h>
-#include <stdio.h>
#include <pwd.h>
#include <sys/types.h>
#include <string.h>
@@ -35,6 +34,8 @@
#include <sys/stat.h>
#include <paths.h>
#include <errno.h>
+#include <sys/param.h>
+#include <stdio.h>
#include <assert.h>
@@ -43,72 +44,75 @@
*/
/* Some forward declarations */
-static int
-parse_dollars (char **word, size_t *word_length, const char *words,
- size_t *offset, int flags, wordexp_t *pwordexp);
-static int
-parse_backtick (char **word, size_t *word_length, const char *words,
- size_t *offset, int flags, wordexp_t *pwordexp);
-
-static int
-eval_expr (char *expr, int *result);
+static int parse_dollars (char **word, size_t *word_length, size_t *max_length,
+ const char *words, size_t *offset, int flags,
+ wordexp_t *pwordexp);
+static int parse_backtick (char **word, size_t *word_length,
+ size_t *max_length, const char *words,
+ size_t *offset, int flags, wordexp_t *pwordexp);
+static int eval_expr (char *expr, int *result);
/* The w_*() functions manipulate word lists. */
-static char*
-w_extend (char *word, size_t *word_length, size_t by)
+#define W_CHUNK (100)
+
+static inline char *
+w_addchar (char *buffer, size_t *actlen, size_t *maxlen, char ch)
+ /* (lengths exclude trailing zero) */
{
- /* Extend the allocated size of word by 'by' characters
- * (from *word_length).
+ /* Add a character to the buffer, allocating room for it if needed.
*/
- char* newword;
- size_t new_length;
- if (word == NULL)
- *word_length = 0;
-
- new_length = *word_length + by;
- newword = realloc (word, 1 + new_length);
- if (newword != NULL)
+ if (*actlen == *maxlen)
{
- *word_length = new_length;
+ char *old_buffer = buffer;
+ assert (buffer == NULL || *maxlen != 0);
+ *maxlen += W_CHUNK;
+ buffer = realloc (buffer, 1 + *maxlen);
+
+ if (buffer == NULL)
+ free (old_buffer);
+ }
- newword[*word_length] = 0;
+ if (buffer != NULL)
+ {
+ buffer[*actlen] = ch;
+ buffer[++(*actlen)] = '\0';
}
- return newword;
+
+ return buffer;
}
-static char*
-w_addstr (char *word, size_t *word_length, const char *str)
+static char *
+w_addstr (char *buffer, size_t *actlen, size_t *maxlen, const char *str)
+ /* (lengths exclude trailing zero) */
{
- /* Add a string to 'word', allocating room for it.
+ /* Add a string to the buffer, allocating room for it if needed.
*/
- char* newword;
- size_t new_length;
+ size_t len;
- if (word == NULL)
- *word_length = '\0';
+ assert (str != NULL); /* w_addstr only called from this file */
+ len = strlen (str);
- new_length = *word_length + strlen (str);
- newword = realloc (word, 1 + new_length);
- if (newword != NULL)
+ if (*actlen + len > *maxlen)
{
- strcpy (&newword[*word_length], str);
- *word_length = new_length;
+ char *old_buffer = buffer;
+ assert (buffer == NULL || *maxlen != 0);
+ *maxlen += MAX (2 * len, W_CHUNK);
+ buffer = realloc (old_buffer, 1 + *maxlen);
+
+ if (buffer == NULL)
+ free (old_buffer);
}
- return newword;
-}
-static inline char*
-w_addchar (char *word, size_t *word_length, char ch)
-{
- /* Add a character to 'word', allocating room for it.
- */
- char* newword = w_extend (word, word_length, 1);
+ if (buffer != NULL)
+ {
+ memcpy (&buffer[*actlen], str, len);
+ *actlen += len;
+ buffer[*actlen] = '\0';
+ }
- if (newword != NULL)
- newword[*word_length - 1] = ch;
- return newword;
+ return buffer;
}
static int
@@ -134,8 +138,8 @@ w_addword (wordexp_t *pwordexp, char *word)
*/
static int
-parse_backslash (char **word, size_t *word_length, const char *words,
- size_t *offset)
+parse_backslash (char **word, size_t *word_length, size_t *max_length,
+ const char *words, size_t *offset)
{
/* We are poised _at_ a backslash, not in quotes */
@@ -146,15 +150,15 @@ parse_backslash (char **word, size_t *word_length, const char *words,
return WRDE_SYNTAX;
case '\n':
- ++(*offset);
+ (*offset)++;
break;
default:
- *word = w_addchar (*word, word_length, words[1 + *offset]);
+ *word = w_addchar (*word, word_length, max_length, words[1 + *offset]);
if (*word == NULL)
return WRDE_NOSPACE;
- ++(*offset);
+ (*offset)++;
break;
}
@@ -162,8 +166,8 @@ parse_backslash (char **word, size_t *word_length, const char *words,
}
static int
-parse_qtd_backslash (char **word, size_t *word_length, const char *words,
- size_t *offset)
+parse_qtd_backslash (char **word, size_t *word_length, size_t *max_length,
+ const char *words, size_t *offset)
{
/* We are poised _at_ a backslash, inside quotes */
@@ -181,21 +185,22 @@ parse_qtd_backslash (char **word, size_t *word_length, const char *words,
case '`':
case '"':
case '\\':
- *word = w_addchar (*word, word_length, words[1 + *offset]);
+ *word = w_addchar (*word, word_length, max_length, words[1 + *offset]);
if (*word == NULL)
return WRDE_NOSPACE;
- (*offset)++;
+ ++(*offset);
break;
default:
- *word = w_extend (*word, word_length, 2);
+ *word = w_addchar (*word, word_length, max_length, words[*offset]);
+ if (*word != NULL)
+ *word = w_addchar (*word, word_length, max_length, words[1 + *offset]);
+
if (*word == NULL)
return WRDE_NOSPACE;
- (*word)[*word_length - 1] = words[1 + *offset];
- (*word)[*word_length - 2] = words[*offset];
- (*offset)++;
+ ++(*offset);
break;
}
@@ -203,8 +208,8 @@ parse_qtd_backslash (char **word, size_t *word_length, const char *words,
}
static int
-parse_tilde (char **word, size_t *word_length, const char *words,
- size_t *offset, size_t wordc)
+parse_tilde (char **word, size_t *word_length, size_t *max_length,
+ const char *words, size_t *offset, size_t wordc)
{
/* We are poised _at_ a tilde */
size_t i;
@@ -214,9 +219,9 @@ parse_tilde (char **word, size_t *word_length, const char *words,
if (!((*word)[*word_length - 1] == '=' && wordc == 0))
{
if (!((*word)[*word_length - 1] == ':' &&
- strchr(*word, '=') && wordc == 0))
+ strchr (*word, '=') && wordc == 0))
{
- *word = w_addchar (*word, word_length, '~');
+ *word = w_addchar (*word, word_length, max_length, '~');
return *word ? 0 : WRDE_NOSPACE;
}
}
@@ -225,12 +230,12 @@ parse_tilde (char **word, size_t *word_length, const char *words,
for (i = 1 + *offset; words[i]; i++)
{
if (words[i] == ':' || words[i] == '/' || words[i] == ' ' ||
- words[i] == '\t' || words[i] == 0 )
+ words[i] == '\t' || words[i] == 0 )
break;
if (words[i] == '\\')
{
- *word = w_addchar (*word, word_length, '~');
+ *word = w_addchar (*word, word_length, max_length, '~');
return *word ? 0 : WRDE_NOSPACE;
}
}
@@ -255,13 +260,13 @@ parse_tilde (char **word, size_t *word_length, const char *words,
if (result == 0 && pwd.pw_dir != NULL)
{
- *word = w_addstr (*word, word_length, pwd.pw_dir);
+ *word = w_addstr (*word, word_length, max_length, pwd.pw_dir);
if (*word == NULL)
return WRDE_NOSPACE;
}
else
{
- *word = w_addchar (*word, word_length, '~');
+ *word = w_addchar (*word, word_length, max_length, '~');
if (*word == NULL)
return WRDE_NOSPACE;
}
@@ -269,7 +274,7 @@ parse_tilde (char **word, size_t *word_length, const char *words,
else
{
/* Look up user name in database to get home directory */
- char *user = strndupa (&words[1 + *offset], i - *offset);
+ char *user = __strndup (&words[1 + *offset], i - *offset);
struct passwd pwd, *tpwd;
int buflen = 1000;
char* buffer = __alloca (buflen);
@@ -283,13 +288,13 @@ parse_tilde (char **word, size_t *word_length, const char *words,
}
if (result == 0 && pwd.pw_dir)
- *word = w_addstr (*word, word_length, pwd.pw_dir);
+ *word = w_addstr (*word, word_length, max_length, pwd.pw_dir);
else
{
/* (invalid login name) */
- *word = w_addchar (*word, word_length, '~');
+ *word = w_addchar (*word, word_length, max_length, '~');
if (*word != NULL)
- *word = w_addstr (*word, word_length, user);
+ *word = w_addstr (*word, word_length, max_length, user);
}
*offset = i - 1;
@@ -298,14 +303,15 @@ parse_tilde (char **word, size_t *word_length, const char *words,
}
static int
-parse_glob (char **word, size_t *word_length, const char *words,
- size_t *offset, int flags, wordexp_t *pwordexp, char *ifs)
+parse_glob (char **word, size_t *word_length, size_t *max_length,
+ const char *words, size_t *offset, int flags,
+ wordexp_t *pwordexp, char *ifs)
{
/* We are poised just after a '*' or a '{'. */
int error;
glob_t globbuf;
int match;
- char * matching_word;
+ char *matching_word;
for (; words[*offset]; (*offset)++)
switch (words[*offset])
@@ -315,8 +321,8 @@ parse_glob (char **word, size_t *word_length, const char *words,
break;
case '$':
- error = parse_dollars (word, word_length, words, offset, flags,
- pwordexp);
+ error = parse_dollars (word, word_length, max_length, words, offset,
+ flags, pwordexp);
if (error)
return error;
@@ -325,7 +331,7 @@ parse_glob (char **word, size_t *word_length, const char *words,
default:
if (ifs == NULL || strchr (ifs, words[*offset]) == NULL)
{
- *word = w_addchar (*word, word_length, words[*offset]);
+ *word = w_addchar (*word, word_length, max_length, words[*offset]);
if (*word == NULL)
return WRDE_NOSPACE;
@@ -355,11 +361,12 @@ parse_glob (char **word, size_t *word_length, const char *words,
strcpy (*word, globbuf.gl_pathv[0]);
- for (match = 1; match < globbuf.gl_pathc; ++match)
+ for (match = 1; match < globbuf.gl_pathc && *word != NULL; ++match)
{
- *word = w_addchar (*word, word_length, ' ');
+ *word = w_addchar (*word, word_length, max_length, ' ');
if (*word != NULL)
- *word = w_addstr (*word, word_length, globbuf.gl_pathv[match]);
+ *word = w_addstr (*word, word_length, max_length,
+ globbuf.gl_pathv[match]);
}
/* Re-parse white space on return */
@@ -383,11 +390,10 @@ parse_glob (char **word, size_t *word_length, const char *words,
for (match = 1; match < globbuf.gl_pathc; ++match)
{
- matching_word = malloc (1 + strlen (globbuf.gl_pathv[match]));
+ matching_word = __strdup (globbuf.gl_pathv[match]);
if (matching_word == NULL)
goto no_space;
- strcpy (matching_word, globbuf.gl_pathv[match]);
if (w_addword (pwordexp, matching_word) == WRDE_NOSPACE)
goto no_space;
}
@@ -404,15 +410,15 @@ no_space:
}
static int
-parse_squote (char **word, size_t *word_length, const char *words,
- size_t *offset)
+parse_squote (char **word, size_t *word_length, size_t *max_length,
+ const char *words, size_t *offset)
{
/* We are poised just after a single quote */
for (; words[*offset]; ++(*offset))
{
if (words[*offset] != '\'')
{
- *word = w_addchar (*word, word_length, words[*offset]);
+ *word = w_addchar (*word, word_length, max_length, words[*offset]);
if (*word == NULL)
return WRDE_NOSPACE;
}
@@ -446,7 +452,7 @@ eval_expr_val (char **expr, int *result)
*(*expr)++ = 0;
- if (eval_expr(digit, result))
+ if (eval_expr (digit, result))
return WRDE_SYNTAX;
return 0;
@@ -466,7 +472,7 @@ eval_expr_val (char **expr, int *result)
}
*result = 0;
- for (; *digit && isdigit(*digit); ++digit)
+ for (; *digit && isdigit (*digit); ++digit)
*result = (*result * 10) + (*digit - '0');
*expr = digit;
@@ -547,24 +553,22 @@ eval_expr (char *expr, int *result)
}
static int
-parse_arith (char **word, size_t *word_length, const char *words,
- size_t *offset, int flags, int bracket)
+parse_arith (char **word, size_t *word_length, size_t *max_length,
+ const char *words, size_t *offset, int flags, int bracket)
{
/* We are poised just after "$((" or "$[" */
int error;
int paren_depth = 1;
size_t expr_length = 0;
- char *expr = calloc (1, sizeof (char)); /* ??? */
-
- if (expr == NULL)
- return WRDE_NOSPACE;
+ size_t expr_maxlen = 0;
+ char *expr = NULL;
for (; words[*offset]; ++(*offset))
{
switch (words[*offset])
{
case '$':
- error = parse_dollars (&expr, &expr_length,
+ error = parse_dollars (&expr, &expr_length, &expr_maxlen,
words, offset, flags, NULL);
/* The NULL here is to tell parse_dollars not to
* split the fields.
@@ -578,7 +582,7 @@ parse_arith (char **word, size_t *word_length, const char *words,
case '`':
(*offset)++;
- error = parse_backtick (&expr, &expr_length,
+ error = parse_backtick (&expr, &expr_length, &expr_maxlen,
words, offset, flags, NULL);
/* The NULL here is to tell parse_backtick not to
* split the fields.
@@ -591,7 +595,8 @@ parse_arith (char **word, size_t *word_length, const char *words,
break;
case '\\':
- error = parse_qtd_backslash (&expr, &expr_length, words, offset);
+ error = parse_qtd_backslash (&expr, &expr_length, &expr_maxlen,
+ words, offset);
if (error)
{
free (expr);
@@ -621,11 +626,11 @@ parse_arith (char **word, size_t *word_length, const char *words,
result = __alloca (100);
__snprintf (result, 100, "%d", numresult);
- *word = w_addstr (*word, word_length, result);
+ *word = w_addstr (*word, word_length, max_length, result);
free (expr);
return *word ? 0 : WRDE_NOSPACE;
}
- expr = w_addchar (expr, &expr_length, words[*offset]);
+ expr = w_addchar (expr, &expr_length, &expr_maxlen, words[*offset]);
if (expr == NULL)
return WRDE_NOSPACE;
@@ -643,7 +648,7 @@ parse_arith (char **word, size_t *word_length, const char *words,
result = __alloca (100);
__snprintf (result, 100, "%d", numresult);
- *word = w_addstr (*word, word_length, result);
+ *word = w_addstr (*word, word_length, max_length, result);
free (expr);
return *word ? 0 : WRDE_NOSPACE;
}
@@ -661,7 +666,7 @@ parse_arith (char **word, size_t *word_length, const char *words,
case '(':
++paren_depth;
default:
- expr = w_addchar (expr, &expr_length, words[*offset]);
+ expr = w_addchar (expr, &expr_length, &expr_maxlen, words[*offset]);
if (expr == NULL)
return WRDE_NOSPACE;
}
@@ -675,10 +680,10 @@ parse_arith (char **word, size_t *word_length, const char *words,
/* Function to execute a command and retrieve the results */
/* pwordexp contains NULL if field-splitting is forbidden */
static int
-exec_comm (char *comm, char **word, size_t *word_length, int flags,
- wordexp_t *pwordexp)
+exec_comm (char *comm, char **word, size_t *word_length, size_t *max_length,
+ int flags, wordexp_t *pwordexp)
{
- int fildes[2];
+ int fildes[2];
int bufsize = 128;
int buflen;
int state = 0;
@@ -716,7 +721,8 @@ exec_comm (char *comm, char **word, size_t *word_length, int flags,
close (2);
execl (_PATH_BSHELL, _PATH_BSHELL, "-c", comm, NULL);
- /* Bad */
+
+ /* Bad. What now? */
exit (1);
}
@@ -740,7 +746,7 @@ exec_comm (char *comm, char **word, size_t *word_length, int flags,
for (i = 0; i < buflen; ++i)
{
- *word = w_addchar (*word, word_length, buffer[i]);
+ *word = w_addchar (*word, word_length, max_length, buffer[i]);
if (*word == NULL)
{
close (fildes[0]);
@@ -769,7 +775,7 @@ exec_comm (char *comm, char **word, size_t *word_length, int flags,
for (i = 0; i < buflen; ++i)
{
/* What if these aren't field separators? FIX */
- if ((buffer[i] == ' ') || (buffer[i] == '\t') || (buffer[i] == '\n'))
+ if (buffer[i] == ' ' || buffer[i] == '\t' || buffer[i] == '\n')
{
if (state != 0)
state = 2;
@@ -790,7 +796,7 @@ exec_comm (char *comm, char **word, size_t *word_length, int flags,
}
state = 1;
- *word = w_addchar (*word, word_length, buffer[i]);
+ *word = w_addchar (*word, word_length, max_length, buffer[i]);
if (*word == NULL)
{
close (fildes[0]);
@@ -804,17 +810,15 @@ exec_comm (char *comm, char **word, size_t *word_length, int flags,
}
static int
-parse_comm (char **word, size_t *word_length, const char *words,
- size_t *offset, int flags, wordexp_t *pwordexp)
+parse_comm (char **word, size_t *word_length, size_t *max_length,
+ const char *words, size_t *offset, int flags, wordexp_t *pwordexp)
{
/* We are poised just after "$(" */
int paren_depth = 1;
int error;
size_t comm_length = 0;
- char *comm = calloc (1, sizeof (char)); /* ??? */
-
- if (comm == NULL)
- return WRDE_NOSPACE;
+ size_t comm_maxlen = 0;
+ char *comm = NULL;
for (; words[*offset]; ++(*offset))
{
@@ -824,13 +828,14 @@ parse_comm (char **word, size_t *word_length, const char *words,
if (--paren_depth == 0)
{
/* Go -- give script to the shell */
- error = exec_comm (comm, word, word_length, flags, pwordexp);
+ error = exec_comm (comm, word, word_length, max_length, flags,
+ pwordexp);
free (comm);
return error;
}
/* This is just part of the script */
- comm = w_addchar (comm, &comm_length, words[*offset]);
+ comm = w_addchar (comm, &comm_length, &comm_maxlen, words[*offset]);
if (comm == NULL)
return WRDE_NOSPACE;
@@ -839,7 +844,7 @@ parse_comm (char **word, size_t *word_length, const char *words,
case '(':
paren_depth++;
default:
- comm = w_addchar (comm, &comm_length, words[*offset]);
+ comm = w_addchar (comm, &comm_length, &comm_maxlen, words[*offset]);
if (comm == NULL)
return WRDE_NOSPACE;
@@ -853,15 +858,17 @@ parse_comm (char **word, size_t *word_length, const char *words,
}
static int
-parse_param (char **word, size_t *word_length, const char *words,
- size_t *offset, int flags, wordexp_t *pwordexp)
+parse_param (char **word, size_t *word_length, size_t *max_length,
+ const char *words, size_t *offset, int flags, wordexp_t *pwordexp)
{
/* We are poised just after "$" */
size_t start = *offset;
size_t env_length = 0;
+ size_t env_maxlen = 0;
size_t pat_length = 0;
- char *env = calloc (1, sizeof (char)); /* ??? */
- char *pattern = calloc (1, sizeof (char)); /* ??? */
+ size_t pat_maxlen = 0;
+ char *env = NULL;
+ char *pattern = NULL;
char *value;
char action = 0;
int prefix = 0;
@@ -870,9 +877,6 @@ parse_param (char **word, size_t *word_length, const char *words,
int depth = 0;
int error;
- if ((env == NULL) || (pattern == NULL))
- return WRDE_NOSPACE;
-
for (; words[*offset]; ++(*offset))
{
switch (words[*offset])
@@ -881,7 +885,8 @@ parse_param (char **word, size_t *word_length, const char *words,
if (action || prefix || suffix)
{
++depth;
- pattern = w_addchar (pattern, &pat_length, words[*offset]);
+ pattern = w_addchar (pattern, &pat_length, &pat_maxlen,
+ words[*offset]);
if (pattern == NULL)
goto no_space;
@@ -905,7 +910,8 @@ parse_param (char **word, size_t *word_length, const char *words,
{
if (--depth)
{
- pattern = w_addchar (pattern, &pat_length, words[*offset]);
+ pattern = w_addchar (pattern, &pat_length, &pat_maxlen,
+ words[*offset]);
if (pattern == NULL)
goto no_space;
@@ -927,7 +933,7 @@ parse_param (char **word, size_t *word_length, const char *words,
/* Separating variable name from prefix pattern? */
if (words[*offset] == '#')
{
- if ((prefix < 2) && (!suffix))
+ if (prefix < 2 && !suffix)
{
++prefix;
break;
@@ -935,7 +941,7 @@ parse_param (char **word, size_t *word_length, const char *words,
}
else
{
- if ((suffix < 2) && (!prefix))
+ if (suffix < 2 && !prefix)
{
++suffix;
break;
@@ -943,7 +949,8 @@ parse_param (char **word, size_t *word_length, const char *words,
}
/* Must be part of prefix/suffix pattern. */
- pattern = w_addchar (pattern, &pat_length, words[*offset]);
+ pattern = w_addchar (pattern, &pat_length, &pat_maxlen,
+ words[*offset]);
if (pattern == NULL)
goto no_space;
@@ -964,7 +971,8 @@ parse_param (char **word, size_t *word_length, const char *words,
if (action || prefix || suffix)
{
- pattern = w_addchar (pattern, &pat_length, words[*offset]);
+ pattern = w_addchar (pattern, &pat_length, &pat_maxlen,
+ words[*offset]);
if (pattern == NULL)
goto no_space;
@@ -995,7 +1003,8 @@ parse_param (char **word, size_t *word_length, const char *words,
if (action || prefix || suffix)
{
- pattern = w_addchar (pattern, &pat_length, words[*offset]);
+ pattern = w_addchar (pattern, &pat_length, &pat_maxlen,
+ words[*offset]);
if (pattern == NULL)
{
free (env);
@@ -1011,7 +1020,8 @@ parse_param (char **word, size_t *word_length, const char *words,
case '\\':
if (action || prefix || suffix)
{
- error = parse_qtd_backslash (word, word_length, words, offset);
+ error = parse_qtd_backslash (word, word_length, max_length,
+ words, offset);
if (error == 0)
break;
}
@@ -1027,7 +1037,8 @@ parse_param (char **word, size_t *word_length, const char *words,
default:
if (action || prefix || suffix)
{
- pattern = w_addchar (pattern, &pat_length, words[*offset]);
+ pattern = w_addchar (pattern, &pat_length, &pat_maxlen,
+ words[*offset]);
if (pattern == NULL)
goto no_space;
@@ -1036,7 +1047,7 @@ parse_param (char **word, size_t *word_length, const char *words,
if ((words[start] == '{') || isalpha (words[*offset]))
{
- env = w_addchar (env, &env_length, words[*offset]);
+ env = w_addchar (env, &env_length, &env_maxlen, words[*offset]);
if (env == NULL)
goto no_space;
@@ -1062,7 +1073,7 @@ envsubst:
if (!env || !*env)
{
*offset = start - 1;
- *word = w_addchar (*word, word_length, '$');
+ *word = w_addchar (*word, word_length, max_length, '$');
free (env);
free (pattern);
return *word ? 0 : WRDE_NOSPACE;
@@ -1133,7 +1144,7 @@ envsubst:
free (env);
free (pattern);
- if (!value)
+ if (value == NULL)
{
/* Variable not defined */
if (flags & WRDE_UNDEF)
@@ -1142,12 +1153,12 @@ envsubst:
return 0;
}
- if (!pwordexp)
+ if (pwordexp == NULL)
/* Quoted - no field split */
- *word = w_addstr (*word, word_length, value);
+ *word = w_addstr (*word, word_length, max_length, value);
else
/* Should field-split here - FIX */
- *word = w_addstr (*word, word_length, value);
+ *word = w_addstr (*word, word_length, max_length, value);
return *word ? 0 : WRDE_NOSPACE;
@@ -1162,8 +1173,9 @@ no_space:
}
static int
-parse_dollars (char **word, size_t *word_length, const char *words,
- size_t *offset, int flags, wordexp_t *pwordexp)
+parse_dollars (char **word, size_t *word_length, size_t *max_length,
+ const char *words, size_t *offset, int flags,
+ wordexp_t *pwordexp)
{
/* We are poised _at_ "$" */
switch (words[1 + *offset])
@@ -1171,7 +1183,7 @@ parse_dollars (char **word, size_t *word_length, const char *words,
case '"':
case '\'':
case 0:
- *word = w_addchar (*word, word_length, '$');
+ *word = w_addchar (*word, word_length, max_length, '$');
return *word ? 0 : WRDE_NOSPACE;
case '(':
@@ -1179,35 +1191,41 @@ parse_dollars (char **word, size_t *word_length, const char *words,
{
(*offset) += 3;
/* Call parse_arith -- 0 is for "no brackets" */
- return parse_arith (word, word_length, words, offset, flags, 0);
+ return parse_arith (word, word_length, max_length, words, offset,
+ flags, 0);
}
if (flags & WRDE_NOCMD)
return WRDE_CMDSUB;
(*offset) += 2;
- return parse_comm (word, word_length, words, offset, flags, pwordexp);
+ return parse_comm (word, word_length, max_length, words, offset, flags,
+ pwordexp);
case '[':
(*offset) += 2;
/* Call parse_arith -- 1 is for "brackets" */
- return parse_arith (word, word_length, words, offset, flags, 1);
+ return parse_arith (word, word_length, max_length, words, offset, flags,
+ 1);
case '{':
default:
++(*offset); /* parse_param needs to know if "{" is there */
- return parse_param (word, word_length, words, offset, flags, pwordexp);
+ return parse_param (word, word_length, max_length, words, offset, flags,
+ pwordexp);
}
}
static int
-parse_backtick (char **word, size_t *word_length, const char *words,
- size_t *offset, int flags, wordexp_t *pwordexp)
+parse_backtick (char **word, size_t *word_length, size_t *max_length,
+ const char *words, size_t *offset, int flags,
+ wordexp_t *pwordexp)
{
/* We are poised just after "`" */
int error;
size_t comm_length = 0;
- char *comm = calloc (1, sizeof (char)); /* ??? */
+ size_t comm_maxlen = 0;
+ char *comm = NULL;
int squoting = 0;
for (; words[*offset]; ++(*offset))
@@ -1216,14 +1234,16 @@ parse_backtick (char **word, size_t *word_length, const char *words,
{
case '`':
/* Go -- give the script to the shell */
- error = exec_comm (comm, word, word_length, flags, pwordexp);
+ error = exec_comm (comm, word, word_length, max_length, flags,
+ pwordexp);
free (comm);
return error;
case '\\':
if (squoting)
{
- error = parse_qtd_backslash (&comm, &comm_length, words, offset);
+ error = parse_qtd_backslash (&comm, &comm_length, &comm_maxlen,
+ words, offset);
if (error)
{
@@ -1235,7 +1255,8 @@ parse_backtick (char **word, size_t *word_length, const char *words,
}
++(*offset);
- error = parse_backslash (&comm, &comm_length, words, offset);
+ error = parse_backslash (&comm, &comm_length, &comm_maxlen, words,
+ offset);
if (error)
{
@@ -1248,7 +1269,7 @@ parse_backtick (char **word, size_t *word_length, const char *words,
case '\'':
squoting = 1 - squoting;
default:
- comm = w_addchar (comm, &comm_length, words[*offset]);
+ comm = w_addchar (comm, &comm_length, &comm_maxlen, words[*offset]);
if (comm == NULL)
return WRDE_NOSPACE;
}
@@ -1260,8 +1281,8 @@ parse_backtick (char **word, size_t *word_length, const char *words,
}
static int
-parse_dquote (char **word, size_t *word_length, const char *words,
- size_t *offset, int flags)
+parse_dquote (char **word, size_t *word_length, size_t *max_length,
+ const char *words, size_t *offset, int flags)
{
/* We are poised just after a double-quote */
int error;
@@ -1274,8 +1295,8 @@ parse_dquote (char **word, size_t *word_length, const char *words,
return 0;
case '$':
- error = parse_dollars (word, word_length, words, offset, flags,
- NULL);
+ error = parse_dollars (word, word_length, max_length, words, offset,
+ flags, NULL);
/* The NULL here is to tell parse_dollars not to
* split the fields.
*/
@@ -1286,13 +1307,11 @@ parse_dquote (char **word, size_t *word_length, const char *words,
case '`':
if (flags & WRDE_NOCMD)
- {
- return WRDE_CMDSUB;
- }
+ return WRDE_CMDSUB;
++(*offset);
- error = parse_backtick (word, word_length, words, offset, flags,
- NULL);
+ error = parse_backtick (word, word_length, max_length, words,
+ offset, flags, NULL);
/* The NULL here is to tell parse_backtick not to
* split the fields.
*/
@@ -1302,7 +1321,8 @@ parse_dquote (char **word, size_t *word_length, const char *words,
break;
case '\\':
- error = parse_qtd_backslash (word, word_length, words, offset);
+ error = parse_qtd_backslash (word, word_length, max_length, words,
+ offset);
if (error)
return error;
@@ -1310,7 +1330,7 @@ parse_dquote (char **word, size_t *word_length, const char *words,
break;
default:
- *word = w_addchar (*word, word_length, words[*offset]);
+ *word = w_addchar (*word, word_length, max_length, words[*offset]);
if (*word == NULL)
return WRDE_NOSPACE;
}
@@ -1351,8 +1371,9 @@ wordexp (const char *words, wordexp_t *pwordexp, int flags)
size_t wordv_offset;
size_t words_offset;
size_t word_length = 0;
- int error;
+ size_t max_length = 0;
char *word = NULL;
+ int error;
char *ifs;
char ifs_white[4];
char **old_wordv = pwordexp->we_wordv;
@@ -1401,7 +1422,7 @@ wordexp (const char *words, wordexp_t *pwordexp, int flags)
collection. */
char *runp = ifs_white;
- while (runp < whch && *runp != '\0')
+ while (runp < whch && *runp != '\0' && *runp != *ifsch)
++runp;
if (runp == whch)
@@ -1429,7 +1450,8 @@ wordexp (const char *words, wordexp_t *pwordexp, int flags)
return WRDE_BADCHAR;
case '\\':
- error = parse_backslash (&word, &word_length, words, &words_offset);
+ error = parse_backslash (&word, &word_length, &max_length, words,
+ &words_offset);
if (error)
goto do_error;
@@ -1437,8 +1459,8 @@ wordexp (const char *words, wordexp_t *pwordexp, int flags)
break;
case '$':
- error = parse_dollars (&word, &word_length, words, &words_offset,
- flags, pwordexp);
+ error = parse_dollars (&word, &word_length, &max_length, words,
+ &words_offset, flags, pwordexp);
if (error)
goto do_error;
@@ -1450,8 +1472,8 @@ wordexp (const char *words, wordexp_t *pwordexp, int flags)
return WRDE_CMDSUB;
++words_offset;
- error = parse_backtick (&word, &word_length, words, &words_offset,
- flags, pwordexp);
+ error = parse_backtick (&word, &word_length, &max_length, words,
+ &words_offset, flags, pwordexp);
if (error)
goto do_error;
@@ -1460,8 +1482,8 @@ wordexp (const char *words, wordexp_t *pwordexp, int flags)
case '"':
++words_offset;
- error = parse_dquote (&word, &word_length, words, &words_offset,
- flags);
+ error = parse_dquote (&word, &word_length, &max_length, words,
+ &words_offset, flags);
if (error)
goto do_error;
@@ -1470,7 +1492,8 @@ wordexp (const char *words, wordexp_t *pwordexp, int flags)
case '\'':
++words_offset;
- error = parse_squote (&word, &word_length, words, &words_offset);
+ error = parse_squote (&word, &word_length, &max_length, words,
+ &words_offset);
if (error)
goto do_error;
@@ -1478,8 +1501,8 @@ wordexp (const char *words, wordexp_t *pwordexp, int flags)
break;
case '~':
- error = parse_tilde (&word, &word_length, words, &words_offset,
- pwordexp->we_wordc);
+ error = parse_tilde (&word, &word_length, &max_length, words,
+ &words_offset, pwordexp->we_wordc);
if (error)
goto do_error;
@@ -1488,8 +1511,8 @@ wordexp (const char *words, wordexp_t *pwordexp, int flags)
case '*':
case '{':
- error = parse_glob (&word, &word_length, words, &words_offset, flags,
- pwordexp, ifs);
+ error = parse_glob (&word, &word_length, &max_length, words,
+ &words_offset, flags, pwordexp, ifs);
if (error)
goto do_error;
@@ -1502,7 +1525,8 @@ wordexp (const char *words, wordexp_t *pwordexp, int flags)
{
/* "Ordinary" character -- add it to word */
- word = w_addchar (word, &word_length, words[words_offset]);
+ word = w_addchar (word, &word_length, &max_length,
+ words[words_offset]);
if (word == NULL)
{
error = WRDE_NOSPACE;
@@ -1532,30 +1556,28 @@ wordexp (const char *words, wordexp_t *pwordexp, int flags)
}
/* It's a non-whitespace IFS char */
- if (!word)
+
+ /* Multiple non-whitespace IFS chars are treated as one;
+ * IS THIS CORRECT?
+ */
+ if (word != NULL)
{
- word = calloc (1, sizeof (char)); /* ??? */
- if (word == NULL)
+ if (w_addword (pwordexp, word) == WRDE_NOSPACE)
{
error = WRDE_NOSPACE;
goto do_error;
}
}
- if (w_addword (pwordexp, word) == WRDE_NOSPACE)
- {
- error = WRDE_NOSPACE;
- goto do_error;
- }
-
word = NULL;
word_length = 0;
+ max_length = 0;
}
/* End of string */
/* There was a field separator at the end */
- if (!word || !*word)
+ if (word == NULL)
return 0;
/* There was no field separator at the end */
diff --git a/resolv/Makefile b/resolv/Makefile
index f48f841b9a..763c13fcb8 100644
--- a/resolv/Makefile
+++ b/resolv/Makefile
@@ -40,7 +40,7 @@ vpath %.c nss_dns
libnss_dns-routines := dns-host dns-network
libnss_dns-map := libnss_dns.map
ifneq ($(build-static-nss),yes)
-libnss_dns-inhibit-o = $(filter-out .so,$(object-suffixes))
+libnss_dns-inhibit-o = $(filter-out .os,$(object-suffixes))
endif
include ../Rules
diff --git a/rpm/Makefile b/rpm/Makefile
index b83b8ea9e9..3edf21ebbf 100644
--- a/rpm/Makefile
+++ b/rpm/Makefile
@@ -43,7 +43,7 @@ install-slib += $(foreach lib,$(versioned),\
install-lib += $(versioned)
# Add libc.a and libc_p.a.
-install-lib += $(foreach o,$(filter-out .so,$(object-suffixes)),\
+install-lib += $(foreach o,$(filter-out .os,$(object-suffixes)),\
$(patsubst %,$(libtype$o),c))
ifeq (yes,$(build-shared))
diff --git a/socket/sys/socket.h b/socket/sys/socket.h
index 9ba7d9a313..3d3f71385f 100644
--- a/socket/sys/socket.h
+++ b/socket/sys/socket.h
@@ -113,7 +113,7 @@ extern int connect __P ((int __fd,
/* Put the address of the peer connected to socket FD into *ADDR
(which is *LEN bytes long), and its actual length into *LEN. */
extern int getpeername __P ((int __fd, __SOCKADDR_ARG __addr,
- size_t *__len));
+ socklen_t *__len));
/* Send N bytes of BUF to socket FD. Returns the number sent or -1. */
diff --git a/stdlib/canonicalize.c b/stdlib/canonicalize.c
index 0985e250b8..ea7883dba5 100644
--- a/stdlib/canonicalize.c
+++ b/stdlib/canonicalize.c
@@ -1,5 +1,5 @@
/* Return the canonical absolute name of a given file.
- Copyright (C) 1996 Free Software Foundation, Inc.
+ Copyright (C) 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
@@ -122,6 +122,7 @@ canonicalize (const char *name, char *resolved)
if (S_ISLNK (st.st_mode))
{
char *buf = __alloca (path_max);
+ size_t len;
if (++num_links > MAXSYMLINKS)
{
@@ -137,21 +138,22 @@ canonicalize (const char *name, char *resolved)
if (!extra_buf)
extra_buf = __alloca (path_max);
- if ((long int) (n + strlen (end)) >= path_max)
+ len = strlen (end);
+ if ((long int) (n + len) >= path_max)
{
__set_errno (ENAMETOOLONG);
goto error;
}
- /* careful here, end may be a pointer into extra_buf... */
- strcat (buf, end);
+ /* Careful here, end may be a pointer into extra_buf... */
+ memcpy (&buf[n], end, len + 1);
strcpy (extra_buf, buf);
name = end = extra_buf;
if (buf[0] == '/')
- dest = rpath + 1; /* it's an absolute symlink */
+ dest = rpath + 1; /* It's an absolute symlink */
else
- /* back up to previous component, ignore if at root already: */
+ /* Back up to previous component, ignore if at root already: */
if (dest > rpath + 1)
while ((--dest)[-1] != '/');
}
diff --git a/sunrpc/Makefile b/sunrpc/Makefile
index d4595482a2..b7c86d4f84 100644
--- a/sunrpc/Makefile
+++ b/sunrpc/Makefile
@@ -88,7 +88,7 @@ install-others += $(inst_includedir)/rpcsvc/bootparam_prot.h
extra-libs := librpcsvc
extra-libs-others := librpcsvc # Make it in `others' pass, not `lib' pass.
librpcsvc-routines = $(rpcsvc:%.x=x%)
-librpcsvc-inhibit-o = .so # Build no shared rpcsvc library.
+librpcsvc-inhibit-o = .os # Build no shared rpcsvc library.
omit-deps = $(librpcsvc-routines)
endif
diff --git a/sysdeps/generic/stpcpy.c b/sysdeps/generic/stpcpy.c
index f010179e08..9800ace993 100644
--- a/sysdeps/generic/stpcpy.c
+++ b/sysdeps/generic/stpcpy.c
@@ -18,9 +18,15 @@
#include <string.h>
+#ifndef weak_alias
+# define __stpcpy stpcpy
+#endif
+
/* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */
char *
-__stpcpy (char *dest, const char *src)
+__stpcpy (dest, src)
+ char *dest;
+ const char *src;
{
register char *d = dest;
register const char *s = src;
@@ -31,4 +37,6 @@ __stpcpy (char *dest, const char *src)
return d - 1;
}
+#ifdef weak_alias
weak_alias (__stpcpy, stpcpy)
+#endif
diff --git a/sysdeps/libm-i387/e_remainder.S b/sysdeps/libm-i387/e_remainder.S
index 06cdddc9d1..2f43cb894c 100644
--- a/sysdeps/libm-i387/e_remainder.S
+++ b/sysdeps/libm-i387/e_remainder.S
@@ -14,6 +14,6 @@ ENTRY(__ieee754_remainder)
fstsw %ax
sahf
jp 1b
- fstpl %st(1)
+ fstp %st(1)
ret
END (__ieee754_remainder)
diff --git a/sysdeps/libm-i387/e_remainderf.S b/sysdeps/libm-i387/e_remainderf.S
index d313a55382..79f821993b 100644
--- a/sysdeps/libm-i387/e_remainderf.S
+++ b/sysdeps/libm-i387/e_remainderf.S
@@ -14,6 +14,6 @@ ENTRY(__ieee754_remainderf)
fstsw %ax
sahf
jp 1b
- fstpl %st(1)
+ fstp %st(1)
ret
END (__ieee754_remainderf)
diff --git a/sysdeps/libm-i387/e_remainderl.S b/sysdeps/libm-i387/e_remainderl.S
index 90a8da7633..5f50b626a2 100644
--- a/sysdeps/libm-i387/e_remainderl.S
+++ b/sysdeps/libm-i387/e_remainderl.S
@@ -16,5 +16,6 @@ ENTRY(__ieee754_remainderl)
fstsw %ax
sahf
jp 1b
+ fstp %st(1)
ret
END (__ieee754_remainderl)
diff --git a/sysdeps/libm-i387/s_cexp.S b/sysdeps/libm-i387/s_cexp.S
index 5630d3cb65..61158d9540 100644
--- a/sysdeps/libm-i387/s_cexp.S
+++ b/sysdeps/libm-i387/s_cexp.S
@@ -237,8 +237,9 @@ ENTRY(__cexp)
fldl MOX(huge_nan_null_null,%edx,1)
fldl MOX(huge_nan_null_null+8,%edx,1)
- fstpl 8(%eax)
+ fxch
fstpl (%eax)
+ fstpl 8(%eax)
ret $4
/* The real part is NaN. */
diff --git a/sysdeps/libm-i387/s_cexpl.S b/sysdeps/libm-i387/s_cexpl.S
index 11c05c52e6..203a7ee779 100644
--- a/sysdeps/libm-i387/s_cexpl.S
+++ b/sysdeps/libm-i387/s_cexpl.S
@@ -161,8 +161,9 @@ ENTRY(__cexpl)
jnz 5f
fldl MOX(huge_nan_null_null,%edx,1)
movl 4(%esp), %edx /* Pointer to memory for result. */
- fstl 8(%edx)
- fstpl (%edx)
+ fld %st
+ fstpt 12(%edx)
+ fstpt (%edx)
ftst
fnstsw
shll $7, %eax
@@ -188,8 +189,9 @@ ENTRY(__cexpl)
fsincos
fldl MOX(huge_nan_null_null,%edx,1)
movl 4(%esp), %edx /* Pointer to memory for result. */
- fstl 8(%edx)
- fstpl (%edx)
+ fld %st
+ fstpt 12(%edx)
+ fstpt (%edx)
ftst
fnstsw
shll $7, %eax
@@ -237,8 +239,9 @@ ENTRY(__cexpl)
fldl MOX(huge_nan_null_null,%edx,1)
fldl MOX(huge_nan_null_null+8,%edx,1)
- fstpt 12(%eax)
+ fxch
fstpt (%eax)
+ fstpt 12(%eax)
ret $4
/* The real part is NaN. */
diff --git a/sysdeps/libm-ieee754/s_csinhl.c b/sysdeps/libm-ieee754/s_csinhl.c
index 694b39d670..471cc7e81e 100644
--- a/sysdeps/libm-ieee754/s_csinhl.c
+++ b/sysdeps/libm-ieee754/s_csinhl.c
@@ -19,6 +19,7 @@
Boston, MA 02111-1307, USA. */
#include <complex.h>
+#include <fenv.h>
#include <math.h>
#include "math_private.h"
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index fb9709fee7..fec30f97d7 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -44,92 +44,98 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/* getaddrinfo() v1.13 */
-/* To do what POSIX says, even when it's broken: */
-#define BROKEN_LIKE_POSIX 1
-#define LOCAL 1
-#define INET6 1
-#define HOSTTABLE 0
-#define RESOLVER 1
-
#include <sys/types.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/socket.h>
-#if LOCAL
#include <stdio.h>
#include <string.h>
#include <sys/utsname.h>
#include <sys/un.h>
-#endif /* LOCAL */
#include <netinet/in.h>
#include <netdb.h>
#include <errno.h>
#include <arpa/inet.h>
-#ifndef AF_LOCAL
-#define AF_LOCAL AF_UNIX
-#endif /* AF_LOCAL */
-#ifndef PF_LOCAL
-#define PF_LOCAL PF_UNIX
-#endif /* PF_LOCAL */
-#ifndef UNIX_PATH_MAX
-#define UNIX_PATH_MAX 108
-#endif /* UNIX_PATH_MAX */
-
#define GAIH_OKIFUNSPEC 0x0100
#define GAIH_EAI ~(GAIH_OKIFUNSPEC)
-#if HOSTTABLE
-struct hostent *_hostname2addr_hosts(const char *name, int);
-struct hostent *_addr2hostname_hosts(const char *name, int, int);
-#endif /* HOSTTABLE */
+#ifndef UNIX_PATH_MAX
+#define UNIX_PATH_MAX 108
+#endif
-static struct addrinfo nullreq =
-{ 0, PF_UNSPEC, 0, 0, 0, NULL, NULL, NULL };
+struct gaih_service
+ {
+ const char *name;
+ int num;
+ };
-struct gaih_service {
- char *name;
- int num;
-};
+struct gaih_servtuple
+ {
+ struct gaih_servtuple *next;
+ int socktype;
+ int protocol;
+ int port;
+ };
-struct gaih_servtuple {
- struct gaih_servtuple *next;
- int socktype;
- int protocol;
- int port;
-};
+static struct gaih_servtuple nullserv = { NULL, 0, 0, 0 };
-static struct gaih_servtuple nullserv = {
- NULL, 0, 0, 0
-};
+struct gaih_addrtuple
+ {
+ struct gaih_addrtuple *next;
+ int family;
+ char addr[16];
+ };
-struct gaih_addrtuple {
- struct gaih_addrtuple *next;
- int family;
- char addr[16];
-};
+struct gaih_typeproto
+ {
+ int socktype;
+ int protocol;
+ char *name;
+ };
-struct gaih_typeproto {
- int socktype;
- int protocol;
- char *name;
+static struct gaih_typeproto gaih_inet_typeproto[] =
+{
+ { 0, 0, NULL },
+ { SOCK_STREAM, IPPROTO_TCP, (char *) "tcp" },
+ { SOCK_DGRAM, IPPROTO_UDP, (char *) "udp" },
+ { 0, 0, NULL }
};
-#if LOCAL
-static int gaih_local(const char *name, const struct gaih_service *service,
- const struct addrinfo *req, struct addrinfo **pai)
+struct gaih
+ {
+ int family;
+ int (*gaih)(const char *name, const struct gaih_service *service,
+ const struct addrinfo *req, struct addrinfo **pai);
+ };
+
+static struct addrinfo default_hints =
+ { 0, PF_UNSPEC, 0, 0, 0, NULL, NULL, NULL };
+
+
+static int
+gaih_local (const char *name, const struct gaih_service *service,
+ const struct addrinfo *req, struct addrinfo **pai)
{
struct utsname utsname;
- if (name || (req->ai_flags & AI_CANONNAME))
+ if ((name != NULL) || (req->ai_flags & AI_CANONNAME))
if (uname(&utsname))
return -EAI_SYSTEM;
- if (name) {
- if (strcmp(name, "localhost") && strcmp(name, "local") && strcmp(name, "unix") && strcmp(name, utsname.nodename))
- return (GAIH_OKIFUNSPEC | -EAI_NONAME);
- };
- if (!(*pai = malloc(sizeof(struct addrinfo) + sizeof(struct sockaddr_un) + ((req->ai_flags & AI_CANONNAME) ? (strlen(utsname.nodename) + 1): 0))))
+ if (name != NULL)
+ {
+ if (strcmp(name, "localhost") &&
+ strcmp(name, "local") &&
+ strcmp(name, "unix") &&
+ strcmp(name, utsname.nodename))
+ return GAIH_OKIFUNSPEC | -EAI_NONAME;
+ }
+
+ *pai = malloc (sizeof(struct addrinfo) + sizeof(struct sockaddr_un)
+ + ((req->ai_flags & AI_CANONNAME)
+ ? (strlen(utsname.nodename) + 1): 0));
+ if (*pai == NULL)
return -EAI_MEMORY;
(*pai)->ai_next = NULL;
@@ -139,63 +145,79 @@ static int gaih_local(const char *name, const struct gaih_service *service,
(*pai)->ai_protocol = req->ai_protocol;
(*pai)->ai_addrlen = sizeof(struct sockaddr_un);
(*pai)->ai_addr = (void *)(*pai) + sizeof(struct addrinfo);
+
#if SALEN
- ((struct sockaddr_un *)(*pai)->ai_addr)->sun_len = sizeof(struct sockaddr_un);
+ ((struct sockaddr_un *) (*pai)->ai_addr)->sun_len =
+ sizeof (struct sockaddr_un);
#endif /* SALEN */
+
((struct sockaddr_un *)(*pai)->ai_addr)->sun_family = AF_LOCAL;
memset(((struct sockaddr_un *)(*pai)->ai_addr)->sun_path, 0, UNIX_PATH_MAX);
- if (service) {
- char *c;
- if (c = strchr(service->name, '/')) {
- if (strlen(service->name) >= sizeof(((struct sockaddr_un *)(*pai)->ai_addr)->sun_path))
- return (GAIH_OKIFUNSPEC | -EAI_SERVICE);
- strcpy(((struct sockaddr_un *)(*pai)->ai_addr)->sun_path, service->name);
- } else {
- if (strlen(P_tmpdir "/") + 1 + strlen(service->name) >= sizeof(((struct sockaddr_un *)(*pai)->ai_addr)->sun_path))
- return (GAIH_OKIFUNSPEC | -EAI_SERVICE);
- strcpy(((struct sockaddr_un *)(*pai)->ai_addr)->sun_path, P_tmpdir "/");
- strcat(((struct sockaddr_un *)(*pai)->ai_addr)->sun_path, service->name);
- };
- } else {
- if (!tmpnam(((struct sockaddr_un *)(*pai)->ai_addr)->sun_path))
- return -EAI_SYSTEM;
- };
+
+ if (service)
+ {
+ struct sockaddr_un *sunp = (struct sockaddr_un *) (*pai)->ai_addr;
+
+ if (strchr (service->name, '/') != NULL)
+ {
+ if (strlen (service->name) >= sizeof (sunp->sun_path))
+ return GAIH_OKIFUNSPEC | -EAI_SERVICE;
+
+ strcpy (sunp->sun_path, service->name);
+ }
+ else
+ {
+ if (strlen (P_tmpdir "/") + 1 + strlen (service->name) >=
+ sizeof (sunp->sun_path))
+ return GAIH_OKIFUNSPEC | -EAI_SERVICE;
+
+ __stpcpy (__stpcpy (sunp->sun_path, P_tmpdir "/"), service->name);
+ }
+ }
+ else
+ {
+ if (tmpnam (((struct sockaddr_un *) (*pai)->ai_addr)->sun_path) == NULL)
+ return -EAI_SYSTEM;
+ }
+
if (req->ai_flags & AI_CANONNAME)
- strcpy((*pai)->ai_canonname = (char *)(*pai) + sizeof(struct addrinfo) + sizeof(struct sockaddr_un), utsname.nodename);
+ strcpy ((*pai)->ai_canonname = (char *)(*pai) + sizeof(struct addrinfo) +
+ sizeof(struct sockaddr_un), utsname.nodename);
else
(*pai)->ai_canonname = NULL;
return 0;
-};
-#endif /* LOCAL */
-
-static struct gaih_typeproto gaih_inet_typeproto[] =
-{
- { 0, 0, NULL },
- { SOCK_STREAM, IPPROTO_TCP, (char *) "tcp" },
- { SOCK_DGRAM, IPPROTO_UDP, (char *) "udp" },
- { 0, 0, NULL }
-};
+}
-static int gaih_inet_serv(char *servicename, struct gaih_typeproto *tp, struct gaih_servtuple **st)
+static int
+gaih_inet_serv (const char *servicename, struct gaih_typeproto *tp,
+ struct gaih_servtuple **st)
{
struct servent *s;
- int tmpbuflen = 1024;
+ size_t tmpbuflen = 1024;
struct servent ts;
- char *tmpbuf = __alloca (tmpbuflen);
- while (__getservbyname_r (servicename, tp->name, &ts, tmpbuf, tmpbuflen, &s))
+ char *tmpbuf;
+ int r;
+
+ do
{
- if (errno == ERANGE)
- {
- tmpbuflen *= 2;
- tmpbuf = __alloca (tmpbuflen);
- }
- else
+ tmpbuf = __alloca (tmpbuflen);
+ if (tmpbuf == NULL)
+ return -EAI_MEMORY;
+
+ r = __getservbyname_r (servicename, tp->name, &ts, tmpbuf, tmpbuflen,
+ &s);
+ if (r)
{
- return GAIH_OKIFUNSPEC | -EAI_SERVICE;
+ if (errno == ERANGE)
+ tmpbuflen *= 2;
+ else
+ return GAIH_OKIFUNSPEC | -EAI_SERVICE;
}
}
+ while (r);
- if (!(*st = malloc (sizeof (struct gaih_servtuple))))
+ *st = malloc (sizeof (struct gaih_servtuple));
+ if (*st == NULL)
return -EAI_MEMORY;
(*st)->next = NULL;
@@ -206,426 +228,330 @@ static int gaih_inet_serv(char *servicename, struct gaih_typeproto *tp, struct g
return 0;
}
-static int gaih_inet(const char *name, const struct gaih_service *service,
- const struct addrinfo *req, struct addrinfo **pai)
+#define gethosts(_family, _type) \
+ { \
+ int i, herrno; \
+ size_t tmpbuflen; \
+ struct hostent th; \
+ char *tmpbuf; \
+ tmpbuflen = 512; \
+ do { \
+ tmpbuflen *= 2; \
+ tmpbuf = __alloca (tmpbuflen); \
+ if (tmpbuf == NULL) \
+ return -EAI_MEMORY; \
+ rc = __gethostbyname2_r (name, _family, &th, tmpbuf, \
+ tmpbuflen, &h, &herrno); \
+ } while ((rc != 0) && \
+ (herrno == NETDB_INTERNAL) && (errno == ERANGE)); \
+ if ((rc != 0) && (herrno == NETDB_INTERNAL)) \
+ { \
+ __set_h_errno (herrno); \
+ return -EAI_SYSTEM; \
+ } \
+ if (h != NULL) \
+ { \
+ for (i = 0; h->h_addr_list[i]; i++) \
+ { \
+ if (*pat == NULL) \
+ { \
+ *pat = __alloca (sizeof(struct gaih_addrtuple)); \
+ if (*pat == NULL) \
+ return -EAI_MEMORY; \
+ } \
+ (*pat)->next = NULL; \
+ (*pat)->family = _family; \
+ memcpy ((*pat)->addr, h->h_addr_list[i], \
+ sizeof(_type)); \
+ pat = &((*pat)->next); \
+ } \
+ } \
+ }
+
+static int
+gaih_inet (const char *name, const struct gaih_service *service,
+ const struct addrinfo *req, struct addrinfo **pai)
{
struct gaih_typeproto *tp = gaih_inet_typeproto;
struct gaih_servtuple *st = &nullserv;
struct gaih_addrtuple *at = NULL;
- int i;
-
- if (req->ai_protocol || req->ai_socktype) {
- for (tp++; tp->name &&
- ((req->ai_socktype != tp->socktype) || !req->ai_socktype) &&
- ((req->ai_protocol != tp->protocol) || !req->ai_protocol); tp++);
- if (!tp->name)
- if (req->ai_socktype)
- return (GAIH_OKIFUNSPEC | -EAI_SOCKTYPE);
- else
- return (GAIH_OKIFUNSPEC | -EAI_SERVICE);
- }
+ int rc;
- if (service) {
- if (service->num < 0) {
- if (tp->name) {
- if (i = gaih_inet_serv(service->name, tp, &st))
- return i;
- } else {
- struct gaih_servtuple **pst = &st;
- for (tp++; tp->name; tp++) {
- if (i = gaih_inet_serv(service->name, tp, pst)) {
- if (i & GAIH_OKIFUNSPEC)
- continue;
- goto ret;
- }
- pst = &((*pst)->next);
+ if (req->ai_protocol || req->ai_socktype)
+ {
+ for (tp++; tp->name &&
+ ((req->ai_socktype != tp->socktype) || !req->ai_socktype) &&
+ ((req->ai_protocol != tp->protocol) || !req->ai_protocol); tp++);
+ if (tp->name == NULL)
+ if (req->ai_socktype)
+ return (GAIH_OKIFUNSPEC | -EAI_SOCKTYPE);
+ else
+ return (GAIH_OKIFUNSPEC | -EAI_SERVICE);
+ }
+
+ if (service != NULL)
+ {
+ if (service->num < 0)
+ {
+ if (tp->name != NULL)
+ {
+ if (rc = gaih_inet_serv (service->name, tp, &st))
+ return rc;
+ }
+ else
+ {
+ struct gaih_servtuple **pst = &st;
+ for (tp++; tp->name; tp++)
+ {
+ if (rc = gaih_inet_serv (service->name, tp, pst))
+ {
+ if (rc & GAIH_OKIFUNSPEC)
+ continue;
+ return rc;
+ }
+ pst = &((*pst)->next);
+ }
+ if (st == &nullserv)
+ return (GAIH_OKIFUNSPEC | -EAI_SERVICE);
+ }
}
- if (st == &nullserv) {
- i = (GAIH_OKIFUNSPEC | -EAI_SERVICE);
- goto ret;
+ else
+ {
+ st = __alloca (sizeof(struct gaih_servtuple));
+ if (st == NULL)
+ return -EAI_MEMORY;
+
+ st->next = NULL;
+ st->socktype = tp->socktype;
+ st->protocol = tp->protocol;
+ st->port = htons (service->num);
}
- }
- } else {
- if (!(st = malloc(sizeof(struct gaih_servtuple))))
+ }
+
+ if (name != NULL)
+ {
+ at = __alloca (sizeof(struct gaih_addrtuple));
+ if (at == NULL)
return -EAI_MEMORY;
- st->next = NULL;
- st->socktype = tp->socktype;
- st->protocol = tp->protocol;
- st->port = htons(service->num);
- }
- }
+ at->family = 0;
+ at->next = NULL;
- if (name) {
- if (!(at = malloc(sizeof(struct gaih_addrtuple)))) {
- i = -EAI_MEMORY;
- goto ret;
- }
+ if (at->family || !req->ai_family || (req->ai_family == AF_INET))
+ if (inet_pton (AF_INET, name, at->addr) > 0)
+ at->family = AF_INET;
- at->family = 0;
- at->next = NULL;
-
- if (!at->family || !req->ai_family || (req->ai_family == AF_INET))
- if (inet_pton(AF_INET, name, at->addr) > 0)
- at->family = AF_INET;
-
-#if INET6
- if (!at->family && (!req->ai_family || (req->ai_family == AF_INET6)))
- if (inet_pton(AF_INET6, name, at->addr) > 0)
- at->family = AF_INET6;
-#endif /* INET6 */
-
-#if HOSTTABLE
- if (!at->family) {
- struct hostent *h;
- struct gaih_addrtuple **pat = &at;
-
-#if INET6
- if (!req->ai_family || (req->ai_family == AF_INET6))
- if (h = _hostname2addr_hosts(name, AF_INET6)) {
- for (i = 0; h->h_addr_list[i]; i++) {
- if (!*pat) {
- if (!(*pat = malloc(sizeof(struct gaih_addrtuple)))) {
- i = -EAI_MEMORY;
- goto ret;
- }
- }
- (*pat)->next = NULL;
- (*pat)->family = AF_INET6;
- memcpy((*pat)->addr, h->h_addr_list[i], sizeof(struct in6_addr));
- pat = &((*pat)->next);
- }
- }
-#endif /* INET6 */
-
- if (!req->ai_family || (req->ai_family == AF_INET))
- if (h = _hostname2addr_hosts(name, AF_INET)) {
- for (i = 0; h->h_addr_list[i]; i++) {
- if (!*pat) {
- if (!(*pat = malloc(sizeof(struct gaih_addrtuple)))) {
- i = -EAI_MEMORY;
- goto ret;
- }
- }
- (*pat)->next = NULL;
- (*pat)->family = AF_INET;
- memcpy((*pat)->addr, h->h_addr_list[i], sizeof(struct in_addr));
- pat = &((*pat)->next);
- }
+ if (!at->family && (!req->ai_family || (req->ai_family == AF_INET6)))
+ if (inet_pton (AF_INET6, name, at->addr) > 0)
+ at->family = AF_INET6;
+
+ if (at->family == AF_UNSPEC)
+ {
+ struct hostent *h;
+ struct gaih_addrtuple **pat = &at;
+
+ if ((req->ai_family == AF_UNSPEC) || (req->ai_family == AF_INET6))
+ gethosts (AF_INET6, struct in6_addr);
+
+ if ((req->ai_family == AF_UNSPEC) || (req->ai_family == AF_INET))
+ gethosts (AF_INET, struct in_addr);
}
+
+ if (at->family == AF_UNSPEC)
+ return (GAIH_OKIFUNSPEC | -EAI_NONAME);
+
}
-#endif /* HOSTTABLE */
-
-#if RESOLVER
- if (!at->family) {
- struct hostent *h;
- struct gaih_addrtuple **pat = &at;
-
-#if INET6
- if (!req->ai_family || (req->ai_family == AF_INET6)) {
- int herrno;
- int tmpbuflen = 1024;
- struct hostent th;
- char *tmpbuf = __alloca(tmpbuflen);
- while (__gethostbyname2_r(name, AF_INET6, &th, tmpbuf, tmpbuflen,
- &h, &herrno)) {
- if (herrno == NETDB_INTERNAL) {
- if (errno == ERANGE) {
- /* Need more buffer */
- tmpbuflen *= 2;
- tmpbuf = __alloca(tmpbuflen);
- } else {
- /* Bail out */
- __set_h_errno(herrno);
- i = -EAI_SYSTEM;
- goto ret;
- }
- } else {
- break;
- }
- }
- if (h) {
- for (i = 0; h->h_addr_list[i]; i++) {
- if (!*pat) {
- if (!(*pat = malloc(sizeof(struct gaih_addrtuple)))) {
- i = -EAI_MEMORY;
- goto ret;
- }
- }
- (*pat)->next = NULL;
- (*pat)->family = AF_INET6;
- memcpy((*pat)->addr, h->h_addr_list[i], sizeof(struct in6_addr));
- pat = &((*pat)->next);
- }
- }
- }
-#endif /* INET6 */
-
- if (!req->ai_family || (req->ai_family == AF_INET)) {
- int herrno;
- struct hostent th;
- int tmpbuflen = 1024;
- char *tmpbuf = __alloca(tmpbuflen);
- while (__gethostbyname2_r(name, AF_INET, &th, tmpbuf, tmpbuflen,
- &h, &herrno)) {
- if (herrno == NETDB_INTERNAL) {
- if (errno == ERANGE) {
- /* Need more buffer */
- tmpbuflen *= 2;
- tmpbuf = __alloca(tmpbuflen);
- } else {
- /* Bail out */
- __set_h_errno(herrno);
- i = -EAI_SYSTEM;
- goto ret;
- }
- } else {
- break;
- }
- }
- if (h) {
- for (i = 0; h->h_addr_list[i]; i++) {
- if (!*pat) {
- if (!(*pat = malloc(sizeof(struct gaih_addrtuple)))) {
- i = -EAI_MEMORY;
- goto ret;
- }
- }
- (*pat)->next = NULL;
- (*pat)->family = AF_INET;
- memcpy((*pat)->addr, h->h_addr_list[i], sizeof(struct in_addr));
- pat = &((*pat)->next);
- }
- }
- }
+ else
+ {
+ at = __alloca (sizeof(struct gaih_addrtuple));
+ if (at == NULL)
+ return -EAI_MEMORY;
+
+ memset (at, 0, sizeof(struct gaih_addrtuple));
+
+ at->next = __alloca (sizeof(struct gaih_addrtuple));
+ if (at->next == NULL)
+ return -EAI_MEMORY;
+
+ at->family = AF_INET6;
+
+ memset (at->next, 0, sizeof(struct gaih_addrtuple));
+ at->next->family = AF_INET;
}
-#endif /* RESOLVER */
-
- if (!at->family)
- return (GAIH_OKIFUNSPEC | -EAI_NONAME);
- } else {
- if (!(at = malloc(sizeof(struct gaih_addrtuple)))) {
- i = -EAI_MEMORY;
- goto ret;
- };
-
- memset(at, 0, sizeof(struct gaih_addrtuple));
-
-#if INET6
- if (!(at->next = malloc(sizeof(struct gaih_addrtuple)))) {
- i = -EAI_MEMORY;
- goto ret;
- };
-
- at->family = AF_INET6;
-
- memset(at->next, 0, sizeof(struct gaih_addrtuple));
- at->next->family = AF_INET;
-#else /* INET6 */
- at->family = AF_INET;
-#endif /* INET6 */
- };
- if (!pai) {
- i = 0;
- goto ret;
- };
+ if (pai == NULL)
+ return 0;
{
const char *c = NULL;
struct gaih_servtuple *st2;
struct gaih_addrtuple *at2 = at;
- int j;
+ size_t socklen, namelen;
+
/*
buffer is the size of an unformatted IPv6 address in printable format.
*/
char buffer[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"];
- while(at2) {
- if (req->ai_flags & AI_CANONNAME) {
- struct hostent *h = NULL;
-
-#if RESOLVER
- int herrno;
- struct hostent th;
- int tmpbuflen = 1024;
- char *tmpbuf = __alloca(tmpbuflen);
- while (__gethostbyaddr_r(at2->addr,
-#if INET6
- (at2->family == AF_INET6) ? sizeof(struct in6_addr) :
-#endif /* INET6 */
- sizeof(struct in_addr), at2->family,
- &th, tmpbuf, tmpbuflen, &h, &herrno)) {
- if (herrno == NETDB_INTERNAL) {
- if (errno == ERANGE) {
- /* Need more buffer */
- tmpbuflen *= 2;
- tmpbuf = __alloca(tmpbuflen);
- } else {
- /* Bail out */
- __set_h_errno(herrno);
- i = -EAI_SYSTEM;
- goto ret;
- }
- } else {
- break;
- }
- }
-#endif /* RESOLVER */
-#if HOSTTABLE
- if (!h)
- h = _addr2hostname_hosts(at2->addr,
-#if INET6
- (at2->family == AF_INET6) ? sizeof(struct in6_addr) :
-#endif /* INET6 */
- sizeof(struct in_addr), at2->family);
-#endif /* HOSTTABLE */
-
- if (!h)
- c = inet_ntop(at2->family, at2->addr, buffer, sizeof(buffer));
- else
- c = h->h_name;
+ while (at2 != NULL)
+ {
+ if (req->ai_flags & AI_CANONNAME)
+ {
+ struct hostent *h = NULL;
- if (!c) {
- i = (GAIH_OKIFUNSPEC | -EAI_NONAME);
- goto ret;
- }
+ int herrno;
+ struct hostent th;
+ size_t tmpbuflen = 512;
+ char *tmpbuf;
- j = strlen(c) + 1;
- } else
- j = 0;
+ do
+ {
+ tmpbuflen *= 2;
+ tmpbuf = __alloca (tmpbuflen);
-#if INET6
- if (at2->family == AF_INET6)
- i = sizeof(struct sockaddr_in6);
- else
-#endif /* INET6 */
- i = sizeof(struct sockaddr_in);
-
- st2 = st;
- while(st2) {
- if (!(*pai = malloc(sizeof(struct addrinfo) + i + j))) {
- i = -EAI_MEMORY;
- goto ret;
- }
- (*pai)->ai_flags = req->ai_flags;
- (*pai)->ai_family = at2->family;
- (*pai)->ai_socktype = st2->socktype;
- (*pai)->ai_protocol = st2->protocol;
- (*pai)->ai_addrlen = i;
- (*pai)->ai_addr = (void *)(*pai) + sizeof(struct addrinfo);
+ if (tmpbuf == NULL)
+ return -EAI_MEMORY;
+
+ rc = __gethostbyaddr_r (at2->addr,
+ ((at2->family == AF_INET6)
+ ? sizeof(struct in6_addr)
+ : sizeof(struct in_addr)),
+ at2->family, &th, tmpbuf, tmpbuflen,
+ &h, &herrno);
+
+ }
+ while ((rc != 0) && (herrno == NETDB_INTERNAL)
+ && (errno == ERANGE));
+
+ if ((rc != 0) && (herrno == NETDB_INTERNAL))
+ {
+ __set_h_errno (herrno);
+ return -EAI_SYSTEM;
+ }
+
+ if (h == NULL)
+ c = inet_ntop (at2->family, at2->addr, buffer, sizeof(buffer));
+ else
+ c = h->h_name;
+
+ if (c == NULL)
+ return GAIH_OKIFUNSPEC | -EAI_NONAME;
+
+ namelen = strlen (c) + 1;
+ }
+ else
+ namelen = 0;
+
+ if (at2->family == AF_INET6)
+ socklen = sizeof (struct sockaddr_in6);
+ else
+ socklen = sizeof (struct sockaddr_in);
+
+ for (st2 = st; st2 != NULL; st2 = st2->next)
+ {
+ *pai = malloc (sizeof (struct addrinfo) + socklen + namelen);
+ if (*pai == NULL)
+ return -EAI_MEMORY;
+
+ (*pai)->ai_flags = req->ai_flags;
+ (*pai)->ai_family = at2->family;
+ (*pai)->ai_socktype = st2->socktype;
+ (*pai)->ai_protocol = st2->protocol;
+ (*pai)->ai_addrlen = socklen;
+ (*pai)->ai_addr = (void *) (*pai) + sizeof(struct addrinfo);
#if SALEN
- ((struct sockaddr_in *)(*pai)->ai_addr)->sin_len = i;
+ ((struct sockaddr_in *) (*pai)->ai_addr)->sin_len = i;
#endif /* SALEN */
- ((struct sockaddr_in *)(*pai)->ai_addr)->sin_family = at2->family;
- ((struct sockaddr_in *)(*pai)->ai_addr)->sin_port = st2->port;
-
-#if INET6
- if (at2->family == AF_INET6) {
- ((struct sockaddr_in6 *)(*pai)->ai_addr)->sin6_flowinfo = 0;
- memcpy(&((struct sockaddr_in6 *)(*pai)->ai_addr)->sin6_addr, at2->addr, sizeof(struct in6_addr));
- } else
-#endif /* INET6 */
- {
- memcpy(&((struct sockaddr_in *)(*pai)->ai_addr)->sin_addr, at2->addr, sizeof(struct in_addr));
- memset(((struct sockaddr_in *)(*pai)->ai_addr)->sin_zero, 0, sizeof(((struct sockaddr_in *)(*pai)->ai_addr)->sin_zero));
- }
+ ((struct sockaddr_in *) (*pai)->ai_addr)->sin_family = at2->family;
+ ((struct sockaddr_in *) (*pai)->ai_addr)->sin_port = st2->port;
- if (c) {
- (*pai)->ai_canonname = (void *)(*pai) + sizeof(struct addrinfo) + i;
- strcpy((*pai)->ai_canonname, c);
- } else
- (*pai)->ai_canonname = NULL;
- (*pai)->ai_next = NULL;
+ if (at2->family == AF_INET6)
+ {
+ struct sockaddr_in6 *sin6p =
+ (struct sockaddr_in6 *) (*pai)->ai_addr;
- pai = &((*pai)->ai_next);
+ sin6p->sin6_flowinfo = 0;
+ memcpy (&sin6p->sin6_addr,
+ at2->addr, sizeof (struct in6_addr));
+ }
+ else
+ {
+ struct sockaddr_in *sinp =
+ (struct sockaddr_in *) (*pai)->ai_addr;
+ memcpy (&sinp->sin_addr,
+ at2->addr, sizeof (struct in_addr));
+ memset (sinp->sin_zero, '\0', sizeof (sinp->sin_zero));
+ }
- st2 = st2->next;
- }
- at2 = at2->next;
- }
- }
+ if (c)
+ {
+ (*pai)->ai_canonname = ((void *) (*pai) +
+ sizeof (struct addrinfo) + socklen);
+ strcpy ((*pai)->ai_canonname, c);
+ }
+ else
+ (*pai)->ai_canonname = NULL;
- i = 0;
+ (*pai)->ai_next = NULL;
+ pai = &((*pai)->ai_next);
+ }
-ret:
- if (st != &nullserv) {
- struct gaih_servtuple *st2 = st;
- while(st) {
- st2 = st->next;
- free(st);
- st = st2;
- }
- }
- if (at) {
- struct gaih_addrtuple *at2 = at;
- while(at) {
- at2 = at->next;
- free(at);
- at = at2;
- }
+ at2 = at2->next;
+ }
}
- return i;
+ return 0;
}
-struct gaih {
- int family;
- int (*gaih)(const char *name, const struct gaih_service *service,
- const struct addrinfo *req, struct addrinfo **pai);
-};
-
-static struct gaih gaih[] = {
-#if INET6
- { PF_INET6, gaih_inet },
-#endif /* INET6 */
- { PF_INET, gaih_inet },
-#if LOCAL
- { PF_LOCAL, gaih_local },
-#endif /* LOCAL */
- { PF_UNSPEC, NULL }
-};
+static struct gaih gaih[] =
+ {
+ { PF_INET6, gaih_inet },
+ { PF_INET, gaih_inet },
+ { PF_LOCAL, gaih_local },
+ { PF_UNSPEC, NULL }
+ };
-int getaddrinfo(const char *name, const char *service,
- const struct addrinfo *req, struct addrinfo **pai)
+int
+getaddrinfo (const char *name, const char *service,
+ const struct addrinfo *hints, struct addrinfo **pai)
{
int i = 0, j = 0;
struct addrinfo *p = NULL, **end;
struct gaih *g = gaih, *pg = NULL;
struct gaih_service gaih_service, *pservice;
- if (name && (name[0] == '*') && !name[1])
+ if (name != NULL && name[0] == '*' && name[1] == 0)
name = NULL;
- if (service && (service[0] == '*') && !service[1])
+ if (service != NULL && service[0] == '*' && service[1] == 0)
service = NULL;
-#if BROKEN_LIKE_POSIX
- if (!name && !service)
+ if (name == NULL && service == NULL)
return EAI_NONAME;
-#endif /* BROKEN_LIKE_POSIX */
- if (!req)
- req = &nullreq;
+ if (hints == NULL)
+ hints = &default_hints;
- if (req->ai_flags & ~3)
+ if (hints->ai_flags & ~3)
return EAI_BADFLAGS;
- if ((req->ai_flags & AI_CANONNAME) && !name)
+ if ((hints->ai_flags & AI_CANONNAME) && name == NULL)
return EAI_BADFLAGS;
- if (service && *service) {
- char *c;
- gaih_service.num = strtoul(gaih_service.name = (void *)service, &c, 10);
- if (*c) {
- gaih_service.num = -1;
- }
-#if BROKEN_LIKE_POSIX
+ if (service && service[0])
+ {
+ char *c;
+ gaih_service.name = service;
+ gaih_service.num = strtoul (gaih_service.name, &c, 10);
+ if (*c)
+ gaih_service.num = -1;
else
- if (!req->ai_socktype)
+ /* Can't specify a numerical socket unless a protocol family was
+ given. */
+ if (hints->ai_socktype == 0)
return EAI_SERVICE;
-#endif /* BROKEN_LIKE_POSIX */
- pservice = &gaih_service;
- } else
+ pservice = &gaih_service;
+ }
+ else
pservice = NULL;
if (pai)
@@ -633,51 +559,58 @@ int getaddrinfo(const char *name, const char *service,
else
end = NULL;
- while(g->gaih) {
- if ((req->ai_family == g->family) || !req->ai_family) {
- j++;
- if (!((pg && (pg->gaih == g->gaih)))) {
- pg = g;
- if (i = g->gaih(name, pservice, req, end)) {
- if (!req->ai_family && (i & GAIH_OKIFUNSPEC))
- continue;
- goto gaih_err;
+ while (g->gaih)
+ {
+ if ((hints->ai_family == g->family) || (hints->ai_family == AF_UNSPEC))
+ {
+ j++;
+ if ((pg == NULL) || (pg->gaih != g->gaih))
+ {
+ pg = g;
+ if (i = g->gaih (name, pservice, hints, end))
+ {
+ if ((hints->ai_family == AF_UNSPEC) && (i & GAIH_OKIFUNSPEC))
+ continue;
+
+ if (p)
+ freeaddrinfo (p);
+
+ return (i)?-(i & GAIH_EAI):EAI_NONAME;
+ }
+ if (end)
+ while(*end) end = &((*end)->ai_next);
+ }
}
- if (end)
- while(*end) end = &((*end)->ai_next);
- }
+ ++g;
}
- g++;
- }
- if (!j)
+ if (j == 0)
return EAI_FAMILY;
- if (p) {
- *pai = p;
- return 0;
- }
+ if (p)
+ {
+ *pai = p;
+ return 0;
+ }
- if (!pai && !i)
+ if (pai == NULL && i == 0)
return 0;
-gaih_err:
if (p)
- freeaddrinfo(p);
-
- if (i)
- return -(i & GAIH_EAI);
+ freeaddrinfo (p);
- return EAI_NONAME;
+ return i ? -(i & GAIH_EAI) : EAI_NONAME;
}
-void freeaddrinfo(struct addrinfo *ai)
+void
+freeaddrinfo (struct addrinfo *ai)
{
struct addrinfo *p;
- while(ai) {
- p = ai;
- ai = ai->ai_next;
- free((void *)p);
- }
+ while (ai != NULL)
+ {
+ p = ai;
+ ai = ai->ai_next;
+ free (p);
+ }
}
diff --git a/sysdeps/sparc/sparc32/elf/Makefile b/sysdeps/sparc/sparc32/elf/Makefile
index 319fbdef10..a995e6cdf1 100644
--- a/sysdeps/sparc/sparc32/elf/Makefile
+++ b/sysdeps/sparc/sparc32/elf/Makefile
@@ -1,4 +1,4 @@
# Sparc/ELF specific definitions.
# The assembler on SPARC needs the -fPIC flag even when it's assembler code.
-ASFLAGS-.so = -fPIC
+ASFLAGS-.os = -fPIC
diff --git a/sysdeps/sparc/sparc64/elf/Makefile b/sysdeps/sparc/sparc64/elf/Makefile
index 1b38355b38..8da8a88c1b 100644
--- a/sysdeps/sparc/sparc64/elf/Makefile
+++ b/sysdeps/sparc/sparc64/elf/Makefile
@@ -1,5 +1,5 @@
# The assembler on SPARC needs the -fPIC flag even when it's assembler code.
-ASFLAGS-.so = -fPIC
+ASFLAGS-.os = -fPIC
ifeq ($(subdir), csu)
extra-objs += crtbegin.o crtend.o crtbeginS.o crtendS.o
diff --git a/sysdeps/unix/sysv/linux/if_index.c b/sysdeps/unix/sysv/linux/if_index.c
index 615a81d14a..7d7fc02717 100644
--- a/sysdeps/unix/sysv/linux/if_index.c
+++ b/sysdeps/unix/sysv/linux/if_index.c
@@ -113,62 +113,85 @@ if_nameindex (void)
int fd = opensock ();
struct ifconf ifc;
unsigned int rq_ifs = 4, nifs, i;
+ int rq_len;
struct if_nameindex *idx = NULL;
+#ifdef SIOCGIFCOUNT
+ static int siocgifcount_works = 1;
+#endif
if (fd < 0)
return NULL;
+#ifdef SIOCGIFCOUNT
+ /* We may be able to find out how many interfaces really exist, rather
+ than guessing. This ioctl is not present in kernels before version
+ 2.1.50. */
+ if (siocgifcount_works)
+ {
+ int serrno = errno;
+
+ if (ioctl (fd, SIOCGIFCOUNT, &nifs) < 0)
+ {
+ if (errno == EINVAL)
+ {
+ siocgifcount_works = 0;
+ __set_errno (serrno);
+ }
+ }
+ else
+ rq_ifs = nifs + 1;
+ }
+#endif
+
ifc.ifc_buf = NULL;
/* Read all the interfaces out of the kernel. */
do
{
- rq_ifs *= 2;
- ifc.ifc_len = rq_ifs * sizeof (struct ifreq);
- ifc.ifc_buf = realloc (ifc.ifc_buf, ifc.ifc_len);
- if (ifc.ifc_buf == NULL)
+ rq_len = ifc.ifc_len = rq_ifs * sizeof (struct ifreq);
+ ifc.ifc_buf = alloca (ifc.ifc_len);
+ if ((ifc.ifc_buf == NULL) || (ioctl (fd, SIOCGIFCONF, &ifc) < 0))
{
- close(fd);
+ close (fd);
return NULL;
}
- if (ioctl (fd, SIOCGIFCONF, &ifc) < 0)
- goto jump;
+ rq_ifs *= 2;
}
- while ((unsigned int) ifc.ifc_len == (rq_ifs * sizeof (struct ifreq)));
+ while (ifc.ifc_len == rq_len);
nifs = ifc.ifc_len / sizeof (struct ifreq);
- ifc.ifc_buf = realloc (ifc.ifc_buf, ifc.ifc_len);
- idx = malloc ((nifs+1) * sizeof (struct if_nameindex));
+ idx = malloc ((nifs + 1) * sizeof (struct if_nameindex));
if (idx == NULL)
- goto jump;
+ {
+ close (fd);
+ return NULL;
+ }
for (i = 0; i < nifs; ++i)
{
struct ifreq *ifr = &ifc.ifc_req[i];
- if ((idx[i].if_name = malloc (strlen (ifr->ifr_name)+1)) == NULL)
- {
- free (idx);
- idx = NULL;
- goto jump;
- }
- strcpy (idx[i].if_name, ifr->ifr_name);
- if (ioctl (fd, SIOGIFINDEX, ifr) < 0)
+ idx[i].if_name = __strdup (ifr->ifr_name);
+ if (idx[i].if_name == NULL
+ || ioctl (fd, SIOGIFINDEX, ifr) < 0)
{
int saved_errno = errno;
+ unsigned int j;
+
+ for (j = 0; j < i; ++j)
+ free (idx[j].if_name);
free (idx);
- idx = NULL;
+ close (fd);
if (saved_errno == EINVAL)
__set_errno (ENOSYS);
- goto jump;
+ return NULL;
}
idx[i].if_index = ifr->ifr_ifindex;
}
+
idx[i].if_index = 0;
idx[i].if_name = NULL;
-jump:
- free (ifc.ifc_buf);
close (fd);
return idx;
#endif
@@ -181,10 +204,46 @@ if_indextoname (unsigned int ifindex, char *ifname)
__set_errno (ENOSYS);
return NULL;
#else
- struct if_nameindex *idx = if_nameindex ();
+ struct if_nameindex *idx;
struct if_nameindex *p;
char *result = NULL;
+#ifdef SIOGIFNAME
+ /* We may be able to do the conversion directly, rather than searching a
+ list. This ioctl is not present in kernels before version 2.1.50. */
+ struct ifreq ifr;
+ int fd;
+ static int siogifname_works = 1;
+
+ if (siogifname_works)
+ {
+ int serrno = errno;
+
+ fd = opensock ();
+
+ if (fd < 0)
+ return NULL;
+
+ ifr.ifr_ifindex = ifindex;
+ if (ioctl (fd, SIOGIFNAME, &ifr) < 0)
+ {
+ if (errno == EINVAL)
+ siogifname_works = 0; /* Don't make the same mistake twice. */
+ }
+ else
+ {
+ close (fd);
+ return strncpy (ifname, ifr.ifr_name, IFNAMSIZ);
+ }
+
+ close (fd);
+
+ __set_errno (serrno);
+ }
+#endif
+
+ idx = if_nameindex ();
+
if (idx != NULL)
{
for (p = idx; p->if_index || p->if_name; ++p)
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/Makefile b/sysdeps/unix/sysv/linux/sparc/sparc32/Makefile
index 4cbd3bd004..01a0e8310f 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/Makefile
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/Makefile
@@ -3,7 +3,7 @@ sysdep_routines += __sigtrampoline
endif
asm-CPPFLAGS=-D__ASSEMBLY__
-as-FLAGS-.so=-fPIC
+ASFLAGS-.os=-fPIC
# When I get this to work, this is the right thing
ifeq ($(subdir),elf)
diff --git a/sysdeps/unix/sysv/linux/sys/mount.h b/sysdeps/unix/sysv/linux/sys/mount.h
index 08a2e3158f..f7d45704d2 100644
--- a/sysdeps/unix/sysv/linux/sys/mount.h
+++ b/sysdeps/unix/sysv/linux/sys/mount.h
@@ -57,28 +57,6 @@ __BEGIN_DECLS
#define MS_MGC_MSK 0xffff0000 /* Magic flag number mask */
-/* Note that read-only etc flags are inode-specific: setting some
- file-system flags just means all the inodes inherit those flags by
- default. It might be possible to override it selectively if you
- really wanted to with some ioctl() that is not currently
- implemented.
-
- Exception: MS_RDONLY is always applied to the entire file system. */
-#define IS_RDONLY(inode) \
- (((inode)->i_sb) && ((inode)->i_sb->s_flags & MS_RDONLY))
-#define DO_UPDATE_ATIME(inode) \
- (!((inode)->i_flags & MS_NOATIME) && !IS_RDONLY (inode))
-#define IS_NOSUID(inode) ((inode)->i_flags & MS_NOSUID)
-#define IS_NODEV(inode) ((inode)->i_flags & MS_NODEV)
-#define IS_NOEXEC(inode) ((inode)->i_flags & MS_NOEXEC)
-#define IS_SYNC(inode) ((inode)->i_flags & MS_SYNCHRONOUS)
-#define IS_MANDLOCK(inode) ((inode)->i_flags & MS_MANDLOCK)
-
-#define IS_WRITABLE(inode) ((inode)->i_flags & S_WRITE)
-#define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
-#define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
-
-
/* The read-only stuff doesn't really belong here, but any other place
is probably as bad and I don't want to create yet another include
file. */
diff --git a/time/tzset.c b/time/tzset.c
index d7659008bc..49935c04d3 100644
--- a/time/tzset.c
+++ b/time/tzset.c
@@ -312,13 +312,18 @@ __tzset_internal (always)
{
free (old_tz);
old_tz = NULL;
+ free (tzbuf);
return;
}
}
}
else
- /* There is no DST. */
- tz_rules[1].name = tz_rules[0].name;
+ {
+ /* There is no DST. */
+ tz_rules[1].name = tz_rules[0].name;
+ free (tzbuf);
+ return;
+ }
done_names:
free (tzbuf);