1997-11-06 00:06  Ulrich Drepper  <drepper@cygnus.com>

	* 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 <gniibe@mri.co.jp>.

	* 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  <drepper@cygnus.com>

	* nss/getXXbyYY.c: Set buffer to NULL if realloc fails so that possible
	next call starts with malloc again.
	Proposed by Joe Keane <jgk@jgk.org>.

1997-11-04 23:57  Ulrich Drepper  <drepper@cygnus.com>

	* configure.in: Correct gcc -pipe test.
	Patch by Zack Weinberg <zack@rabi.phys.columbia.edu>.

	* posix/glob.c: Cleanups.  Patch by H.J. Lu <hjl@lucon.org>.

1997-11-04  Andreas Jaeger  <aj@arthur.rhein-neckar.de>

	* manual/creature.texi (Feature Test Macros): Add _POSIX_C_SOURCE
	definition.
This commit is contained in:
Ulrich Drepper 1997-11-06 00:02:46 +00:00
parent 1618c59038
commit 86187531d3
50 changed files with 808 additions and 581 deletions

5
BUGS
View File

@ -1,7 +1,7 @@
List of known bugs (certainly very incomplete) 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 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 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 [ *] The rcmd() functions (more concrete: the handling of .rhosts) does
not support netgroups and wildcards (+). 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" [ *] When assembling a locale definition, that uses the "copy"
directive, with localedef, not only the copied category is directive, with localedef, not only the copied category is
checked for errors, but the whole file containing the same checked for errors, but the whole file containing the same

View File

@ -1,3 +1,87 @@
1997-11-06 00:06 Ulrich Drepper <drepper@cygnus.com>
* 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 <gniibe@mri.co.jp>.
* 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 <drepper@cygnus.com>
* nss/getXXbyYY.c: Set buffer to NULL if realloc fails so that possible
next call starts with malloc again.
Proposed by Joe Keane <jgk@jgk.org>.
1997-11-04 23:57 Ulrich Drepper <drepper@cygnus.com>
* configure.in: Correct gcc -pipe test.
Patch by Zack Weinberg <zack@rabi.phys.columbia.edu>.
* posix/glob.c: Cleanups. Patch by H.J. Lu <hjl@lucon.org>.
1997-11-04 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* manual/creature.texi (Feature Test Macros): Add _POSIX_C_SOURCE
definition.
1997-11-04 Ulrich Drepper <drepper@cygnus.com> 1997-11-04 Ulrich Drepper <drepper@cygnus.com>
* manual/filesys.texi: Correct description of return value for * manual/filesys.texi: Correct description of return value for

View File

@ -778,7 +778,7 @@ hol_append (struct hol *hol, struct hol *more)
more->num_entries = 0; /* Mark MORE's fields as invalid. */ more->num_entries = 0; /* Mark MORE's fields as invalid. */
} }
else 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. */ non-shadowed SHORT_OPTIONS values. */
{ {
unsigned left; unsigned left;
@ -791,12 +791,12 @@ hol_append (struct hol *hol, struct hol *more)
char *short_options = char *short_options =
malloc (hol_so_len + strlen (more->short_options) + 1); malloc (hol_so_len + strlen (more->short_options) + 1);
memcpy (entries, hol->entries, __mempcpy (__mempcpy (entries, hol->entries,
hol->num_entries * sizeof (struct hol_entry)); hol->num_entries * sizeof (struct hol_entry)),
memcpy (entries + hol->num_entries, more->entries, more->entries,
more->num_entries * sizeof (struct hol_entry)); 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. */ /* Fix up the short options pointers from HOL. */
for (e = entries, left = hol->num_entries; left > 0; e++, left--) for (e = entries, left = hol->num_entries; left > 0; e++, left--)

View File

@ -316,8 +316,9 @@ enum
#define _SC_NL_TEXTMAX _SC_NL_TEXTMAX #define _SC_NL_TEXTMAX _SC_NL_TEXTMAX
}; };
#if (defined __USE_POSIX2 || defined __USE_FILE_OFFSET64 \ #if (defined __USE_POSIX2 || defined __USE_UNIX98 \
|| defined __USE_LARGEFILE64 || defined __USE_LARGEFILE) || defined __USE_FILE_OFFSET64 || defined __USE_LARGEFILE64 \
|| defined __USE_LARGEFILE)
/* Values for the NAME argument to `confstr'. */ /* Values for the NAME argument to `confstr'. */
enum enum
{ {
@ -340,8 +341,43 @@ enum
# define _CS_LFS64_LDFLAGS _CS_LFS64_LDFLAGS # define _CS_LFS64_LDFLAGS _CS_LFS64_LDFLAGS
_CS_LFS64_LIBS, _CS_LFS64_LIBS,
# define _CS_LFS64_LIBS _CS_LFS64_LIBS # define _CS_LFS64_LIBS _CS_LFS64_LIBS
_CS_LFS64_LINTFLAGS _CS_LFS64_LINTFLAGS,
# define _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
}; };
#endif #endif

69
configure vendored
View File

@ -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 if eval "test \"`echo '$''{'libc_cv_gcc_pipe_bug'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
cat >conftest.s <<EOF cp /dev/null conftest.s
foo: cat >conftest1.s <<EOF
.nosuchdirective
EOF EOF
if ${CC-cc} -pipe -c conftest.s <conftest.s 2>/dev/null; then if ${CC-cc} -pipe -c conftest.s <conftest1.s 2>/dev/null; then
libc_cv_gcc_pipe_bug=no libc_cv_gcc_pipe_bug=no
else else
libc_cv_gcc_pipe_bug=yes libc_cv_gcc_pipe_bug=yes
@ -1850,7 +1851,7 @@ else
fi fi
echo $ac_n "checking for assembler global-symbol directive""... $ac_c" 1>&6 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 if eval "test \"`echo '$''{'libc_cv_asm_global_directive'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
@ -1880,7 +1881,7 @@ EOF
fi fi
echo $ac_n "checking for .set assembler directive""... $ac_c" 1>&6 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 if eval "test \"`echo '$''{'libc_cv_asm_set_directive'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
@ -1914,7 +1915,7 @@ EOF
fi fi
echo $ac_n "checking for .symver assembler directive""... $ac_c" 1>&6 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 if eval "test \"`echo '$''{'libc_cv_asm_symver_directive'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
@ -1933,7 +1934,7 @@ fi
echo "$ac_t""$libc_cv_asm_symver_directive" 1>&6 echo "$ac_t""$libc_cv_asm_symver_directive" 1>&6
echo $ac_n "checking for ld --version-script""... $ac_c" 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 if eval "test \"`echo '$''{'libc_cv_ld_version_script_option'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
@ -1952,7 +1953,7 @@ EOF
if { ac_try='${CC-cc} $CFLAGS -shared -o conftest.so conftest.o if { ac_try='${CC-cc} $CFLAGS -shared -o conftest.so conftest.o
-nostartfiles -nostdlib -nostartfiles -nostdlib
-Wl,--version-script,conftest.map -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 then
libc_cv_ld_version_script_option=yes libc_cv_ld_version_script_option=yes
else else
@ -1983,7 +1984,7 @@ fi
if test $elf = yes; then if test $elf = yes; then
echo $ac_n "checking for .previous assembler directive""... $ac_c" 1>&6 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 if eval "test \"`echo '$''{'libc_cv_asm_previous_directive'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
@ -1991,7 +1992,7 @@ else
.section foo_section .section foo_section
.previous .previous
EOF 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 libc_cv_asm_previous_directive=yes
else else
libc_cv_asm_previous_directive=no libc_cv_asm_previous_directive=no
@ -2007,7 +2008,7 @@ EOF
else else
echo $ac_n "checking for .popsection assembler directive""... $ac_c" 1>&6 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 if eval "test \"`echo '$''{'libc_cv_asm_popsection_directive'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
@ -2015,7 +2016,7 @@ else
.pushsection foo_section .pushsection foo_section
.popsection .popsection
EOF 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 libc_cv_asm_popsection_directive=yes
else else
libc_cv_asm_popsection_directive=no libc_cv_asm_popsection_directive=no
@ -2035,12 +2036,12 @@ fi
if test $elf != yes; then if test $elf != yes; then
echo $ac_n "checking for .init and .fini sections""... $ac_c" 1>&6 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 if eval "test \"`echo '$''{'libc_cv_have_initfini'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 2044 "configure" #line 2045 "configure"
#include "confdefs.h" #include "confdefs.h"
int main() { int main() {
@ -2049,7 +2050,7 @@ asm (".section .init");
asm (".text"); asm (".text");
; return 0; } ; return 0; }
EOF EOF
if { (eval echo configure:2053: \"$ac_compile\") 1>&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* rm -rf conftest*
libc_cv_have_initfini=yes libc_cv_have_initfini=yes
else else
@ -2077,19 +2078,19 @@ if test $elf = yes; then
else else
if test $ac_cv_prog_cc_works = yes; then if test $ac_cv_prog_cc_works = yes; then
echo $ac_n "checking for _ prefix on C symbol names""... $ac_c" 1>&6 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 if eval "test \"`echo '$''{'libc_cv_asm_underscores'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 2086 "configure" #line 2087 "configure"
#include "confdefs.h" #include "confdefs.h"
asm ("_glibc_foobar:"); asm ("_glibc_foobar:");
int main() { int main() {
glibc_foobar (); glibc_foobar ();
; return 0; } ; return 0; }
EOF EOF
if { (eval echo configure:2093: \"$ac_link\") 1>&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* rm -rf conftest*
libc_cv_asm_underscores=yes libc_cv_asm_underscores=yes
else else
@ -2104,17 +2105,17 @@ fi
echo "$ac_t""$libc_cv_asm_underscores" 1>&6 echo "$ac_t""$libc_cv_asm_underscores" 1>&6
else else
echo $ac_n "checking for _ prefix on C symbol names""... $ac_c" 1>&6 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 if eval "test \"`echo '$''{'libc_cv_asm_underscores'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 2113 "configure" #line 2114 "configure"
#include "confdefs.h" #include "confdefs.h"
void underscore_test(void) { void underscore_test(void) {
return; } return; }
EOF EOF
if { (eval echo configure:2118: \"$ac_compile\") 1>&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 if grep _underscore_test conftest* >/dev/null; then
rm -f conftest* rm -f conftest*
libc_cv_asm_underscores=yes libc_cv_asm_underscores=yes
@ -2147,7 +2148,7 @@ if test $elf = yes; then
libc_cv_asm_weakext_directive=no libc_cv_asm_weakext_directive=no
else else
echo $ac_n "checking for assembler .weak directive""... $ac_c" 1>&6 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 if eval "test \"`echo '$''{'libc_cv_asm_weak_directive'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
@ -2170,7 +2171,7 @@ echo "$ac_t""$libc_cv_asm_weak_directive" 1>&6
if test $libc_cv_asm_weak_directive = no; then if test $libc_cv_asm_weak_directive = no; then
echo $ac_n "checking for assembler .weakext directive""... $ac_c" 1>&6 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 if eval "test \"`echo '$''{'libc_cv_asm_weakext_directive'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
@ -2207,7 +2208,7 @@ EOF
fi fi
echo $ac_n "checking for ld --no-whole-archive""... $ac_c" 1>&6 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 if eval "test \"`echo '$''{'libc_cv_ld_no_whole_archive'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
@ -2218,7 +2219,7 @@ __throw () {}
EOF EOF
if { ac_try='${CC-cc} $CFLAGS if { ac_try='${CC-cc} $CFLAGS
-nostdlib -nostartfiles -Wl,--no-whole-archive -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 libc_cv_ld_no_whole_archive=yes
else else
libc_cv_ld_no_whole_archive=no 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_t""$libc_cv_ld_no_whole_archive" 1>&6
echo $ac_n "checking for gcc -fno-exceptions""... $ac_c" 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 if eval "test \"`echo '$''{'libc_cv_gcc_no_exceptions'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
@ -2240,7 +2241,7 @@ __throw () {}
EOF EOF
if { ac_try='${CC-cc} $CFLAGS if { ac_try='${CC-cc} $CFLAGS
-nostdlib -nostartfiles -fno-exceptions -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 libc_cv_gcc_no_exceptions=yes
else else
libc_cv_gcc_no_exceptions=no libc_cv_gcc_no_exceptions=no
@ -2251,12 +2252,12 @@ fi
echo "$ac_t""$libc_cv_gcc_no_exceptions" 1>&6 echo "$ac_t""$libc_cv_gcc_no_exceptions" 1>&6
echo $ac_n "checking for DWARF2 unwind info support""... $ac_c" 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 if eval "test \"`echo '$''{'libc_cv_gcc_dwarf2_unwind_info'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
cat > conftest.c <<EOF cat > conftest.c <<EOF
#line 2260 "configure" #line 2261 "configure"
static char __EH_FRAME_BEGIN__; static char __EH_FRAME_BEGIN__;
_start () _start ()
{ {
@ -2277,7 +2278,7 @@ __bzero () {}
EOF EOF
if { ac_try='${CC-cc} $CFLAGS if { ac_try='${CC-cc} $CFLAGS
-nostdlib -nostartfiles -nostdlib -nostartfiles
-o conftest conftest.c -lgcc >&5'; { (eval echo configure:2281: \"$ac_try\") 1>&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 libc_cv_gcc_dwarf2_unwind_info=yes
else else
libc_cv_gcc_dwarf2_unwind_info=no libc_cv_gcc_dwarf2_unwind_info=no
@ -2335,7 +2336,7 @@ if test "$uname" = "sysdeps/generic"; then
fi fi
echo $ac_n "checking OS release for uname""... $ac_c" 1>&6 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 if eval "test \"`echo '$''{'libc_cv_uname_release'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
@ -2357,7 +2358,7 @@ echo "$ac_t""$libc_cv_uname_release" 1>&6
uname_release="$libc_cv_uname_release" uname_release="$libc_cv_uname_release"
echo $ac_n "checking OS version for uname""... $ac_c" 1>&6 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 if eval "test \"`echo '$''{'libc_cv_uname_version'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
@ -2379,7 +2380,7 @@ else
fi fi
echo $ac_n "checking stdio selection""... $ac_c" 1>&6 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 case $stdio in
libio) cat >> confdefs.h <<\EOF libio) cat >> confdefs.h <<\EOF
@ -2391,7 +2392,7 @@ esac
echo "$ac_t""$stdio" 1>&6 echo "$ac_t""$stdio" 1>&6
echo $ac_n "checking ldap selection""... $ac_c" 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 case $add_ons in
*ldap*) *ldap*)

View File

@ -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 # We must check this even if -pipe is not given here, because the user
# might do `make CFLAGS=-pipe'. # might do `make CFLAGS=-pipe'.
AC_CACHE_CHECK(for gcc 2.7.x -pipe bug, libc_cv_gcc_pipe_bug, [dnl AC_CACHE_CHECK(for gcc 2.7.x -pipe bug, libc_cv_gcc_pipe_bug, [dnl
cat >conftest.s <<EOF cp /dev/null conftest.s
foo: cat >conftest1.s <<EOF
.nosuchdirective
EOF EOF
if ${CC-cc} -pipe -c conftest.s <conftest.s 2>/dev/null; then if ${CC-cc} -pipe -c conftest.s <conftest1.s 2>/dev/null; then
libc_cv_gcc_pipe_bug=no libc_cv_gcc_pipe_bug=no
else else
libc_cv_gcc_pipe_bug=yes libc_cv_gcc_pipe_bug=yes

View File

@ -238,12 +238,12 @@ fillin_rpath (char *rpath, struct r_search_path_elem **result, const char *sep,
if (tmp == NULL) if (tmp == NULL)
_dl_signal_error (ENOMEM, NULL, _dl_signal_error (ENOMEM, NULL,
"cannot create cache for search path"); "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; dirp->dirname = tmp;
tmp = __mempcpy (tmp, cp, len);
tmp = __mempcpy (tmp, _dl_platform, _dl_platformlen);
*tmp++ = '/';
*tmp = '\0';
dirp->machdirstatus = dirp->dirstatus; dirp->machdirstatus = dirp->dirstatus;
if (max_dirnamelen < dirp->machdirnamelen) 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) if (tmp == NULL)
_dl_signal_error (ENOMEM, NULL, _dl_signal_error (ENOMEM, NULL,
"cannot create cache for search path"); "cannot create cache for search path");
memcpy (tmp, cp, len); dirp->dirname = tmp;
tmp[len] = '\0'; *((char *) __mempcpy (tmp, cp, len)) = '\0';
if (max_dirnamelen < dirp->dirnamelen) if (max_dirnamelen < dirp->dirnamelen)
max_dirnamelen = dirp->dirnamelen; max_dirnamelen = dirp->dirnamelen;
dirp->dirname = tmp;
} }
dirp->next = all_dirs; dirp->next = all_dirs;
@ -430,12 +428,11 @@ _dl_init_paths (void)
_dl_signal_error (ENOMEM, NULL, _dl_signal_error (ENOMEM, NULL,
"cannot create cache for search path"); "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; relem->dirname = tmp;
tmp = __mempcpy (tmp, relem->dirname, relem->dirnamelen);
tmp = __mempcpy (tmp, _dl_platform, _dl_platformlen);
*tmp++ = '/';
*tmp = '\0';
relem->machdirstatus = unknown; relem->machdirstatus = unknown;
@ -812,9 +809,10 @@ open_path (const char *name, size_t namelen,
if (this_dir->machdirstatus != nonexisting) if (this_dir->machdirstatus != nonexisting)
{ {
/* Construct the pathname to try. */ /* Construct the pathname to try. */
(void) memcpy (buf, this_dir->dirname, this_dir->machdirnamelen); buflen = ((char *) __mempcpy (__mempcpy (buf, this_dir->dirname,
(void) memcpy (buf + this_dir->machdirnamelen, name, namelen); this_dir->machdirnamelen),
buflen = this_dir->machdirnamelen + namelen; name, namelen)
- buf);
fd = __open (buf, O_RDONLY); fd = __open (buf, O_RDONLY);
if (this_dir->machdirstatus == unknown) if (this_dir->machdirstatus == unknown)
@ -839,9 +837,10 @@ open_path (const char *name, size_t namelen,
if (fd == -1 && this_dir->dirstatus != nonexisting) if (fd == -1 && this_dir->dirstatus != nonexisting)
{ {
/* Construct the pathname to try. */ /* Construct the pathname to try. */
(void) memcpy (buf, this_dir->dirname, this_dir->dirnamelen); buflen = ((char *) __mempcpy (__mempcpy (buf, this_dir->dirname,
(void) memcpy (buf + this_dir->dirnamelen, name, namelen); this_dir->dirnamelen),
buflen = this_dir->dirnamelen + namelen; name, namelen)
- buf);
fd = __open (buf, O_RDONLY); fd = __open (buf, O_RDONLY);
if (this_dir->dirstatus == unknown) if (this_dir->dirstatus == unknown)

View File

@ -355,8 +355,8 @@ _dl_lookup_versioned_symbol_skip (const char *undef_name,
/* We could find no value for a strong reference. */ /* We could find no value for a strong reference. */
const size_t len = strlen (undef_name); const size_t len = strlen (undef_name);
char buf[sizeof undefined_msg + len]; char buf[sizeof undefined_msg + len];
memcpy (buf, undefined_msg, sizeof undefined_msg - 1); __mempcpy (__mempcpy (buf, undefined_msg, sizeof undefined_msg - 1),
memcpy (&buf[sizeof undefined_msg - 1], undef_name, len + 1); undef_name, len + 1);
_dl_signal_error (0, reference_name, buf); _dl_signal_error (0, reference_name, buf);
} }

View File

@ -262,7 +262,7 @@ _dl_start_profile (struct link_map *map, const char *output_dir)
fd = __open (filename, O_RDWR | O_CREAT, 0666); fd = __open (filename, O_RDWR | O_CREAT, 0666);
if (fd == -1) 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]; char buf[400];
_dl_sysdep_message (filename, ": cannot open file: ", _dl_sysdep_message (filename, ": cannot open file: ",
_strerror_internal (errno, buf, sizeof buf), _strerror_internal (errno, buf, sizeof buf),

View File

@ -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. This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@ -21,7 +21,7 @@
#include <netinet/if_ether.h> #include <netinet/if_ether.h>
#include <string.h> #include <string.h>
#include "../nss/nsswitch.h" #include <nss/nsswitch.h>
/* Because the `ethers' lookup does not fit so well in the scheme so /* 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 we define a dummy struct here which helps us to use the available

View File

@ -35,4 +35,4 @@
#define HANDLE_DIGITS_DOTS 1 #define HANDLE_DIGITS_DOTS 1
#include "../nss/getXXbyYY.c" #include <nss/getXXbyYY.c>

View File

@ -330,8 +330,8 @@ again:
dirlen = strlen (pwd->pw_dir); dirlen = strlen (pwd->pw_dir);
pbuf = alloca (dirlen + sizeof "/.rhosts"); pbuf = alloca (dirlen + sizeof "/.rhosts");
memcpy (pbuf, pwd->pw_dir, dirlen); __mempcpy (__mempcpy (pbuf, pwd->pw_dir, dirlen),
memcpy (pbuf + dirlen, "/.rhosts", sizeof "/.rhosts"); "/.rhosts", sizeof "/.rhosts");
/* /*
* Change effective uid while opening .rhosts. If root and * Change effective uid while opening .rhosts. If root and

View File

@ -63,7 +63,7 @@ static FILE *cfile;
static char tokval[100]; static char tokval[100];
static struct toktab { static struct toktab {
char *tokstr; const char *tokstr;
int tval; int tval;
} toktab[]= { } toktab[]= {
{ "default", DEFAULT }, { "default", DEFAULT },
@ -98,7 +98,7 @@ ruserpass(host, aname, apass)
buf = alloca (strlen (hdir) + 8); buf = alloca (strlen (hdir) + 8);
(void) sprintf(buf, "%s/.netrc", hdir); __stpcpy (__stpcpy (buf, hdir), "/.netrc");
cfile = fopen(buf, "r"); cfile = fopen(buf, "r");
if (cfile == NULL) { if (cfile == NULL) {
if (errno != ENOENT) if (errno != ENOENT)

View File

@ -186,9 +186,9 @@ open_dir_stream (struct ftw_data *data, struct dir_data *dirp)
buf = newp; buf = newp;
} }
memcpy (buf + actsize, d->d_name, this_len); *((char *) __mempcpy (buf + actsize, d->d_name, this_len))
actsize += this_len; = '\0';
buf[actsize++] = '\0'; actsize += this_len + 1;
} }
/* Terminate the list with an additional NUL byte. */ /* 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; data->dirbuf = newp;
} }
memcpy (data->dirbuf + data->ftw.base, name, namlen); *((char *) __mempcpy (data->dirbuf + data->ftw.base, name, namlen)) = '\0';
data->dirbuf[data->ftw.base + namlen] = '\0';
if (((data->flags & FTW_PHYS) if (((data->flags & FTW_PHYS)
? LXSTAT (_STAT_VER, data->dirbuf, &st) ? LXSTAT (_STAT_VER, data->dirbuf, &st)

View File

@ -706,7 +706,12 @@ _IO_file_xsputn (f, data, n)
count = to_do; count = to_do;
if (count > 20) if (count > 20)
{ {
#ifdef _LIBC
f->_IO_write_ptr = __mempcpy (f->_IO_write_ptr, s, count);
#else
memcpy (f->_IO_write_ptr, s, count); memcpy (f->_IO_write_ptr, s, count);
f->_IO_write_ptr += count;
#endif
s += count; s += count;
} }
else else
@ -715,8 +720,8 @@ _IO_file_xsputn (f, data, n)
register int i = (int) count; register int i = (int) count;
while (--i >= 0) while (--i >= 0)
*p++ = *s++; *p++ = *s++;
f->_IO_write_ptr = p;
} }
f->_IO_write_ptr += count;
to_do -= count; to_do -= count;
} }
if (to_do + must_flush > 0) if (to_do + must_flush > 0)
@ -765,8 +770,12 @@ _IO_file_xsgetn (fp, data, n)
count = more; count = more;
if (count > 20) if (count > 20)
{ {
#ifdef _LIBC
s = __mempcpy (s, fp->_IO_read_ptr, count);
#else
memcpy (s, fp->_IO_read_ptr, count); memcpy (s, fp->_IO_read_ptr, count);
s += count; s += count;
#endif
fp->_IO_read_ptr += count; fp->_IO_read_ptr += count;
} }
else if (count <= 0) else if (count <= 0)

View File

@ -210,12 +210,20 @@ save_for_backup (fp)
return EOF; /* FIXME */ return EOF; /* FIXME */
if (least_mark < 0) 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, memcpy (new_buffer + avail,
fp->_IO_save_end + least_mark, fp->_IO_save_end + least_mark,
-least_mark); -least_mark);
memcpy (new_buffer + avail - least_mark, memcpy (new_buffer + avail - least_mark,
fp->_IO_read_base, fp->_IO_read_base,
fp->_IO_read_end - fp->_IO_read_base); fp->_IO_read_end - fp->_IO_read_base);
#endif
} }
else else
memcpy (new_buffer + avail, memcpy (new_buffer + avail,
@ -368,9 +376,13 @@ _IO_default_xsputn (f, data, n)
count = more; count = more;
if (count > 20) if (count > 20)
{ {
#ifdef _LIBC
f->_IO_write_ptr = __mempcpy (f->_IO_write_ptr, s, count);
#else
memcpy (f->_IO_write_ptr, s, count); memcpy (f->_IO_write_ptr, s, count);
s += count;
f->_IO_write_ptr += count; f->_IO_write_ptr += count;
#endif
s += count;
} }
else if (count <= 0) else if (count <= 0)
count = 0; count = 0;
@ -419,8 +431,12 @@ _IO_default_xsgetn (fp, data, n)
count = more; count = more;
if (count > 20) if (count > 20)
{ {
#ifdef _LIBC
s = __mempcpy (s, fp->_IO_read_ptr, count);
#else
memcpy (s, fp->_IO_read_ptr, count); memcpy (s, fp->_IO_read_ptr, count);
s += count; s += count;
#endif
fp->_IO_read_ptr += count; fp->_IO_read_ptr += count;
} }
else if (count <= 0) else if (count <= 0)

View File

@ -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); obstack_blank_fast (obstack, fp->_IO_write_end - fp->_IO_write_ptr);
} }
else else
{ fp->_IO_write_ptr = __mempcpy (fp->_IO_write_ptr, data, n);
memcpy (fp->_IO_write_ptr, data, n);
fp->_IO_write_ptr += n;
}
return n; return n;
} }

View File

@ -707,10 +707,10 @@ struct _IO_jump_t _IO_old_file_jumps =
JUMP_INIT(seekoff, _IO_old_file_seekoff), JUMP_INIT(seekoff, _IO_old_file_seekoff),
JUMP_INIT(seekpos, _IO_default_seekpos), JUMP_INIT(seekpos, _IO_default_seekpos),
JUMP_INIT(setbuf, _IO_old_file_setbuf), 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(doallocate, _IO_file_doallocate),
JUMP_INIT(read, _IO_file_read), 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(seek, _IO_file_seek),
JUMP_INIT(close, _IO_file_close), JUMP_INIT(close, _IO_file_close),
JUMP_INIT(stat, _IO_file_stat) JUMP_INIT(stat, _IO_file_stat)

View File

@ -208,8 +208,10 @@ do_setutent (int sock)
setutent_request *request; setutent_request *request;
setutent_reply reply; setutent_reply reply;
size_t size; 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); request = malloc (size);
if (request == NULL) if (request == NULL)
@ -218,7 +220,7 @@ do_setutent (int sock)
request->header.version = UTMPD_VERSION; request->header.version = UTMPD_VERSION;
request->header.size = size; request->header.size = size;
request->header.type = UTMPD_REQ_SETUTENT; 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.version = UTMPD_VERSION;
reply.header.size = sizeof (setutent_reply); 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_request *request;
updwtmp_reply reply; updwtmp_reply reply;
size_t size; 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); request = malloc (size);
if (request == NULL) if (request == NULL)
@ -378,7 +382,7 @@ do_updwtmp (int sock, const char *file, const struct utmp *utmp)
request->header.size = size; request->header.size = size;
request->header.type = UTMPD_REQ_UPDWTMP; request->header.type = UTMPD_REQ_UPDWTMP;
memcpy (&request->utmp, utmp, sizeof (struct utmp)); memcpy (&request->utmp, utmp, sizeof (struct utmp));
strcpy (request->file, file); memcpy (request->file, file, file_len);
reply.header.version = UTMPD_VERSION; reply.header.version = UTMPD_VERSION;
reply.header.size = sizeof (updwtmp_reply); reply.header.size = sizeof (updwtmp_reply);

View File

@ -32,6 +32,7 @@ macro @code{_POSIX_C_SOURCE} to a positive integer.
@comment (none) @comment (none)
@comment POSIX.2 @comment POSIX.2
@defvr Macro _POSIX_C_SOURCE
Define this macro to a positive integer to control which POSIX Define this macro to a positive integer to control which POSIX
functionality is made available. The greater the value of this macro, functionality is made available. The greater the value of this macro,
the more functionality is made available. the more functionality is made available.

View File

@ -359,8 +359,7 @@ __tdelete (const void *key, void **vrootp, __compar_fn_t compar)
node **newstack; node **newstack;
stacksize += 20; stacksize += 20;
newstack = alloca (sizeof (node *) * stacksize); newstack = alloca (sizeof (node *) * stacksize);
memcpy (newstack, nodestack, sp * sizeof (node *)); nodestack = memcpy (newstack, nodestack, sp * sizeof (node *));
nodestack = newstack;
} }
nodestack[sp++] = rootp; nodestack[sp++] = rootp;
@ -398,8 +397,7 @@ __tdelete (const void *key, void **vrootp, __compar_fn_t compar)
node **newstack; node **newstack;
stacksize += 20; stacksize += 20;
newstack = alloca (sizeof (node *) * stacksize); newstack = alloca (sizeof (node *) * stacksize);
memcpy (newstack, nodestack, sp * sizeof (node *)); nodestack = memcpy (newstack, nodestack, sp * sizeof (node *));
nodestack = newstack;
} }
nodestack[sp++] = parent; nodestack[sp++] = parent;
parent = up; parent = up;

View File

@ -246,8 +246,7 @@
goto done; goto done;
} }
strcpy (hostname, name); resbuf.h_name = strcpy (hostname, name);
resbuf.h_name = hostname;
resbuf.h_aliases = *host_aliases; resbuf.h_aliases = *host_aliases;
(*host_aliases)[0] = NULL; (*host_aliases)[0] = NULL;
(*h_addr_ptrs)[0] = (char *) host_addr; (*h_addr_ptrs)[0] = (char *) host_addr;

View File

@ -117,6 +117,7 @@ FUNCTION_NAME (ADD_PARAMS)
process gets a chance for a normal termination. */ process gets a chance for a normal termination. */
save = errno; save = errno;
free (buffer); free (buffer);
buffer = NULL;
__set_errno (save); __set_errno (save);
} }
buffer = new_buf; buffer = new_buf;

View File

@ -587,8 +587,7 @@ nss_parse_service_list (const char *line)
free (new_service); free (new_service);
return result; return result;
} }
memcpy (source, name, line - name); *((char *) __mempcpy (source, name, line - name)) = '\0';
source[line - name] = '\0';
new_service->name = source; new_service->name = source;
} }

View File

@ -47,7 +47,7 @@ confstr (name, buf, len)
case _CS_LFS_CFLAGS: case _CS_LFS_CFLAGS:
/* Signal that we want the new ABI. */ /* 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 = file_offset;
string_len = sizeof (file_offset); string_len = sizeof (file_offset);
} }
@ -60,6 +60,23 @@ confstr (name, buf, len)
case _CS_LFS64_LINTFLAGS: case _CS_LFS64_LINTFLAGS:
case _CS_LFS64_LDFLAGS: case _CS_LFS64_LDFLAGS:
case _CS_LFS64_LIBS: 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. */ /* GNU libc does not require special actions to use LFS functions. */
string = ""; string = "";
string_len = 1; string_len = 1;

View File

@ -104,9 +104,9 @@ execvp (file, argv)
else else
{ {
/* Construct the pathname to try. */ /* Construct the pathname to try. */
(void) memcpy (name, path, p - path); char *tmp = __mempcpy (name, path, p - path);
name[p - path] = '/'; *tmp++ = '/';
(void) memcpy (&name[(p - path) + 1], file, len); (void) __mempcpy (tmp, file, len);
} }
/* Try to execute this name. If it works, execv will not return. */ /* Try to execute this name. If it works, execv will not return. */

View File

@ -328,9 +328,9 @@ exchange (argv)
nonoption_flags_len = nonoption_flags_max_len = 0; nonoption_flags_len = nonoption_flags_max_len = 0;
else else
{ {
memcpy (new_str, __getopt_nonoption_flags, nonoption_flags_max_len); memset (__mempcpy (new_str, __getopt_nonoption_flags,
memset (&new_str[nonoption_flags_max_len], '\0', nonoption_flags_max_len),
top + 1 - nonoption_flags_max_len); '\0', top + 1 - nonoption_flags_max_len);
nonoption_flags_max_len = top + 1; nonoption_flags_max_len = top + 1;
__getopt_nonoption_flags = new_str; __getopt_nonoption_flags = new_str;
} }
@ -439,11 +439,8 @@ _getopt_initialize (argc, argv, optstring)
if (__getopt_nonoption_flags == NULL) if (__getopt_nonoption_flags == NULL)
nonoption_flags_max_len = -1; nonoption_flags_max_len = -1;
else else
{ memset (__mempcpy (__getopt_nonoption_flags, orig_str, len),
memcpy (__getopt_nonoption_flags, orig_str, len); '\0', nonoption_flags_max_len - len);
memset (&__getopt_nonoption_flags[len], '\0',
nonoption_flags_max_len - len);
}
} }
} }
nonoption_flags_len = nonoption_flags_max_len; nonoption_flags_len = nonoption_flags_max_len;

View File

@ -374,8 +374,12 @@ glob (pattern, flags, errfunc, pglob)
#endif #endif
/* We know the prefix for all sub-patterns. */ /* We know the prefix for all sub-patterns. */
#ifdef HAVE_MEMPCPY
alt_start = mempcpy (onealt, pattern, begin - pattern);
#else
memcpy (onealt, pattern, begin - pattern); memcpy (onealt, pattern, begin - pattern);
alt_start = &onealt[begin - pattern]; alt_start = &onealt[begin - pattern];
#endif
/* Find the first sub-pattern and at the same time find the /* Find the first sub-pattern and at the same time find the
rest after the closing brace. */ rest after the closing brace. */
@ -951,11 +955,10 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
char *name; char *name;
}; };
struct globlink *names = NULL; struct globlink *names = NULL;
size_t nfound = 0; size_t nfound;
int meta;
int save;
if (!__glob_pattern_p (pattern, !(flags & GLOB_NOESCAPE)))
{
/* We must check whether the file in this directory exists. */
stream = ((flags & GLOB_ALTDIRFUNC) ? stream = ((flags & GLOB_ALTDIRFUNC) ?
(*pglob->gl_opendir) (directory) : (*pglob->gl_opendir) (directory) :
(__ptr_t) opendir (directory)); (__ptr_t) opendir (directory));
@ -964,6 +967,8 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
if ((errfunc != NULL && (*errfunc) (directory, errno)) || if ((errfunc != NULL && (*errfunc) (directory, errno)) ||
(flags & GLOB_ERR)) (flags & GLOB_ERR))
return GLOB_ABORTED; return GLOB_ABORTED;
nfound = 0;
meta = 0;
} }
else if (pattern[0] == '\0') else if (pattern[0] == '\0')
{ {
@ -976,61 +981,15 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
names->name[0] = '\0'; names->name[0] = '\0';
names->next = NULL; names->next = NULL;
nfound = 1; nfound = 1;
} meta = 0;
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;
}
}
} }
else else
{ {
nfound = 0;
meta = __glob_pattern_p (pattern, !(flags & GLOB_NOESCAPE));
if(meta)
flags |= GLOB_MAGCHAR; flags |= GLOB_MAGCHAR;
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
while (1) while (1)
{ {
const char *name; const char *name;
@ -1043,17 +1002,18 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
if (! REAL_DIR_ENTRY (d)) if (! REAL_DIR_ENTRY (d))
continue; continue;
name = d->d_name;
#ifdef HAVE_D_TYPE #ifdef HAVE_D_TYPE
/* If we shall match only directories use the information /* If we shall match only directories use the information
provided by the dirent if possible. */ provided by the dirent call if possible. */
if ((flags & GLOB_ONLYDIR) if ((flags & GLOB_ONLYDIR)
&& d->d_type != DT_UNKNOWN && d->d_type != DT_DIR) && d->d_type != DT_UNKNOWN && d->d_type != DT_DIR)
continue; continue;
#endif #endif
if (fnmatch (pattern, name, name = d->d_name;
if ((!meta && strcmp (pattern, name) == 0)
|| fnmatch (pattern, name,
(!(flags & GLOB_PERIOD) ? FNM_PERIOD : 0) | (!(flags & GLOB_PERIOD) ? FNM_PERIOD : 0) |
((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0) ((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0)
#ifdef _AMIGA #ifdef _AMIGA
@ -1064,8 +1024,7 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
struct globlink *new struct globlink *new
= (struct globlink *) __alloca (sizeof (struct globlink)); = (struct globlink *) __alloca (sizeof (struct globlink));
len = NAMLEN (d); len = NAMLEN (d);
new->name new->name = (char *) malloc (len + 1);
= (char *) malloc (len + 1);
if (new->name == NULL) if (new->name == NULL)
goto memory_error; goto memory_error;
#ifdef HAVE_MEMPCPY #ifdef HAVE_MEMPCPY
@ -1077,12 +1036,13 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
new->next = names; new->next = names;
names = new; names = new;
++nfound; ++nfound;
if (!meta)
break;
} }
} }
} }
if (nfound == 0 && (flags & GLOB_NOMAGIC) && if (nfound == 0 && (flags & GLOB_NOMAGIC) && !meta)
! __glob_pattern_p (pattern, !(flags & GLOB_NOESCAPE)))
flags |= GLOB_NOCHECK; flags |= GLOB_NOCHECK;
if (nfound == 0 && (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; pglob->gl_flags = flags;
} }
if (stream != NULL) save = errno;
{
int save = errno;
if (flags & GLOB_ALTDIRFUNC) if (flags & GLOB_ALTDIRFUNC)
(*pglob->gl_closedir) (stream); (*pglob->gl_closedir) (stream);
else else
closedir ((DIR *) stream); closedir ((DIR *) stream);
__set_errno (save); __set_errno (save);
}
return nfound == 0 ? GLOB_NOMATCH : 0; return nfound == 0 ? GLOB_NOMATCH : 0;
memory_error: memory_error:

View File

@ -2,12 +2,8 @@
version 0.12. version 0.12.
(Implements POSIX draft P1003.2/D11.2, except for some of the (Implements POSIX draft P1003.2/D11.2, except for some of the
internationalization features.) internationalization features.)
Copyright (C) 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc. 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 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 modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the published by the Free Software Foundation; either version 2 of the
@ -24,7 +20,7 @@
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
/* AIX requires this to be the first thing in the file. */ /* 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 #pragma alloca
#endif #endif
@ -32,14 +28,14 @@
#define _GNU_SOURCE #define _GNU_SOURCE
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> # include <config.h>
#endif #endif
#if defined(STDC_HEADERS) && !defined(emacs) #if defined STDC_HEADERS && !defined emacs
#include <stddef.h> # include <stddef.h>
#else #else
/* We need this for `regex.h', and perhaps for the Emacs include files. */ /* We need this for `regex.h', and perhaps for the Emacs include files. */
#include <sys/types.h> # include <sys/types.h>
#endif #endif
/* For platform which support the ISO C amendement 1 functionality we /* For platform which support the ISO C amendement 1 functionality we
@ -50,7 +46,7 @@
#endif #endif
/* This is for other GNU distributions with internationalized messages. */ /* This is for other GNU distributions with internationalized messages. */
#if HAVE_LIBINTL_H || defined (_LIBC) #if HAVE_LIBINTL_H || defined _LIBC
# include <libintl.h> # include <libintl.h>
#else #else
# define gettext(msgid) (msgid) # define gettext(msgid) (msgid)
@ -59,83 +55,83 @@
#ifndef gettext_noop #ifndef gettext_noop
/* This define is so xgettext can find the internationalizable /* This define is so xgettext can find the internationalizable
strings. */ strings. */
#define gettext_noop(String) String # define gettext_noop(String) String
#endif #endif
/* The `emacs' switch turns on certain matching commands /* The `emacs' switch turns on certain matching commands
that make sense only in Emacs. */ that make sense only in Emacs. */
#ifdef emacs #ifdef emacs
#include "lisp.h" # include "lisp.h"
#include "buffer.h" # include "buffer.h"
#include "syntax.h" # include "syntax.h"
#else /* not emacs */ #else /* not emacs */
/* If we are not linking with Emacs proper, /* If we are not linking with Emacs proper,
we can't use the relocating allocator we can't use the relocating allocator
even if config.h says that we can. */ even if config.h says that we can. */
#undef REL_ALLOC # undef REL_ALLOC
#if defined (STDC_HEADERS) || defined (_LIBC) # if defined STDC_HEADERS || defined _LIBC
#include <stdlib.h> # include <stdlib.h>
#else # else
char *malloc (); char *malloc ();
char *realloc (); char *realloc ();
#endif # endif
/* When used in Emacs's lib-src, we need to get bzero and bcopy somehow. /* 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. */ If nothing else has been done, use the method below. */
#ifdef INHIBIT_STRING_HEADER # ifdef INHIBIT_STRING_HEADER
#if !(defined (HAVE_BZERO) && defined (HAVE_BCOPY)) # if !(defined HAVE_BZERO && defined HAVE_BCOPY)
#if !defined (bzero) && !defined (bcopy) # if !defined bzero && !defined bcopy
#undef INHIBIT_STRING_HEADER # undef INHIBIT_STRING_HEADER
#endif # endif
#endif # endif
#endif # endif
/* This is the normal way of making sure we have a bcopy and a bzero. /* 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 This is used in most programs--a few other programs avoid this
by defining INHIBIT_STRING_HEADER. */ by defining INHIBIT_STRING_HEADER. */
#ifndef INHIBIT_STRING_HEADER # ifndef INHIBIT_STRING_HEADER
#if defined (HAVE_STRING_H) || defined (STDC_HEADERS) || defined (_LIBC) # if defined HAVE_STRING_H || defined STDC_HEADERS || defined _LIBC
#include <string.h> # include <string.h>
#ifndef bcmp # if !defined bzero && !defined _LIBC
#define bcmp(s1, s2, n) memcmp ((s1), (s2), (n)) # define bzero(s, n) (memset (s, '\0', n), (s))
#endif # endif
#ifndef bcopy # else
#define bcopy(s, d, n) memcpy ((d), (s), (n)) # include <strings.h>
#endif # ifndef memcmp
#ifndef bzero # define memcmp(s1, s2, n) bcmp (s1, s2, n)
#define bzero(s, n) memset ((s), 0, (n)) # endif
#endif # ifndef memcpy
#else # define memcpy(d, s, n) (bcopy (s, d, n), (d))
#include <strings.h> # endif
#endif # endif
#endif # endif
/* Define the syntax stuff for \<, \>, etc. */ /* Define the syntax stuff for \<, \>, etc. */
/* This must be nonzero for the wordchar and notwordchar pattern /* This must be nonzero for the wordchar and notwordchar pattern
commands in re_match_2. */ commands in re_match_2. */
#ifndef Sword # ifndef Sword
#define Sword 1 # define Sword 1
#endif # endif
#ifdef SWITCH_ENUM_BUG # ifdef SWITCH_ENUM_BUG
#define SWITCH_ENUM_CAST(x) ((int)(x)) # define SWITCH_ENUM_CAST(x) ((int)(x))
#else # else
#define SWITCH_ENUM_CAST(x) (x) # define SWITCH_ENUM_CAST(x) (x)
#endif # endif
/* How many characters in the character set. */ /* 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; extern char *re_syntax_table;
#else /* not SYNTAX_TABLE */ # else /* not SYNTAX_TABLE */
static char re_syntax_table[CHAR_SET_SIZE]; static char re_syntax_table[CHAR_SET_SIZE];
@ -164,9 +160,9 @@ init_syntax_once ()
done = 1; 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 */ #endif /* not emacs */
@ -187,21 +183,21 @@ init_syntax_once ()
Defining isascii to 1 should let any compiler worth its salt Defining isascii to 1 should let any compiler worth its salt
eliminate the && through constant folding." */ eliminate the && through constant folding." */
#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII)) #if defined STDC_HEADERS || (!defined isascii && !defined HAVE_ISASCII)
#define ISASCII(c) 1 # define ISASCII(c) 1
#else #else
#define ISASCII(c) isascii(c) # define ISASCII(c) isascii(c)
#endif #endif
#ifdef isblank #ifdef isblank
#define ISBLANK(c) (ISASCII (c) && isblank (c)) # define ISBLANK(c) (ISASCII (c) && isblank (c))
#else #else
#define ISBLANK(c) ((c) == ' ' || (c) == '\t') # define ISBLANK(c) ((c) == ' ' || (c) == '\t')
#endif #endif
#ifdef isgraph #ifdef isgraph
#define ISGRAPH(c) (ISASCII (c) && isgraph (c)) # define ISGRAPH(c) (ISASCII (c) && isgraph (c))
#else #else
#define ISGRAPH(c) (ISASCII (c) && isprint (c) && !isspace (c)) # define ISGRAPH(c) (ISASCII (c) && isprint (c) && !isspace (c))
#endif #endif
#define ISPRINT(c) (ISASCII (c) && isprint (c)) #define ISPRINT(c) (ISASCII (c) && isprint (c))
@ -216,7 +212,7 @@ init_syntax_once ()
#define ISXDIGIT(c) (ISASCII (c) && isxdigit (c)) #define ISXDIGIT(c) (ISASCII (c) && isxdigit (c))
#ifndef NULL #ifndef NULL
#define NULL (void *)0 # define NULL (void *)0
#endif #endif
/* We remove any previous definition of `SIGN_EXTEND_CHAR', /* We remove any previous definition of `SIGN_EXTEND_CHAR',
@ -225,10 +221,10 @@ init_syntax_once ()
(Per Bothner suggested the basic approach.) */ (Per Bothner suggested the basic approach.) */
#undef SIGN_EXTEND_CHAR #undef SIGN_EXTEND_CHAR
#if __STDC__ #if __STDC__
#define SIGN_EXTEND_CHAR(c) ((signed char) (c)) # define SIGN_EXTEND_CHAR(c) ((signed char) (c))
#else /* not __STDC__ */ #else /* not __STDC__ */
/* As in Harbison and Steele. */ /* 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 #endif
/* Should we use malloc or alloca? If REGEX_MALLOC is not defined, we /* Should we use malloc or alloca? If REGEX_MALLOC is not defined, we
@ -243,74 +239,67 @@ init_syntax_once ()
#ifdef REGEX_MALLOC #ifdef REGEX_MALLOC
#define REGEX_ALLOCATE malloc # define REGEX_ALLOCATE malloc
#define REGEX_REALLOCATE(source, osize, nsize) realloc (source, nsize) # define REGEX_REALLOCATE(source, osize, nsize) realloc (source, nsize)
#define REGEX_FREE free # define REGEX_FREE free
#else /* not REGEX_MALLOC */ #else /* not REGEX_MALLOC */
/* Emacs already defines alloca, sometimes. */ /* Emacs already defines alloca, sometimes. */
#ifndef alloca # ifndef alloca
/* Make alloca work the best possible way. */ /* Make alloca work the best possible way. */
#ifdef __GNUC__ # ifdef __GNUC__
#define alloca __builtin_alloca # define alloca __builtin_alloca
#else /* not __GNUC__ */ # else /* not __GNUC__ */
#if HAVE_ALLOCA_H # if HAVE_ALLOCA_H
#include <alloca.h> # include <alloca.h>
#else /* not __GNUC__ or HAVE_ALLOCA_H */ # endif /* HAVE_ALLOCA_H */
#if 0 /* It is a bad idea to declare alloca. We always cast the result. */ # endif /* not __GNUC__ */
#ifndef _AIX /* Already did AIX, up at the top. */
char *alloca ();
#endif /* not _AIX */
#endif
#endif /* not 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. */ /* Assumes a `char *destination' variable. */
#define REGEX_REALLOCATE(source, osize, nsize) \ # define REGEX_REALLOCATE(source, osize, nsize) \
(destination = (char *) alloca (nsize), \ (destination = (char *) alloca (nsize), \
bcopy (source, destination, osize), \ memcpy (destination, source, osize))
destination)
/* No need to do anything to free, after alloca. */ /* 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 */ #endif /* not REGEX_MALLOC */
/* Define how to allocate the failure stack. */ /* 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)) 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)) r_re_alloc (&failure_stack_ptr, (nsize))
#define REGEX_FREE_STACK(ptr) \ # define REGEX_FREE_STACK(ptr) \
r_alloc_free (&failure_stack_ptr) r_alloc_free (&failure_stack_ptr)
#else /* not using relocating allocator */ #else /* not using relocating allocator */
#ifdef REGEX_MALLOC # ifdef REGEX_MALLOC
#define REGEX_ALLOCATE_STACK malloc # define REGEX_ALLOCATE_STACK malloc
#define REGEX_REALLOCATE_STACK(source, osize, nsize) realloc (source, nsize) # define REGEX_REALLOCATE_STACK(source, osize, nsize) realloc (source, nsize)
#define REGEX_FREE_STACK free # 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) REGEX_REALLOCATE (source, osize, nsize)
/* No need to explicitly free anything. */ /* 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 */ #endif /* not using relocating allocator */
@ -522,10 +511,10 @@ extract_number (dest, source)
*dest += temp << 8; *dest += temp << 8;
} }
#ifndef EXTRACT_MACROS /* To debug the macros. */ # ifndef EXTRACT_MACROS /* To debug the macros. */
#undef EXTRACT_NUMBER # undef EXTRACT_NUMBER
#define EXTRACT_NUMBER(dest, src) extract_number (&dest, src) # define EXTRACT_NUMBER(dest, src) extract_number (&dest, src)
#endif /* not EXTRACT_MACROS */ # endif /* not EXTRACT_MACROS */
#endif /* DEBUG */ #endif /* DEBUG */
@ -550,11 +539,11 @@ extract_number_and_incr (destination, source)
*source += 2; *source += 2;
} }
#ifndef EXTRACT_MACROS # ifndef EXTRACT_MACROS
#undef EXTRACT_NUMBER_AND_INCR # undef EXTRACT_NUMBER_AND_INCR
#define EXTRACT_NUMBER_AND_INCR(dest, src) \ # define EXTRACT_NUMBER_AND_INCR(dest, src) \
extract_number_and_incr (&dest, &src) extract_number_and_incr (&dest, &src)
#endif /* not EXTRACT_MACROS */ # endif /* not EXTRACT_MACROS */
#endif /* DEBUG */ #endif /* DEBUG */
@ -567,21 +556,21 @@ extract_number_and_incr (destination, source)
#ifdef DEBUG #ifdef DEBUG
/* We use standard I/O for debugging. */ /* We use standard I/O for debugging. */
#include <stdio.h> # include <stdio.h>
/* It is useful to test things that ``must'' be true when debugging. */ /* It is useful to test things that ``must'' be true when debugging. */
#include <assert.h> # include <assert.h>
static int debug = 0; static int debug = 0;
#define DEBUG_STATEMENT(e) e # define DEBUG_STATEMENT(e) e
#define DEBUG_PRINT1(x) if (debug) printf (x) # define DEBUG_PRINT1(x) if (debug) printf (x)
#define DEBUG_PRINT2(x1, x2) if (debug) printf (x1, x2) # define DEBUG_PRINT2(x1, x2) if (debug) printf (x1, x2)
#define DEBUG_PRINT3(x1, x2, x3) if (debug) printf (x1, x2, x3) # 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_PRINT4(x1, x2, x3, x4) if (debug) printf (x1, x2, x3, x4)
#define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) \ # define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) \
if (debug) print_partial_compiled_pattern (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) if (debug) print_double_string (w, s1, sz1, s2, sz2)
@ -801,7 +790,7 @@ print_partial_compiled_pattern (start, end)
case wordend: case wordend:
printf ("/wordend"); printf ("/wordend");
#ifdef emacs # ifdef emacs
case before_dot: case before_dot:
printf ("/before_dot"); printf ("/before_dot");
break; break;
@ -825,7 +814,7 @@ print_partial_compiled_pattern (start, end)
mcnt = *p++; mcnt = *p++;
printf ("/%d", mcnt); printf ("/%d", mcnt);
break; break;
#endif /* emacs */ # endif /* emacs */
case wordchar: case wordchar:
printf ("/wordchar"); printf ("/wordchar");
@ -918,16 +907,16 @@ printchar (c)
#else /* not DEBUG */ #else /* not DEBUG */
#undef assert # undef assert
#define assert(e) # define assert(e)
#define DEBUG_STATEMENT(e) # define DEBUG_STATEMENT(e)
#define DEBUG_PRINT1(x) # define DEBUG_PRINT1(x)
#define DEBUG_PRINT2(x1, x2) # define DEBUG_PRINT2(x1, x2)
#define DEBUG_PRINT3(x1, x2, x3) # define DEBUG_PRINT3(x1, x2, x3)
#define DEBUG_PRINT4(x1, x2, x3, x4) # define DEBUG_PRINT4(x1, x2, x3, x4)
#define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) # define DEBUG_PRINT_COMPILED_PATTERN(p, s, e)
#define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) # define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2)
#endif /* not DEBUG */ #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 /* 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. */ what config.h may say. So don't take precautions for it. */
#ifdef __GNUC__ #ifdef __GNUC__
#undef C_ALLOCA # undef C_ALLOCA
#endif #endif
/* The match routines may not allocate if (1) they would do it with malloc /* 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 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; failure stack, but we would still use it for the register vectors;
so REL_ALLOC should not affect this. */ so REL_ALLOC should not affect this. */
#if (defined (C_ALLOCA) || defined (REGEX_MALLOC)) && defined (emacs) #if (defined C_ALLOCA || defined REGEX_MALLOC) && defined emacs
#undef MATCH_MAY_ALLOCATE # undef MATCH_MAY_ALLOCATE
#endif #endif
@ -1035,7 +1024,7 @@ static const char *re_error_msgid[] =
when matching. If this number is exceeded, we allocate more when matching. If this number is exceeded, we allocate more
space, so it is not a hard limit. */ space, so it is not a hard limit. */
#ifndef INIT_FAILURE_ALLOC #ifndef INIT_FAILURE_ALLOC
#define INIT_FAILURE_ALLOC 5 # define INIT_FAILURE_ALLOC 5
#endif #endif
/* Roughly the maximum number of failure points on the stack. Would be /* 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 #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, /* 4400 was enough to cause a crash on Alpha OSF/1,
whose default stack limit is 2mb. */ whose default stack limit is 2mb. */
long int re_max_failures = 4000; long int re_max_failures = 4000;
#else # else
long int re_max_failures = 2000; long int re_max_failures = 2000;
#endif # endif
union fail_stack_elt union fail_stack_elt
{ {
@ -1070,13 +1059,13 @@ typedef struct
#else /* not INT_IS_16BIT */ #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, /* 4400 was enough to cause a crash on Alpha OSF/1,
whose default stack limit is 2mb. */ whose default stack limit is 2mb. */
int re_max_failures = 20000; int re_max_failures = 20000;
#else # else
int re_max_failures = 2000; int re_max_failures = 2000;
#endif # endif
union fail_stack_elt union fail_stack_elt
{ {
@ -1104,7 +1093,7 @@ typedef struct
Do `return -2' if the alloc fails. */ Do `return -2' if the alloc fails. */
#ifdef MATCH_MAY_ALLOCATE #ifdef MATCH_MAY_ALLOCATE
#define INIT_FAIL_STACK() \ # define INIT_FAIL_STACK() \
do { \ do { \
fail_stack.stack = (fail_stack_elt_t *) \ 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)); \
@ -1116,14 +1105,14 @@ typedef struct
fail_stack.avail = 0; \ fail_stack.avail = 0; \
} while (0) } while (0)
#define RESET_FAIL_STACK() REGEX_FREE_STACK (fail_stack.stack) # define RESET_FAIL_STACK() REGEX_FREE_STACK (fail_stack.stack)
#else #else
#define INIT_FAIL_STACK() \ # define INIT_FAIL_STACK() \
do { \ do { \
fail_stack.avail = 0; \ fail_stack.avail = 0; \
} while (0) } while (0)
#define RESET_FAIL_STACK() # define RESET_FAIL_STACK()
#endif #endif
@ -1184,11 +1173,11 @@ typedef struct
/* Used to omit pushing failure point id's when we're not debugging. */ /* Used to omit pushing failure point id's when we're not debugging. */
#ifdef DEBUG #ifdef DEBUG
#define DEBUG_PUSH PUSH_FAILURE_INT # define DEBUG_PUSH PUSH_FAILURE_INT
#define DEBUG_POP(item_addr) *(item_addr) = POP_FAILURE_INT () # define DEBUG_POP(item_addr) *(item_addr) = POP_FAILURE_INT ()
#else #else
#define DEBUG_PUSH(item) # define DEBUG_PUSH(item)
#define DEBUG_POP(item_addr) # define DEBUG_POP(item_addr)
#endif #endif
@ -1286,9 +1275,9 @@ typedef struct
/* Individual items aside from the registers. */ /* Individual items aside from the registers. */
#ifdef DEBUG #ifdef DEBUG
#define NUM_NONREG_ITEMS 5 /* Includes failure point id. */ # define NUM_NONREG_ITEMS 5 /* Includes failure point id. */
#else #else
#define NUM_NONREG_ITEMS 4 # define NUM_NONREG_ITEMS 4
#endif #endif
/* We push at most this many items on the stack. */ /* 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 string passed to us by the user to an unsigned char that we can use
as an array index (in, e.g., `translate'). */ as an array index (in, e.g., `translate'). */
#ifndef PATFETCH #ifndef PATFETCH
#define PATFETCH(c) \ # define PATFETCH(c) \
do {if (p == pend) return REG_EEND; \ do {if (p == pend) return REG_EEND; \
c = (unsigned char) *p++; \ c = (unsigned char) *p++; \
if (translate) c = (unsigned char) translate[c]; \ 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 `char *', to avoid warnings when a string constant is passed. But
when we use a character as a subscript we must make it unsigned. */ when we use a character as a subscript we must make it unsigned. */
#ifndef TRANSLATE #ifndef TRANSLATE
#define TRANSLATE(d) \ # define TRANSLATE(d) \
(translate ? (char) translate[(unsigned char) (d)] : (d)) (translate ? (char) translate[(unsigned char) (d)] : (d))
#endif #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 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. reallocating to 0 bytes. Such thing is not going to work too well.
You have been warned!! */ 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. /* Microsoft C 16-bit versions limit malloc to approx 65512 bytes.
The REALLOC define eliminates a flurry of conversion warnings, The REALLOC define eliminates a flurry of conversion warnings,
but is not required. */ but is not required. */
#define MAX_BUF_SIZE 65500L # define MAX_BUF_SIZE 65500L
#define REALLOC(p,s) realloc ((p), (size_t) (s)) # define REALLOC(p,s) realloc ((p), (size_t) (s))
#else #else
#define MAX_BUF_SIZE (1L << 16) # define MAX_BUF_SIZE (1L << 16)
#define REALLOC(p,s) realloc ((p), (s)) # define REALLOC(p,s) realloc ((p), (s))
#endif #endif
/* Extend the buffer by twice its current size via realloc and /* 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. */ /* Always count groups, whether or not bufp->no_sub is set. */
bufp->re_nsub = 0; bufp->re_nsub = 0;
#if !defined (emacs) && !defined (SYNTAX_TABLE) #if !defined emacs && !defined SYNTAX_TABLE
/* Initialize the syntax table. */ /* Initialize the syntax table. */
init_syntax_once (); init_syntax_once ();
#endif #endif
@ -2842,7 +2831,7 @@ regex_compile (pattern, size, syntax, bufp)
{ {
fail_stack.size = (2 * re_max_failures * MAX_FAILURE_ITEMS); fail_stack.size = (2 * re_max_failures * MAX_FAILURE_ITEMS);
#ifdef emacs # ifdef emacs
if (! fail_stack.stack) if (! fail_stack.stack)
fail_stack.stack fail_stack.stack
= (fail_stack_elt_t *) xmalloc (fail_stack.size = (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_elt_t *) xrealloc (fail_stack.stack,
(fail_stack.size (fail_stack.size
* sizeof (fail_stack_elt_t))); * sizeof (fail_stack_elt_t)));
#else /* not emacs */ # else /* not emacs */
if (! fail_stack.stack) if (! fail_stack.stack)
fail_stack.stack fail_stack.stack
= (fail_stack_elt_t *) malloc (fail_stack.size = (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_elt_t *) realloc (fail_stack.stack,
(fail_stack.size (fail_stack.size
* sizeof (fail_stack_elt_t))); * sizeof (fail_stack_elt_t)));
#endif /* not emacs */ # endif /* not emacs */
} }
regex_grow_registers (num_regs); 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, val = re_match_2_internal (bufp, string1, size1, string2, size2,
startpos, regs, stop); startpos, regs, stop);
#ifndef REGEX_MALLOC #ifndef REGEX_MALLOC
#ifdef C_ALLOCA # ifdef C_ALLOCA
alloca (0); alloca (0);
#endif # endif
#endif #endif
if (val >= 0) if (val >= 0)
@ -3622,8 +3611,8 @@ re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop)
/* Free everything we malloc. */ /* Free everything we malloc. */
#ifdef MATCH_MAY_ALLOCATE #ifdef MATCH_MAY_ALLOCATE
#define FREE_VAR(var) if (var) REGEX_FREE (var); var = NULL # define FREE_VAR(var) if (var) REGEX_FREE (var); var = NULL
#define FREE_VARIABLES() \ # define FREE_VARIABLES() \
do { \ do { \
REGEX_FREE_STACK (fail_stack.stack); \ REGEX_FREE_STACK (fail_stack.stack); \
FREE_VAR (regstart); \ FREE_VAR (regstart); \
@ -3637,7 +3626,7 @@ re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop)
FREE_VAR (reg_info_dummy); \ FREE_VAR (reg_info_dummy); \
} while (0) } while (0)
#else #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 */ #endif /* not MATCH_MAY_ALLOCATE */
/* These values must meet several constraints. They must not be valid /* 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, int result = re_match_2_internal (bufp, NULL, 0, string, size,
pos, regs, size); pos, regs, size);
#ifndef REGEX_MALLOC # ifndef REGEX_MALLOC
#ifdef C_ALLOCA # ifdef C_ALLOCA
alloca (0); alloca (0);
#endif # endif
#endif # endif
return result; return result;
} }
#endif /* not emacs */ #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, int result = re_match_2_internal (bufp, string1, size1, string2, size2,
pos, regs, stop); pos, regs, stop);
#ifndef REGEX_MALLOC #ifndef REGEX_MALLOC
#ifdef C_ALLOCA # ifdef C_ALLOCA
alloca (0); alloca (0);
#endif # endif
#endif #endif
return result; return result;
} }
@ -4460,7 +4449,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
past them. */ past them. */
if (translate if (translate
? bcmp_translate (d, d2, mcnt, translate) ? bcmp_translate (d, d2, mcnt, translate)
: bcmp (d, d2, mcnt)) : memcmp (d, d2, mcnt))
goto fail; goto fail;
d += mcnt, d2 += mcnt; 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 /* Entry points compatible with 4.2 BSD regex library. We don't define
them unless specifically requested. */ 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. */ /* BSD has one and only one pattern buffer. */
static struct re_pattern_buffer re_comp_buf; static struct re_pattern_buffer re_comp_buf;
@ -5687,11 +5676,15 @@ regerror (errcode, preg, errbuf, errbuf_size)
{ {
if (msg_size > 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; errbuf[errbuf_size - 1] = 0;
#endif
} }
else else
strcpy (errbuf, msg); memcpy (errbuf, msg, msg_size);
} }
return msg_size; return msg_size;

View File

@ -124,6 +124,17 @@ __BEGIN_DECLS
_XOPEN_SHM Shared memory interface according to XPG4.2. _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 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 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 option is true for all files. If a symbol is not defined at all, the value

View File

@ -38,6 +38,8 @@
#include <stdio.h> #include <stdio.h>
#include <fnmatch.h> #include <fnmatch.h>
#include <stdio-common/_itoa.h>
/* Undefine the following line for the production version. */ /* Undefine the following line for the production version. */
/* #define NDEBUG 1 */ /* #define NDEBUG 1 */
#include <assert.h> #include <assert.h>
@ -112,9 +114,8 @@ w_addstr (char *buffer, size_t *actlen, size_t *maxlen, const char *str)
if (buffer != NULL) if (buffer != NULL)
{ {
memcpy (&buffer[*actlen], str, len); *((char *) __mempcpy (&buffer[*actlen], str, len)) = '\0';
*actlen += len; *actlen += len;
buffer[*actlen] = '\0';
} }
return buffer; return buffer;
@ -156,7 +157,7 @@ parse_backslash (char **word, size_t *word_length, size_t *max_length,
return WRDE_SYNTAX; return WRDE_SYNTAX;
case '\n': case '\n':
(*offset)++; ++(*offset);
break; break;
default: default:
@ -164,7 +165,7 @@ parse_backslash (char **word, size_t *word_length, size_t *max_length,
if (*word == NULL) if (*word == NULL)
return WRDE_NOSPACE; return WRDE_NOSPACE;
(*offset)++; ++(*offset);
break; break;
} }
@ -363,12 +364,13 @@ parse_glob (char **word, size_t *word_length, size_t *max_length,
if (ifs && !*ifs) if (ifs && !*ifs)
{ {
/* No field splitting allowed */ /* No field splitting allowed */
*word_length = strlen (globbuf.gl_pathv[0]); size_t length = strlen (globbuf.gl_pathv[0]);
*word = realloc (*word, 1 + *word_length); *word = realloc (*word, length + 1);
if (*word == NULL) if (*word == NULL)
goto no_space; 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) 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 = NULL;
*word_length = 0; *word_length = 0;
matching_word = malloc (1 + strlen (globbuf.gl_pathv[0])); matching_word = __strdup (globbuf.gl_pathv[0]);
if (matching_word == NULL) if (matching_word == NULL)
goto no_space; goto no_space;
strcpy (matching_word, globbuf.gl_pathv[0]);
if (w_addword (pwordexp, matching_word) == WRDE_NOSPACE) if (w_addword (pwordexp, matching_word) == WRDE_NOSPACE)
goto no_space; goto no_space;
@ -624,7 +625,7 @@ parse_arith (char **word, size_t *word_length, size_t *max_length,
case ')': case ')':
if (--paren_depth == 0) if (--paren_depth == 0)
{ {
char *result; char result[21]; /* 21 = ceil(log10(2^64)) + 1 */
int numresult = 0; int numresult = 0;
if (bracket || words[1 + *offset] != ')') 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) eval_expr (expr, &numresult) != 0)
return WRDE_SYNTAX; return WRDE_SYNTAX;
result = __alloca (100); result[20] = '\0';
__snprintf (result, 100, "%d", numresult); *word = w_addstr (*word, word_length, max_length,
*word = w_addstr (*word, word_length, max_length, result); _itoa_word (numresult, &result[20], 10, 0));
free (expr); free (expr);
return *word ? 0 : WRDE_NOSPACE; return *word ? 0 : WRDE_NOSPACE;
} }
@ -652,16 +653,16 @@ parse_arith (char **word, size_t *word_length, size_t *max_length,
case ']': case ']':
if (bracket && paren_depth == 1) if (bracket && paren_depth == 1)
{ {
char *result; char result[21]; /* 21 = ceil(log10(2^64)) + 1 */
int numresult = 0; int numresult = 0;
/* Go - evaluate. */ /* Go - evaluate. */
if (*expr && eval_expr (expr, &numresult) != 0) if (*expr && eval_expr (expr, &numresult) != 0)
return WRDE_SYNTAX; return WRDE_SYNTAX;
result = __alloca (100); result[20] = '\0';
__snprintf (result, 100, "%d", numresult); *word = w_addstr (*word, word_length, max_length,
*word = w_addstr (*word, word_length, max_length, result); _itoa_word (numresult, &result[20], 10, 0));
free (expr); free (expr);
return *word ? 0 : WRDE_NOSPACE; 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) if (pid == 0)
{ {
/* Child */ /* Child */
const char *args[4] = { _PATH_BSHELL, "-c", comm, NULL };
/* Redirect input and output */ /* Redirect input and output */
dup2 (fildes[1], 1); 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) if ((flags & WRDE_SHOWERR) == 0)
close (2); close (2);
execl (_PATH_BSHELL, _PATH_BSHELL, "-c", comm, NULL); __execve (_PATH_BSHELL, (char *const *) args, __environ);
/* Bad. What now? */ /* Bad. What now? */
exit (1); abort ();
} }
/* Parent */ /* 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 ((buflen = read (fildes[0], buffer, bufsize)) < 1)
{ {
if (waitpid (pid, NULL, WNOHANG) == 0) if (__waitpid (pid, NULL, WNOHANG) == 0)
continue; continue;
if ((buflen = read (fildes[0], buffer, bufsize)) < 1) if ((buflen = read (fildes[0], buffer, bufsize)) < 1)
break; 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 ((buflen = read (fildes[0], buffer, bufsize)) < 1)
{ {
if (waitpid (pid, NULL, WNOHANG) == 0) if (__waitpid (pid, NULL, WNOHANG) == 0)
continue; continue;
if ((read (fildes[0], buffer, bufsize)) < 1) if ((read (fildes[0], buffer, bufsize)) < 1)
break; break;
@ -856,7 +859,7 @@ parse_comm (char **word, size_t *word_length, size_t *max_length,
break; break;
case '(': case '(':
paren_depth++; ++paren_depth;
default: default:
comm = w_addchar (comm, &comm_length, &comm_maxlen, words[*offset]); comm = w_addchar (comm, &comm_length, &comm_maxlen, words[*offset]);
if (comm == NULL) if (comm == NULL)

View File

@ -26,7 +26,7 @@ static char rcsid[] = "$Id$";
#include <arpa/nameser.h> #include <arpa/nameser.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include "../conf/portability.h" #include <conf/portability.h>
/* /*
* WARNING: Don't even consider trying to compile this on a system where * WARNING: Don't even consider trying to compile this on a system where

View File

@ -32,7 +32,7 @@ struct spent_data {};
#define FALSE(arg) 0 #define FALSE(arg) 0
#include "../nss/nss_files/files-parse.c" #include <nss/nss_files/files-parse.c>
LINE_PARSER LINE_PARSER
(, (,
STRING_FIELD (result->sp_namp, ISCOLON, 0); STRING_FIELD (result->sp_namp, ISCOLON, 0);

View File

@ -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. */ /* Copy existing string so that nothing gets overwritten. */
src = (char *) alloca (rear_ptr - w); src = (char *) alloca (rear_ptr - w);
memcpy (src, w + 1, rear_ptr - w); s = (char *) __mempcpy (src, w + 1, rear_ptr - w) - 1;
s = &src[rear_ptr - w - 1];
w = rear_ptr; w = rear_ptr;
/* Process all characters in the string. */ /* Process all characters in the string. */

View File

@ -45,6 +45,22 @@ canonicalize (const char *name, char *resolved)
long int path_max; long int path_max;
int num_links = 0; 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 #ifdef PATH_MAX
path_max = PATH_MAX; path_max = PATH_MAX;
#else #else
@ -73,21 +89,23 @@ canonicalize (const char *name, char *resolved)
struct stat st; struct stat st;
int n; int n;
/* skip sequence of multiple path-separators: */ /* Skip sequence of multiple path-separators. */
while (*start == '/') ++start; while (*start == '/') ++start;
/* find end of path component: */ /* Find end of path component. */
for (end = start; *end && *end != '/'; ++end); for (end = start; *end && *end != '/'; ++end);
if (end - start == 0) if (end - start == 0)
break; break;
else if (strncmp (start, ".", end - start) == 0) else if (strncmp (start, ".", end - start) == 0)
/* nothing */; /* nothing */;
else if (strncmp (start, "..", end - start) == 0) { else if (strncmp (start, "..", end - start) == 0)
/* back up to previous component, ignore if at root already: */ {
/* Back up to previous component, ignore if at root already. */
if (dest > rpath + 1) if (dest > rpath + 1)
while ((--dest)[-1] != '/'); while ((--dest)[-1] != '/');
} else }
else
{ {
size_t new_size; size_t new_size;
@ -112,8 +130,7 @@ canonicalize (const char *name, char *resolved)
return NULL; return NULL;
} }
memcpy (dest, start, end - start); dest = __mempcpy (dest, start, end - start);
dest += end - start;
*dest = '\0'; *dest = '\0';
if (__lstat (rpath, &st) < 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... */ /* Careful here, end may be a pointer into extra_buf... */
memcpy (&buf[n], end, len + 1); memmove (&extra_buf[n], end, len + 1);
strcpy (extra_buf, buf); memcpy (extra_buf, buf, n);
name = end = extra_buf; name = end = extra_buf;
if (buf[0] == '/') if (buf[0] == '/')

View File

@ -71,17 +71,16 @@ msort_with_tmp (b, n, s, cmp, t)
{ {
if ((*cmp) (b1, b2) <= 0) if ((*cmp) (b1, b2) <= 0)
{ {
memcpy (tmp, b1, s); tmp = (char *) __mempcpy (tmp, b1, s);
b1 += s; b1 += s;
--n1; --n1;
} }
else else
{ {
memcpy (tmp, b2, s); tmp = (char *) __mempcpy (tmp, b2, s);
b2 += s; b2 += s;
--n2; --n2;
} }
tmp += s;
} }
if (n1 > 0) if (n1 > 0)
memcpy (tmp, b1, n1 * s); memcpy (tmp, b1, n1 * s);

View File

@ -117,6 +117,30 @@ main (int argc, char ** argv)
getcwd (cwd, sizeof(buf)); getcwd (cwd, sizeof(buf));
cwd_len = strlen (cwd); 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) for (i = 0; i < (int) (sizeof (symlinks) / sizeof (symlinks[0])); ++i)
symlink (symlinks[i].value, symlinks[i].name); symlink (symlinks[i].value, symlinks[i].name);

View File

@ -18,6 +18,7 @@
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <argz.h> #include <argz.h>
/* Append BUF, of length BUF_LEN to *TO, of length *TO_LEN, reallocating and /* 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) if (new_to)
{ {
memcpy (new_to + *to_len, buf, buf_len); *((char *) __mempcpy (new_to + *to_len, buf, buf_len)) = '\0';
new_to[new_len] = '\0';
*to = new_to; *to = new_to;
*to_len = new_len; *to_len = new_len;
} }

View File

@ -328,17 +328,19 @@ _svcauth_des (register struct svc_req *rqst, register struct rpc_msg *msg)
cache_ref (sid); cache_ref (sid);
if (cred->adc_namekind == ADN_FULLNAME) if (cred->adc_namekind == ADN_FULLNAME)
{ {
size_t full_len;
cred->adc_fullname.window = window; cred->adc_fullname.window = window;
cred->adc_nickname = (u_long) sid; /* save nickname */ cred->adc_nickname = (u_long) sid; /* save nickname */
if (entry->rname != NULL) if (entry->rname != NULL)
{ {
mem_free (entry->rname, strlen (entry->rname) + 1); mem_free (entry->rname, strlen (entry->rname) + 1);
} }
entry->rname = mem_alloc ((u_int) strlen (cred->adc_fullname.name) full_len = strlen (cred->adc_fullname.name) + 1;
+ 1); entry->rname = mem_alloc ((u_int) full_len);
if (entry->rname != NULL) if (entry->rname != NULL)
{ {
strcpy (entry->rname, cred->adc_fullname.name); memcpy (entry->rname, cred->adc_fullname.name, full_len);
} }
else else
{ {

View File

@ -316,8 +316,9 @@ enum
#define _SC_NL_TEXTMAX _SC_NL_TEXTMAX #define _SC_NL_TEXTMAX _SC_NL_TEXTMAX
}; };
#if (defined __USE_POSIX2 || defined __USE_FILE_OFFSET64 \ #if (defined __USE_POSIX2 || defined __USE_UNIX98 \
|| defined __USE_LARGEFILE64 || defined __USE_LARGEFILE) || defined __USE_FILE_OFFSET64 || defined __USE_LARGEFILE64 \
|| defined __USE_LARGEFILE)
/* Values for the NAME argument to `confstr'. */ /* Values for the NAME argument to `confstr'. */
enum enum
{ {
@ -340,8 +341,43 @@ enum
# define _CS_LFS64_LDFLAGS _CS_LFS64_LDFLAGS # define _CS_LFS64_LDFLAGS _CS_LFS64_LDFLAGS
_CS_LFS64_LIBS, _CS_LFS64_LIBS,
# define _CS_LFS64_LIBS _CS_LFS64_LIBS # define _CS_LFS64_LIBS _CS_LFS64_LIBS
_CS_LFS64_LINTFLAGS _CS_LFS64_LINTFLAGS,
# define _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
}; };
#endif #endif

View File

@ -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. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or 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, '='); const char *const name_end = strchr (string, '=');
if (name_end) if (name_end != NULL)
{ {
char *name = alloca (name_end - string + 1); char *name = alloca (name_end - string + 1);
#ifdef _LIBC
*((char *) __mempcpy (name, string, name_end - string)) = '\0';
#else
memcpy (name, string, name_end - string); memcpy (name, string, name_end - string);
name[name_end - string] = '\0'; name[name_end - string] = '\0';
#endif
return setenv (name, name_end + 1, 1); return setenv (name, name_end + 1, 1);
} }

View File

@ -91,6 +91,8 @@ setenv (name, value, replace)
if (__environ == NULL || *ep == NULL) if (__environ == NULL || *ep == NULL)
{ {
char **new_environ; char **new_environ;
char *tmp;
if (__environ == last_environ && __environ != NULL) if (__environ == last_environ && __environ != NULL)
/* We allocated this space; we can extend it. */ /* We allocated this space; we can extend it. */
new_environ = (char **) realloc (last_environ, new_environ = (char **) realloc (last_environ,
@ -117,9 +119,15 @@ setenv (name, value, replace)
memcpy ((char *) new_environ, (char *) __environ, memcpy ((char *) new_environ, (char *) __environ,
size * sizeof (char *)); size * sizeof (char *));
#ifdef _LIBC
tmp = __mempcpy (new_environ[size], name, namelen);
*tmp++ = '=';
__mempcpy (tmp, value, vallen);
#else
memcpy (new_environ[size], name, namelen); memcpy (new_environ[size], name, namelen);
new_environ[size][namelen] = '='; new_environ[size][namelen] = '=';
memcpy (&new_environ[size][namelen + 1], value, vallen); memcpy (&new_environ[size][namelen + 1], value, vallen);
#endif
new_environ[size + 1] = NULL; new_environ[size + 1] = NULL;
@ -138,8 +146,12 @@ setenv (name, value, replace)
return -1; return -1;
} }
*ep = new; *ep = new;
#ifdef _LIBC
*((char *) __mempcpy (*ep, name, namelen)) = '=';
#else
memcpy (*ep, name, namelen); memcpy (*ep, name, namelen);
(*ep)[namelen] = '='; (*ep)[namelen] = '=';
#endif
} }
memcpy (&(*ep)[namelen + 1], value, vallen); memcpy (&(*ep)[namelen + 1], value, vallen);
} }

View File

@ -26,12 +26,12 @@
*/ */
/* AIX requires this to be the first thing in the file. */ /* AIX requires this to be the first thing in the file. */
#if defined (_AIX) && !defined (__GNUC__) #if defined _AIX && !defined __GNUC__
#pragma alloca #pragma alloca
#endif #endif
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "config.h" # include "config.h"
#endif #endif
#include <errno.h> #include <errno.h>
@ -39,92 +39,91 @@
#include <sys/stat.h> #include <sys/stat.h>
#ifdef STDC_HEADERS #ifdef STDC_HEADERS
#include <stddef.h> # include <stddef.h>
#endif #endif
#if !defined(__GNU_LIBRARY__) && !defined(STDC_HEADERS) #if !defined __GNU_LIBRARY__ && !defined STDC_HEADERS
extern int errno; extern int errno;
#endif #endif
#ifndef __set_errno #ifndef __set_errno
#define __set_errno(val) errno = (val) # define __set_errno(val) errno = (val)
#endif #endif
#ifndef NULL #ifndef NULL
#define NULL 0 # define NULL 0
#endif #endif
#if defined (USGr3) && !defined (DIRENT) #if defined USGr3 && !defined DIRENT
#define DIRENT # define DIRENT
#endif /* USGr3 */ #endif /* USGr3 */
#if defined (Xenix) && !defined (SYSNDIR) #if defined Xenix && !defined SYSNDIR
#define SYSNDIR # define SYSNDIR
#endif /* Xenix */ #endif /* Xenix */
#if defined (POSIX) || defined (DIRENT) || defined (__GNU_LIBRARY__) #if defined POSIX || defined DIRENT || defined __GNU_LIBRARY__
#include <dirent.h> # include <dirent.h>
#ifndef __GNU_LIBRARY__ # ifndef __GNU_LIBRARY__
#define D_NAMLEN(d) strlen((d)->d_name) # define D_NAMLEN(d) strlen((d)->d_name)
#else # else
#define HAVE_D_NAMLEN # define HAVE_D_NAMLEN
#define D_NAMLEN(d) ((d)->d_namlen) # define D_NAMLEN(d) ((d)->d_namlen)
#endif # endif
#else /* not POSIX or DIRENT */ #else /* not POSIX or DIRENT */
#define dirent direct # define dirent direct
#define D_NAMLEN(d) ((d)->d_namlen) # define D_NAMLEN(d) ((d)->d_namlen)
#define HAVE_D_NAMLEN # define HAVE_D_NAMLEN
#if defined (USG) && !defined (sgi) # if defined USG && !defined sgi
#if defined (SYSNDIR) # if defined SYSNDIR
#include <sys/ndir.h> # include <sys/ndir.h>
#else /* Not SYSNDIR */ # else /* Not SYSNDIR */
#include "ndir.h" # include "ndir.h"
#endif /* SYSNDIR */ # endif /* SYSNDIR */
#else /* not USG */ # else /* not USG */
#include <sys/dir.h> # include <sys/dir.h>
#endif /* USG */ # endif /* USG */
#endif /* POSIX or DIRENT or __GNU_LIBRARY__ */ #endif /* POSIX or DIRENT or __GNU_LIBRARY__ */
#if defined (HAVE_UNISTD_H) || defined (__GNU_LIBRARY__) #if defined HAVE_UNISTD_H || defined __GNU_LIBRARY__
#include <unistd.h> # include <unistd.h>
#endif #endif
#if (defined (STDC_HEADERS) || defined (__GNU_LIBRARY__) \ #if defined STDC_HEADERS || defined __GNU_LIBRARY__ || defined POSIX
|| defined (POSIX)) # include <stdlib.h>
#include <stdlib.h> # include <string.h>
#include <string.h> # define ANSI_STRING
#define ANSI_STRING
#else /* No standard headers. */ #else /* No standard headers. */
#ifdef USG # ifdef USG
#include <string.h> # include <string.h>
#ifdef NEED_MEMORY_H # ifdef NEED_MEMORY_H
#include <memory.h> # include <memory.h>
#endif # endif
#define ANSI_STRING # define ANSI_STRING
#else /* Not USG. */ # else /* Not USG. */
#ifdef NeXT # ifdef NeXT
#include <string.h> # include <string.h>
#else /* Not NeXT. */ # else /* Not NeXT. */
#include <strings.h> # include <strings.h>
#ifndef bcmp # ifndef bcmp
extern int bcmp (); extern int bcmp ();
#endif # endif
#ifndef bzero # ifndef bzero
extern void bzero (); extern void bzero ();
#endif # endif
#ifndef bcopy # ifndef bcopy
extern void bcopy (); extern void bcopy ();
#endif # endif
#endif /* NeXT. */ # endif /* NeXT. */
#endif /* USG. */ # endif /* USG. */
extern char *malloc (), *realloc (); extern char *malloc (), *realloc ();
extern void free (); extern void free ();
@ -132,59 +131,58 @@ extern void free ();
#endif /* Standard headers. */ #endif /* Standard headers. */
#ifndef ANSI_STRING #ifndef ANSI_STRING
#define memcpy(d, s, n) bcopy((s), (d), (n)) # define memcpy(d, s, n) bcopy((s), (d), (n))
#define memmove memcpy # define memmove memcpy
#endif /* Not ANSI_STRING. */ #endif /* Not ANSI_STRING. */
#if !defined(__alloca) && !defined(__GNU_LIBRARY__) #if !defined __alloca && !defined __GNU_LIBRARY__
#ifdef __GNUC__ # ifdef __GNUC__
#undef alloca # undef alloca
#define alloca(n) __builtin_alloca (n) # define alloca(n) __builtin_alloca (n)
#else /* Not GCC. */ # else /* Not GCC. */
#if defined (sparc) || defined (HAVE_ALLOCA_H) # if defined sparc || defined HAVE_ALLOCA_H
#include <alloca.h> # include <alloca.h>
#else /* Not sparc or HAVE_ALLOCA_H. */ # else /* Not sparc or HAVE_ALLOCA_H. */
#ifndef _AIX # ifndef _AIX
extern char *alloca (); extern char *alloca ();
#endif /* Not _AIX. */ # endif /* Not _AIX. */
#endif /* sparc or HAVE_ALLOCA_H. */ # endif /* sparc or HAVE_ALLOCA_H. */
#endif /* GCC. */ # endif /* GCC. */
#define __alloca alloca # define __alloca alloca
#endif #endif
#if (defined (HAVE_LIMITS_H) || defined (STDC_HEADERS) || \ #if defined HAVE_LIMITS_H || defined STDC_HEADERS || defined __GNU_LIBRARY__
defined (__GNU_LIBRARY__)) # include <limits.h>
#include <limits.h>
#else #else
#include <sys/param.h> # include <sys/param.h>
#endif #endif
#ifndef PATH_MAX #ifndef PATH_MAX
#ifdef MAXPATHLEN # ifdef MAXPATHLEN
#define PATH_MAX MAXPATHLEN # define PATH_MAX MAXPATHLEN
#else # else
#define PATH_MAX 1024 # define PATH_MAX 1024
#endif # endif
#endif #endif
#if !defined (STDC_HEADERS) && !defined (__GNU_LIBRARY__) #if !defined STDC_HEADERS && !defined __GNU_LIBRARY__
#undef size_t # undef size_t
#define size_t unsigned int # define size_t unsigned int
#endif #endif
#if !__STDC__ && !defined (const) #if !__STDC__ && !defined const
#define const # define const
#endif #endif
#ifndef __GNU_LIBRARY__ #ifndef __GNU_LIBRARY__
#define __lstat stat # define __lstat stat
#endif #endif
#ifndef _LIBC #ifndef _LIBC
#define __getcwd getcwd # define __getcwd getcwd
#endif #endif
/* Get the pathname of the current working directory, and put it in SIZE /* 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); new = malloc (dotsize * 2 + 1);
if (new == NULL) if (new == NULL)
return NULL; return NULL;
#ifdef HAVE_MEMPCPY
dotp = mempcpy (new, dots, dotsize);
#else
memcpy (new, dots, dotsize); memcpy (new, dots, dotsize);
dotp = &new[dotsize];
#endif
} }
else else
{ {
new = realloc ((__ptr_t) dotlist, dotsize * 2 + 1); new = realloc ((__ptr_t) dotlist, dotsize * 2 + 1);
if (new == NULL) if (new == NULL)
goto lose; goto lose;
}
memcpy (&new[dotsize], new, dotsize);
dotp = &new[dotsize]; dotp = &new[dotsize];
}
#ifdef HAVE_MEMPCPY
*((char *) mempcpy (dotp, new, dotsize)) = '\0';
dotsize *= 2;
#else
memcpy (dotp, new, dotsize);
dotsize *= 2; dotsize *= 2;
new[dotsize] = '\0'; new[dotsize] = '\0';
#endif
dotlist = new; dotlist = new;
} }
@ -301,9 +309,15 @@ __getcwd (buf, size)
if (mount_point || (ino_t) d->d_ino == thisino) if (mount_point || (ino_t) d->d_ino == thisino)
{ {
char name[dotlist + dotsize - dotp + 1 + _D_ALLOC_NAMLEN (d)]; 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); memcpy (name, dotp, dotlist + dotsize - dotp);
name[dotlist + dotsize - dotp] = '/'; name[dotlist + dotsize - dotp] = '/';
strcpy (&name[dotlist + dotsize - dotp + 1], d->d_name); strcpy (&name[dotlist + dotsize - dotp + 1], d->d_name);
#endif
if (__lstat (name, &st) < 0) if (__lstat (name, &st) < 0)
{ {
int save = errno; int save = errno;

View File

@ -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. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or The GNU C Library is free software; you can redistribute it and/or
@ -71,10 +71,9 @@ ttyname (fd)
(void) closedir (dirstream); (void) closedir (dirstream);
return NULL; return NULL;
} }
(void) memcpy (name, dev, sizeof (dev) - 1); *((char *) __mempcpy (name, dev, sizeof (dev) - 1)) = '/';
name[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) if (stat (name, &st) == 0 && st.st_dev == mydev)
{ {
(void) closedir (dirstream); (void) closedir (dirstream);

View File

@ -53,11 +53,10 @@ __writev (fd, vector, count)
#define min(a, b) ((a) > (b) ? (b) : (a)) #define min(a, b) ((a) > (b) ? (b) : (a))
size_t copy = min (vector[i].iov_len, to_copy); 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; to_copy -= copy;
if (bytes == 0) if (to_copy == 0)
break; break;
} }

View File

@ -96,10 +96,7 @@ __readdir_r (DIR *dirp, struct dirent *entry, struct dirent **result)
} while (dp->d_ino == 0); } while (dp->d_ino == 0);
if (dp != NULL) if (dp != NULL)
{ *result = memcpy (entry, dp, reclen);
memcpy (entry, dp, reclen);
*result = entry;
}
__libc_lock_unlock (dirp->lock); __libc_lock_unlock (dirp->lock);

View File

@ -30,6 +30,7 @@ __gethostname (name, len)
size_t len; size_t len;
{ {
struct utsname buf; struct utsname buf;
size_t node_len;
if (name == NULL) if (name == NULL)
{ {
@ -40,13 +41,14 @@ __gethostname (name, len)
if (uname (&buf)) if (uname (&buf))
return -1; return -1;
if (strlen (buf.nodename) + 1 > len) node_len = strlen (buf.nodename) + 1;
if (node_len > len)
{ {
__set_errno (EINVAL); __set_errno (EINVAL);
return -1; return -1;
} }
strcpy (name, buf.nodename); memcpy (name, buf.nodename, node_len);
return 0; return 0;
} }

View File

@ -89,6 +89,14 @@ extern char *tzname[];
# endif # endif
#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 #ifndef __P
# if defined (__GNUC__) || (defined (__STDC__) && __STDC__) # if defined (__GNUC__) || (defined (__STDC__) && __STDC__)
# define __P(args) args # define __P(args) args
@ -194,8 +202,7 @@ static const char zeroes[16] = /* "0000000000000000" */
do \ do \
{ \ { \
int _this = _len > 16 ? 16 : _len; \ int _this = _len > 16 ? 16 : _len; \
memcpy ((P), spaces, _this); \ (P) = mempcpy ((P), spaces, _this); \
(P) += _this; \
_len -= _this; \ _len -= _this; \
} \ } \
while (_len > 0); \ while (_len > 0); \
@ -208,8 +215,7 @@ static const char zeroes[16] = /* "0000000000000000" */
do \ do \
{ \ { \
int _this = _len > 16 ? 16 : _len; \ int _this = _len > 16 ? 16 : _len; \
memcpy ((P), zeroes, _this); \ (P) = mempcpy ((P), zeroes, _this); \
(P) += _this; \
_len -= _this; \ _len -= _this; \
} \ } \
while (_len > 0); \ while (_len > 0); \

View File

@ -134,7 +134,7 @@ __tzfile_read (const char *file)
{ {
const char *tzdir; const char *tzdir;
unsigned int len, tzdir_len; unsigned int len, tzdir_len;
char *new; char *new, *tmp;
tzdir = __secure_getenv ("TZDIR"); tzdir = __secure_getenv ("TZDIR");
if (tzdir == NULL || *tzdir == '\0') if (tzdir == NULL || *tzdir == '\0')
@ -146,9 +146,9 @@ __tzfile_read (const char *file)
tzdir_len = strlen (tzdir); tzdir_len = strlen (tzdir);
len = strlen (file) + 1; len = strlen (file) + 1;
new = (char *) __alloca (tzdir_len + 1 + len); new = (char *) __alloca (tzdir_len + 1 + len);
memcpy (new, tzdir, tzdir_len); tmp = __mempcpy (new, tzdir, tzdir_len);
new[tzdir_len] = '/'; *tmp++ = '/';
memcpy (&new[tzdir_len + 1], file, len); __mempcpy (tmp, file, len);
file = new; file = new;
} }
@ -316,8 +316,7 @@ __tzfile_default (const char *std, const char *dst,
__use_tzfile = 0; __use_tzfile = 0;
return; return;
} }
memcpy (zone_names, std, stdlen); __mempcpy (__mempcpy (zone_names, std, stdlen), dst, dstlen);
memcpy (&zone_names[stdlen], dst, dstlen);
/* Find the standard and daylight time offsets used by the rule file. /* Find the standard and daylight time offsets used by the rule file.
We choose the offsets in the types of each flavor that are We choose the offsets in the types of each flavor that are

View File

@ -33,7 +33,5 @@ wcsdup (s)
if (new == NULL) if (new == NULL)
return NULL; return NULL;
memcpy (new, (void *) s, len); return (wchar_t *) memcpy (new, (void *) s, len);
return (wchar_t *) new;
} }