summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1996-05-26 19:19:51 +0000
committerRoland McGrath <roland@gnu.org>1996-05-26 19:19:51 +0000
commit59dd864187ee61b6f0bfd7abc85e2fea4b479cb7 (patch)
treee935d6f39bffe914520946c22a89e11180ba4745
parent27a110706b570569049e6702f99670e3064e53c1 (diff)
Sun May 26 15:15:08 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
* stdlib/ldiv.c: Deansideclized. Sun May 26 19:39:53 1996 Ulrich Drepper <drepper@cygnus.com> * intl/loadmsgcat.c (_nl_load_domain): Test correct variable after malloc. * string/Makefile (tester-ENV): New variable to suppress message translation in test. * string/tester.c: Add tests for strtok_r and strsep. * sysdeps/i386/i486/strcat.S: Correct some more 8bit operation <-> 32 bit operand conflicts. * sysdeps/i386/strsep.S: Wrapper around <sysdeps/i386/strtok.S> to produce strsep function. * sysdeps/i386/strtok.S: Optimized implementation of strtok function. * sysdeps/i386/strtok_r.S: Wrapper around <sysdeps/i386/strtok.S> to produce strtok_r function. * sysdeps/generic/strtok.c: Moved here from string/strtok.c. Corrected example in comment. * string/Makefile (routines): Add strtok_r. * sysdeps/generic/strtok_r.c: New file. Implement reentrant version of strtok_r. * string/string.h: Add prototype for strtok_r. * wcsmbs/wcstok.c: Handle illegal SAVE_PTR argument the same as in strtok_r. Sun May 26 13:28:23 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu> * time/tzset.c (__tzset): Ignore leading : in $TZ; always try tzfile first and fall back to 1003.1 syntax only if it fails. * time/Makefile (install-others): Also install posix/ZONE and right/ZONE for each ZONE in $(zonenames). (z.% rule): Generate rules for right/ZONE and posix/ZONE targets too, the difference begin leapseconds vs /dev/null as 3rd dep. For original ZONE targets use $(leapseconds), to be set in Makeconfig. (target-zone-flavor): New variable. (tzcompile): Use it to get the right -d for posix/ and right/ flavors. * Makeconfig (leapseconds): New variable. * mach/Machrules (%.udeps rule): Depend on Machrules. Emit deps for .uh and .__h files. (%.uh, %.__h rules): Don't depend on %.defs; use #include <$*.defs> instead. Sun May 26 01:06:47 1996 Ulrich Drepper <drepper@cygnus.com> * stdlib/Makefile (routines): Add llabs, lldiv. * stdlib/llabs.c: New file. Implementation of return absolute value of long long argument. * stdlib/lldiv.c: New file. Implementation of division with remainder of long long argument. * stdlib/stdlib.h [__USE_GNU] (lldiv_t): New type for lldiv function. Define prototypes for lldiv and llabs functions. * locale/C-collate.c: Initialize _NL_COLLATE_NRULES element. * stdlib/strtod.c: Replace wchar_t with wint_t. The later is really the type for a single wide character. * string/strxfrm.c (print_val): Define separate version for use as wcsxfrm. Here we don't need UTF8 encoding. * wcsmbs/wchar.h: gcc-2.7.2-960517 finally introduces wint_t in <stddef.h>. Use this value and only for older gcc version define in place. (uwchar_t): Remove definition. * wcsmbs/wcscmp.c, wcsmbs/wcscoll.c, wcsmbs/wcsncmp.c, wcsmbs/wcsxfrm.c, wcsmbs/wmemcmp.c: : Don't use uwchar_t as unsigned type. wint_t is intended for this. Sat May 25 14:10:19 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu> * sysdeps/unix/bsd/direntry.h: Use [1] instead of [0] for d_name to quiet -ansi -pedantic. * sysdeps/unix/common/direntry.h: Likewise. * login/Makefile (headers): Add lastlog.h. * login/lastlog.h: New file. * login/Makefile (CFLAGS): Don't append -D_THREAD_SAFE. * login/utmp.h [_REENTRANT || _THREAD_SAFE]: Replace this conditional with #ifdef __USE_REENTRANT. * features.h (__GNU_LIBRARY__): Set to 6. [_GNU_SOURCE] (_POSIX_SOURCE, _POSIX_C_SOURCE, _BSD_SOURCE, _SVID_SOURCE): Make sure they are all defined. * sysdeps/unix/sysv/linux/gnu/types.h: Instead of including <linux/posix_types.h>, define _LINUX_TYPES_DONT_EXPORT and then include <linux/types.h>. * resource/sys/resource.h: Remove trailing commas from enums. * sysdeps/generic/netinet/in.h: Remove trailing commas from enums. * sysdeps/unix/sysv/linux/netinet/in.h: Likewise.
-rw-r--r--ChangeLog107
-rw-r--r--Makeconfig10
-rwxr-xr-xconfig.guess4
-rw-r--r--features.h31
-rw-r--r--intl/loadmsgcat.c2
-rw-r--r--locale/C-collate.c5
-rw-r--r--login/Makefile4
-rw-r--r--login/lastlog.h4
-rw-r--r--login/utmp.h4
-rw-r--r--mach/Machrules15
-rw-r--r--resource/sys/resource.h6
-rw-r--r--stdlib/Makefile4
-rw-r--r--stdlib/llabs.c31
-rw-r--r--stdlib/lldiv.c57
-rw-r--r--stdlib/stdlib.h17
-rw-r--r--stdlib/strtod.c13
-rw-r--r--string/Makefile4
-rw-r--r--string/string.h5
-rw-r--r--string/strtok.c20
-rw-r--r--string/strxfrm.c54
-rw-r--r--string/tester.c96
-rw-r--r--sysdeps/generic/netinet/in.h6
-rw-r--r--sysdeps/generic/strtok.c73
-rw-r--r--sysdeps/generic/strtok_r.c74
-rw-r--r--sysdeps/i386/i486/strcat.S20
-rw-r--r--sysdeps/i386/strsep.S3
-rw-r--r--sysdeps/i386/strtok.S329
-rw-r--r--sysdeps/i386/strtok_r.S3
-rw-r--r--sysdeps/unix/bsd/direntry.h2
-rw-r--r--sysdeps/unix/common/direntry.h2
-rw-r--r--sysdeps/unix/sysv/linux/gnu/types.h6
-rw-r--r--sysdeps/unix/sysv/linux/netinet/in.h6
-rw-r--r--time/Makefile21
-rw-r--r--time/tzset.c15
-rw-r--r--wcsmbs/wchar.h25
-rw-r--r--wcsmbs/wcscmp.c14
-rw-r--r--wcsmbs/wcscoll.c2
-rw-r--r--wcsmbs/wcsncmp.c32
-rw-r--r--wcsmbs/wcstok.c30
-rw-r--r--wcsmbs/wcsxfrm.c4
-rw-r--r--wcsmbs/wmemcmp.c34
41 files changed, 1042 insertions, 152 deletions
diff --git a/ChangeLog b/ChangeLog
index 8aa5f1f171..99b53b65f0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,112 @@
+Sun May 26 15:15:08 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
+
+ * stdlib/ldiv.c: Deansideclized.
+
+Sun May 26 19:39:53 1996 Ulrich Drepper <drepper@cygnus.com>
+
+ * intl/loadmsgcat.c (_nl_load_domain): Test correct variable
+ after malloc.
+
+ * string/Makefile (tester-ENV): New variable to suppress message
+ translation in test.
+
+ * string/tester.c: Add tests for strtok_r and strsep.
+
+ * sysdeps/i386/i486/strcat.S: Correct some more 8bit operation
+ <-> 32 bit operand conflicts.
+
+ * sysdeps/i386/strsep.S: Wrapper around <sysdeps/i386/strtok.S>
+ to produce strsep function.
+ * sysdeps/i386/strtok.S: Optimized implementation of strtok
+ function.
+ * sysdeps/i386/strtok_r.S: Wrapper around <sysdeps/i386/strtok.S>
+ to produce strtok_r function.
+
+ * sysdeps/generic/strtok.c: Moved here from string/strtok.c.
+ Corrected example in comment.
+
+ * string/Makefile (routines): Add strtok_r.
+ * sysdeps/generic/strtok_r.c: New file. Implement reentrant version
+ of strtok_r.
+ * string/string.h: Add prototype for strtok_r.
+ * wcsmbs/wcstok.c: Handle illegal SAVE_PTR argument the same
+ as in strtok_r.
+
+Sun May 26 13:28:23 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
+
+ * time/tzset.c (__tzset): Ignore leading : in $TZ; always try tzfile
+ first and fall back to 1003.1 syntax only if it fails.
+
+ * time/Makefile (install-others): Also install posix/ZONE and
+ right/ZONE for each ZONE in $(zonenames).
+ (z.% rule): Generate rules for right/ZONE and posix/ZONE targets too,
+ the difference begin leapseconds vs /dev/null as 3rd dep. For
+ original ZONE targets use $(leapseconds), to be set in Makeconfig.
+ (target-zone-flavor): New variable.
+ (tzcompile): Use it to get the right -d for posix/ and right/ flavors.
+ * Makeconfig (leapseconds): New variable.
+
+ * mach/Machrules (%.udeps rule): Depend on Machrules.
+ Emit deps for .uh and .__h files.
+ (%.uh, %.__h rules): Don't depend on %.defs; use #include <$*.defs>
+ instead.
+
+Sun May 26 01:06:47 1996 Ulrich Drepper <drepper@cygnus.com>
+
+ * stdlib/Makefile (routines): Add llabs, lldiv.
+ * stdlib/llabs.c: New file. Implementation of return
+ absolute value of long long argument.
+ * stdlib/lldiv.c: New file. Implementation of division with remainder
+ of long long argument.
+ * stdlib/stdlib.h [__USE_GNU] (lldiv_t): New type for lldiv
+ function.
+ Define prototypes for lldiv and llabs functions.
+
+ * locale/C-collate.c: Initialize _NL_COLLATE_NRULES element.
+
+ * stdlib/strtod.c: Replace wchar_t with wint_t. The later is
+ really the type for a single wide character.
+
+ * string/strxfrm.c (print_val): Define separate version for
+ use as wcsxfrm. Here we don't need UTF8 encoding.
+
+ * wcsmbs/wchar.h: gcc-2.7.2-960517 finally introduces wint_t
+ in <stddef.h>. Use this value and only for older gcc version
+ define in place.
+ (uwchar_t): Remove definition.
+
+ * wcsmbs/wcscmp.c, wcsmbs/wcscoll.c, wcsmbs/wcsncmp.c,
+ wcsmbs/wcsxfrm.c, wcsmbs/wmemcmp.c: : Don't use uwchar_t as unsigned
+ type. wint_t is intended for this.
+
+Sat May 25 14:10:19 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
+
+ * sysdeps/unix/bsd/direntry.h: Use [1] instead of [0] for d_name to
+ quiet -ansi -pedantic.
+ * sysdeps/unix/common/direntry.h: Likewise.
+
+ * login/Makefile (headers): Add lastlog.h.
+ * login/lastlog.h: New file.
+
+ * login/Makefile (CFLAGS): Don't append -D_THREAD_SAFE.
+ * login/utmp.h [_REENTRANT || _THREAD_SAFE]: Replace this conditional
+ with #ifdef __USE_REENTRANT.
+
+ * features.h (__GNU_LIBRARY__): Set to 6.
+ [_GNU_SOURCE] (_POSIX_SOURCE, _POSIX_C_SOURCE, _BSD_SOURCE,
+ _SVID_SOURCE): Make sure they are all defined.
+
+ * sysdeps/unix/sysv/linux/gnu/types.h: Instead of including
+ <linux/posix_types.h>, define _LINUX_TYPES_DONT_EXPORT and then
+ include <linux/types.h>.
+
+ * resource/sys/resource.h: Remove trailing commas from enums.
+
Fri May 24 17:30:50 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
+ * sysdeps/generic/netinet/in.h: Remove trailing commas from enums.
+ * sysdeps/unix/sysv/linux/netinet/in.h: Likewise.
+
* login/getutline_r.c: Include string.h.
* Rules (static-only-routines): Restore the rule to make these .so's
diff --git a/Makeconfig b/Makeconfig
index d871789e28..d2bbbb2517 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -221,6 +221,16 @@ ifndef localtime-file
localtime-file = $(sysconfdir)/localtime
endif
+# What to use for leap second specifications in compiling the default
+# timezone files. Set this to `/dev/null' for no leap second handling as
+# 1003.1 requires, or to `leapseconds' for proper leap second handling.
+# Both zone flavors are always available as `posix/ZONE' and `right/ZONE'.
+# This variable determines the default: if it's `/dev/null',
+# ZONE==posix/ZONE; if it's `leapseconds', ZONE==right/ZONE.
+ifndef leapseconds
+leapseconds = /dev/null
+endif
+
# What timezone's DST rules should be used when a POSIX-style TZ
# environment variable doesn't specify any rules. For 1003.1 compliance
# this timezone must use rules that are as U.S. federal law defines DST.
diff --git a/config.guess b/config.guess
index d8c24708af..ab53d14633 100755
--- a/config.guess
+++ b/config.guess
@@ -137,7 +137,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
AViiON:dgux:*:*)
# DG/UX returns AViiON for all architectures
UNAME_PROCESSOR=`/usr/bin/uname -p`
- if [ $UNAME_PROCESSOR = mc88100 -o $UNAME_PROCESSOR = mc88100 ] ; then
+ if [ $UNAME_PROCESSOR = mc88100 -o $UNAME_PROCESSOR = mc88110 ] ; then
if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \
-o ${TARGET_BINARY_INTERFACE}x = x ] ; then
echo m88k-dg-dgux${UNAME_RELEASE}
@@ -211,7 +211,7 @@ EOF
echo romp-ibm-bsd4.4
exit 0 ;;
ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC NetBSD and
- echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
+ echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
exit 0 ;; # report: romp-ibm BSD 4.3
*:BOSX:*:*)
echo rs6000-bull-bosx
diff --git a/features.h b/features.h
index de1fe008a2..4b50bea75a 100644
--- a/features.h
+++ b/features.h
@@ -50,7 +50,6 @@ Cambridge, MA 02139, USA. */
The macro `__GNU_LIBRARY__' is defined by this file unconditionally.
- All macros defined by this file are defined as 1.
All macros listed above as possibly being defined by this file are
explicitly undefined if they are not explicitly defined.
Feature-test macros that are not defined by the user or compiler
@@ -80,32 +79,42 @@ Cambridge, MA 02139, USA. */
#define __FAVOR_BSD 1
#endif
+/* If _GNU_SOURCE was defined by the user, turn on all the other features. */
+#ifdef _GNU_SOURCE
+/* If the user specifies some of the following without _GNU_SOURCE,
+ they are mutually exclusive. But they all default below to on,
+ so undefine them to get all the features turned on for _GNU_SOURCE. */
+#undef _POSIX_SOURCE
+#undef _POSIX_C_SOURCE
+#undef _BSD_SOURCE
+#undef _SVID_SOURCE
+#endif
/* If nothing (other than _GNU_SOURCE) is defined,
define _BSD_SOURCE and _SVID_SOURCE. */
-#if (!defined(__STRICT_ANSI__) && !defined(_POSIX_SOURCE) && \
- !defined(_POSIX_C_SOURCE) && !defined(_BSD_SOURCE) && \
- !defined(_SVID_SOURCE))
+#if (!defined (__STRICT_ANSI__) && !defined (_POSIX_SOURCE) && \
+ !defined (_POSIX_C_SOURCE) && !defined (_BSD_SOURCE) && \
+ !defined (_SVID_SOURCE))
#define _BSD_SOURCE 1
#define _SVID_SOURCE 1
#endif
/* If none of the ANSI/POSIX macros are defined, use POSIX.1 and POSIX.2. */
-#if (!defined(__STRICT_ANSI__) && !defined(_POSIX_SOURCE) && \
- !defined(_POSIX_C_SOURCE))
+#if (!defined (__STRICT_ANSI__) && !defined (_POSIX_SOURCE) && \
+ !defined (_POSIX_C_SOURCE))
#define _POSIX_SOURCE 1
#define _POSIX_C_SOURCE 2
#endif
-#if defined(_POSIX_SOURCE) || _POSIX_C_SOURCE >= 1
+#if defined (_POSIX_SOURCE) || _POSIX_C_SOURCE >= 1
#define __USE_POSIX 1
#endif
-#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 2
+#if defined (_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 2
#define __USE_POSIX2 1
#endif
-#if defined(_BSD_SOURCE) || defined(_SVID_SOURCE)
+#if defined (_BSD_SOURCE) || defined (_SVID_SOURCE)
#define __USE_MISC 1
#endif
@@ -133,10 +142,10 @@ Cambridge, MA 02139, USA. */
the shared C library corresponding to this set of header files. */
#undef __GNU_LIBRARY__
-#define __GNU_LIBRARY__ 5
+#define __GNU_LIBRARY__ 6
-#if !defined(__GNUC__) || __GNUC__ < 2
+#if !defined (__GNUC__) || __GNUC__ < 2
/* In GCC version 2, (__extension__ EXPR) will not complain
about GCC extensions used in EXPR under -ansi or -pedantic. */
#define __extension__
diff --git a/intl/loadmsgcat.c b/intl/loadmsgcat.c
index 1daf72a09f..90eed87fd9 100644
--- a/intl/loadmsgcat.c
+++ b/intl/loadmsgcat.c
@@ -161,7 +161,7 @@ _nl_load_domain (domain_file)
domain_file->data
= (struct loaded_domain *) malloc (sizeof (struct loaded_domain *));
- if (domain->data == NULL)
+ if (domain_file->data == NULL)
return;
domain = (struct loaded_domain *) domain_file->data;
diff --git a/locale/C-collate.c b/locale/C-collate.c
index 3b89e4fbe8..9535d4faa1 100644
--- a/locale/C-collate.c
+++ b/locale/C-collate.c
@@ -23,5 +23,8 @@ const struct locale_data _nl_C_LC_COLLATE =
{
_nl_C_name,
NULL, 0, /* no file mapped */
- 0,
+ 1,
+ {
+ { word: 0 }
+ }
};
diff --git a/login/Makefile b/login/Makefile
index d3e6ac8aa5..99687433a0 100644
--- a/login/Makefile
+++ b/login/Makefile
@@ -22,7 +22,7 @@
subdir := login
-headers := utmp.h utmpbits.h
+headers := utmp.h utmpbits.h lastlog.h
routines := setutent endutent getutent getutid getutline pututline \
setutent_r endutent_r getutent_r getutid_r getutline_r \
@@ -34,5 +34,3 @@ libutil-routines:= login login_tty logout logwtmp pty
include ../Rules
-
-override CFLAGS += -D_THREAD_SAFE
diff --git a/login/lastlog.h b/login/lastlog.h
new file mode 100644
index 0000000000..f2443eb702
--- /dev/null
+++ b/login/lastlog.h
@@ -0,0 +1,4 @@
+/* This header file is used in 4.3BSD to define `struct lastlog',
+ which we define in <utmpbits.h>. */
+
+#include <utmp.h>
diff --git a/login/utmp.h b/login/utmp.h
index 2ba3da8e0b..b53e13a9e0 100644
--- a/login/utmp.h
+++ b/login/utmp.h
@@ -62,7 +62,7 @@ extern struct utmp *getutline __P ((__const struct utmp *__line));
extern struct utmp *pututline __P ((__const struct utmp *__utmp_ptr));
-#if defined(_REENTRANT) || defined(_THREAD_SAFE)
+#ifdef __USE_REENTRANT
/* Define the data structure needed for the reentrent version. */
struct utmp_data
{
@@ -89,7 +89,7 @@ extern int getutline_r __P ((__const struct utmp *__line, struct utmp **__utmp,
extern int pututline_r __P ((__const struct utmp *__utmp_ptr,
struct utmp_data *__utmp_data));
-#endif /* _REENTRENT || _THREAD_SAFE */
+#endif /* Use reentrant. */
__END_DECLS
diff --git a/mach/Machrules b/mach/Machrules
index 6f1c1948c5..bc0ee3783b 100644
--- a/mach/Machrules
+++ b/mach/Machrules
@@ -115,11 +115,12 @@ $(patsubst %,$(objpfx)%.ustamp,$(user-interfaces)): $(objpfx)%.ustamp:
done
touch $@
-include $(patsubst %,$(objpfx)%.udeps,$(user-interfaces))
-$(patsubst %,$(objpfx)%.udeps,$(user-interfaces)): $(objpfx)%.udeps:
+$(patsubst %,$(objpfx)%.udeps,$(user-interfaces)):
+ $(objpfx)%.udeps: $(..)mach/Machrules
$(make-target-directory)
echo '#include <$*.defs>' | \
$(CC) $(CPPFLAGS) -M -x c - | \
- sed -e 's,- *:,$@ $(@:.udeps=.ustamp) \
+ sed -e 's,- *:,$@ $(@:.udeps=.ustamp) $(@:.udeps=.uh) $(@:.udeps=.__h)\
$(@:.udeps=_server.c) $(@:.udeps=_server.h):,' \
$(sed-remove-objpfx) > $@.new
mv -f $@.new $@
@@ -137,16 +138,18 @@ $(objpfx)%_server.c $(objpfx)%_server.h:
# To get header files that declare both the straight and __ functions,
# we generate two files and paste them together.
-$(objpfx)%.uh: %.defs; $(mig.uh)
+$(objpfx)%.uh:; $(mig.uh)
define mig.uh
$(make-target-directory)
-$(MIG) $< $(MIGFLAGS) \
+echo '#include <$*.defs>' | \
+$(MIG) - /dev/null $(MIGFLAGS) \
-header $@ -server /dev/null -user /dev/null
endef
-$(objpfx)%.__h: %.defs; $(mig.__h)
+$(objpfx)%.__h:; $(mig.__h)
define mig.__h
$(make-target-directory)
-$(MIG) $< $(MIGFLAGS) -prefix __ \
+echo '#include <$*.defs>' | \
+$(MIG) - /dev/null $(MIGFLAGS) -prefix __ \
-header $@ -server /dev/null -user /dev/null
endef
diff --git a/resource/sys/resource.h b/resource/sys/resource.h
index 9bef483359..14bec34d74 100644
--- a/resource/sys/resource.h
+++ b/resource/sys/resource.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 1994 Free Software Foundation, Inc.
+/* Copyright (C) 1992, 1994, 1996 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
@@ -59,7 +59,7 @@ enum __rusage_who
RUSAGE_SELF = 0,
#define RUSAGE_SELF RUSAGE_SELF
/* All of its terminated child processes. */
- RUSAGE_CHILDREN = -1,
+ RUSAGE_CHILDREN = -1
#define RUSAGE_CHILDREN RUSAGE_CHILDREN
};
@@ -134,7 +134,7 @@ enum __priority_which
{
PRIO_PROCESS = 0, /* WHO is a process ID. */
PRIO_PGRP = 1, /* WHO is a process group ID. */
- PRIO_USER = 2, /* WHO is a user ID. */
+ PRIO_USER = 2 /* WHO is a user ID. */
};
/* Return the highest priority of any process specified by WHICH and WHO
diff --git a/stdlib/Makefile b/stdlib/Makefile
index d30a0f2a06..46d7aa13a5 100644
--- a/stdlib/Makefile
+++ b/stdlib/Makefile
@@ -29,8 +29,8 @@ routines := \
bsearch qsort msort \
getenv putenv setenv \
exit on_exit atexit \
- abs labs \
- div ldiv \
+ abs labs llabs \
+ div ldiv lldiv \
mblen mbstowcs mbtowc wcstombs wctomb \
random random_r rand \
drand48 erand48 lrand48 nrand48 mrand48 jrand48 \
diff --git a/stdlib/llabs.c b/stdlib/llabs.c
new file mode 100644
index 0000000000..465028c481
--- /dev/null
+++ b/stdlib/llabs.c
@@ -0,0 +1,31 @@
+/* `long long int' absolute value.
+Copyright (C) 1991, 1996 Free Software Foundation, Inc.
+This file is part of the GNU C Library.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#include <stdlib.h>
+
+#undef llabs
+
+
+/* Return the absolute value of I. */
+long long int
+llabs (i)
+ long long int i;
+{
+ return i < 0 ? -i : i;
+}
diff --git a/stdlib/lldiv.c b/stdlib/lldiv.c
new file mode 100644
index 0000000000..1659e0f837
--- /dev/null
+++ b/stdlib/lldiv.c
@@ -0,0 +1,57 @@
+/* `long long int' divison with remainder.
+Copyright (C) 1992, 1996 Free Software Foundation, Inc.
+This file is part of the GNU C Library.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#include <stdlib.h>
+
+
+/* Return the `lldiv_t' representation of NUMER over DENOM. */
+lldiv_t
+lldiv (numer, denom)
+ long long int numer;
+ long long int denom;
+{
+ lldiv_t result;
+
+ result.quot = numer / denom;
+ result.rem = numer % denom;
+
+ /* The ANSI standard says that |QUOT| <= |NUMER / DENOM|, where
+ NUMER / DENOM is to be computed in infinite precision. In
+ other words, we should always truncate the quotient towards
+ zero, never -infinity. Machine division and remainer may
+ work either way when one or both of NUMER or DENOM is
+ negative. If only one is negative and QUOT has been
+ truncated towards -infinity, REM will have the same sign as
+ DENOM and the opposite sign of NUMER; if both are negative
+ and QUOT has been truncated towards -infinity, REM will be
+ positive (will have the opposite sign of NUMER). These are
+ considered `wrong'. If both are NUM and DENOM are positive,
+ RESULT will always be positive. This all boils down to: if
+ NUMER >= 0, but REM < 0, we got the wrong answer. In that
+ case, to get the right answer, add 1 to QUOT and subtract
+ DENOM from REM. */
+
+ if (numer >= 0 && result.rem < 0)
+ {
+ ++result.quot;
+ result.rem -= denom;
+ }
+
+ return result;
+}
diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h
index 1853c5babb..97b257248e 100644
--- a/stdlib/stdlib.h
+++ b/stdlib/stdlib.h
@@ -50,6 +50,15 @@ typedef struct
long int rem; /* Remainder. */
} ldiv_t;
+#ifdef __USE_GNU
+/* Returned by `lldiv'. */
+typedef struct
+ {
+ long long int quot; /* Quotient. */
+ long long int rem; /* Remainder. */
+ } lldiv_t;
+#endif
+
/* The largest number rand will return (same as INT_MAX). */
#define RAND_MAX 2147483647
@@ -407,13 +416,19 @@ extern void qsort __P ((__ptr_t __base, size_t __nmemb, size_t __size,
/* Return the absolute value of X. */
extern int abs __P ((int __x)) __attribute__ ((__const__));
extern long int labs __P ((long int __x)) __attribute__ ((__const__));
+#ifdef __USE_GNU
+extern long long int llabs __P ((long long int __x)) __attribute__ ((__const__));
+#endif
-/* Return the `div_t' or `ldiv_t' representation
+/* Return the `div_t', `ldiv_t' or `lldiv_t' representation
of the value of NUMER over DENOM. */
/* GCC may have built-ins for these someday. */
extern div_t div __P ((int __numer, int __denom)) __attribute__ ((__const__));
extern ldiv_t ldiv __P ((long int __numer, long int __denom)) __attribute__ ((__const__));
+#ifdef __USE_GNU
+extern lldiv_t lldiv __P ((long long int __numer, long long int __denom)) __attribute__ ((__const__));
+#endif
#ifdef __USE_SVID
diff --git a/stdlib/strtod.c b/stdlib/strtod.c
index 525a6f98a9..03a37bfb70 100644
--- a/stdlib/strtod.c
+++ b/stdlib/strtod.c
@@ -365,9 +365,9 @@ INTERNAL (STRTOF) (nptr, endptr, group)
CHAR_TYPE c;
/* The radix character of the current locale. */
- wchar_t decimal;
+ wint_t decimal;
/* The thousands character of the current locale. */
- wchar_t thousands;
+ wint_t thousands;
/* The numeric grouping specification of the current locale,
in the format described in <locale.h>. */
const char *grouping;
@@ -380,9 +380,10 @@ INTERNAL (STRTOF) (nptr, endptr, group)
else
{
/* Figure out the thousands separator character. */
- if (mbtowc (&thousands, _NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP),
+ if (mbtowc ((wchar_t *) &thousands,
+ _NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP),
strlen (_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP))) <= 0)
- thousands = (wchar_t) *_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP);
+ thousands = (wint_t) *_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP);
if (thousands == L'\0')
grouping = NULL;
}
@@ -394,9 +395,9 @@ INTERNAL (STRTOF) (nptr, endptr, group)
}
/* Find the locale's decimal point character. */
- if (mbtowc (&decimal, _NL_CURRENT (LC_NUMERIC, DECIMAL_POINT),
+ if (mbtowc ((wchar_t *) &decimal, _NL_CURRENT (LC_NUMERIC, DECIMAL_POINT),
strlen (_NL_CURRENT (LC_NUMERIC, DECIMAL_POINT))) <= 0)
- decimal = (wchar_t) *_NL_CURRENT (LC_NUMERIC, DECIMAL_POINT);
+ decimal = (wint_t) *_NL_CURRENT (LC_NUMERIC, DECIMAL_POINT);
/* Prepare number representation. */
diff --git a/string/Makefile b/string/Makefile
index af371ed689..02137316bf 100644
--- a/string/Makefile
+++ b/string/Makefile
@@ -28,7 +28,7 @@ routines := strcat strchr strcmp strcoll strcpy strcspn strdup \
strerror _strerror strlen strnlen \
strncat strncmp strncpy \
strrchr strpbrk strsignal strspn strstr strtok \
- strxfrm memchr memcmp memmove memset \
+ strtok_r strxfrm memchr memcmp memmove memset \
bcopy bzero ffs stpcpy stpncpy \
strcasecmp strncase \
memccpy memcpy wordcopy strsep \
@@ -42,3 +42,5 @@ distribute := memcopy.h pagecopy.h
include ../Rules
+
+tester-ENV = LANGUAGE=C
diff --git a/string/string.h b/string/string.h
index 5443d5009e..0df63d0653 100644
--- a/string/string.h
+++ b/string/string.h
@@ -120,6 +120,11 @@ extern char *strstr __P ((__const char *__haystack, __const char *__needle));
extern char *strtok __P ((char *__s, __const char *__delim));
#ifdef __USE_GNU
+/* Divide S into tokens separated by characters in DELIM. Information
+ passed between calls are stored in SAVE_PTR. */
+extern char *strtok_r __P ((char *__s, __const char *__delim,
+ char **__save_ptr));
+
/* Find the first occurence of NEEDLE in HAYSTACK.
NEEDLE is NEEDLELEN bytes long;
HAYSTACK is HAYSTACKLEN bytes long. */
diff --git a/string/strtok.c b/string/strtok.c
index 0b95084f53..954471322b 100644
--- a/string/strtok.c
+++ b/string/strtok.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1996 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
@@ -13,10 +13,9 @@ 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., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
-#include <ansidecl.h>
#include <errno.h>
#include <string.h>
@@ -26,15 +25,16 @@ static char *olds = NULL;
/* Parse S into tokens separated by characters in DELIM.
If S is NULL, the last string strtok() was called with is
used. For example:
- char s[] = "-abc=-def";
+ char s[] = "-abc-=-def";
x = strtok(s, "-"); // x = "abc"
- x = strtok(NULL, "=-"); // x = "def"
+ x = strtok(NULL, "-="); // x = "def"
x = strtok(NULL, "="); // x = NULL
// s = "abc\0-def\0"
*/
char *
-DEFUN(strtok, (s, delim),
- register char *s AND register CONST char *delim)
+strtok (s, delim)
+ char *s;
+ const char *delim;
{
char *token;
@@ -50,7 +50,7 @@ DEFUN(strtok, (s, delim),
}
/* Scan leading delimiters. */
- s += strspn(s, delim);
+ s += strspn (s, delim);
if (*s == '\0')
{
olds = NULL;
@@ -59,7 +59,7 @@ DEFUN(strtok, (s, delim),
/* Find the end of the token. */
token = s;
- s = strpbrk(token, delim);
+ s = strpbrk (token, delim);
if (s == NULL)
/* This token finishes the string. */
olds = NULL;
diff --git a/string/strxfrm.c b/string/strxfrm.c
index 300967bc2b..f94c16b50b 100644
--- a/string/strxfrm.c
+++ b/string/strxfrm.c
@@ -21,9 +21,10 @@ Boston, MA 02111-1307, USA. */
#include <stdlib.h>
#include <string.h>
-#ifndef STRING_TYPE
+#ifndef WIDE_VERSION
# define STRING_TYPE char
# define USTRING_TYPE unsigned char
+# define L_(Ch) Ch
# define STRXFRM strxfrm
# define STRLEN strlen
# define STPNCPY __stpncpy
@@ -34,9 +35,10 @@ Boston, MA 02111-1307, USA. */
#include "../locale/weight.h"
+#ifndef WIDE_VERSION
/* Write 32 bit value UTF-8 encoded but only if enough space is left. */
static __inline size_t
-print_val (u_int32_t value, STRING_TYPE *dest, size_t max, size_t act)
+print_val (u_int32_t value, char *dest, size_t max, size_t act)
{
char tmp[6];
int idx = 0;
@@ -90,6 +92,48 @@ print_val (u_int32_t value, STRING_TYPE *dest, size_t max, size_t act)
return act;
}
+#else
+static __inline size_t
+print_val (u_int32_t value, wchar_t *dest, size_t max, size_t act)
+{
+ /* We cannot really assume wchar_t is 32 bits wide. But it is for
+ GCC and so we don't do much optimization for the other case. */
+ if (sizeof (wchar_t) == 4)
+ {
+ if (act < max)
+ dest[act] = (wchar_t) value;
+ ++act;
+ }
+ else
+ {
+ wchar_t tmp[3];
+ size_t idx = 0;
+
+ if (value < 0x8000)
+ tmp[idx++] = (wchar_t) act;
+ else
+ {
+ tmp[idx++] = (wchar_t) (0x8000 + (value & 0x3fff));
+ value >>= 14;
+ if (value < 0x2000)
+ tmp[idx++] = (wchar_t) (0xc000 + value);
+ else
+ {
+ tmp[idx++] = (wchar_t) (0x8000 + (value & 0x3fff));
+ value >>= 14;
+ tmp[idx++] = (wchar_t) (0xe000 + value);
+ }
+ }
+ while (idx-- > 0)
+ {
+ if (act < max)
+ dest[act] = tmp[idx];
+ ++act;
+ }
+ }
+ return act;
+}
+#endif
/* Transform SRC into a form such that the result of strcmp
@@ -184,5 +228,9 @@ STRXFRM (STRING_TYPE *dest, const STRING_TYPE *src, size_t n)
}
/* Terminate string. */
- return print_val (0, dest, n, written);
+ if (written < n)
+ dest[written] = L_('\0');
+
+ /* Return length without counting the terminating '\0'. */
+ return written;
}
diff --git a/string/tester.c b/string/tester.c
index d826ff7beb..1b87c9f544 100644
--- a/string/tester.c
+++ b/string/tester.c
@@ -40,6 +40,8 @@ char two[50];
int
DEFUN(main, (argc, argv), int argc AND char **argv)
{
+ char *cp;
+
/* Test strcmp first because we use it to test other things. */
it = "strcmp";
check(strcmp("", "") == 0, 1); /* Trivial case. */
@@ -359,6 +361,100 @@ DEFUN(main, (argc, argv), int argc AND char **argv)
equal(one+2, "b", 32);
equal(one+4, "c", 33);
+ /* strtok_r. */
+ it = "strtok_r";
+ (void) strcpy(one, "first, second, third");
+ equal(strtok_r(one, ", ", &cp), "first", 1); /* Basic test. */
+ equal(one, "first", 2);
+ equal(strtok_r((char *)NULL, ", ", &cp), "second", 3);
+ equal(strtok_r((char *)NULL, ", ", &cp), "third", 4);
+ check(strtok_r((char *)NULL, ", ", &cp) == NULL, 5);
+ (void) strcpy(one, ", first, ");
+ equal(strtok_r(one, ", ", &cp), "first", 6); /* Extra delims, 1 tok. */
+ check(strtok_r((char *)NULL, ", ", &cp) == NULL, 7);
+ (void) strcpy(one, "1a, 1b; 2a, 2b");
+ equal(strtok_r(one, ", ", &cp), "1a", 8); /* Changing delim lists. */
+ equal(strtok_r((char *)NULL, "; ", &cp), "1b", 9);
+ equal(strtok_r((char *)NULL, ", ", &cp), "2a", 10);
+ (void) strcpy(two, "x-y");
+ equal(strtok_r(two, "-", &cp), "x", 11); /* New string before done. */
+ equal(strtok_r((char *)NULL, "-", &cp), "y", 12);
+ check(strtok_r((char *)NULL, "-", &cp) == NULL, 13);
+ (void) strcpy(one, "a,b, c,, ,d");
+ equal(strtok_r(one, ", ", &cp), "a", 14); /* Different separators. */
+ equal(strtok_r((char *)NULL, ", ", &cp), "b", 15);
+ equal(strtok_r((char *)NULL, " ,", &cp), "c", 16); /* Permute list too. */
+ equal(strtok_r((char *)NULL, " ,", &cp), "d", 17);
+ check(strtok_r((char *)NULL, ", ", &cp) == NULL, 18);
+ check(strtok_r((char *)NULL, ", ", &cp) == NULL, 19); /* Persistence. */
+ (void) strcpy(one, ", ");
+ check(strtok_r(one, ", ", &cp) == NULL, 20); /* No tokens. */
+ (void) strcpy(one, "");
+ check(strtok_r(one, ", ", &cp) == NULL, 21); /* Empty string. */
+ (void) strcpy(one, "abc");
+ equal(strtok_r(one, ", ", &cp), "abc", 22); /* No delimiters. */
+ check(strtok_r((char *)NULL, ", ", &cp) == NULL, 23);
+ (void) strcpy(one, "abc");
+ equal(strtok_r(one, "", &cp), "abc", 24); /* Empty delimiter list. */
+ check(strtok_r((char *)NULL, "", &cp) == NULL, 25);
+ (void) strcpy(one, "abcdefgh");
+ (void) strcpy(one, "a,b,c");
+ equal(strtok_r(one, ",", &cp), "a", 26); /* Basics again... */
+ equal(strtok_r((char *)NULL, ",", &cp), "b", 27);
+ equal(strtok_r((char *)NULL, ",", &cp), "c", 28);
+ check(strtok_r((char *)NULL, ",", &cp) == NULL, 29);
+ equal(one+6, "gh", 30); /* Stomped past end? */
+ equal(one, "a", 31); /* Stomped old tokens? */
+ equal(one+2, "b", 32);
+ equal(one+4, "c", 33);
+
+ /* strsep. */
+ it = "strsep";
+ cp = strcpy(one, "first, second, third");
+ equal(strsep(&cp, ", "), "first", 1); /* Basic test. */
+ equal(one, "first", 2);
+ equal(strsep(&cp, ", "), "second", 3);
+ equal(strsep(&cp, ", "), "third", 4);
+ check(strsep(&cp, ", ") == NULL, 5);
+ cp = strcpy(one, ", first, ");
+ equal(strsep(&cp, ", "), "first", 6); /* Extra delims, 1 tok. */
+ check(strsep(&cp, ", ") == NULL, 7);
+ cp = strcpy(one, "1a, 1b; 2a, 2b");
+ equal(strsep(&cp, ", "), "1a", 8); /* Changing delim lists. */
+ equal(strsep(&cp, "; "), "1b", 9);
+ equal(strsep(&cp, ", "), "2a", 10);
+ cp = strcpy(two, "x-y");
+ equal(strsep(&cp, "-"), "x", 11); /* New string before done. */
+ equal(strsep(&cp, "-"), "y", 12);
+ check(strsep(&cp, "-") == NULL, 13);
+ cp = strcpy(one, "a,b, c,, ,d");
+ equal(strsep(&cp, ", "), "a", 14); /* Different separators. */
+ equal(strsep(&cp, ", "), "b", 15);
+ equal(strsep(&cp, " ,"), "c", 16); /* Permute list too. */
+ equal(strsep(&cp, " ,"), "d", 17);
+ check(strsep(&cp, ", ") == NULL, 18);
+ check(strsep(&cp, ", ") == NULL, 19); /* Persistence. */
+ cp = strcpy(one, ", ");
+ check(strsep(&cp, ", ") == NULL, 20); /* No tokens. */
+ cp = strcpy(one, "");
+ check(strsep(&cp, ", ") == NULL, 21); /* Empty string. */
+ cp = strcpy(one, "abc");
+ equal(strsep(&cp, ", "), "abc", 22); /* No delimiters. */
+ check(strsep(&cp, ", ") == NULL, 23);
+ cp = strcpy(one, "abc");
+ equal(strsep(&cp, ""), "abc", 24); /* Empty delimiter list. */
+ check(strsep(&cp, "") == NULL, 25);
+ (void) strcpy(one, "abcdefgh");
+ cp = strcpy(one, "a,b,c");
+ equal(strsep(&cp, ","), "a", 26); /* Basics again... */
+ equal(strsep(&cp, ","), "b", 27);
+ equal(strsep(&cp, ","), "c", 28);
+ check(strsep(&cp, ",") == NULL, 29);
+ equal(one+6, "gh", 30); /* Stomped past end? */
+ equal(one, "a", 31); /* Stomped old tokens? */
+ equal(one+2, "b", 32);
+ equal(one+4, "c", 33);
+
/* memcmp. */
it = "memcmp";
check(memcmp("a", "a", 1) == 0, 1); /* Identity. */
diff --git a/sysdeps/generic/netinet/in.h b/sysdeps/generic/netinet/in.h
index a135cf25b2..160618a3d1 100644
--- a/sysdeps/generic/netinet/in.h
+++ b/sysdeps/generic/netinet/in.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or modify
@@ -36,7 +36,7 @@ enum
IPPROTO_IDP = 22, /* XNS IDP protocol. */
IPPROTO_RAW = 255, /* Raw IP packets. */
- IPPROTO_MAX,
+ IPPROTO_MAX
};
/* Standard well-known ports. */
@@ -76,7 +76,7 @@ enum
IPPORT_RESERVED = 1024,
/* Ports greater this value are reserved for (non-privileged) servers. */
- IPPORT_USERRESERVED = 5000,
+ IPPORT_USERRESERVED = 5000
};
diff --git a/sysdeps/generic/strtok.c b/sysdeps/generic/strtok.c
new file mode 100644
index 0000000000..954471322b
--- /dev/null
+++ b/sysdeps/generic/strtok.c
@@ -0,0 +1,73 @@
+/* Copyright (C) 1991, 1996 Free Software Foundation, Inc.
+This file is part of the GNU C Library.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#include <errno.h>
+#include <string.h>
+
+
+static char *olds = NULL;
+
+/* Parse S into tokens separated by characters in DELIM.
+ If S is NULL, the last string strtok() was called with is
+ used. For example:
+ char s[] = "-abc-=-def";
+ x = strtok(s, "-"); // x = "abc"
+ x = strtok(NULL, "-="); // x = "def"
+ x = strtok(NULL, "="); // x = NULL
+ // s = "abc\0-def\0"
+*/
+char *
+strtok (s, delim)
+ char *s;
+ const char *delim;
+{
+ char *token;
+
+ if (s == NULL)
+ {
+ if (olds == NULL)
+ {
+ errno = EINVAL;
+ return NULL;
+ }
+ else
+ s = olds;
+ }
+
+ /* Scan leading delimiters. */
+ s += strspn (s, delim);
+ if (*s == '\0')
+ {
+ olds = NULL;
+ return NULL;
+ }
+
+ /* Find the end of the token. */
+ token = s;
+ s = strpbrk (token, delim);
+ if (s == NULL)
+ /* This token finishes the string. */
+ olds = NULL;
+ else
+ {
+ /* Terminate the token and make OLDS point past it. */
+ *s = '\0';
+ olds = s + 1;
+ }
+ return token;
+}
diff --git a/sysdeps/generic/strtok_r.c b/sysdeps/generic/strtok_r.c
new file mode 100644
index 0000000000..08a29361c7
--- /dev/null
+++ b/sysdeps/generic/strtok_r.c
@@ -0,0 +1,74 @@
+/* Reentrant string tokenizer. Generic version.
+Copyright (C) 1991, 1996 Free Software Foundation, Inc.
+This file is part of the GNU C Library.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#include <errno.h>
+#include <string.h>
+
+
+/* Parse S into tokens separated by characters in DELIM.
+ If S is NULL, the saved pointer in SAVE_PTR is used as
+ the next starting point. For example:
+ char s[] = "-abc-=-def";
+ char *sp;
+ x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def"
+ x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL
+ x = strtok_r(NULL, "=", &sp); // x = NULL
+ // s = "abc\0-def\0"
+*/
+char *
+strtok_r (s, delim, save_ptr)
+ char *s;
+ const char *delim;
+ char **save_ptr;
+{
+ char *token;
+
+ if (s == NULL)
+ {
+ if (*save_ptr == NULL)
+ {
+ errno = EINVAL;
+ return NULL;
+ }
+ else
+ s = *save_ptr;
+ }
+
+ /* Scan leading delimiters. */
+ s += strspn (s, delim);
+ if (*s == '\0')
+ {
+ *save_ptr = NULL;
+ return NULL;
+ }
+
+ /* Find the end of the token. */
+ token = s;
+ s = strpbrk (token, delim);
+ if (s == NULL)
+ /* This token finishes the string. */
+ *save_ptr = NULL;
+ else
+ {
+ /* Terminate the token and make *SAVE_PTR point past it. */
+ *s = '\0';
+ *save_ptr = s + 1;
+ }
+ return token;
+}
diff --git a/sysdeps/i386/i486/strcat.S b/sysdeps/i386/i486/strcat.S
index e3d2181bdb..081a797933 100644
--- a/sysdeps/i386/i486/strcat.S
+++ b/sysdeps/i386/i486/strcat.S
@@ -1,6 +1,6 @@
/* strcat(dest, src) -- Append SRC on the end of DEST.
For Intel 80x86, x>=4.
-Copyright (C) 1994, 1995 Free Software Foundation, Inc.
+Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
Contributed by Ulrich Drepper <drepper@ipd.info.uni-karlsruhe.de>.
Optimised a little by Alan Modra <Alan@SPRI.Levels.UniSA.Edu.Au>
This file is part of the GNU C Library.
@@ -40,19 +40,19 @@ ENTRY (strcat)
jz L8 /* yes => return */
/* Test the first bytes separately until destination is aligned. */
- testb $3, %edx /* destination pointer aligned? */
+ testl $3, %edx /* destination pointer aligned? */
jz L1 /* yes => begin scan loop */
testb $0xff, (%edx) /* is end of string? */
jz L2 /* yes => start appending */
incl %edx /* increment source pointer */
- testb $3, %edx /* destination pointer aligned? */
+ testl $3, %edx /* destination pointer aligned? */
jz L1 /* yes => begin scan loop */
testb $0xff, (%edx) /* is end of string? */
jz L2 /* yes => start appending */
incl %edx /* increment source pointer */
- testb $3, %edx /* destination pointer aligned? */
+ testl $3, %edx /* destination pointer aligned? */
jz L1 /* yes => begin scan loop */
testb $0xff, (%edx) /* is end of string? */
jz L2 /* yes => start appending */
@@ -152,27 +152,27 @@ L3: testb %al, %al /* is first byte NUL? */
L2: subl %ecx, %edx /* reduce number of loop variants */
/* Now we have to align the source pointer. */
- testb $3, %ecx /* pointer correctly aligned? */
+ testl $3, %ecx /* pointer correctly aligned? */
jz L29 /* yes => start copy loop */
movb (%ecx), %al /* get first byte */
movb %al, (%ecx,%edx) /* and store it */
- andl %al, %al /* is byte NUL? */
+ andb %al, %al /* is byte NUL? */
jz L8 /* yes => return */
incl %ecx /* increment pointer */
- testb $3, %ecx /* pointer correctly aligned? */
+ testl $3, %ecx /* pointer correctly aligned? */
jz L29 /* yes => start copy loop */
movb (%ecx), %al /* get first byte */
movb %al, (%ecx,%edx) /* and store it */
- andl %al, %al /* is byte NUL? */
+ andb %al, %al /* is byte NUL? */
jz L8 /* yes => return */
incl %ecx /* increment pointer */
- testb $3, %ecx /* pointer correctly aligned? */
+ testl $3, %ecx /* pointer correctly aligned? */
jz L29 /* yes => start copy loop */
movb (%ecx), %al /* get first byte */
movb %al, (%ecx,%edx) /* and store it */
- andl %al, %al /* is byte NUL? */
+ andb %al, %al /* is byte NUL? */
jz L8 /* yes => return */
incl %ecx /* increment pointer */
diff --git a/sysdeps/i386/strsep.S b/sysdeps/i386/strsep.S
new file mode 100644
index 0000000000..8c425dd505
--- /dev/null
+++ b/sysdeps/i386/strsep.S
@@ -0,0 +1,3 @@
+#define FUNCTION strsep
+#define USE_AS_STRSEP 1
+#include <sysdeps/i386/strtok.S>
diff --git a/sysdeps/i386/strtok.S b/sysdeps/i386/strtok.S
new file mode 100644
index 0000000000..28845e08cf
--- /dev/null
+++ b/sysdeps/i386/strtok.S
@@ -0,0 +1,329 @@
+/* strtok (str, delim) -- Return next DELIM separated token from STR.
+For Intel 80x86, x>=3.
+Copyright (C) 1996 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. */
+
+#include <errnos.h>
+#include <sysdep.h>
+
+/* This file can be used for three variants of the strtok function:
+
+ strtok:
+ INPUT PARAMETER:
+ str (sp + 4)
+ delim (sp + 8)
+
+ strtok_r:
+ INPUT PARAMETER:
+ str (sp + 4)
+ delim (sp + 8)
+ save_ptr (sp + 12)
+
+ strsep:
+ INPUT PARAMETERS
+ str_ptr (sp + 4)
+ delim (sp + 8)
+
+ We do a common implementation here. */
+
+#if !defined (USE_AS_STRTOK_R) && !defined (USE_AS_STRSEP)
+ .bss
+ .local save_ptr
+ ASM_TYPE_DIRECTIVE (save_ptr, @object)
+ .size save_ptr, 4
+save_ptr:
+ .space 4
+
+#define FUNCTION strtok
+#endif
+
+ /* We use the possibility to do some more initialization
+ for the strtok implementation. */
+ .text
+Lillegal_argument:
+#ifndef PIC
+ movl $EINVAL, C_SYMBOL_NAME(errno)
+ xorl %eax, %eax
+#else
+# if defined (USE_AS_STRTOK_R) || defined (USE_AS_STRSEP)
+ pushl %ebx /* Save PIC register. */
+ call Lhere2
+Lhere2: popl %ebx
+ addl $_GLOBAL_OFFSET_TABLE_+[.-Lhere2], %ebx
+# endif
+ movl errno@GOT(%ebx), %ebx
+ movl $EINVAL, (%ebx)
+ xorl %eax, %eax
+ popl %ebx
+#endif
+ ret
+
+
+ENTRY (FUNCTION)
+
+ movl 4(%esp), %edx /* Get start of string. */
+ movl 8(%esp), %eax /* Get start of delimiter set. */
+
+#ifdef USE_AS_STRSEP
+ /* %EDX does not yet contain the string starting point. Only
+ a pointer to the location where it is stored. */
+ movl (%edx), %edx
+#else
+# if !defined (USE_AS_STRTOK_R) && defined (PIC)
+ pushl %ebx /* Save PIC register. */
+ call Lhere
+Lhere: popl %ebx
+ addl $_GLOBAL_OFFSET_TABLE_+[.-Lhere], %ebx
+# endif
+
+ /* If the pointer is NULL we have to use the stored value of
+ the last run. */
+ cmpl $0, %edx
+ jne L0
+
+# ifdef USE_AS_STRTOK_R
+ /* The value is stored in the third argument. */
+ movl 12(%esp), %edx
+ movl (%edx), %edx
+# else
+ /* The value is in the local variable defined above. But
+ we have to take care for PIC code. */
+# ifndef PIC
+ movl save_ptr, %edx
+# else
+ movl save_ptr@GOTOFF(%ebx), %edx
+# endif
+# endif
+#endif
+
+ /* Compare whether pointer is NULL. We are tolerant here
+ because the C function do the same. */
+ cmpl $0, %edx
+ je Lillegal_argument
+
+#ifndef USE_AS_STRSEP
+L0:
+#endif
+ /* First we create a table with flags for all possible characters.
+ For the ASCII (7bit/8bit) or ISO-8859-X character sets which are
+ supported by the C string functions we have 256 characters.
+ Before inserting marks for the stop characters we clear the whole
+ table. The unrolled form is much faster than a loop. */
+ xorl %ecx, %ecx /* %ecx = 0 !!! */
+
+ pushl %ecx /* make a 256 bytes long block filled with 0 */
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl %ecx
+ pushl $0 /* These immediate values make the label 2 */
+ pushl $0 /* to be aligned on a 16 byte boundary to */
+ pushl $0 /* get a better performance of the loop. */
+ pushl $0
+ pushl $0
+ pushl $0
+
+/* For understanding the following code remember that %ecx == 0 now.
+ Although all the following instruction only modify %cl we always
+ have a correct zero-extended 32-bit value in %ecx. */
+
+L2: movb (%eax), %cl /* get byte from stopset */
+ testb %cl, %cl /* is NUL char? */
+ jz L1 /* yes => start compare loop */
+ movb %cl, (%esp,%ecx) /* set corresponding byte in stopset table */
+
+ movb 1(%eax), %cl /* get byte from stopset */
+ testb $0xff, %cl /* is NUL char? */
+ jz L1 /* yes => start compare loop */
+ movb %cl, (%esp,%ecx) /* set corresponding byte in stopset table */
+
+ movb 2(%eax), %cl /* get byte from stopset */
+ testb $0xff, %cl /* is NUL char? */
+ jz L1 /* yes => start compare loop */
+ movb %cl, (%esp,%ecx) /* set corresponding byte in stopset table */
+
+ movb 3(%eax), %cl /* get byte from stopset */
+ addl $4, %eax /* increment stopset pointer */
+ movb %cl, (%esp,%ecx) /* set corresponding byte in stopset table */
+ testb $0xff, %cl /* is NUL char? */
+ jnz L2 /* no => process next dword from stopset */
+
+L1: leal -4(%edx), %eax /* prepare loop */
+
+ /* We use a neat trick for the following loop. Normally we would
+ have to test for two termination conditions
+ 1. a character in the stopset was found
+ and
+ 2. the end of the string was found
+ But as a sign that the chracter is in the stopset we store its
+ value in the table. But the value of NUL is NUL so the loop
+ terminates for NUL in every case. */
+
+L3: addl $4, %eax /* adjust pointer for full loop round */
+
+ movb (%eax), %cl /* get byte from string */
+ testb %cl, (%esp,%ecx) /* is it contained in stopset? */
+ jz L4 /* no => start of token */
+
+ movb 1(%eax), %cl /* get byte from string */
+ testb %cl, (%esp,%ecx) /* is it contained in stopset? */
+ jz L5 /* no => start of token */
+
+ movb 2(%eax), %cl /* get byte from string */
+ testb %cl, (%esp,%ecx) /* is it contained in stopset? */
+ jz L6 /* no => start of token */
+
+ movb 3(%eax), %cl /* get byte from string */
+ testb %cl, (%esp,%ecx) /* is it contained in stopset? */
+ jnz L3 /* yes => start of loop */
+
+ incl %eax /* adjust pointer */
+L6: incl %eax
+L5: incl %eax
+
+ /* Now we have to terminate the string. */
+
+L4: leal -4(%eax), %edx /* We use %EDX for the next run. */
+
+L7: addl $4, %edx /* adjust pointer for full loop round */
+
+ movb (%edx), %cl /* get byte from string */
+ cmpb %cl, (%esp,%ecx) /* is it contained in skipset? */
+ je L8 /* yes => return */
+
+ movb 1(%edx), %cl /* get byte from string */
+ cmpb %cl, (%esp,%ecx) /* is it contained in skipset? */
+ je L9 /* yes => return */
+
+ movb 2(%edx), %cl /* get byte from string */
+ cmpb %cl, (%esp,%ecx) /* is it contained in skipset? */
+ je L10 /* yes => return */
+
+ movb 3(%edx), %cl /* get byte from string */
+ cmpb %cl, (%esp,%ecx) /* is it contained in skipset? */
+ jne L7 /* no => start loop again */
+
+ incl %edx /* adjust pointer */
+L10: incl %edx
+L9: incl %edx
+
+L8: /* Remove the stopset table. */
+ addl $256, %esp
+
+ cmpl %eax, %edx
+ je LreturnNULL /* There was no token anymore. */
+
+ movb $0, (%edx) /* Terminate string. */
+
+ /* Are we at end of string? */
+ cmpb $0, %cl
+ je L11
+
+ incl %edx
+L11:
+
+ /* Store the pointer to the next character. */
+#ifdef USE_AS_STRTOK_R
+ movl 12(%esp), %ecx
+ movl %edx, (%ecx)
+#elif USE_AS_STRSEP
+ movl 4(%esp), %ecx
+ movl %edx, (%ecx)
+#else
+# ifndef PIC
+ movl %edx, save_ptr
+# else
+ movl %edx, save_ptr@GOTOFF(%ebx)
+ popl %ebx
+# endif
+#endif
+ ret
+
+LreturnNULL:
+ xorl %eax, %eax
+
+ /* Store NULL as pointer to the next character. */
+#ifdef USE_AS_STRTOK_R
+ movl 12(%esp), %ecx
+ movl %eax, (%ecx)
+#elif USE_AS_STRSEP
+ movl 4(%esp), %ecx
+ movl %eax, (%ecx)
+#else
+# ifndef PIC
+ movl %eax, save_ptr
+# else
+ movl %eax, save_ptr@GOTOFF(%ebx)
+ popl %ebx
+# endif
+#endif
+ ret
diff --git a/sysdeps/i386/strtok_r.S b/sysdeps/i386/strtok_r.S
new file mode 100644
index 0000000000..297ba282ac
--- /dev/null
+++ b/sysdeps/i386/strtok_r.S
@@ -0,0 +1,3 @@
+#define FUNCTION strtok_r
+#define USE_AS_STRTOK_R 1
+#include <sysdeps/i386/strtok.S>
diff --git a/sysdeps/unix/bsd/direntry.h b/sysdeps/unix/bsd/direntry.h
index eb55d57af7..2f563ec306 100644
--- a/sysdeps/unix/bsd/direntry.h
+++ b/sysdeps/unix/bsd/direntry.h
@@ -22,7 +22,7 @@ struct dirent
unsigned int d_fileno; /* 32 bits. */
unsigned short int d_reclen; /* 16 bits. */
unsigned short int d_namlen; /* 16 bits. */
- char d_name[0]; /* Variable length. */
+ char d_name[1]; /* Variable length. */
};
#define _DIRENT_HAVE_D_RECLEN 1
diff --git a/sysdeps/unix/common/direntry.h b/sysdeps/unix/common/direntry.h
index 5decd56db6..aa065474bf 100644
--- a/sysdeps/unix/common/direntry.h
+++ b/sysdeps/unix/common/direntry.h
@@ -22,7 +22,7 @@ struct dirent
unsigned int d_fileno;
int d_off; /* Position in directory of following entry. */
unsigned short int d_reclen;
- char d_name[0]; /* Variable length. */
+ char d_name[1]; /* Variable length. */
};
#define _DIRENT_HAVE_D_RECLEN 1
diff --git a/sysdeps/unix/sysv/linux/gnu/types.h b/sysdeps/unix/sysv/linux/gnu/types.h
index 7876c408c4..4f1b0961ee 100644
--- a/sysdeps/unix/sysv/linux/gnu/types.h
+++ b/sysdeps/unix/sysv/linux/gnu/types.h
@@ -19,8 +19,10 @@ Cambridge, MA 02139, USA. */
#ifndef _GNU_TYPES_H
#define _GNU_TYPES_H 1
-/* Get actual type definitions for architecture from kernel headers. */
-#include <linux/posix_types.h>
+/* Get actual type definitions for architecture from kernel headers.
+ This #define tells <linux/types.h> not to define `dev_t' et al itself. */
+#define _LINUX_TYPES_DONT_EXPORT
+#include <linux/types.h>
/* Convenience types. */
typedef unsigned char __u_char;
diff --git a/sysdeps/unix/sysv/linux/netinet/in.h b/sysdeps/unix/sysv/linux/netinet/in.h
index 2ce224ca43..ebe6b4cf58 100644
--- a/sysdeps/unix/sysv/linux/netinet/in.h
+++ b/sysdeps/unix/sysv/linux/netinet/in.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or modify
@@ -36,7 +36,7 @@ enum
IPPROTO_IDP = 22, /* XNS IDP protocol. */
IPPROTO_RAW = 255, /* Raw IP packets. */
- IPPROTO_MAX,
+ IPPROTO_MAX
};
/* Standard well-known ports. */
@@ -76,7 +76,7 @@ enum
IPPORT_RESERVED = 1024,
/* Ports greater this value are reserved for (non-privileged) servers. */
- IPPORT_USERRESERVED = 5000,
+ IPPORT_USERRESERVED = 5000
};
diff --git a/time/Makefile b/time/Makefile
index ac422bfc42..5efb638c9e 100644
--- a/time/Makefile
+++ b/time/Makefile
@@ -64,7 +64,9 @@ installed-posixrules-file := $(firstword $(filter /%,$(posixrules-file)) \
ifeq ($(cross-compiling),no)
# Don't try to install the zoneinfo files since we can't run zic.
-install-others = $(addprefix $(zonedir)/,$(zonenames)) \
+install-others = $(addprefix $(zonedir)/,$(zonenames) \
+ $(zonenames:%=posix/%) \
+ $(zonenames:%=right/%)) \
$(installed-localtime-file) $(installed-posixrules-file)
endif
@@ -81,8 +83,14 @@ $(tzfiles:%=$(objpfx)z.%): $(objpfx)z.%: % Makefile
echo '$*-zones := $$(subst $$(nl), ,$$($*-zones))' ;\
echo 'ifdef $*-zones' ;\
echo '$$(addprefix $$(datadir)/zone%/,$$($*-zones)): \' ;\
+ echo '$< $$(objpfx)zic $$(leapseconds) yearistype' ;\
+ echo ' $$(tzcompile)' ;\
+ echo '$$(addprefix $$(datadir)/zone%/right/,$$($*-zones)): \' ;\
echo '$< $$(objpfx)zic leapseconds yearistype' ;\
echo ' $$(tzcompile)' ;\
+ echo '$$(addprefix $$(datadir)/zone%/posix/,$$($*-zones)): \' ;\
+ echo '$< $$(objpfx)zic /dev/null yearistype' ;\
+ echo ' $$(tzcompile)' ;\
echo 'endif' ;\
echo 'zonenames := $$(zonenames) $$($*-zones)' ;\
) > $@.new
@@ -98,9 +106,18 @@ echo-zonenames: zonenames
# the command line of `make install' (e.g., "make install prefix=/foo").
zic-cmd = $(built-program-cmd) -d $(zonedir)
define tzcompile
-$(zic-cmd) -L $(word 3,$^) -y $(dir $(word 4,$^))$(notdir $(word 4,$^)) $<
+$(zic-cmd)$(target-zone-flavor)
+ -L $(word 3,$^) -y $(dir $(word 4,$^))$(notdir $(word 4,$^)) $<
endef
+# The source files specify the zone names relative to the -d directory,
+# so for the posix/ and right/ flavors we need to pass -d $(zonedir)/posix
+# and the like. This magic extracts /posix or /right if it's the first
+# component after $(zonedir) in the target name $@.
+target-zone-flavor = $(filter /posix /right, \
+ /$(firstword $(subst /, , \
+ $(patsubst $(zonedir)/%,%,$@))))
+
ifdef localtime
$(installed-localtime-file): $(zonedir)/$(localtime) $(objpfx)zic
$(zic-cmd) -l $(localtime)
diff --git a/time/tzset.c b/time/tzset.c
index 2635155dd2..007997f541 100644
--- a/time/tzset.c
+++ b/time/tzset.c
@@ -90,18 +90,23 @@ DEFUN_VOID(__tzset)
tz_rules[1].name != tz_rules[0].name)
free((PTR) tz_rules[1].name);
- tz = getenv("TZ");
+ /* Examine the TZ environment variable. */
+ tz = getenv ("TZ");
- if (tz != NULL && *tz == ':')
+ if (tz != NULL)
{
- __tzfile_read(tz + 1);
+ /* A leading colon means "implementation defined syntax".
+ We ignore the colon and always use the same algorithm:
+ try a data file, and if none exists parse the 1003.1 syntax. */
+ if (*tz == ':')
+ ++tz;
+
+ __tzfile_read (tz);
if (__use_tzfile)
{
__tzset_run = 1;
return;
}
- else
- tz = NULL;
}
if (tz == NULL || *tz == '\0')
diff --git a/wcsmbs/wchar.h b/wcsmbs/wchar.h
index 3b15d9f38a..b54170c3f3 100644
--- a/wcsmbs/wchar.h
+++ b/wcsmbs/wchar.h
@@ -27,44 +27,31 @@ Cambridge, MA 02139, USA. */
__BEGIN_DECLS
-/* Get size_t, wchar_t, uwchar_t and NULL from <stddef.h>. */
+/* Get size_t, wchar_t, wint_t and NULL from <stddef.h>. */
#define __need_size_t
#define __need_wchar_t
-/* #define __need_uwchar_t */
+#define __need_wint_t
#define __need_NULL
-/* __need_WCHAR_MAX */
-/* __need_WCHAR_MIN */
#include <stddef.h>
-/* FIXME: Should go with this or another name in stddef.h. */
-typedef unsigned int uwchar_t;
-
/* Conversion state information. */
typedef int mbstate_t; /* FIXME */
-/* Should come from <stddef.h> */
-#define WCHAR_MIN ((wchar_t) 0) /* FIXME */
-#define WCHAR_MAX (~WCHAR_MIN) /* FIXME */
+#define WCHAR_MIN ((wchar_t) 0)
+#define WCHAR_MAX (~WCHAR_MIN)
#ifndef WEOF
# define WEOF (0xffffffffu)
#endif
-/* FIXME: should this go into <stddef.h>??? */
-#if 0
-#define __need_wint_t
-#include <stddef.h>
-#else
+#ifndef _WINT_T
/* Integral type unchanged by default argument promotions that can
hold any value corresponding to members of the extended character
set, as well as at least one value that does not correspond to any
member of the extended character set. */
-#ifndef __have_wint_t_defined
-#define __have_wint_t_defined 1
-/* This is a hack!!! */
+#define _WINT_T 1
typedef unsigned int wint_t;
#endif
-#endif
/* Copy SRC to DEST. */
diff --git a/wcsmbs/wcscmp.c b/wcsmbs/wcscmp.c
index 08da116787..2cc31992d2 100644
--- a/wcsmbs/wcscmp.c
+++ b/wcsmbs/wcscmp.c
@@ -1,6 +1,6 @@
/* Copyright (C) 1995, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
-Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>
+Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
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
@@ -13,9 +13,9 @@ 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., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
+License along with the GNU C Library; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
#include <wchar.h>
@@ -28,12 +28,12 @@ wcscmp (s1, s2)
const wchar_t *s1;
const wchar_t *s2;
{
- uwchar_t c1, c2;
+ wint_t c1, c2;
do
{
- c1 = (uwchar_t) *s1++;
- c2 = (uwchar_t) *s2++;
+ c1 = (wint_t) *s1++;
+ c2 = (wint_t) *s2++;
if (c1 == L'\0')
return c1 - c2;
}
diff --git a/wcsmbs/wcscoll.c b/wcsmbs/wcscoll.c
index e033b4a6de..ad4c23244b 100644
--- a/wcsmbs/wcscoll.c
+++ b/wcsmbs/wcscoll.c
@@ -19,7 +19,7 @@ Boston, MA 02111-1307, USA. */
#include <wchar.h>
#define STRING_TYPE wchar_t
-#define USTRING_TYPE uwchar_t
+#define USTRING_TYPE wint_t
#define STRCOLL wcscoll
#define STRCMP wcscmp
diff --git a/wcsmbs/wcsncmp.c b/wcsmbs/wcsncmp.c
index 3df6bfc151..fb554cbfb5 100644
--- a/wcsmbs/wcsncmp.c
+++ b/wcsmbs/wcsncmp.c
@@ -1,6 +1,6 @@
/* Copyright (C) 1995, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
-Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>
+Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
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
@@ -13,9 +13,9 @@ 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., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
+License along with the GNU C Library; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
#include <wchar.h>
@@ -30,28 +30,28 @@ wcsncmp (s1, s2, n)
const wchar_t *s2;
size_t n;
{
- uwchar_t c1 = L'\0';
- uwchar_t c2 = L'\0';
+ wint_t c1 = L'\0';
+ wint_t c2 = L'\0';
if (n >= 4)
{
size_t n4 = n >> 2;
do
{
- c1 = (uwchar_t) *s1++;
- c2 = (uwchar_t) *s2++;
+ c1 = (wint_t) *s1++;
+ c2 = (wint_t) *s2++;
if (c1 == L'\0' || c1 != c2)
return c1 - c2;
- c1 = (uwchar_t) *s1++;
- c2 = (uwchar_t) *s2++;
+ c1 = (wint_t) *s1++;
+ c2 = (wint_t) *s2++;
if (c1 == L'\0' || c1 != c2)
return c1 - c2;
- c1 = (uwchar_t) *s1++;
- c2 = (uwchar_t) *s2++;
+ c1 = (wint_t) *s1++;
+ c2 = (wint_t) *s2++;
if (c1 == L'\0' || c1 != c2)
return c1 - c2;
- c1 = (uwchar_t) *s1++;
- c2 = (uwchar_t) *s2++;
+ c1 = (wint_t) *s1++;
+ c2 = (wint_t) *s2++;
if (c1 == L'\0' || c1 != c2)
return c1 - c2;
} while (--n4 > 0);
@@ -60,8 +60,8 @@ wcsncmp (s1, s2, n)
while (n > 0)
{
- c1 = (uwchar_t) *s1++;
- c2 = (uwchar_t) *s2++;
+ c1 = (wint_t) *s1++;
+ c2 = (wint_t) *s2++;
if (c1 == L'\0' || c1 != c2)
return c1 - c2;
n--;
diff --git a/wcsmbs/wcstok.c b/wcsmbs/wcstok.c
index 376fe7bfcb..b6baf311a4 100644
--- a/wcsmbs/wcstok.c
+++ b/wcsmbs/wcstok.c
@@ -1,6 +1,6 @@
/* Copyright (C) 1995, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
-Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>
+Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
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
@@ -13,9 +13,9 @@ 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., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
+License along with the GNU C Library; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
#include <wchar.h>
#include <errno.h>
@@ -25,20 +25,26 @@ Cambridge, MA 02139, USA. */
NULL, the last string wcstok() was called with is used. */
wchar_t *
wcstok (wcs, delim, ptr)
- register wchar_t *wcs;
- register const wchar_t *delim;
- register wchar_t **ptr;
+ wchar_t *wcs;
+ const wchar_t *delim;
+ wchar_t **save_ptr;
{
wchar_t *result;
if (wcs == NULL)
- wcs = *ptr;
+ if (*save_ptr == NULL)
+ {
+ errno = EINVAL;
+ return NULL;
+ }
+ else
+ wcs = *save_ptr;
/* Scan leading delimiters. */
wcs += wcsspn (wcs, delim);
if (*wcs == L'\0')
{
- *ptr = NULL;
+ *save_ptr = NULL;
return NULL;
}
@@ -47,12 +53,12 @@ wcstok (wcs, delim, ptr)
wcs = wcspbrk (result, delim);
if (wcs == NULL)
/* This token finishes the string. */
- *ptr = NULL;
+ *save_ptr = NULL;
else
{
- /* Terminate the token and make OLDS point past it. */
+ /* Terminate the token and make *SAVE_PTR point past it. */
*wcs = L'\0';
- *ptr = wcs + 1;
+ *save_ptr = wcs + 1;
}
return result;
}
diff --git a/wcsmbs/wcsxfrm.c b/wcsmbs/wcsxfrm.c
index 96a32382e0..0a04fd96f2 100644
--- a/wcsmbs/wcsxfrm.c
+++ b/wcsmbs/wcsxfrm.c
@@ -18,8 +18,10 @@ Boston, MA 02111-1307, USA. */
#include <wchar.h>
+#define WIDE_VERSION 1
#define STRING_TYPE wchar_t
-#define USTRING_TYPE uwchar_t
+#define USTRING_TYPE wint_t
+#define L_(Ch) L##Ch
#define STRXFRM wcsxfrm
#define STRLEN wcslen
#define STPNCPY __wcpncpy
diff --git a/wcsmbs/wmemcmp.c b/wcsmbs/wmemcmp.c
index f96cad9c0e..8d04148466 100644
--- a/wcsmbs/wmemcmp.c
+++ b/wcsmbs/wmemcmp.c
@@ -1,6 +1,6 @@
/* Copyright (C) 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
-Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>
+Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 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
@@ -26,25 +26,25 @@ wmemcmp (s1, s2, n)
const wchar_t *s2;
size_t n;
{
- register uwchar_t c1;
- register uwchar_t c2;
+ register wint_t c1;
+ register wint_t c2;
while (n >= 4)
{
- c1 = (uwchar_t) s1[0];
- c2 = (uwchar_t) s2[0];
+ c1 = (wint_t) s1[0];
+ c2 = (wint_t) s2[0];
if (c1 - c2 != 0)
return c1 - c2;
- c1 = (uwchar_t) s1[1];
- c2 = (uwchar_t) s2[1];
+ c1 = (wint_t) s1[1];
+ c2 = (wint_t) s2[1];
if (c1 - c2 != 0)
return c1 - c2;
- c1 = (uwchar_t) s1[2];
- c2 = (uwchar_t) s2[2];
+ c1 = (wint_t) s1[2];
+ c2 = (wint_t) s2[2];
if (c1 - c2 != 0)
return c1 - c2;
- c1 = (uwchar_t) s1[3];
- c2 = (uwchar_t) s2[3];
+ c1 = (wint_t) s1[3];
+ c2 = (wint_t) s2[3];
if (c1 - c2 != 0)
return c1 - c2;
s1 += 4;
@@ -54,8 +54,8 @@ wmemcmp (s1, s2, n)
if (n > 0)
{
- c1 = (uwchar_t) s1[0];
- c2 = (uwchar_t) s2[0];
+ c1 = (wint_t) s1[0];
+ c2 = (wint_t) s2[0];
if (c1 - c2 != 0)
return c1 - c2;
++s1;
@@ -64,8 +64,8 @@ wmemcmp (s1, s2, n)
}
if (n > 0)
{
- c1 = (uwchar_t) s1[0];
- c2 = (uwchar_t) s2[0];
+ c1 = (wint_t) s1[0];
+ c2 = (wint_t) s2[0];
if (c1 - c2 != 0)
return c1 - c2;
++s1;
@@ -74,8 +74,8 @@ wmemcmp (s1, s2, n)
}
if (n > 0)
{
- c1 = (uwchar_t) s1[0];
- c2 = (uwchar_t) s2[0];
+ c1 = (wint_t) s1[0];
+ c2 = (wint_t) s2[0];
if (c1 - c2 != 0)
return c1 - c2;
}