From 86187531d302de284b67ac162cf76c60c86bd7da Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 6 Nov 1997 00:02:46 +0000 Subject: Update. 1997-11-06 00:06 Ulrich Drepper * argp/argp-help.c: Optimize a bit by using mempcpy. * elf/dl-load.c: Likewise. * elf/dl-lookup.c: Likewise. * inet/rcmd.c: Likewise. * io/ftw.c: Likewise. * libio/fileops.c: Likewise. * libio/genops.c: Likewise. * libio/obprintf.c: Likewise. * nss/nsswitch.c: Likewise. * posix/execvp.c: Likewise. * posix/getopt.c: Likewise. * posix/glob.c: Likewise. * posix/wordexp.c: Likewise. * stdio-common/vfprintf.c: Likewise. * stdlib/canonicalize.c: Likewise. * stdlib/msort.c: Likewise. * string/argz-replace.c: Likewise. * sysdeps/generic/putenv.c: Likewise. * sysdeps/generic/setenv.c: Likewise. * sysdeps/posix/getcwd.c: Likewise. * sysdeps/posix/ttyname.c: Likewise. * sysdeps/posix/writev.c: Likewise. * time/strftime.c: Likewise. * time/tzfile.c: Likewise. * login/utmp_daemon.c: Use memcpy instead of strcpy where possible. * sunrpc/svcauth_des.c: Likewise. * sysdeps/unix/sysv/linux/gethostname.c: Likewise. * misc/tsearch.c: Use memcpy return value if possible. * posix/regex.c: Likewise. * sysdeps/unix/readdir_r.c: Likewise. * wcsmbc/wcsdup.c: Likewise. * nss/digits_dots.c: Little optimization. * inet/ruserpass.c (ruserpass): Optimize by using stpcpy. (struct toktab): Make tokstr field a const char *. * elf/dl-profile.c: Fix typo. * inet/ether_ntoh.c: Don't use relative #include path. * inet/gethstbynm.c: Likewise. * resolv/inet_pton.c: Likewise. * shadow/sgetspent_r.c: Likewise. * libio/oldfileops.c (_IO_old_file_jumps): Use correct sync and write callbacks. Patch by NIIBE Yutaka . * posix/confstr.c: Correct string for _CS_LFS_CFLAGS. Handle _CS_XBS5_* constants. * posix/unistd.h: Add comment describing _XBS5_* constants. * sysdeps/generic/bits/confname.h: Add _CS_XBS5_* constants. * posix/regex.c: Indent preprocessor code. * posix/wordexp.c: Using _itoa_word instead of sprintf. * stdlib/canonicalize.c: Avoid unnecessary copying. Handle NULL and "" arguments correctly according to SUS. * stdlib/test-canon.c: Test "" and NULL argument handling. * sysdeps/posix/writev.c: Correct condition to leave the loop. 1997-11-05 18:13 Ulrich Drepper * nss/getXXbyYY.c: Set buffer to NULL if realloc fails so that possible next call starts with malloc again. Proposed by Joe Keane . 1997-11-04 23:57 Ulrich Drepper * configure.in: Correct gcc -pipe test. Patch by Zack Weinberg . * posix/glob.c: Cleanups. Patch by H.J. Lu . 1997-11-04 Andreas Jaeger * manual/creature.texi (Feature Test Macros): Add _POSIX_C_SOURCE definition. --- BUGS | 5 +- ChangeLog | 84 +++++++++ argp/argp-help.c | 12 +- bits/confname.h | 42 ++++- configure | 69 +++---- configure.in | 7 +- elf/dl-load.c | 39 ++-- elf/dl-lookup.c | 4 +- elf/dl-profile.c | 2 +- inet/ether_ntoh.c | 4 +- inet/gethstbynm.c | 2 +- inet/rcmd.c | 4 +- inet/ruserpass.c | 4 +- io/ftw.c | 9 +- libio/fileops.c | 11 +- libio/genops.c | 18 +- libio/obprintf.c | 5 +- libio/oldfileops.c | 4 +- login/utmp_daemon.c | 12 +- manual/creature.texi | 1 + misc/tsearch.c | 6 +- nss/digits_dots.c | 3 +- nss/getXXbyYY.c | 1 + nss/nsswitch.c | 3 +- posix/confstr.c | 19 +- posix/execvp.c | 6 +- posix/getopt.c | 13 +- posix/glob.c | 204 ++++++++------------ posix/regex.c | 345 +++++++++++++++++----------------- posix/unistd.h | 11 ++ posix/wordexp.c | 49 ++--- resolv/inet_pton.c | 2 +- shadow/sgetspent_r.c | 2 +- stdio-common/vfprintf.c | 3 +- stdlib/canonicalize.c | 39 ++-- stdlib/msort.c | 5 +- stdlib/test-canon.c | 24 +++ string/argz-replace.c | 4 +- sunrpc/svcauth_des.c | 8 +- sysdeps/generic/bits/confname.h | 42 ++++- sysdeps/generic/putenv.c | 8 +- sysdeps/generic/setenv.c | 12 ++ sysdeps/posix/getcwd.c | 192 ++++++++++--------- sysdeps/posix/ttyname.c | 7 +- sysdeps/posix/writev.c | 5 +- sysdeps/unix/readdir_r.c | 5 +- sysdeps/unix/sysv/linux/gethostname.c | 6 +- time/strftime.c | 14 +- time/tzfile.c | 11 +- wcsmbs/wcsdup.c | 4 +- 50 files changed, 809 insertions(+), 582 deletions(-) diff --git a/BUGS b/BUGS index efe407b..7585e7f 100644 --- a/BUGS +++ b/BUGS @@ -1,7 +1,7 @@ List of known bugs (certainly very incomplete) ---------------------------------------------- -Time-stamp: <1997-11-02T15:10:48+0100 drepper> +Time-stamp: <1997-11-05T16:59:11+0100 drepper> This following list contains those bugs which I'm aware of. Please make sure that bugs you report are not listed here. If you can fix one @@ -50,9 +50,6 @@ Severity: [ *] to [***] [ *] The rcmd() functions (more concrete: the handling of .rhosts) does not support netgroups and wildcards (+). -[ *] The first alias definition in locale.alias is ignored. - [PR libc/205] - [ *] When assembling a locale definition, that uses the "copy" directive, with localedef, not only the copied category is checked for errors, but the whole file containing the same diff --git a/ChangeLog b/ChangeLog index 6b54555..f420373 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,87 @@ +1997-11-06 00:06 Ulrich Drepper + + * argp/argp-help.c: Optimize a bit by using mempcpy. + * elf/dl-load.c: Likewise. + * elf/dl-lookup.c: Likewise. + * inet/rcmd.c: Likewise. + * io/ftw.c: Likewise. + * libio/fileops.c: Likewise. + * libio/genops.c: Likewise. + * libio/obprintf.c: Likewise. + * nss/nsswitch.c: Likewise. + * posix/execvp.c: Likewise. + * posix/getopt.c: Likewise. + * posix/glob.c: Likewise. + * posix/wordexp.c: Likewise. + * stdio-common/vfprintf.c: Likewise. + * stdlib/canonicalize.c: Likewise. + * stdlib/msort.c: Likewise. + * string/argz-replace.c: Likewise. + * sysdeps/generic/putenv.c: Likewise. + * sysdeps/generic/setenv.c: Likewise. + * sysdeps/posix/getcwd.c: Likewise. + * sysdeps/posix/ttyname.c: Likewise. + * sysdeps/posix/writev.c: Likewise. + * time/strftime.c: Likewise. + * time/tzfile.c: Likewise. + + * login/utmp_daemon.c: Use memcpy instead of strcpy where possible. + * sunrpc/svcauth_des.c: Likewise. + * sysdeps/unix/sysv/linux/gethostname.c: Likewise. + + * misc/tsearch.c: Use memcpy return value if possible. + * posix/regex.c: Likewise. + * sysdeps/unix/readdir_r.c: Likewise. + * wcsmbc/wcsdup.c: Likewise. + + * nss/digits_dots.c: Little optimization. + + * inet/ruserpass.c (ruserpass): Optimize by using stpcpy. + (struct toktab): Make tokstr field a const char *. + + * elf/dl-profile.c: Fix typo. + + * inet/ether_ntoh.c: Don't use relative #include path. + * inet/gethstbynm.c: Likewise. + * resolv/inet_pton.c: Likewise. + * shadow/sgetspent_r.c: Likewise. + + * libio/oldfileops.c (_IO_old_file_jumps): Use correct sync and write + callbacks. Patch by NIIBE Yutaka . + + * posix/confstr.c: Correct string for _CS_LFS_CFLAGS. + Handle _CS_XBS5_* constants. + * posix/unistd.h: Add comment describing _XBS5_* constants. + * sysdeps/generic/bits/confname.h: Add _CS_XBS5_* constants. + + * posix/regex.c: Indent preprocessor code. + + * posix/wordexp.c: Using _itoa_word instead of sprintf. + + * stdlib/canonicalize.c: Avoid unnecessary copying. Handle NULL + and "" arguments correctly according to SUS. + * stdlib/test-canon.c: Test "" and NULL argument handling. + + * sysdeps/posix/writev.c: Correct condition to leave the loop. + +1997-11-05 18:13 Ulrich Drepper + + * nss/getXXbyYY.c: Set buffer to NULL if realloc fails so that possible + next call starts with malloc again. + Proposed by Joe Keane . + +1997-11-04 23:57 Ulrich Drepper + + * configure.in: Correct gcc -pipe test. + Patch by Zack Weinberg . + + * posix/glob.c: Cleanups. Patch by H.J. Lu . + +1997-11-04 Andreas Jaeger + + * manual/creature.texi (Feature Test Macros): Add _POSIX_C_SOURCE + definition. + 1997-11-04 Ulrich Drepper * manual/filesys.texi: Correct description of return value for diff --git a/argp/argp-help.c b/argp/argp-help.c index f0e86d9..8faacd5 100644 --- a/argp/argp-help.c +++ b/argp/argp-help.c @@ -778,7 +778,7 @@ hol_append (struct hol *hol, struct hol *more) more->num_entries = 0; /* Mark MORE's fields as invalid. */ } else - /* append the entries in MORE to those in HOL, taking care to only add + /* Append the entries in MORE to those in HOL, taking care to only add non-shadowed SHORT_OPTIONS values. */ { unsigned left; @@ -791,12 +791,12 @@ hol_append (struct hol *hol, struct hol *more) char *short_options = malloc (hol_so_len + strlen (more->short_options) + 1); - memcpy (entries, hol->entries, - hol->num_entries * sizeof (struct hol_entry)); - memcpy (entries + hol->num_entries, more->entries, - more->num_entries * sizeof (struct hol_entry)); + __mempcpy (__mempcpy (entries, hol->entries, + hol->num_entries * sizeof (struct hol_entry)), + more->entries, + more->num_entries * sizeof (struct hol_entry)); - memcpy (short_options, hol->short_options, hol_so_len); + __mempcpy (short_options, hol->short_options, hol_so_len); /* Fix up the short options pointers from HOL. */ for (e = entries, left = hol->num_entries; left > 0; e++, left--) diff --git a/bits/confname.h b/bits/confname.h index 6926cad..40228e1 100644 --- a/bits/confname.h +++ b/bits/confname.h @@ -316,8 +316,9 @@ enum #define _SC_NL_TEXTMAX _SC_NL_TEXTMAX }; -#if (defined __USE_POSIX2 || defined __USE_FILE_OFFSET64 \ - || defined __USE_LARGEFILE64 || defined __USE_LARGEFILE) +#if (defined __USE_POSIX2 || defined __USE_UNIX98 \ + || defined __USE_FILE_OFFSET64 || defined __USE_LARGEFILE64 \ + || defined __USE_LARGEFILE) /* Values for the NAME argument to `confstr'. */ enum { @@ -340,8 +341,43 @@ enum # define _CS_LFS64_LDFLAGS _CS_LFS64_LDFLAGS _CS_LFS64_LIBS, # define _CS_LFS64_LIBS _CS_LFS64_LIBS - _CS_LFS64_LINTFLAGS + _CS_LFS64_LINTFLAGS, # define _CS_LFS64_LINTFLAGS _CS_LFS64_LINTFLAGS #endif + +#ifdef __USE_UNIX98 + _CS_XBS5_ILP32_OFF32_CFLAGS = 1100, +# define _CS_XBS5_ILP32_OFF32_CFLAGS _CS_XBS5_ILP32_OFF32_CFLAGS + _CS_XBS5_ILP32_OFF32_LDFLAGS, +# define _CS_XBS5_ILP32_OFF32_LDFLAGS _CS_XBS5_ILP32_OFF32_LDFLAGS + _CS_XBS5_ILP32_OFF32_LIBS, +# define _CS_XBS5_ILP32_OFF32_LIBS _CS_XBS5_ILP32_OFF32_LIBS + _CS_XBS5_ILP32_OFF32_LINTFLAGS, +# define _CS_XBS5_ILP32_OFF32_LINTFLAGS _CS_XBS5_ILP32_OFF32_LINTFLAGS + _CS_XBS5_ILP32_OFFBIG_CFLAGS, +# define _CS_XBS5_ILP32_OFFBIG_CFLAGS _CS_XBS5_ILP32_OFFBIG_CFLAGS + _CS_XBS5_ILP32_OFFBIG_LDFLAGS, +# define _CS_XBS5_ILP32_OFFBIG_LDFLAGS _CS_XBS5_ILP32_OFFBIG_LDFLAGS + _CS_XBS5_ILP32_OFFBIG_LIBS, +# define _CS_XBS5_ILP32_OFFBIG_LIBS _CS_XBS5_ILP32_OFFBIG_LIBS + _CS_XBS5_ILP32_OFFBIG_LINTFLAGS, +# define _CS_XBS5_ILP32_OFFBIG_LINTFLAGS _CS_XBS5_ILP32_OFFBIG_LINTFLAGS + _CS_XBS5_LP64_OFF64_CFLAGS, +# define _CS_XBS5_LP64_OFF64_CFLAGS _CS_XBS5_LP64_OFF64_CFLAGS + _CS_XBS5_LP64_OFF64_LDFLAGS, +# define _CS_XBS5_LP64_OFF64_LDFLAGS _CS_XBS5_LP64_OFF64_LDFLAGS + _CS_XBS5_LP64_OFF64_LIBS, +# define _CS_XBS5_LP64_OFF64_LIBS _CS_XBS5_LP64_OFF64_LIBS + _CS_XBS5_LP64_OFF64_LINTFLAGS, +# define _CS_XBS5_LP64_OFF64_LINTFLAGS _CS_XBS5_LP64_OFF64_LINTFLAGS + _CS_XBS5_LPBIG_OFFBIG_CFLAGS, +# define _CS_XBS5_LPBIG_OFFBIG_CFLAGS _CS_XBS5_LPBIG_OFFBIG_CFLAGS + _CS_XBS5_LPBIG_OFFBIG_LDFLAGS, +# define _CS_XBS5_LPBIG_OFFBIG_LDFLAGS _CS_XBS5_LPBIG_OFFBIG_LDFLAGS + _CS_XBS5_LPBIG_OFFBIG_LIBS, +# define _CS_XBS5_LPBIG_OFFBIG_LIBS _CS_XBS5_LPBIG_OFFBIG_LIBS + _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS, +# define _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS +#endif }; #endif diff --git a/configure b/configure index 2955226..2ef2fee 100755 --- a/configure +++ b/configure @@ -1826,10 +1826,11 @@ echo "configure:1826: checking for gcc 2.7.x -pipe bug" >&5 if eval "test \"`echo '$''{'libc_cv_gcc_pipe_bug'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else - cat >conftest.s <conftest1.s </dev/null; then + if ${CC-cc} -pipe -c conftest.s /dev/null; then libc_cv_gcc_pipe_bug=no else libc_cv_gcc_pipe_bug=yes @@ -1850,7 +1851,7 @@ else fi echo $ac_n "checking for assembler global-symbol directive""... $ac_c" 1>&6 -echo "configure:1854: checking for assembler global-symbol directive" >&5 +echo "configure:1855: checking for assembler global-symbol directive" >&5 if eval "test \"`echo '$''{'libc_cv_asm_global_directive'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1880,7 +1881,7 @@ EOF fi echo $ac_n "checking for .set assembler directive""... $ac_c" 1>&6 -echo "configure:1884: checking for .set assembler directive" >&5 +echo "configure:1885: checking for .set assembler directive" >&5 if eval "test \"`echo '$''{'libc_cv_asm_set_directive'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1914,7 +1915,7 @@ EOF fi echo $ac_n "checking for .symver assembler directive""... $ac_c" 1>&6 -echo "configure:1918: checking for .symver assembler directive" >&5 +echo "configure:1919: checking for .symver assembler directive" >&5 if eval "test \"`echo '$''{'libc_cv_asm_symver_directive'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1933,7 +1934,7 @@ fi echo "$ac_t""$libc_cv_asm_symver_directive" 1>&6 echo $ac_n "checking for ld --version-script""... $ac_c" 1>&6 -echo "configure:1937: checking for ld --version-script" >&5 +echo "configure:1938: checking for ld --version-script" >&5 if eval "test \"`echo '$''{'libc_cv_ld_version_script_option'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1952,7 +1953,7 @@ EOF if { ac_try='${CC-cc} $CFLAGS -shared -o conftest.so conftest.o -nostartfiles -nostdlib -Wl,--version-script,conftest.map - 1>&5'; { (eval echo configure:1956: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; + 1>&5'; { (eval echo configure:1957: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then libc_cv_ld_version_script_option=yes else @@ -1983,7 +1984,7 @@ fi if test $elf = yes; then echo $ac_n "checking for .previous assembler directive""... $ac_c" 1>&6 -echo "configure:1987: checking for .previous assembler directive" >&5 +echo "configure:1988: checking for .previous assembler directive" >&5 if eval "test \"`echo '$''{'libc_cv_asm_previous_directive'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1991,7 +1992,7 @@ else .section foo_section .previous EOF - if { ac_try='${CC-cc} -c $CFLAGS conftest.s 1>&5'; { (eval echo configure:1995: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then + if { ac_try='${CC-cc} -c $CFLAGS conftest.s 1>&5'; { (eval echo configure:1996: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then libc_cv_asm_previous_directive=yes else libc_cv_asm_previous_directive=no @@ -2007,7 +2008,7 @@ EOF else echo $ac_n "checking for .popsection assembler directive""... $ac_c" 1>&6 -echo "configure:2011: checking for .popsection assembler directive" >&5 +echo "configure:2012: checking for .popsection assembler directive" >&5 if eval "test \"`echo '$''{'libc_cv_asm_popsection_directive'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2015,7 +2016,7 @@ else .pushsection foo_section .popsection EOF - if { ac_try='${CC-cc} -c $CFLAGS conftest.s 1>&5'; { (eval echo configure:2019: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then + if { ac_try='${CC-cc} -c $CFLAGS conftest.s 1>&5'; { (eval echo configure:2020: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then libc_cv_asm_popsection_directive=yes else libc_cv_asm_popsection_directive=no @@ -2035,12 +2036,12 @@ fi if test $elf != yes; then echo $ac_n "checking for .init and .fini sections""... $ac_c" 1>&6 -echo "configure:2039: checking for .init and .fini sections" >&5 +echo "configure:2040: checking for .init and .fini sections" >&5 if eval "test \"`echo '$''{'libc_cv_have_initfini'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2054: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* libc_cv_have_initfini=yes else @@ -2077,19 +2078,19 @@ if test $elf = yes; then else if test $ac_cv_prog_cc_works = yes; then echo $ac_n "checking for _ prefix on C symbol names""... $ac_c" 1>&6 -echo "configure:2081: checking for _ prefix on C symbol names" >&5 +echo "configure:2082: checking for _ prefix on C symbol names" >&5 if eval "test \"`echo '$''{'libc_cv_asm_underscores'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:2094: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* libc_cv_asm_underscores=yes else @@ -2104,17 +2105,17 @@ fi echo "$ac_t""$libc_cv_asm_underscores" 1>&6 else echo $ac_n "checking for _ prefix on C symbol names""... $ac_c" 1>&6 -echo "configure:2108: checking for _ prefix on C symbol names" >&5 +echo "configure:2109: checking for _ prefix on C symbol names" >&5 if eval "test \"`echo '$''{'libc_cv_asm_underscores'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2119: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then if grep _underscore_test conftest* >/dev/null; then rm -f conftest* libc_cv_asm_underscores=yes @@ -2147,7 +2148,7 @@ if test $elf = yes; then libc_cv_asm_weakext_directive=no else echo $ac_n "checking for assembler .weak directive""... $ac_c" 1>&6 -echo "configure:2151: checking for assembler .weak directive" >&5 +echo "configure:2152: checking for assembler .weak directive" >&5 if eval "test \"`echo '$''{'libc_cv_asm_weak_directive'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2170,7 +2171,7 @@ echo "$ac_t""$libc_cv_asm_weak_directive" 1>&6 if test $libc_cv_asm_weak_directive = no; then echo $ac_n "checking for assembler .weakext directive""... $ac_c" 1>&6 -echo "configure:2174: checking for assembler .weakext directive" >&5 +echo "configure:2175: checking for assembler .weakext directive" >&5 if eval "test \"`echo '$''{'libc_cv_asm_weakext_directive'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2207,7 +2208,7 @@ EOF fi echo $ac_n "checking for ld --no-whole-archive""... $ac_c" 1>&6 -echo "configure:2211: checking for ld --no-whole-archive" >&5 +echo "configure:2212: checking for ld --no-whole-archive" >&5 if eval "test \"`echo '$''{'libc_cv_ld_no_whole_archive'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2218,7 +2219,7 @@ __throw () {} EOF if { ac_try='${CC-cc} $CFLAGS -nostdlib -nostartfiles -Wl,--no-whole-archive - -o conftest conftest.c 1>&5'; { (eval echo configure:2222: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then + -o conftest conftest.c 1>&5'; { (eval echo configure:2223: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then libc_cv_ld_no_whole_archive=yes else libc_cv_ld_no_whole_archive=no @@ -2229,7 +2230,7 @@ fi echo "$ac_t""$libc_cv_ld_no_whole_archive" 1>&6 echo $ac_n "checking for gcc -fno-exceptions""... $ac_c" 1>&6 -echo "configure:2233: checking for gcc -fno-exceptions" >&5 +echo "configure:2234: checking for gcc -fno-exceptions" >&5 if eval "test \"`echo '$''{'libc_cv_gcc_no_exceptions'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2240,7 +2241,7 @@ __throw () {} EOF if { ac_try='${CC-cc} $CFLAGS -nostdlib -nostartfiles -fno-exceptions - -o conftest conftest.c 1>&5'; { (eval echo configure:2244: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then + -o conftest conftest.c 1>&5'; { (eval echo configure:2245: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then libc_cv_gcc_no_exceptions=yes else libc_cv_gcc_no_exceptions=no @@ -2251,12 +2252,12 @@ fi echo "$ac_t""$libc_cv_gcc_no_exceptions" 1>&6 echo $ac_n "checking for DWARF2 unwind info support""... $ac_c" 1>&6 -echo "configure:2255: checking for DWARF2 unwind info support" >&5 +echo "configure:2256: checking for DWARF2 unwind info support" >&5 if eval "test \"`echo '$''{'libc_cv_gcc_dwarf2_unwind_info'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.c <&5; (eval $ac_try) 2>&5; }; }; then + -o conftest conftest.c -lgcc >&5'; { (eval echo configure:2282: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then libc_cv_gcc_dwarf2_unwind_info=yes else libc_cv_gcc_dwarf2_unwind_info=no @@ -2335,7 +2336,7 @@ if test "$uname" = "sysdeps/generic"; then fi echo $ac_n "checking OS release for uname""... $ac_c" 1>&6 -echo "configure:2339: checking OS release for uname" >&5 +echo "configure:2340: checking OS release for uname" >&5 if eval "test \"`echo '$''{'libc_cv_uname_release'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2357,7 +2358,7 @@ echo "$ac_t""$libc_cv_uname_release" 1>&6 uname_release="$libc_cv_uname_release" echo $ac_n "checking OS version for uname""... $ac_c" 1>&6 -echo "configure:2361: checking OS version for uname" >&5 +echo "configure:2362: checking OS version for uname" >&5 if eval "test \"`echo '$''{'libc_cv_uname_version'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2379,7 +2380,7 @@ else fi echo $ac_n "checking stdio selection""... $ac_c" 1>&6 -echo "configure:2383: checking stdio selection" >&5 +echo "configure:2384: checking stdio selection" >&5 case $stdio in libio) cat >> confdefs.h <<\EOF @@ -2391,7 +2392,7 @@ esac echo "$ac_t""$stdio" 1>&6 echo $ac_n "checking ldap selection""... $ac_c" 1>&6 -echo "configure:2395: checking ldap selection" >&5 +echo "configure:2396: checking ldap selection" >&5 case $add_ons in *ldap*) diff --git a/configure.in b/configure.in index d0659bf..3b3be45 100644 --- a/configure.in +++ b/configure.in @@ -509,10 +509,11 @@ if test $ac_cv_prog_gcc = yes; then # We must check this even if -pipe is not given here, because the user # might do `make CFLAGS=-pipe'. AC_CACHE_CHECK(for gcc 2.7.x -pipe bug, libc_cv_gcc_pipe_bug, [dnl - cat >conftest.s <conftest1.s </dev/null; then + if ${CC-cc} -pipe -c conftest.s /dev/null; then libc_cv_gcc_pipe_bug=no else libc_cv_gcc_pipe_bug=yes diff --git a/elf/dl-load.c b/elf/dl-load.c index 9a6aae6..0b75267 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -238,12 +238,12 @@ fillin_rpath (char *rpath, struct r_search_path_elem **result, const char *sep, if (tmp == NULL) _dl_signal_error (ENOMEM, NULL, "cannot create cache for search path"); - memcpy (tmp, cp, len); - memcpy (tmp + len, _dl_platform, _dl_platformlen); - tmp[len + _dl_platformlen] = '/'; - tmp[len + _dl_platformlen + 1] = '\0'; - dirp->dirname = tmp; + tmp = __mempcpy (tmp, cp, len); + tmp = __mempcpy (tmp, _dl_platform, _dl_platformlen); + *tmp++ = '/'; + *tmp = '\0'; + dirp->machdirstatus = dirp->dirstatus; if (max_dirnamelen < dirp->machdirnamelen) @@ -260,13 +260,11 @@ fillin_rpath (char *rpath, struct r_search_path_elem **result, const char *sep, if (tmp == NULL) _dl_signal_error (ENOMEM, NULL, "cannot create cache for search path"); - memcpy (tmp, cp, len); - tmp[len] = '\0'; + dirp->dirname = tmp; + *((char *) __mempcpy (tmp, cp, len)) = '\0'; if (max_dirnamelen < dirp->dirnamelen) max_dirnamelen = dirp->dirnamelen; - - dirp->dirname = tmp; } dirp->next = all_dirs; @@ -430,12 +428,11 @@ _dl_init_paths (void) _dl_signal_error (ENOMEM, NULL, "cannot create cache for search path"); - memcpy (tmp, relem->dirname, relem->dirnamelen); - memcpy (tmp + relem->dirnamelen, _dl_platform, _dl_platformlen); - tmp[relem->dirnamelen + _dl_platformlen] = '/'; - tmp[relem->dirnamelen + _dl_platformlen + 1] = '\0'; - relem->dirname = tmp; + tmp = __mempcpy (tmp, relem->dirname, relem->dirnamelen); + tmp = __mempcpy (tmp, _dl_platform, _dl_platformlen); + *tmp++ = '/'; + *tmp = '\0'; relem->machdirstatus = unknown; @@ -812,9 +809,10 @@ open_path (const char *name, size_t namelen, if (this_dir->machdirstatus != nonexisting) { /* Construct the pathname to try. */ - (void) memcpy (buf, this_dir->dirname, this_dir->machdirnamelen); - (void) memcpy (buf + this_dir->machdirnamelen, name, namelen); - buflen = this_dir->machdirnamelen + namelen; + buflen = ((char *) __mempcpy (__mempcpy (buf, this_dir->dirname, + this_dir->machdirnamelen), + name, namelen) + - buf); fd = __open (buf, O_RDONLY); if (this_dir->machdirstatus == unknown) @@ -839,9 +837,10 @@ open_path (const char *name, size_t namelen, if (fd == -1 && this_dir->dirstatus != nonexisting) { /* Construct the pathname to try. */ - (void) memcpy (buf, this_dir->dirname, this_dir->dirnamelen); - (void) memcpy (buf + this_dir->dirnamelen, name, namelen); - buflen = this_dir->dirnamelen + namelen; + buflen = ((char *) __mempcpy (__mempcpy (buf, this_dir->dirname, + this_dir->dirnamelen), + name, namelen) + - buf); fd = __open (buf, O_RDONLY); if (this_dir->dirstatus == unknown) diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c index ef34479..c517240 100644 --- a/elf/dl-lookup.c +++ b/elf/dl-lookup.c @@ -355,8 +355,8 @@ _dl_lookup_versioned_symbol_skip (const char *undef_name, /* We could find no value for a strong reference. */ const size_t len = strlen (undef_name); char buf[sizeof undefined_msg + len]; - memcpy (buf, undefined_msg, sizeof undefined_msg - 1); - memcpy (&buf[sizeof undefined_msg - 1], undef_name, len + 1); + __mempcpy (__mempcpy (buf, undefined_msg, sizeof undefined_msg - 1), + undef_name, len + 1); _dl_signal_error (0, reference_name, buf); } diff --git a/elf/dl-profile.c b/elf/dl-profile.c index dcbbcd0..1a4f6b3 100644 --- a/elf/dl-profile.c +++ b/elf/dl-profile.c @@ -262,7 +262,7 @@ _dl_start_profile (struct link_map *map, const char *output_dir) fd = __open (filename, O_RDWR | O_CREAT, 0666); if (fd == -1) { - /* We cannot write the profiling data so don't do anthing. */ + /* We cannot write the profiling data so don't do anything. */ char buf[400]; _dl_sysdep_message (filename, ": cannot open file: ", _strerror_internal (errno, buf, sizeof buf), diff --git a/inet/ether_ntoh.c b/inet/ether_ntoh.c index 93c2cf8..ab3650f 100644 --- a/inet/ether_ntoh.c +++ b/inet/ether_ntoh.c @@ -1,4 +1,4 @@ -/* 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 , 1996. @@ -21,7 +21,7 @@ #include #include -#include "../nss/nsswitch.h" +#include /* Because the `ethers' lookup does not fit so well in the scheme so we define a dummy struct here which helps us to use the available diff --git a/inet/gethstbynm.c b/inet/gethstbynm.c index 08ee4cd..38d045c 100644 --- a/inet/gethstbynm.c +++ b/inet/gethstbynm.c @@ -35,4 +35,4 @@ #define HANDLE_DIGITS_DOTS 1 -#include "../nss/getXXbyYY.c" +#include diff --git a/inet/rcmd.c b/inet/rcmd.c index 92ce094..d496a7a 100644 --- a/inet/rcmd.c +++ b/inet/rcmd.c @@ -330,8 +330,8 @@ again: dirlen = strlen (pwd->pw_dir); pbuf = alloca (dirlen + sizeof "/.rhosts"); - memcpy (pbuf, pwd->pw_dir, dirlen); - memcpy (pbuf + dirlen, "/.rhosts", sizeof "/.rhosts"); + __mempcpy (__mempcpy (pbuf, pwd->pw_dir, dirlen), + "/.rhosts", sizeof "/.rhosts"); /* * Change effective uid while opening .rhosts. If root and diff --git a/inet/ruserpass.c b/inet/ruserpass.c index a0a4b97..421bfc5 100644 --- a/inet/ruserpass.c +++ b/inet/ruserpass.c @@ -63,7 +63,7 @@ static FILE *cfile; static char tokval[100]; static struct toktab { - char *tokstr; + const char *tokstr; int tval; } toktab[]= { { "default", DEFAULT }, @@ -98,7 +98,7 @@ ruserpass(host, aname, apass) buf = alloca (strlen (hdir) + 8); - (void) sprintf(buf, "%s/.netrc", hdir); + __stpcpy (__stpcpy (buf, hdir), "/.netrc"); cfile = fopen(buf, "r"); if (cfile == NULL) { if (errno != ENOENT) diff --git a/io/ftw.c b/io/ftw.c index e0835c2..a7b537f 100644 --- a/io/ftw.c +++ b/io/ftw.c @@ -186,9 +186,9 @@ open_dir_stream (struct ftw_data *data, struct dir_data *dirp) buf = newp; } - memcpy (buf + actsize, d->d_name, this_len); - actsize += this_len; - buf[actsize++] = '\0'; + *((char *) __mempcpy (buf + actsize, d->d_name, this_len)) + = '\0'; + actsize += this_len + 1; } /* Terminate the list with an additional NUL byte. */ @@ -259,8 +259,7 @@ process_entry (struct ftw_data *data, struct dir_data *dir, const char *name, data->dirbuf = newp; } - memcpy (data->dirbuf + data->ftw.base, name, namlen); - data->dirbuf[data->ftw.base + namlen] = '\0'; + *((char *) __mempcpy (data->dirbuf + data->ftw.base, name, namlen)) = '\0'; if (((data->flags & FTW_PHYS) ? LXSTAT (_STAT_VER, data->dirbuf, &st) diff --git a/libio/fileops.c b/libio/fileops.c index e82e2b3..ffc57f1 100644 --- a/libio/fileops.c +++ b/libio/fileops.c @@ -706,7 +706,12 @@ _IO_file_xsputn (f, data, n) count = to_do; if (count > 20) { +#ifdef _LIBC + f->_IO_write_ptr = __mempcpy (f->_IO_write_ptr, s, count); +#else memcpy (f->_IO_write_ptr, s, count); + f->_IO_write_ptr += count; +#endif s += count; } else @@ -715,8 +720,8 @@ _IO_file_xsputn (f, data, n) register int i = (int) count; while (--i >= 0) *p++ = *s++; + f->_IO_write_ptr = p; } - f->_IO_write_ptr += count; to_do -= count; } if (to_do + must_flush > 0) @@ -765,8 +770,12 @@ _IO_file_xsgetn (fp, data, n) count = more; if (count > 20) { +#ifdef _LIBC + s = __mempcpy (s, fp->_IO_read_ptr, count); +#else memcpy (s, fp->_IO_read_ptr, count); s += count; +#endif fp->_IO_read_ptr += count; } else if (count <= 0) diff --git a/libio/genops.c b/libio/genops.c index 20d0df2..3776b9e 100644 --- a/libio/genops.c +++ b/libio/genops.c @@ -210,12 +210,20 @@ save_for_backup (fp) return EOF; /* FIXME */ if (least_mark < 0) { +#ifdef _LIBC + __mempcpy (__mempcpy (new_buffer + avail, + fp->_IO_save_end + least_mark, + -least_mark), + fp->_IO_read_base, + fp->_IO_read_end - fp->_IO_read_base); +#else 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); +#endif } else memcpy (new_buffer + avail, @@ -368,9 +376,13 @@ _IO_default_xsputn (f, data, n) count = more; if (count > 20) { +#ifdef _LIBC + f->_IO_write_ptr = __mempcpy (f->_IO_write_ptr, s, count); +#else memcpy (f->_IO_write_ptr, s, count); - s += count; f->_IO_write_ptr += count; +#endif + s += count; } else if (count <= 0) count = 0; @@ -419,8 +431,12 @@ _IO_default_xsgetn (fp, data, n) count = more; if (count > 20) { +#ifdef _LIBC + s = __mempcpy (s, fp->_IO_read_ptr, count); +#else memcpy (s, fp->_IO_read_ptr, count); s += count; +#endif fp->_IO_read_ptr += count; } else if (count <= 0) diff --git a/libio/obprintf.c b/libio/obprintf.c index a0c4df6..a4d685a 100644 --- a/libio/obprintf.c +++ b/libio/obprintf.c @@ -80,10 +80,7 @@ _IO_obstack_xsputn (_IO_FILE *fp, const void *data, _IO_size_t n) obstack_blank_fast (obstack, fp->_IO_write_end - fp->_IO_write_ptr); } else - { - memcpy (fp->_IO_write_ptr, data, n); - fp->_IO_write_ptr += n; - } + fp->_IO_write_ptr = __mempcpy (fp->_IO_write_ptr, data, n); return n; } diff --git a/libio/oldfileops.c b/libio/oldfileops.c index ab4445c..71a2bc2 100644 --- a/libio/oldfileops.c +++ b/libio/oldfileops.c @@ -707,10 +707,10 @@ struct _IO_jump_t _IO_old_file_jumps = JUMP_INIT(seekoff, _IO_old_file_seekoff), JUMP_INIT(seekpos, _IO_default_seekpos), JUMP_INIT(setbuf, _IO_old_file_setbuf), - JUMP_INIT(sync, _IO_file_sync), + JUMP_INIT(sync, _IO_old_file_sync), JUMP_INIT(doallocate, _IO_file_doallocate), JUMP_INIT(read, _IO_file_read), - JUMP_INIT(write, _IO_file_write), + JUMP_INIT(write, _IO_old_file_write), JUMP_INIT(seek, _IO_file_seek), JUMP_INIT(close, _IO_file_close), JUMP_INIT(stat, _IO_file_stat) diff --git a/login/utmp_daemon.c b/login/utmp_daemon.c index db3c90e..e3c9371 100644 --- a/login/utmp_daemon.c +++ b/login/utmp_daemon.c @@ -208,8 +208,10 @@ do_setutent (int sock) setutent_request *request; setutent_reply reply; size_t size; + size_t name_len; - size = sizeof (setutent_request) + strlen (__libc_utmp_file_name) + 1; + name_len = strlen (__libc_utmp_file_name) + 1; + size = sizeof (setutent_request) + name_len; request = malloc (size); if (request == NULL) @@ -218,7 +220,7 @@ do_setutent (int sock) request->header.version = UTMPD_VERSION; request->header.size = size; request->header.type = UTMPD_REQ_SETUTENT; - strcpy (request->file, __libc_utmp_file_name); + memcpy (request->file, __libc_utmp_file_name, name_len); reply.header.version = UTMPD_VERSION; reply.header.size = sizeof (setutent_reply); @@ -367,8 +369,10 @@ do_updwtmp (int sock, const char *file, const struct utmp *utmp) updwtmp_request *request; updwtmp_reply reply; size_t size; + size_t file_len; - size = sizeof (updwtmp_request) + strlen (file) + 1; + file_len = strlen (file) + 1; + size = sizeof (updwtmp_request) + file_len; request = malloc (size); if (request == NULL) @@ -378,7 +382,7 @@ do_updwtmp (int sock, const char *file, const struct utmp *utmp) request->header.size = size; request->header.type = UTMPD_REQ_UPDWTMP; memcpy (&request->utmp, utmp, sizeof (struct utmp)); - strcpy (request->file, file); + memcpy (request->file, file, file_len); reply.header.version = UTMPD_VERSION; reply.header.size = sizeof (updwtmp_reply); diff --git a/manual/creature.texi b/manual/creature.texi index 1efd1f5..4cdcce9 100644 --- a/manual/creature.texi +++ b/manual/creature.texi @@ -32,6 +32,7 @@ macro @code{_POSIX_C_SOURCE} to a positive integer. @comment (none) @comment POSIX.2 +@defvr Macro _POSIX_C_SOURCE Define this macro to a positive integer to control which POSIX functionality is made available. The greater the value of this macro, the more functionality is made available. diff --git a/misc/tsearch.c b/misc/tsearch.c index c5af3ec..0cf854b 100644 --- a/misc/tsearch.c +++ b/misc/tsearch.c @@ -359,8 +359,7 @@ __tdelete (const void *key, void **vrootp, __compar_fn_t compar) node **newstack; stacksize += 20; newstack = alloca (sizeof (node *) * stacksize); - memcpy (newstack, nodestack, sp * sizeof (node *)); - nodestack = newstack; + nodestack = memcpy (newstack, nodestack, sp * sizeof (node *)); } nodestack[sp++] = rootp; @@ -398,8 +397,7 @@ __tdelete (const void *key, void **vrootp, __compar_fn_t compar) node **newstack; stacksize += 20; newstack = alloca (sizeof (node *) * stacksize); - memcpy (newstack, nodestack, sp * sizeof (node *)); - nodestack = newstack; + nodestack = memcpy (newstack, nodestack, sp * sizeof (node *)); } nodestack[sp++] = parent; parent = up; diff --git a/nss/digits_dots.c b/nss/digits_dots.c index dab64bf..29aa5b1 100644 --- a/nss/digits_dots.c +++ b/nss/digits_dots.c @@ -246,8 +246,7 @@ goto done; } - strcpy (hostname, name); - resbuf.h_name = hostname; + resbuf.h_name = strcpy (hostname, name); resbuf.h_aliases = *host_aliases; (*host_aliases)[0] = NULL; (*h_addr_ptrs)[0] = (char *) host_addr; diff --git a/nss/getXXbyYY.c b/nss/getXXbyYY.c index 47df15b..0df916b 100644 --- a/nss/getXXbyYY.c +++ b/nss/getXXbyYY.c @@ -117,6 +117,7 @@ FUNCTION_NAME (ADD_PARAMS) process gets a chance for a normal termination. */ save = errno; free (buffer); + buffer = NULL; __set_errno (save); } buffer = new_buf; diff --git a/nss/nsswitch.c b/nss/nsswitch.c index 18129bb..36c1d00 100644 --- a/nss/nsswitch.c +++ b/nss/nsswitch.c @@ -587,8 +587,7 @@ nss_parse_service_list (const char *line) free (new_service); return result; } - memcpy (source, name, line - name); - source[line - name] = '\0'; + *((char *) __mempcpy (source, name, line - name)) = '\0'; new_service->name = source; } diff --git a/posix/confstr.c b/posix/confstr.c index c8d4d73..3fabf1a 100644 --- a/posix/confstr.c +++ b/posix/confstr.c @@ -47,7 +47,7 @@ confstr (name, buf, len) case _CS_LFS_CFLAGS: /* Signal that we want the new ABI. */ { - static const char file_offset[] = "-D_FILE_OFFSET_SIZE=64"; + static const char file_offset[] = "-D_FILE_OFFSET_BITS=64"; string = file_offset; string_len = sizeof (file_offset); } @@ -60,6 +60,23 @@ confstr (name, buf, len) case _CS_LFS64_LINTFLAGS: case _CS_LFS64_LDFLAGS: case _CS_LFS64_LIBS: + + case _CS_XBS5_ILP32_OFF32_CFLAGS: + case _CS_XBS5_ILP32_OFF32_LDFLAGS: + case _CS_XBS5_ILP32_OFF32_LIBS: + case _CS_XBS5_ILP32_OFF32_LINTFLAGS: + case _CS_XBS5_ILP32_OFFBIG_CFLAGS: + case _CS_XBS5_ILP32_OFFBIG_LDFLAGS: + case _CS_XBS5_ILP32_OFFBIG_LIBS: + case _CS_XBS5_ILP32_OFFBIG_LINTFLAGS: + case _CS_XBS5_LP64_OFF64_CFLAGS: + case _CS_XBS5_LP64_OFF64_LDFLAGS: + case _CS_XBS5_LP64_OFF64_LIBS: + case _CS_XBS5_LP64_OFF64_LINTFLAGS: + case _CS_XBS5_LPBIG_OFFBIG_CFLAGS: + case _CS_XBS5_LPBIG_OFFBIG_LDFLAGS: + case _CS_XBS5_LPBIG_OFFBIG_LIBS: + case _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS: /* GNU libc does not require special actions to use LFS functions. */ string = ""; string_len = 1; diff --git a/posix/execvp.c b/posix/execvp.c index 26c7be9..2eda603 100644 --- a/posix/execvp.c +++ b/posix/execvp.c @@ -104,9 +104,9 @@ execvp (file, argv) else { /* Construct the pathname to try. */ - (void) memcpy (name, path, p - path); - name[p - path] = '/'; - (void) memcpy (&name[(p - path) + 1], file, len); + char *tmp = __mempcpy (name, path, p - path); + *tmp++ = '/'; + (void) __mempcpy (tmp, file, len); } /* Try to execute this name. If it works, execv will not return. */ diff --git a/posix/getopt.c b/posix/getopt.c index 8f639eb..8311121 100644 --- a/posix/getopt.c +++ b/posix/getopt.c @@ -328,9 +328,9 @@ exchange (argv) nonoption_flags_len = nonoption_flags_max_len = 0; else { - memcpy (new_str, __getopt_nonoption_flags, nonoption_flags_max_len); - memset (&new_str[nonoption_flags_max_len], '\0', - top + 1 - nonoption_flags_max_len); + memset (__mempcpy (new_str, __getopt_nonoption_flags, + nonoption_flags_max_len), + '\0', top + 1 - nonoption_flags_max_len); nonoption_flags_max_len = top + 1; __getopt_nonoption_flags = new_str; } @@ -439,11 +439,8 @@ _getopt_initialize (argc, argv, optstring) if (__getopt_nonoption_flags == NULL) nonoption_flags_max_len = -1; else - { - memcpy (__getopt_nonoption_flags, orig_str, len); - memset (&__getopt_nonoption_flags[len], '\0', - nonoption_flags_max_len - len); - } + memset (__mempcpy (__getopt_nonoption_flags, orig_str, len), + '\0', nonoption_flags_max_len - len); } } nonoption_flags_len = nonoption_flags_max_len; diff --git a/posix/glob.c b/posix/glob.c index 909b4f1..85747f5 100644 --- a/posix/glob.c +++ b/posix/glob.c @@ -374,8 +374,12 @@ glob (pattern, flags, errfunc, pglob) #endif /* We know the prefix for all sub-patterns. */ +#ifdef HAVE_MEMPCPY + alt_start = mempcpy (onealt, pattern, begin - pattern); +#else memcpy (onealt, pattern, begin - pattern); alt_start = &onealt[begin - pattern]; +#endif /* Find the first sub-pattern and at the same time find the rest after the closing brace. */ @@ -951,138 +955,94 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob) char *name; }; struct globlink *names = NULL; - size_t nfound = 0; - - if (!__glob_pattern_p (pattern, !(flags & GLOB_NOESCAPE))) + size_t nfound; + int meta; + int save; + + stream = ((flags & GLOB_ALTDIRFUNC) ? + (*pglob->gl_opendir) (directory) : + (__ptr_t) opendir (directory)); + if (stream == NULL) { - /* We must check whether the file in this directory exists. */ - stream = ((flags & GLOB_ALTDIRFUNC) ? - (*pglob->gl_opendir) (directory) : - (__ptr_t) opendir (directory)); - if (stream == NULL) - { - if ((errfunc != NULL && (*errfunc) (directory, errno)) || - (flags & GLOB_ERR)) - return GLOB_ABORTED; - } - else if (pattern[0] == '\0') - { - /* This is a special case for matching directories like in - "*a/". */ - names = (struct globlink *) __alloca (sizeof (struct globlink)); - names->name = (char *) malloc (1); - if (names->name == NULL) - goto memory_error; - names->name[0] = '\0'; - names->next = NULL; - nfound = 1; - } - else - while (1) - { - struct dirent *d = ((flags & GLOB_ALTDIRFUNC) ? - (*pglob->gl_readdir) (stream) : - readdir ((DIR *) stream)); - if (d == NULL) - break; - if (! REAL_DIR_ENTRY (d)) - continue; - -#ifdef HAVE_D_TYPE - /* If we shall match only directories use the information - provided by the dirent if possible. */ - if ((flags & GLOB_ONLYDIR) - && d->d_type != DT_UNKNOWN && d->d_type != DT_DIR) - continue; -#endif - - if (strcmp (pattern, d->d_name) == 0) - { - size_t len = NAMLEN (d); - names = - (struct globlink *) __alloca (sizeof (struct globlink)); - names->name = (char *) malloc (len + 1); - if (names->name == NULL) - goto memory_error; -#ifdef HAVE_MEMPCPY - *((char *) mempcpy ((__ptr_t) names->name, pattern, len)) - = '\0'; -#else - memcpy ((__ptr_t) names->name, pattern, len); - names->name[len] = '\0'; -#endif - names->next = NULL; - nfound = 1; - break; - } - } + if ((errfunc != NULL && (*errfunc) (directory, errno)) || + (flags & GLOB_ERR)) + return GLOB_ABORTED; + nfound = 0; + meta = 0; + } + else if (pattern[0] == '\0') + { + /* This is a special case for matching directories like in + "*a/". */ + names = (struct globlink *) __alloca (sizeof (struct globlink)); + names->name = (char *) malloc (1); + if (names->name == NULL) + goto memory_error; + names->name[0] = '\0'; + names->next = NULL; + nfound = 1; + meta = 0; } else { - flags |= GLOB_MAGCHAR; + nfound = 0; + meta = __glob_pattern_p (pattern, !(flags & GLOB_NOESCAPE)); + if(meta) + flags |= GLOB_MAGCHAR; - stream = ((flags & GLOB_ALTDIRFUNC) ? - (*pglob->gl_opendir) (directory) : - (__ptr_t) opendir (directory)); - if (stream == NULL) + while (1) { - if ((errfunc != NULL && (*errfunc) (directory, errno)) || - (flags & GLOB_ERR)) - return GLOB_ABORTED; - } - else - while (1) - { - const char *name; - size_t len; - struct dirent *d = ((flags & GLOB_ALTDIRFUNC) ? - (*pglob->gl_readdir) (stream) : - readdir ((DIR *) stream)); - if (d == NULL) - break; - if (! REAL_DIR_ENTRY (d)) - continue; - - name = d->d_name; + const char *name; + size_t len; + struct dirent *d = ((flags & GLOB_ALTDIRFUNC) ? + (*pglob->gl_readdir) (stream) : + readdir ((DIR *) stream)); + if (d == NULL) + break; + if (! REAL_DIR_ENTRY (d)) + continue; #ifdef HAVE_D_TYPE - /* If we shall match only directories use the information - provided by the dirent if possible. */ - if ((flags & GLOB_ONLYDIR) - && d->d_type != DT_UNKNOWN && d->d_type != DT_DIR) - continue; + /* If we shall match only directories use the information + provided by the dirent call if possible. */ + if ((flags & GLOB_ONLYDIR) + && d->d_type != DT_UNKNOWN && d->d_type != DT_DIR) + continue; #endif - if (fnmatch (pattern, name, - (!(flags & GLOB_PERIOD) ? FNM_PERIOD : 0) | - ((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0) + name = d->d_name; + + if ((!meta && strcmp (pattern, name) == 0) + || fnmatch (pattern, name, + (!(flags & GLOB_PERIOD) ? FNM_PERIOD : 0) | + ((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0) #ifdef _AMIGA - | FNM_CASEFOLD + | FNM_CASEFOLD #endif ) == 0) - { - struct globlink *new - = (struct globlink *) __alloca (sizeof (struct globlink)); - len = NAMLEN (d); - new->name - = (char *) malloc (len + 1); - if (new->name == NULL) - goto memory_error; + { + struct globlink *new + = (struct globlink *) __alloca (sizeof (struct globlink)); + len = NAMLEN (d); + new->name = (char *) malloc (len + 1); + if (new->name == NULL) + goto memory_error; #ifdef HAVE_MEMPCPY - *((char *) mempcpy ((__ptr_t) new->name, name, len)) = '\0'; + *((char *) mempcpy ((__ptr_t) new->name, name, len)) = '\0'; #else - memcpy ((__ptr_t) new->name, name, len); - new->name[len] = '\0'; + memcpy ((__ptr_t) new->name, name, len); + new->name[len] = '\0'; #endif - new->next = names; - names = new; - ++nfound; - } - } + new->next = names; + names = new; + ++nfound; + if (!meta) + break; + } + } } - if (nfound == 0 && (flags & GLOB_NOMAGIC) && - ! __glob_pattern_p (pattern, !(flags & GLOB_NOESCAPE))) + if (nfound == 0 && (flags & GLOB_NOMAGIC) && !meta) flags |= GLOB_NOCHECK; if (nfound == 0 && (flags & GLOB_NOCHECK)) @@ -1124,15 +1084,13 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob) pglob->gl_flags = flags; } - if (stream != NULL) - { - int save = errno; - if (flags & GLOB_ALTDIRFUNC) - (*pglob->gl_closedir) (stream); - else - closedir ((DIR *) stream); - __set_errno (save); - } + save = errno; + if (flags & GLOB_ALTDIRFUNC) + (*pglob->gl_closedir) (stream); + else + closedir ((DIR *) stream); + __set_errno (save); + return nfound == 0 ? GLOB_NOMATCH : 0; memory_error: diff --git a/posix/regex.c b/posix/regex.c index 4f125be..b80ad1b 100644 --- a/posix/regex.c +++ b/posix/regex.c @@ -2,12 +2,8 @@ version 0.12. (Implements POSIX draft P1003.2/D11.2, except for some of the internationalization features.) - Copyright (C) 1993, 1994, 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 @@ -24,7 +20,7 @@ Boston, MA 02111-1307, USA. */ /* AIX requires this to be the first thing in the file. */ -#if defined (_AIX) && !defined (REGEX_MALLOC) +#if defined _AIX && !defined REGEX_MALLOC #pragma alloca #endif @@ -32,14 +28,14 @@ #define _GNU_SOURCE #ifdef HAVE_CONFIG_H -#include +# include #endif -#if defined(STDC_HEADERS) && !defined(emacs) -#include +#if defined STDC_HEADERS && !defined emacs +# include #else /* We need this for `regex.h', and perhaps for the Emacs include files. */ -#include +# include #endif /* For platform which support the ISO C amendement 1 functionality we @@ -50,7 +46,7 @@ #endif /* This is for other GNU distributions with internationalized messages. */ -#if HAVE_LIBINTL_H || defined (_LIBC) +#if HAVE_LIBINTL_H || defined _LIBC # include #else # define gettext(msgid) (msgid) @@ -59,83 +55,83 @@ #ifndef gettext_noop /* This define is so xgettext can find the internationalizable strings. */ -#define gettext_noop(String) String +# define gettext_noop(String) String #endif /* The `emacs' switch turns on certain matching commands that make sense only in Emacs. */ #ifdef emacs -#include "lisp.h" -#include "buffer.h" -#include "syntax.h" +# include "lisp.h" +# include "buffer.h" +# include "syntax.h" #else /* not emacs */ /* If we are not linking with Emacs proper, we can't use the relocating allocator even if config.h says that we can. */ -#undef REL_ALLOC +# undef REL_ALLOC -#if defined (STDC_HEADERS) || defined (_LIBC) -#include -#else +# if defined STDC_HEADERS || defined _LIBC +# include +# else char *malloc (); char *realloc (); -#endif +# endif /* When used in Emacs's lib-src, we need to get bzero and bcopy somehow. If nothing else has been done, use the method below. */ -#ifdef INHIBIT_STRING_HEADER -#if !(defined (HAVE_BZERO) && defined (HAVE_BCOPY)) -#if !defined (bzero) && !defined (bcopy) -#undef INHIBIT_STRING_HEADER -#endif -#endif -#endif +# ifdef INHIBIT_STRING_HEADER +# if !(defined HAVE_BZERO && defined HAVE_BCOPY) +# if !defined bzero && !defined bcopy +# undef INHIBIT_STRING_HEADER +# endif +# endif +# endif /* This is the normal way of making sure we have a bcopy and a bzero. This is used in most programs--a few other programs avoid this by defining INHIBIT_STRING_HEADER. */ -#ifndef INHIBIT_STRING_HEADER -#if defined (HAVE_STRING_H) || defined (STDC_HEADERS) || defined (_LIBC) -#include -#ifndef bcmp -#define bcmp(s1, s2, n) memcmp ((s1), (s2), (n)) -#endif -#ifndef bcopy -#define bcopy(s, d, n) memcpy ((d), (s), (n)) -#endif -#ifndef bzero -#define bzero(s, n) memset ((s), 0, (n)) -#endif -#else -#include -#endif -#endif +# ifndef INHIBIT_STRING_HEADER +# if defined HAVE_STRING_H || defined STDC_HEADERS || defined _LIBC +# include +# if !defined bzero && !defined _LIBC +# define bzero(s, n) (memset (s, '\0', n), (s)) +# endif +# else +# include +# ifndef memcmp +# define memcmp(s1, s2, n) bcmp (s1, s2, n) +# endif +# ifndef memcpy +# define memcpy(d, s, n) (bcopy (s, d, n), (d)) +# endif +# endif +# endif /* Define the syntax stuff for \<, \>, etc. */ /* This must be nonzero for the wordchar and notwordchar pattern commands in re_match_2. */ -#ifndef Sword -#define Sword 1 -#endif +# ifndef Sword +# define Sword 1 +# endif -#ifdef SWITCH_ENUM_BUG -#define SWITCH_ENUM_CAST(x) ((int)(x)) -#else -#define SWITCH_ENUM_CAST(x) (x) -#endif +# ifdef SWITCH_ENUM_BUG +# define SWITCH_ENUM_CAST(x) ((int)(x)) +# else +# define SWITCH_ENUM_CAST(x) (x) +# endif /* How many characters in the character set. */ -#define CHAR_SET_SIZE 256 +# define CHAR_SET_SIZE 256 -#ifdef SYNTAX_TABLE +# ifdef SYNTAX_TABLE extern char *re_syntax_table; -#else /* not SYNTAX_TABLE */ +# else /* not SYNTAX_TABLE */ static char re_syntax_table[CHAR_SET_SIZE]; @@ -164,9 +160,9 @@ init_syntax_once () done = 1; } -#endif /* not SYNTAX_TABLE */ +# endif /* not SYNTAX_TABLE */ -#define SYNTAX(c) re_syntax_table[c] +# define SYNTAX(c) re_syntax_table[c] #endif /* not emacs */ @@ -187,21 +183,21 @@ init_syntax_once () Defining isascii to 1 should let any compiler worth its salt eliminate the && through constant folding." */ -#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII)) -#define ISASCII(c) 1 +#if defined STDC_HEADERS || (!defined isascii && !defined HAVE_ISASCII) +# define ISASCII(c) 1 #else -#define ISASCII(c) isascii(c) +# define ISASCII(c) isascii(c) #endif #ifdef isblank -#define ISBLANK(c) (ISASCII (c) && isblank (c)) +# define ISBLANK(c) (ISASCII (c) && isblank (c)) #else -#define ISBLANK(c) ((c) == ' ' || (c) == '\t') +# define ISBLANK(c) ((c) == ' ' || (c) == '\t') #endif #ifdef isgraph -#define ISGRAPH(c) (ISASCII (c) && isgraph (c)) +# define ISGRAPH(c) (ISASCII (c) && isgraph (c)) #else -#define ISGRAPH(c) (ISASCII (c) && isprint (c) && !isspace (c)) +# define ISGRAPH(c) (ISASCII (c) && isprint (c) && !isspace (c)) #endif #define ISPRINT(c) (ISASCII (c) && isprint (c)) @@ -216,7 +212,7 @@ init_syntax_once () #define ISXDIGIT(c) (ISASCII (c) && isxdigit (c)) #ifndef NULL -#define NULL (void *)0 +# define NULL (void *)0 #endif /* We remove any previous definition of `SIGN_EXTEND_CHAR', @@ -225,10 +221,10 @@ init_syntax_once () (Per Bothner suggested the basic approach.) */ #undef SIGN_EXTEND_CHAR #if __STDC__ -#define SIGN_EXTEND_CHAR(c) ((signed char) (c)) +# define SIGN_EXTEND_CHAR(c) ((signed char) (c)) #else /* not __STDC__ */ /* As in Harbison and Steele. */ -#define SIGN_EXTEND_CHAR(c) ((((unsigned char) (c)) ^ 128) - 128) +# define SIGN_EXTEND_CHAR(c) ((((unsigned char) (c)) ^ 128) - 128) #endif /* Should we use malloc or alloca? If REGEX_MALLOC is not defined, we @@ -243,74 +239,67 @@ init_syntax_once () #ifdef REGEX_MALLOC -#define REGEX_ALLOCATE malloc -#define REGEX_REALLOCATE(source, osize, nsize) realloc (source, nsize) -#define REGEX_FREE free +# define REGEX_ALLOCATE malloc +# define REGEX_REALLOCATE(source, osize, nsize) realloc (source, nsize) +# define REGEX_FREE free #else /* not REGEX_MALLOC */ /* Emacs already defines alloca, sometimes. */ -#ifndef alloca +# ifndef alloca /* Make alloca work the best possible way. */ -#ifdef __GNUC__ -#define alloca __builtin_alloca -#else /* not __GNUC__ */ -#if HAVE_ALLOCA_H -#include -#else /* not __GNUC__ or HAVE_ALLOCA_H */ -#if 0 /* It is a bad idea to declare alloca. We always cast the result. */ -#ifndef _AIX /* Already did AIX, up at the top. */ -char *alloca (); -#endif /* not _AIX */ -#endif -#endif /* not HAVE_ALLOCA_H */ -#endif /* not __GNUC__ */ +# ifdef __GNUC__ +# define alloca __builtin_alloca +# else /* not __GNUC__ */ +# if HAVE_ALLOCA_H +# include +# endif /* HAVE_ALLOCA_H */ +# endif /* not __GNUC__ */ -#endif /* not alloca */ +# endif /* not alloca */ -#define REGEX_ALLOCATE alloca +# define REGEX_ALLOCATE alloca /* Assumes a `char *destination' variable. */ -#define REGEX_REALLOCATE(source, osize, nsize) \ +# define REGEX_REALLOCATE(source, osize, nsize) \ (destination = (char *) alloca (nsize), \ - bcopy (source, destination, osize), \ - destination) + memcpy (destination, source, osize)) /* No need to do anything to free, after alloca. */ -#define REGEX_FREE(arg) ((void)0) /* Do nothing! But inhibit gcc warning. */ +# define REGEX_FREE(arg) ((void)0) /* Do nothing! But inhibit gcc warning. */ #endif /* not REGEX_MALLOC */ /* Define how to allocate the failure stack. */ -#if defined (REL_ALLOC) && defined (REGEX_MALLOC) +#if defined REL_ALLOC && defined REGEX_MALLOC -#define REGEX_ALLOCATE_STACK(size) \ +# define REGEX_ALLOCATE_STACK(size) \ r_alloc (&failure_stack_ptr, (size)) -#define REGEX_REALLOCATE_STACK(source, osize, nsize) \ +# define REGEX_REALLOCATE_STACK(source, osize, nsize) \ r_re_alloc (&failure_stack_ptr, (nsize)) -#define REGEX_FREE_STACK(ptr) \ +# define REGEX_FREE_STACK(ptr) \ r_alloc_free (&failure_stack_ptr) #else /* not using relocating allocator */ -#ifdef REGEX_MALLOC +# ifdef REGEX_MALLOC -#define REGEX_ALLOCATE_STACK malloc -#define REGEX_REALLOCATE_STACK(source, osize, nsize) realloc (source, nsize) -#define REGEX_FREE_STACK free +# define REGEX_ALLOCATE_STACK malloc +# define REGEX_REALLOCATE_STACK(source, osize, nsize) realloc (source, nsize) +# define REGEX_FREE_STACK free -#else /* not REGEX_MALLOC */ +# else /* not REGEX_MALLOC */ -#define REGEX_ALLOCATE_STACK alloca +# define REGEX_ALLOCATE_STACK alloca -#define REGEX_REALLOCATE_STACK(source, osize, nsize) \ +# define REGEX_REALLOCATE_STACK(source, osize, nsize) \ REGEX_REALLOCATE (source, osize, nsize) /* No need to explicitly free anything. */ -#define REGEX_FREE_STACK(arg) +# define REGEX_FREE_STACK(arg) -#endif /* not REGEX_MALLOC */ +# endif /* not REGEX_MALLOC */ #endif /* not using relocating allocator */ @@ -522,10 +511,10 @@ extract_number (dest, source) *dest += temp << 8; } -#ifndef EXTRACT_MACROS /* To debug the macros. */ -#undef EXTRACT_NUMBER -#define EXTRACT_NUMBER(dest, src) extract_number (&dest, src) -#endif /* not EXTRACT_MACROS */ +# ifndef EXTRACT_MACROS /* To debug the macros. */ +# undef EXTRACT_NUMBER +# define EXTRACT_NUMBER(dest, src) extract_number (&dest, src) +# endif /* not EXTRACT_MACROS */ #endif /* DEBUG */ @@ -550,11 +539,11 @@ extract_number_and_incr (destination, source) *source += 2; } -#ifndef EXTRACT_MACROS -#undef EXTRACT_NUMBER_AND_INCR -#define EXTRACT_NUMBER_AND_INCR(dest, src) \ +# ifndef EXTRACT_MACROS +# undef EXTRACT_NUMBER_AND_INCR +# define EXTRACT_NUMBER_AND_INCR(dest, src) \ extract_number_and_incr (&dest, &src) -#endif /* not EXTRACT_MACROS */ +# endif /* not EXTRACT_MACROS */ #endif /* DEBUG */ @@ -567,21 +556,21 @@ extract_number_and_incr (destination, source) #ifdef DEBUG /* We use standard I/O for debugging. */ -#include +# include /* It is useful to test things that ``must'' be true when debugging. */ -#include +# include static int debug = 0; -#define DEBUG_STATEMENT(e) e -#define DEBUG_PRINT1(x) if (debug) printf (x) -#define DEBUG_PRINT2(x1, x2) if (debug) printf (x1, x2) -#define DEBUG_PRINT3(x1, x2, x3) if (debug) printf (x1, x2, x3) -#define DEBUG_PRINT4(x1, x2, x3, x4) if (debug) printf (x1, x2, x3, x4) -#define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) \ +# define DEBUG_STATEMENT(e) e +# define DEBUG_PRINT1(x) if (debug) printf (x) +# define DEBUG_PRINT2(x1, x2) if (debug) printf (x1, x2) +# define DEBUG_PRINT3(x1, x2, x3) if (debug) printf (x1, x2, x3) +# define DEBUG_PRINT4(x1, x2, x3, x4) if (debug) printf (x1, x2, x3, x4) +# define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) \ if (debug) print_partial_compiled_pattern (s, e) -#define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) \ +# define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) \ if (debug) print_double_string (w, s1, sz1, s2, sz2) @@ -801,7 +790,7 @@ print_partial_compiled_pattern (start, end) case wordend: printf ("/wordend"); -#ifdef emacs +# ifdef emacs case before_dot: printf ("/before_dot"); break; @@ -825,7 +814,7 @@ print_partial_compiled_pattern (start, end) mcnt = *p++; printf ("/%d", mcnt); break; -#endif /* emacs */ +# endif /* emacs */ case wordchar: printf ("/wordchar"); @@ -918,16 +907,16 @@ printchar (c) #else /* not DEBUG */ -#undef assert -#define assert(e) +# undef assert +# define assert(e) -#define DEBUG_STATEMENT(e) -#define DEBUG_PRINT1(x) -#define DEBUG_PRINT2(x1, x2) -#define DEBUG_PRINT3(x1, x2, x3) -#define DEBUG_PRINT4(x1, x2, x3, x4) -#define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) -#define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) +# define DEBUG_STATEMENT(e) +# define DEBUG_PRINT1(x) +# define DEBUG_PRINT2(x1, x2) +# define DEBUG_PRINT3(x1, x2, x3) +# define DEBUG_PRINT4(x1, x2, x3, x4) +# define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) +# define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) #endif /* not DEBUG */ @@ -1013,7 +1002,7 @@ static const char *re_error_msgid[] = /* When using GNU C, we are not REALLY using the C alloca, no matter what config.h may say. So don't take precautions for it. */ #ifdef __GNUC__ -#undef C_ALLOCA +# undef C_ALLOCA #endif /* The match routines may not allocate if (1) they would do it with malloc @@ -1021,8 +1010,8 @@ static const char *re_error_msgid[] = Note that if REL_ALLOC is defined, matching would not use malloc for the failure stack, but we would still use it for the register vectors; so REL_ALLOC should not affect this. */ -#if (defined (C_ALLOCA) || defined (REGEX_MALLOC)) && defined (emacs) -#undef MATCH_MAY_ALLOCATE +#if (defined C_ALLOCA || defined REGEX_MALLOC) && defined emacs +# undef MATCH_MAY_ALLOCATE #endif @@ -1035,7 +1024,7 @@ static const char *re_error_msgid[] = when matching. If this number is exceeded, we allocate more space, so it is not a hard limit. */ #ifndef INIT_FAILURE_ALLOC -#define INIT_FAILURE_ALLOC 5 +# define INIT_FAILURE_ALLOC 5 #endif /* Roughly the maximum number of failure points on the stack. Would be @@ -1045,13 +1034,13 @@ static const char *re_error_msgid[] = #ifdef INT_IS_16BIT -#if defined (MATCH_MAY_ALLOCATE) +# if defined MATCH_MAY_ALLOCATE /* 4400 was enough to cause a crash on Alpha OSF/1, whose default stack limit is 2mb. */ long int re_max_failures = 4000; -#else +# else long int re_max_failures = 2000; -#endif +# endif union fail_stack_elt { @@ -1070,13 +1059,13 @@ typedef struct #else /* not INT_IS_16BIT */ -#if defined (MATCH_MAY_ALLOCATE) +# if defined MATCH_MAY_ALLOCATE /* 4400 was enough to cause a crash on Alpha OSF/1, whose default stack limit is 2mb. */ int re_max_failures = 20000; -#else +# else int re_max_failures = 2000; -#endif +# endif union fail_stack_elt { @@ -1104,10 +1093,10 @@ typedef struct Do `return -2' if the alloc fails. */ #ifdef MATCH_MAY_ALLOCATE -#define INIT_FAIL_STACK() \ +# define INIT_FAIL_STACK() \ do { \ fail_stack.stack = (fail_stack_elt_t *) \ - REGEX_ALLOCATE_STACK (INIT_FAILURE_ALLOC * sizeof (fail_stack_elt_t)); \ + REGEX_ALLOCATE_STACK (INIT_FAILURE_ALLOC * sizeof (fail_stack_elt_t)); \ \ if (fail_stack.stack == NULL) \ return -2; \ @@ -1116,14 +1105,14 @@ typedef struct fail_stack.avail = 0; \ } while (0) -#define RESET_FAIL_STACK() REGEX_FREE_STACK (fail_stack.stack) +# define RESET_FAIL_STACK() REGEX_FREE_STACK (fail_stack.stack) #else -#define INIT_FAIL_STACK() \ +# define INIT_FAIL_STACK() \ do { \ fail_stack.avail = 0; \ } while (0) -#define RESET_FAIL_STACK() +# define RESET_FAIL_STACK() #endif @@ -1184,11 +1173,11 @@ typedef struct /* Used to omit pushing failure point id's when we're not debugging. */ #ifdef DEBUG -#define DEBUG_PUSH PUSH_FAILURE_INT -#define DEBUG_POP(item_addr) *(item_addr) = POP_FAILURE_INT () +# define DEBUG_PUSH PUSH_FAILURE_INT +# define DEBUG_POP(item_addr) *(item_addr) = POP_FAILURE_INT () #else -#define DEBUG_PUSH(item) -#define DEBUG_POP(item_addr) +# define DEBUG_PUSH(item) +# define DEBUG_POP(item_addr) #endif @@ -1286,9 +1275,9 @@ typedef struct /* Individual items aside from the registers. */ #ifdef DEBUG -#define NUM_NONREG_ITEMS 5 /* Includes failure point id. */ +# define NUM_NONREG_ITEMS 5 /* Includes failure point id. */ #else -#define NUM_NONREG_ITEMS 4 +# define NUM_NONREG_ITEMS 4 #endif /* We push at most this many items on the stack. */ @@ -1479,7 +1468,7 @@ static reg_errcode_t compile_range _RE_ARGS ((const char **p_ptr, string passed to us by the user to an unsigned char that we can use as an array index (in, e.g., `translate'). */ #ifndef PATFETCH -#define PATFETCH(c) \ +# define PATFETCH(c) \ do {if (p == pend) return REG_EEND; \ c = (unsigned char) *p++; \ if (translate) c = (unsigned char) translate[c]; \ @@ -1502,7 +1491,7 @@ static reg_errcode_t compile_range _RE_ARGS ((const char **p_ptr, `char *', to avoid warnings when a string constant is passed. But when we use a character as a subscript we must make it unsigned. */ #ifndef TRANSLATE -#define TRANSLATE(d) \ +# define TRANSLATE(d) \ (translate ? (char) translate[(unsigned char) (d)] : (d)) #endif @@ -1570,15 +1559,15 @@ static reg_errcode_t compile_range _RE_ARGS ((const char **p_ptr, MSC and drop MAX_BUF_SIZE a bit. Otherwise you may end up reallocating to 0 bytes. Such thing is not going to work too well. You have been warned!! */ -#if defined(_MSC_VER) && !defined(WIN32) +#if defined _MSC_VER && !defined WIN32 /* Microsoft C 16-bit versions limit malloc to approx 65512 bytes. The REALLOC define eliminates a flurry of conversion warnings, but is not required. */ -#define MAX_BUF_SIZE 65500L -#define REALLOC(p,s) realloc ((p), (size_t) (s)) +# define MAX_BUF_SIZE 65500L +# define REALLOC(p,s) realloc ((p), (size_t) (s)) #else -#define MAX_BUF_SIZE (1L << 16) -#define REALLOC(p,s) realloc ((p), (s)) +# define MAX_BUF_SIZE (1L << 16) +# define REALLOC(p,s) realloc ((p), (s)) #endif /* Extend the buffer by twice its current size via realloc and @@ -1865,7 +1854,7 @@ regex_compile (pattern, size, syntax, bufp) /* Always count groups, whether or not bufp->no_sub is set. */ bufp->re_nsub = 0; -#if !defined (emacs) && !defined (SYNTAX_TABLE) +#if !defined emacs && !defined SYNTAX_TABLE /* Initialize the syntax table. */ init_syntax_once (); #endif @@ -2842,7 +2831,7 @@ regex_compile (pattern, size, syntax, bufp) { fail_stack.size = (2 * re_max_failures * MAX_FAILURE_ITEMS); -#ifdef emacs +# ifdef emacs if (! fail_stack.stack) fail_stack.stack = (fail_stack_elt_t *) xmalloc (fail_stack.size @@ -2852,7 +2841,7 @@ regex_compile (pattern, size, syntax, bufp) = (fail_stack_elt_t *) xrealloc (fail_stack.stack, (fail_stack.size * sizeof (fail_stack_elt_t))); -#else /* not emacs */ +# else /* not emacs */ if (! fail_stack.stack) fail_stack.stack = (fail_stack_elt_t *) malloc (fail_stack.size @@ -2862,7 +2851,7 @@ regex_compile (pattern, size, syntax, bufp) = (fail_stack_elt_t *) realloc (fail_stack.stack, (fail_stack.size * sizeof (fail_stack_elt_t))); -#endif /* not emacs */ +# endif /* not emacs */ } regex_grow_registers (num_regs); @@ -3543,9 +3532,9 @@ re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop) val = re_match_2_internal (bufp, string1, size1, string2, size2, startpos, regs, stop); #ifndef REGEX_MALLOC -#ifdef C_ALLOCA +# ifdef C_ALLOCA alloca (0); -#endif +# endif #endif if (val >= 0) @@ -3622,8 +3611,8 @@ re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop) /* Free everything we malloc. */ #ifdef MATCH_MAY_ALLOCATE -#define FREE_VAR(var) if (var) REGEX_FREE (var); var = NULL -#define FREE_VARIABLES() \ +# define FREE_VAR(var) if (var) REGEX_FREE (var); var = NULL +# define FREE_VARIABLES() \ do { \ REGEX_FREE_STACK (fail_stack.stack); \ FREE_VAR (regstart); \ @@ -3637,7 +3626,7 @@ re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop) FREE_VAR (reg_info_dummy); \ } while (0) #else -#define FREE_VARIABLES() ((void)0) /* Do nothing! But inhibit gcc warning. */ +# define FREE_VARIABLES() ((void)0) /* Do nothing! But inhibit gcc warning. */ #endif /* not MATCH_MAY_ALLOCATE */ /* These values must meet several constraints. They must not be valid @@ -3664,11 +3653,11 @@ re_match (bufp, string, size, pos, regs) { int result = re_match_2_internal (bufp, NULL, 0, string, size, pos, regs, size); -#ifndef REGEX_MALLOC -#ifdef C_ALLOCA +# ifndef REGEX_MALLOC +# ifdef C_ALLOCA alloca (0); -#endif -#endif +# endif +# endif return result; } #endif /* not emacs */ @@ -3710,9 +3699,9 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) int result = re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop); #ifndef REGEX_MALLOC -#ifdef C_ALLOCA +# ifdef C_ALLOCA alloca (0); -#endif +# endif #endif return result; } @@ -4460,7 +4449,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) past them. */ if (translate ? bcmp_translate (d, d2, mcnt, translate) - : bcmp (d, d2, mcnt)) + : memcmp (d, d2, mcnt)) goto fail; d += mcnt, d2 += mcnt; @@ -5413,7 +5402,7 @@ re_compile_pattern (pattern, length, bufp) /* Entry points compatible with 4.2 BSD regex library. We don't define them unless specifically requested. */ -#if defined (_REGEX_RE_COMP) || defined (_LIBC) +#if defined _REGEX_RE_COMP || defined _LIBC /* BSD has one and only one pattern buffer. */ static struct re_pattern_buffer re_comp_buf; @@ -5687,11 +5676,15 @@ regerror (errcode, preg, errbuf, errbuf_size) { if (msg_size > errbuf_size) { - strncpy (errbuf, msg, errbuf_size - 1); +#if defined HAVE_MEMPCPY || defined _LIBC + *((char *) __mempcpy (errbuf, msg, errbuf_size - 1)) = '\0'; +#else + memcpy (errbuf, msg, errbuf_size - 1); errbuf[errbuf_size - 1] = 0; +#endif } else - strcpy (errbuf, msg); + memcpy (errbuf, msg, msg_size); } return msg_size; diff --git a/posix/unistd.h b/posix/unistd.h index 04fb89b..f14e02d 100644 --- a/posix/unistd.h +++ b/posix/unistd.h @@ -124,6 +124,17 @@ __BEGIN_DECLS _XOPEN_SHM Shared memory interface according to XPG4.2. + _XBS5_ILP32_OFF32 Implementation provides environment with 32-bit + int, long, pointer, and off_t types. + _XBS5_ILP32_OFFBIG Implementation provides environment with 32-bit + int, long, and pointer and off_t with at least + 64 bits. + _XBS5_LP64_OFF64 Implementation provides environment with 32-bit + int, and 64-bit long, pointer, and off_t types. + _XBS5_LPBIG_OFFBIG Implementation provides environment with at + least 32 bits int and long, pointer, and off_t + with at least 64 bits. + If any of these symbols is defined as -1, the corresponding option is not true for any file. If any is defined as other than -1, the corresponding option is true for all files. If a symbol is not defined at all, the value diff --git a/posix/wordexp.c b/posix/wordexp.c index 54a550b..42b22ec 100644 --- a/posix/wordexp.c +++ b/posix/wordexp.c @@ -38,6 +38,8 @@ #include #include +#include + /* Undefine the following line for the production version. */ /* #define NDEBUG 1 */ #include @@ -112,9 +114,8 @@ w_addstr (char *buffer, size_t *actlen, size_t *maxlen, const char *str) if (buffer != NULL) { - memcpy (&buffer[*actlen], str, len); + *((char *) __mempcpy (&buffer[*actlen], str, len)) = '\0'; *actlen += len; - buffer[*actlen] = '\0'; } return buffer; @@ -156,7 +157,7 @@ parse_backslash (char **word, size_t *word_length, size_t *max_length, return WRDE_SYNTAX; case '\n': - (*offset)++; + ++(*offset); break; default: @@ -164,7 +165,7 @@ parse_backslash (char **word, size_t *word_length, size_t *max_length, if (*word == NULL) return WRDE_NOSPACE; - (*offset)++; + ++(*offset); break; } @@ -363,12 +364,13 @@ parse_glob (char **word, size_t *word_length, size_t *max_length, if (ifs && !*ifs) { /* No field splitting allowed */ - *word_length = strlen (globbuf.gl_pathv[0]); - *word = realloc (*word, 1 + *word_length); + size_t length = strlen (globbuf.gl_pathv[0]); + *word = realloc (*word, length + 1); if (*word == NULL) goto no_space; - strcpy (*word, globbuf.gl_pathv[0]); + memcpy (*word, globbuf.gl_pathv[0], length + 1); + *word_length = length; for (match = 1; match < globbuf.gl_pathc && *word != NULL; ++match) { @@ -389,11 +391,10 @@ parse_glob (char **word, size_t *word_length, size_t *max_length, *word = NULL; *word_length = 0; - matching_word = malloc (1 + strlen (globbuf.gl_pathv[0])); + matching_word = __strdup (globbuf.gl_pathv[0]); if (matching_word == NULL) goto no_space; - strcpy (matching_word, globbuf.gl_pathv[0]); if (w_addword (pwordexp, matching_word) == WRDE_NOSPACE) goto no_space; @@ -624,7 +625,7 @@ parse_arith (char **word, size_t *word_length, size_t *max_length, case ')': if (--paren_depth == 0) { - char *result; + char result[21]; /* 21 = ceil(log10(2^64)) + 1 */ int numresult = 0; if (bracket || words[1 + *offset] != ')') @@ -637,9 +638,9 @@ parse_arith (char **word, size_t *word_length, size_t *max_length, eval_expr (expr, &numresult) != 0) return WRDE_SYNTAX; - result = __alloca (100); - __snprintf (result, 100, "%d", numresult); - *word = w_addstr (*word, word_length, max_length, result); + result[20] = '\0'; + *word = w_addstr (*word, word_length, max_length, + _itoa_word (numresult, &result[20], 10, 0)); free (expr); return *word ? 0 : WRDE_NOSPACE; } @@ -652,16 +653,16 @@ parse_arith (char **word, size_t *word_length, size_t *max_length, case ']': if (bracket && paren_depth == 1) { - char *result; + char result[21]; /* 21 = ceil(log10(2^64)) + 1 */ int numresult = 0; /* Go - evaluate. */ if (*expr && eval_expr (expr, &numresult) != 0) return WRDE_SYNTAX; - result = __alloca (100); - __snprintf (result, 100, "%d", numresult); - *word = w_addstr (*word, word_length, max_length, result); + result[20] = '\0'; + *word = w_addstr (*word, word_length, max_length, + _itoa_word (numresult, &result[20], 10, 0)); free (expr); return *word ? 0 : WRDE_NOSPACE; } @@ -727,6 +728,8 @@ exec_comm (char *comm, char **word, size_t *word_length, size_t *max_length, if (pid == 0) { /* Child */ + const char *args[4] = { _PATH_BSHELL, "-c", comm, NULL }; + /* Redirect input and output */ dup2 (fildes[1], 1); @@ -734,10 +737,10 @@ exec_comm (char *comm, char **word, size_t *word_length, size_t *max_length, if ((flags & WRDE_SHOWERR) == 0) close (2); - execl (_PATH_BSHELL, _PATH_BSHELL, "-c", comm, NULL); + __execve (_PATH_BSHELL, (char *const *) args, __environ); - /* Bad. What now? */ - exit (1); + /* Bad. What now? */ + abort (); } /* Parent */ @@ -752,7 +755,7 @@ exec_comm (char *comm, char **word, size_t *word_length, size_t *max_length, { if ((buflen = read (fildes[0], buffer, bufsize)) < 1) { - if (waitpid (pid, NULL, WNOHANG) == 0) + if (__waitpid (pid, NULL, WNOHANG) == 0) continue; if ((buflen = read (fildes[0], buffer, bufsize)) < 1) break; @@ -780,7 +783,7 @@ exec_comm (char *comm, char **word, size_t *word_length, size_t *max_length, { if ((buflen = read (fildes[0], buffer, bufsize)) < 1) { - if (waitpid (pid, NULL, WNOHANG) == 0) + if (__waitpid (pid, NULL, WNOHANG) == 0) continue; if ((read (fildes[0], buffer, bufsize)) < 1) break; @@ -856,7 +859,7 @@ parse_comm (char **word, size_t *word_length, size_t *max_length, break; case '(': - paren_depth++; + ++paren_depth; default: comm = w_addchar (comm, &comm_length, &comm_maxlen, words[*offset]); if (comm == NULL) diff --git a/resolv/inet_pton.c b/resolv/inet_pton.c index 0c8f79f..7f8370d 100644 --- a/resolv/inet_pton.c +++ b/resolv/inet_pton.c @@ -26,7 +26,7 @@ static char rcsid[] = "$Id$"; #include #include #include -#include "../conf/portability.h" +#include /* * WARNING: Don't even consider trying to compile this on a system where diff --git a/shadow/sgetspent_r.c b/shadow/sgetspent_r.c index 8aa5a9b..01f0115 100644 --- a/shadow/sgetspent_r.c +++ b/shadow/sgetspent_r.c @@ -32,7 +32,7 @@ struct spent_data {}; #define FALSE(arg) 0 -#include "../nss/nss_files/files-parse.c" +#include LINE_PARSER (, STRING_FIELD (result->sp_namp, ISCOLON, 0); diff --git a/stdio-common/vfprintf.c b/stdio-common/vfprintf.c index ef9e62f..d97476b 100644 --- a/stdio-common/vfprintf.c +++ b/stdio-common/vfprintf.c @@ -1499,8 +1499,7 @@ group_number (CHAR_T *w, CHAR_T *rear_ptr, const CHAR_T *grouping, /* Copy existing string so that nothing gets overwritten. */ src = (char *) alloca (rear_ptr - w); - memcpy (src, w + 1, rear_ptr - w); - s = &src[rear_ptr - w - 1]; + s = (char *) __mempcpy (src, w + 1, rear_ptr - w) - 1; w = rear_ptr; /* Process all characters in the string. */ diff --git a/stdlib/canonicalize.c b/stdlib/canonicalize.c index ea7883d..3617226 100644 --- a/stdlib/canonicalize.c +++ b/stdlib/canonicalize.c @@ -45,6 +45,22 @@ canonicalize (const char *name, char *resolved) long int path_max; int num_links = 0; + if (name == NULL || resolved == NULL) + { + /* As per Single Unix Specification V2 we must return an error if + either parameter is a null pointer. */ + __set_errno (EINVAL); + return NULL; + } + + if (name[0] == '\0') + { + /* As per Single Unix Specification V2 we must return an error if + the name argument points to an empty string. */ + __set_errno (ENOENT); + return NULL; + } + #ifdef PATH_MAX path_max = PATH_MAX; #else @@ -73,21 +89,23 @@ canonicalize (const char *name, char *resolved) struct stat st; int n; - /* skip sequence of multiple path-separators: */ + /* Skip sequence of multiple path-separators. */ while (*start == '/') ++start; - /* find end of path component: */ + /* Find end of path component. */ for (end = start; *end && *end != '/'; ++end); if (end - start == 0) break; else if (strncmp (start, ".", end - start) == 0) /* nothing */; - else if (strncmp (start, "..", end - start) == 0) { - /* back up to previous component, ignore if at root already: */ - if (dest > rpath + 1) - while ((--dest)[-1] != '/'); - } else + else if (strncmp (start, "..", end - start) == 0) + { + /* Back up to previous component, ignore if at root already. */ + if (dest > rpath + 1) + while ((--dest)[-1] != '/'); + } + else { size_t new_size; @@ -112,8 +130,7 @@ canonicalize (const char *name, char *resolved) return NULL; } - memcpy (dest, start, end - start); - dest += end - start; + dest = __mempcpy (dest, start, end - start); *dest = '\0'; if (__lstat (rpath, &st) < 0) @@ -146,8 +163,8 @@ canonicalize (const char *name, char *resolved) } /* Careful here, end may be a pointer into extra_buf... */ - memcpy (&buf[n], end, len + 1); - strcpy (extra_buf, buf); + memmove (&extra_buf[n], end, len + 1); + memcpy (extra_buf, buf, n); name = end = extra_buf; if (buf[0] == '/') diff --git a/stdlib/msort.c b/stdlib/msort.c index 4cd3e3f..1c36a4c 100644 --- a/stdlib/msort.c +++ b/stdlib/msort.c @@ -71,17 +71,16 @@ msort_with_tmp (b, n, s, cmp, t) { if ((*cmp) (b1, b2) <= 0) { - memcpy (tmp, b1, s); + tmp = (char *) __mempcpy (tmp, b1, s); b1 += s; --n1; } else { - memcpy (tmp, b2, s); + tmp = (char *) __mempcpy (tmp, b2, s); b2 += s; --n2; } - tmp += s; } if (n1 > 0) memcpy (tmp, b1, n1 * s); diff --git a/stdlib/test-canon.c b/stdlib/test-canon.c index ffd6fa9..c239d50 100644 --- a/stdlib/test-canon.c +++ b/stdlib/test-canon.c @@ -117,6 +117,30 @@ main (int argc, char ** argv) getcwd (cwd, sizeof(buf)); cwd_len = strlen (cwd); + errno = 0; + if (realpath (NULL, buf) != NULL || errno != EINVAL) + { + printf ("%s: expected return value NULL and errno set to EINVAL" + " for realpath(NULL,...)\n", argv[0]); + ++errors; + } + + errno = 0; + if (realpath ("/", NULL) != NULL || errno != EINVAL) + { + printf ("%s: expected return value NULL and errno set to EINVAL" + " for realpath(...,NULL)\n", argv[0]); + ++errors; + } + + errno = 0; + if (realpath ("", buf) != NULL || errno != ENOENT) + { + printf ("%s: expected return value NULL and set errno to ENOENT", + " for realpath(\"\",...)\n", argv[0]); + ++errors; + } + for (i = 0; i < (int) (sizeof (symlinks) / sizeof (symlinks[0])); ++i) symlink (symlinks[i].value, symlinks[i].name); diff --git a/string/argz-replace.c b/string/argz-replace.c index 4d658f4..4540cba 100644 --- a/string/argz-replace.c +++ b/string/argz-replace.c @@ -18,6 +18,7 @@ Boston, MA 02111-1307, USA. */ #include +#include #include /* Append BUF, of length BUF_LEN to *TO, of length *TO_LEN, reallocating and @@ -31,8 +32,7 @@ str_append (char **to, size_t *to_len, const char *buf, const size_t buf_len) if (new_to) { - memcpy (new_to + *to_len, buf, buf_len); - new_to[new_len] = '\0'; + *((char *) __mempcpy (new_to + *to_len, buf, buf_len)) = '\0'; *to = new_to; *to_len = new_len; } diff --git a/sunrpc/svcauth_des.c b/sunrpc/svcauth_des.c index c2dde69..7160726 100644 --- a/sunrpc/svcauth_des.c +++ b/sunrpc/svcauth_des.c @@ -328,17 +328,19 @@ _svcauth_des (register struct svc_req *rqst, register struct rpc_msg *msg) cache_ref (sid); if (cred->adc_namekind == ADN_FULLNAME) { + size_t full_len; + cred->adc_fullname.window = window; cred->adc_nickname = (u_long) sid; /* save nickname */ if (entry->rname != NULL) { mem_free (entry->rname, strlen (entry->rname) + 1); } - entry->rname = mem_alloc ((u_int) strlen (cred->adc_fullname.name) - + 1); + full_len = strlen (cred->adc_fullname.name) + 1; + entry->rname = mem_alloc ((u_int) full_len); if (entry->rname != NULL) { - strcpy (entry->rname, cred->adc_fullname.name); + memcpy (entry->rname, cred->adc_fullname.name, full_len); } else { diff --git a/sysdeps/generic/bits/confname.h b/sysdeps/generic/bits/confname.h index 6926cad..40228e1 100644 --- a/sysdeps/generic/bits/confname.h +++ b/sysdeps/generic/bits/confname.h @@ -316,8 +316,9 @@ enum #define _SC_NL_TEXTMAX _SC_NL_TEXTMAX }; -#if (defined __USE_POSIX2 || defined __USE_FILE_OFFSET64 \ - || defined __USE_LARGEFILE64 || defined __USE_LARGEFILE) +#if (defined __USE_POSIX2 || defined __USE_UNIX98 \ + || defined __USE_FILE_OFFSET64 || defined __USE_LARGEFILE64 \ + || defined __USE_LARGEFILE) /* Values for the NAME argument to `confstr'. */ enum { @@ -340,8 +341,43 @@ enum # define _CS_LFS64_LDFLAGS _CS_LFS64_LDFLAGS _CS_LFS64_LIBS, # define _CS_LFS64_LIBS _CS_LFS64_LIBS - _CS_LFS64_LINTFLAGS + _CS_LFS64_LINTFLAGS, # define _CS_LFS64_LINTFLAGS _CS_LFS64_LINTFLAGS #endif + +#ifdef __USE_UNIX98 + _CS_XBS5_ILP32_OFF32_CFLAGS = 1100, +# define _CS_XBS5_ILP32_OFF32_CFLAGS _CS_XBS5_ILP32_OFF32_CFLAGS + _CS_XBS5_ILP32_OFF32_LDFLAGS, +# define _CS_XBS5_ILP32_OFF32_LDFLAGS _CS_XBS5_ILP32_OFF32_LDFLAGS + _CS_XBS5_ILP32_OFF32_LIBS, +# define _CS_XBS5_ILP32_OFF32_LIBS _CS_XBS5_ILP32_OFF32_LIBS + _CS_XBS5_ILP32_OFF32_LINTFLAGS, +# define _CS_XBS5_ILP32_OFF32_LINTFLAGS _CS_XBS5_ILP32_OFF32_LINTFLAGS + _CS_XBS5_ILP32_OFFBIG_CFLAGS, +# define _CS_XBS5_ILP32_OFFBIG_CFLAGS _CS_XBS5_ILP32_OFFBIG_CFLAGS + _CS_XBS5_ILP32_OFFBIG_LDFLAGS, +# define _CS_XBS5_ILP32_OFFBIG_LDFLAGS _CS_XBS5_ILP32_OFFBIG_LDFLAGS + _CS_XBS5_ILP32_OFFBIG_LIBS, +# define _CS_XBS5_ILP32_OFFBIG_LIBS _CS_XBS5_ILP32_OFFBIG_LIBS + _CS_XBS5_ILP32_OFFBIG_LINTFLAGS, +# define _CS_XBS5_ILP32_OFFBIG_LINTFLAGS _CS_XBS5_ILP32_OFFBIG_LINTFLAGS + _CS_XBS5_LP64_OFF64_CFLAGS, +# define _CS_XBS5_LP64_OFF64_CFLAGS _CS_XBS5_LP64_OFF64_CFLAGS + _CS_XBS5_LP64_OFF64_LDFLAGS, +# define _CS_XBS5_LP64_OFF64_LDFLAGS _CS_XBS5_LP64_OFF64_LDFLAGS + _CS_XBS5_LP64_OFF64_LIBS, +# define _CS_XBS5_LP64_OFF64_LIBS _CS_XBS5_LP64_OFF64_LIBS + _CS_XBS5_LP64_OFF64_LINTFLAGS, +# define _CS_XBS5_LP64_OFF64_LINTFLAGS _CS_XBS5_LP64_OFF64_LINTFLAGS + _CS_XBS5_LPBIG_OFFBIG_CFLAGS, +# define _CS_XBS5_LPBIG_OFFBIG_CFLAGS _CS_XBS5_LPBIG_OFFBIG_CFLAGS + _CS_XBS5_LPBIG_OFFBIG_LDFLAGS, +# define _CS_XBS5_LPBIG_OFFBIG_LDFLAGS _CS_XBS5_LPBIG_OFFBIG_LDFLAGS + _CS_XBS5_LPBIG_OFFBIG_LIBS, +# define _CS_XBS5_LPBIG_OFFBIG_LIBS _CS_XBS5_LPBIG_OFFBIG_LIBS + _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS, +# define _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS +#endif }; #endif diff --git a/sysdeps/generic/putenv.c b/sysdeps/generic/putenv.c index e5031c4..296f2847 100644 --- a/sysdeps/generic/putenv.c +++ b/sysdeps/generic/putenv.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1994, 1995, 1996 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1994, 1995, 1996, 1997 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -55,11 +55,15 @@ putenv (string) { const char *const name_end = strchr (string, '='); - if (name_end) + if (name_end != NULL) { char *name = alloca (name_end - string + 1); +#ifdef _LIBC + *((char *) __mempcpy (name, string, name_end - string)) = '\0'; +#else memcpy (name, string, name_end - string); name[name_end - string] = '\0'; +#endif return setenv (name, name_end + 1, 1); } diff --git a/sysdeps/generic/setenv.c b/sysdeps/generic/setenv.c index e740fa9..f58c65b 100644 --- a/sysdeps/generic/setenv.c +++ b/sysdeps/generic/setenv.c @@ -91,6 +91,8 @@ setenv (name, value, replace) if (__environ == NULL || *ep == NULL) { char **new_environ; + char *tmp; + if (__environ == last_environ && __environ != NULL) /* We allocated this space; we can extend it. */ new_environ = (char **) realloc (last_environ, @@ -117,9 +119,15 @@ setenv (name, value, replace) memcpy ((char *) new_environ, (char *) __environ, size * sizeof (char *)); +#ifdef _LIBC + tmp = __mempcpy (new_environ[size], name, namelen); + *tmp++ = '='; + __mempcpy (tmp, value, vallen); +#else memcpy (new_environ[size], name, namelen); new_environ[size][namelen] = '='; memcpy (&new_environ[size][namelen + 1], value, vallen); +#endif new_environ[size + 1] = NULL; @@ -138,8 +146,12 @@ setenv (name, value, replace) return -1; } *ep = new; +#ifdef _LIBC + *((char *) __mempcpy (*ep, name, namelen)) = '='; +#else memcpy (*ep, name, namelen); (*ep)[namelen] = '='; +#endif } memcpy (&(*ep)[namelen + 1], value, vallen); } diff --git a/sysdeps/posix/getcwd.c b/sysdeps/posix/getcwd.c index 865bd3f..01f86ef 100644 --- a/sysdeps/posix/getcwd.c +++ b/sysdeps/posix/getcwd.c @@ -26,12 +26,12 @@ */ /* AIX requires this to be the first thing in the file. */ -#if defined (_AIX) && !defined (__GNUC__) +#if defined _AIX && !defined __GNUC__ #pragma alloca #endif #ifdef HAVE_CONFIG_H -#include "config.h" +# include "config.h" #endif #include @@ -39,92 +39,91 @@ #include #ifdef STDC_HEADERS -#include +# include #endif -#if !defined(__GNU_LIBRARY__) && !defined(STDC_HEADERS) +#if !defined __GNU_LIBRARY__ && !defined STDC_HEADERS extern int errno; #endif #ifndef __set_errno -#define __set_errno(val) errno = (val) +# define __set_errno(val) errno = (val) #endif #ifndef NULL -#define NULL 0 +# define NULL 0 #endif -#if defined (USGr3) && !defined (DIRENT) -#define DIRENT +#if defined USGr3 && !defined DIRENT +# define DIRENT #endif /* USGr3 */ -#if defined (Xenix) && !defined (SYSNDIR) -#define SYSNDIR +#if defined Xenix && !defined SYSNDIR +# define SYSNDIR #endif /* Xenix */ -#if defined (POSIX) || defined (DIRENT) || defined (__GNU_LIBRARY__) -#include -#ifndef __GNU_LIBRARY__ -#define D_NAMLEN(d) strlen((d)->d_name) -#else -#define HAVE_D_NAMLEN -#define D_NAMLEN(d) ((d)->d_namlen) -#endif +#if defined POSIX || defined DIRENT || defined __GNU_LIBRARY__ +# include +# ifndef __GNU_LIBRARY__ +# define D_NAMLEN(d) strlen((d)->d_name) +# else +# define HAVE_D_NAMLEN +# define D_NAMLEN(d) ((d)->d_namlen) +# endif #else /* not POSIX or DIRENT */ -#define dirent direct -#define D_NAMLEN(d) ((d)->d_namlen) -#define HAVE_D_NAMLEN -#if defined (USG) && !defined (sgi) -#if defined (SYSNDIR) -#include -#else /* Not SYSNDIR */ -#include "ndir.h" -#endif /* SYSNDIR */ -#else /* not USG */ -#include -#endif /* USG */ +# define dirent direct +# define D_NAMLEN(d) ((d)->d_namlen) +# define HAVE_D_NAMLEN +# if defined USG && !defined sgi +# if defined SYSNDIR +# include +# else /* Not SYSNDIR */ +# include "ndir.h" +# endif /* SYSNDIR */ +# else /* not USG */ +# include +# endif /* USG */ #endif /* POSIX or DIRENT or __GNU_LIBRARY__ */ -#if defined (HAVE_UNISTD_H) || defined (__GNU_LIBRARY__) -#include +#if defined HAVE_UNISTD_H || defined __GNU_LIBRARY__ +# include #endif -#if (defined (STDC_HEADERS) || defined (__GNU_LIBRARY__) \ - || defined (POSIX)) -#include -#include -#define ANSI_STRING +#if defined STDC_HEADERS || defined __GNU_LIBRARY__ || defined POSIX +# include +# include +# define ANSI_STRING #else /* No standard headers. */ -#ifdef USG +# ifdef USG -#include -#ifdef NEED_MEMORY_H -#include -#endif -#define ANSI_STRING +# include +# ifdef NEED_MEMORY_H +# include +# endif +# define ANSI_STRING -#else /* Not USG. */ +# else /* Not USG. */ -#ifdef NeXT +# ifdef NeXT -#include +# include -#else /* Not NeXT. */ +# else /* Not NeXT. */ -#include +# include -#ifndef bcmp +# ifndef bcmp extern int bcmp (); -#endif -#ifndef bzero +# endif +# ifndef bzero extern void bzero (); -#endif -#ifndef bcopy +# endif +# ifndef bcopy extern void bcopy (); -#endif +# endif -#endif /* NeXT. */ +# endif /* NeXT. */ -#endif /* USG. */ +# endif /* USG. */ extern char *malloc (), *realloc (); extern void free (); @@ -132,59 +131,58 @@ extern void free (); #endif /* Standard headers. */ #ifndef ANSI_STRING -#define memcpy(d, s, n) bcopy((s), (d), (n)) -#define memmove memcpy +# define memcpy(d, s, n) bcopy((s), (d), (n)) +# define memmove memcpy #endif /* Not ANSI_STRING. */ -#if !defined(__alloca) && !defined(__GNU_LIBRARY__) +#if !defined __alloca && !defined __GNU_LIBRARY__ -#ifdef __GNUC__ -#undef alloca -#define alloca(n) __builtin_alloca (n) -#else /* Not GCC. */ -#if defined (sparc) || defined (HAVE_ALLOCA_H) -#include -#else /* Not sparc or HAVE_ALLOCA_H. */ -#ifndef _AIX +# ifdef __GNUC__ +# undef alloca +# define alloca(n) __builtin_alloca (n) +# else /* Not GCC. */ +# if defined sparc || defined HAVE_ALLOCA_H +# include +# else /* Not sparc or HAVE_ALLOCA_H. */ +# ifndef _AIX extern char *alloca (); -#endif /* Not _AIX. */ -#endif /* sparc or HAVE_ALLOCA_H. */ -#endif /* GCC. */ +# endif /* Not _AIX. */ +# endif /* sparc or HAVE_ALLOCA_H. */ +# endif /* GCC. */ -#define __alloca alloca +# define __alloca alloca #endif -#if (defined (HAVE_LIMITS_H) || defined (STDC_HEADERS) || \ - defined (__GNU_LIBRARY__)) -#include +#if defined HAVE_LIMITS_H || defined STDC_HEADERS || defined __GNU_LIBRARY__ +# include #else -#include +# include #endif #ifndef PATH_MAX -#ifdef MAXPATHLEN -#define PATH_MAX MAXPATHLEN -#else -#define PATH_MAX 1024 -#endif +# ifdef MAXPATHLEN +# define PATH_MAX MAXPATHLEN +# else +# define PATH_MAX 1024 +# endif #endif -#if !defined (STDC_HEADERS) && !defined (__GNU_LIBRARY__) -#undef size_t -#define size_t unsigned int +#if !defined STDC_HEADERS && !defined __GNU_LIBRARY__ +# undef size_t +# define size_t unsigned int #endif -#if !__STDC__ && !defined (const) -#define const +#if !__STDC__ && !defined const +# define const #endif #ifndef __GNU_LIBRARY__ -#define __lstat stat +# define __lstat stat #endif #ifndef _LIBC -#define __getcwd getcwd +# define __getcwd getcwd #endif /* Get the pathname of the current working directory, and put it in SIZE @@ -264,18 +262,28 @@ __getcwd (buf, size) new = malloc (dotsize * 2 + 1); if (new == NULL) return NULL; +#ifdef HAVE_MEMPCPY + dotp = mempcpy (new, dots, dotsize); +#else memcpy (new, dots, dotsize); + dotp = &new[dotsize]; +#endif } else { new = realloc ((__ptr_t) dotlist, dotsize * 2 + 1); if (new == NULL) goto lose; + dotp = &new[dotsize]; } - memcpy (&new[dotsize], new, dotsize); - dotp = &new[dotsize]; +#ifdef HAVE_MEMPCPY + *((char *) mempcpy (dotp, new, dotsize)) = '\0'; + dotsize *= 2; +#else + memcpy (dotp, new, dotsize); dotsize *= 2; new[dotsize] = '\0'; +#endif dotlist = new; } @@ -301,9 +309,15 @@ __getcwd (buf, size) if (mount_point || (ino_t) d->d_ino == thisino) { char name[dotlist + dotsize - dotp + 1 + _D_ALLOC_NAMLEN (d)]; +#ifdef HAVE_MEMPCPY + char *tmp = mempcpy (name, dotp, dotlist + dotsize - dotp); + *tmp++ = '/'; + strcpy (tmp, d->d_name); +#else memcpy (name, dotp, dotlist + dotsize - dotp); name[dotlist + dotsize - dotp] = '/'; strcpy (&name[dotlist + dotsize - dotp + 1], d->d_name); +#endif if (__lstat (name, &st) < 0) { int save = errno; diff --git a/sysdeps/posix/ttyname.c b/sysdeps/posix/ttyname.c index ce384eb..a4e4f30 100644 --- a/sysdeps/posix/ttyname.c +++ b/sysdeps/posix/ttyname.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992, 1993, 1996 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1993, 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 @@ -71,10 +71,9 @@ ttyname (fd) (void) closedir (dirstream); return NULL; } - (void) memcpy (name, dev, sizeof (dev) - 1); - name[sizeof (dev) - 1] = '/'; + *((char *) __mempcpy (name, dev, sizeof (dev) - 1)) = '/'; } - (void) memcpy (&name[sizeof (dev)], d->d_name, dlen); + (void) __mempcpy (&name[sizeof (dev)], d->d_name, dlen); if (stat (name, &st) == 0 && st.st_dev == mydev) { (void) closedir (dirstream); diff --git a/sysdeps/posix/writev.c b/sysdeps/posix/writev.c index f6f685c..ae38fef 100644 --- a/sysdeps/posix/writev.c +++ b/sysdeps/posix/writev.c @@ -53,11 +53,10 @@ __writev (fd, vector, count) #define min(a, b) ((a) > (b) ? (b) : (a)) size_t copy = min (vector[i].iov_len, to_copy); - (void) memcpy ((void *) bp, (void *) vector[i].iov_base, copy); + bp = __mempcpy ((void *) bp, (void *) vector[i].iov_base, copy); - bp += copy; to_copy -= copy; - if (bytes == 0) + if (to_copy == 0) break; } diff --git a/sysdeps/unix/readdir_r.c b/sysdeps/unix/readdir_r.c index a4462f7..6d70233 100644 --- a/sysdeps/unix/readdir_r.c +++ b/sysdeps/unix/readdir_r.c @@ -96,10 +96,7 @@ __readdir_r (DIR *dirp, struct dirent *entry, struct dirent **result) } while (dp->d_ino == 0); if (dp != NULL) - { - memcpy (entry, dp, reclen); - *result = entry; - } + *result = memcpy (entry, dp, reclen); __libc_lock_unlock (dirp->lock); diff --git a/sysdeps/unix/sysv/linux/gethostname.c b/sysdeps/unix/sysv/linux/gethostname.c index 5df8096..0e3ca57 100644 --- a/sysdeps/unix/sysv/linux/gethostname.c +++ b/sysdeps/unix/sysv/linux/gethostname.c @@ -30,6 +30,7 @@ __gethostname (name, len) size_t len; { struct utsname buf; + size_t node_len; if (name == NULL) { @@ -40,13 +41,14 @@ __gethostname (name, len) if (uname (&buf)) return -1; - if (strlen (buf.nodename) + 1 > len) + node_len = strlen (buf.nodename) + 1; + if (node_len > len) { __set_errno (EINVAL); return -1; } - strcpy (name, buf.nodename); + memcpy (name, buf.nodename, node_len); return 0; } diff --git a/time/strftime.c b/time/strftime.c index fdf0500..8d94dcd 100644 --- a/time/strftime.c +++ b/time/strftime.c @@ -89,6 +89,14 @@ extern char *tzname[]; # endif #endif +#ifdef _LIBC +# define MEMPCPY(d, s, n) __mempcpy (d, s, n) +#else +# ifndef HAVE_MEMPCPY +# define MEMPCPY(d, s, n) ((void *) ((char *) memcpy (d, s, n) + (n))) +# endif +#endif + #ifndef __P # if defined (__GNUC__) || (defined (__STDC__) && __STDC__) # define __P(args) args @@ -194,8 +202,7 @@ static const char zeroes[16] = /* "0000000000000000" */ do \ { \ int _this = _len > 16 ? 16 : _len; \ - memcpy ((P), spaces, _this); \ - (P) += _this; \ + (P) = mempcpy ((P), spaces, _this); \ _len -= _this; \ } \ while (_len > 0); \ @@ -208,8 +215,7 @@ static const char zeroes[16] = /* "0000000000000000" */ do \ { \ int _this = _len > 16 ? 16 : _len; \ - memcpy ((P), zeroes, _this); \ - (P) += _this; \ + (P) = mempcpy ((P), zeroes, _this); \ _len -= _this; \ } \ while (_len > 0); \ diff --git a/time/tzfile.c b/time/tzfile.c index e3cb299..3d2d3e0 100644 --- a/time/tzfile.c +++ b/time/tzfile.c @@ -134,7 +134,7 @@ __tzfile_read (const char *file) { const char *tzdir; unsigned int len, tzdir_len; - char *new; + char *new, *tmp; tzdir = __secure_getenv ("TZDIR"); if (tzdir == NULL || *tzdir == '\0') @@ -146,9 +146,9 @@ __tzfile_read (const char *file) tzdir_len = strlen (tzdir); len = strlen (file) + 1; new = (char *) __alloca (tzdir_len + 1 + len); - memcpy (new, tzdir, tzdir_len); - new[tzdir_len] = '/'; - memcpy (&new[tzdir_len + 1], file, len); + tmp = __mempcpy (new, tzdir, tzdir_len); + *tmp++ = '/'; + __mempcpy (tmp, file, len); file = new; } @@ -316,8 +316,7 @@ __tzfile_default (const char *std, const char *dst, __use_tzfile = 0; return; } - memcpy (zone_names, std, stdlen); - memcpy (&zone_names[stdlen], dst, dstlen); + __mempcpy (__mempcpy (zone_names, std, stdlen), dst, dstlen); /* Find the standard and daylight time offsets used by the rule file. We choose the offsets in the types of each flavor that are diff --git a/wcsmbs/wcsdup.c b/wcsmbs/wcsdup.c index addbdda..3d676ca 100644 --- a/wcsmbs/wcsdup.c +++ b/wcsmbs/wcsdup.c @@ -33,7 +33,5 @@ wcsdup (s) if (new == NULL) return NULL; - memcpy (new, (void *) s, len); - - return (wchar_t *) new; + return (wchar_t *) memcpy (new, (void *) s, len); } -- cgit v1.1