From 10b57b38b38d1308425d0d372884fd1a0fffec06 Mon Sep 17 00:00:00 2001 From: DJ Delorie Date: Wed, 16 Apr 2003 03:51:54 +0000 Subject: [PATCH] merge from gcc --- libiberty/ChangeLog | 11 +++ libiberty/Makefile.in | 19 +++-- libiberty/config.in | 9 +++ libiberty/configure | 163 ++++++++++++++++++++------------------- libiberty/configure.in | 7 +- libiberty/functions.texi | 28 ++++++- libiberty/mempcpy.c | 48 ++++++++++++ libiberty/stpcpy.c | 49 ++++++++++++ libiberty/stpncpy.c | 54 +++++++++++++ 9 files changed, 297 insertions(+), 91 deletions(-) create mode 100644 libiberty/mempcpy.c create mode 100644 libiberty/stpcpy.c create mode 100644 libiberty/stpncpy.c diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index 9a1cf0d8fb3..1e290a559a1 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,14 @@ +2003-04-15 Kaveh R. Ghazi + + * mempcpy.c, stpcpy.c, stpncpy.c: New files. + * configure.in (funcs, AC_CHECK_FUNCS): Add mempcpy, stpcpy + and stpncpy. + * Makefile.in (CFILES): Add mempcpy.c, stpcpy.c and stpncpy.c. + (CONFIGURED_OFILES): Add mempcpy.o, stpcpy.o and stpncpy.o. + Regenerate dependencies. + + * functions.texi, configure, config.in: Regenerated. + 2003-04-15 Kaveh R. Ghazi * argv.c: Fix comments. diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in index 2e9bff43fbb..af512a2b1fa 100644 --- a/libiberty/Makefile.in +++ b/libiberty/Makefile.in @@ -140,7 +140,7 @@ CFILES = alloca.c argv.c asprintf.c atexit.c \ lrealpath.c \ make-relative-prefix.c \ make-temp-file.c md5.c memchr.c memcmp.c memcpy.c memmove.c \ - memset.c mkstemps.c \ + mempcpy.c memset.c mkstemps.c \ objalloc.c obstack.c \ partition.c \ pex-djgpp.c pex-mpw.c pex-msdos.c pex-os2.c \ @@ -148,9 +148,9 @@ CFILES = alloca.c argv.c asprintf.c atexit.c \ physmem.c putenv.c \ random.c regex.c rename.c rindex.c \ safe-ctype.c setenv.c sigsetmask.c sort.c spaces.c \ - splay-tree.c strcasecmp.c strchr.c strdup.c strerror.c \ - strncasecmp.c strncmp.c strrchr.c strsignal.c strstr.c \ - strtod.c strtol.c strtoul.c \ + splay-tree.c stpcpy.c stpncpy.c strcasecmp.c strchr.c strdup.c \ + strerror.c strncasecmp.c strncmp.c strrchr.c strsignal.c \ + strstr.c strtod.c strtol.c strtoul.c \ ternary.c tmpnam.c \ vasprintf.c vfork.c vfprintf.c vprintf.c vsprintf.c \ waitpid.c \ @@ -186,14 +186,14 @@ CONFIGURED_OFILES = asprintf.o atexit.o \ ffs.o \ getcwd.o getpagesize.o \ index.o insque.o \ - memchr.o memcmp.o memcpy.o memmove.o memset.o mkstemps.o \ + memchr.o memcmp.o memcpy.o memmove.o mempcpy.o memset.o mkstemps.o \ pex-djgpp.o pex-mpw.o pex-msdos.o pex-os2.o \ pex-unix.o pex-win32.o \ putenv.o \ random.o rename.o rindex.o \ - setenv.o sigsetmask.o strcasecmp.o strchr.o strdup.o \ - strncasecmp.o strncmp.o strrchr.o strstr.o strtod.o strtol.o \ - strtoul.o \ + setenv.o sigsetmask.o stpcpy.o stpncpy.o strcasecmp.o strchr.o \ + strdup.o strncasecmp.o strncmp.o strrchr.o strstr.o strtod.o \ + strtol.o strtoul.o \ tmpnam.o \ vasprintf.o vfork.o vfprintf.o vprintf.o vsprintf.o \ waitpid.o @@ -459,6 +459,7 @@ memchr.o: $(INCDIR)/ansidecl.h memcmp.o: $(INCDIR)/ansidecl.h memcpy.o: $(INCDIR)/ansidecl.h memmove.o: $(INCDIR)/ansidecl.h +mempcpy.o: $(INCDIR)/ansidecl.h memset.o: $(INCDIR)/ansidecl.h mkstemps.o: config.h $(INCDIR)/ansidecl.h objalloc.o: config.h $(INCDIR)/ansidecl.h $(INCDIR)/objalloc.h @@ -490,6 +491,8 @@ sort.o: config.h $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h \ spaces.o: $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h splay-tree.o: config.h $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h \ $(INCDIR)/splay-tree.h +stpcpy.o: $(INCDIR)/ansidecl.h +stpncpy.o: $(INCDIR)/ansidecl.h strcasecmp.o: $(INCDIR)/ansidecl.h strchr.o: $(INCDIR)/ansidecl.h strdup.o: $(INCDIR)/ansidecl.h diff --git a/libiberty/config.in b/libiberty/config.in index f0e174696cb..0efae6d901e 100644 --- a/libiberty/config.in +++ b/libiberty/config.in @@ -105,6 +105,9 @@ /* Define if you have the memmove function. */ #undef HAVE_MEMMOVE +/* Define if you have the mempcpy function. */ +#undef HAVE_MEMPCPY + /* Define if you have the memset function. */ #undef HAVE_MEMSET @@ -147,6 +150,12 @@ /* Define if you have the sigsetmask function. */ #undef HAVE_SIGSETMASK +/* Define if you have the stpcpy function. */ +#undef HAVE_STPCPY + +/* Define if you have the stpncpy function. */ +#undef HAVE_STPNCPY + /* Define if you have the strcasecmp function. */ #undef HAVE_STRCASECMP diff --git a/libiberty/configure b/libiberty/configure index 8c5582d5a2c..ed8b3886625 100755 --- a/libiberty/configure +++ b/libiberty/configure @@ -1708,6 +1708,7 @@ funcs="$funcs memchr" funcs="$funcs memcmp" funcs="$funcs memcpy" funcs="$funcs memmove" +funcs="$funcs mempcpy" funcs="$funcs memset" funcs="$funcs mkstemps" funcs="$funcs putenv" @@ -1716,6 +1717,8 @@ funcs="$funcs rename" funcs="$funcs rindex" funcs="$funcs setenv" funcs="$funcs sigsetmask" +funcs="$funcs stpcpy" +funcs="$funcs stpncpy" funcs="$funcs strcasecmp" funcs="$funcs strchr" funcs="$funcs strdup" @@ -1746,12 +1749,12 @@ if test "x" = "y"; then for ac_func in asprintf atexit basename bcmp bcopy bsearch bzero calloc clock do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:1750: checking for $ac_func" >&5 +echo "configure:1753: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1781: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -1801,12 +1804,12 @@ done for ac_func in getcwd getpagesize index insque mkstemps memchr memcmp memcpy do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:1805: checking for $ac_func" >&5 +echo "configure:1808: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1836: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -1853,15 +1856,15 @@ else fi done - for ac_func in memmove memset putenv random rename rindex sigsetmask + for ac_func in memmove mempcpy memset putenv random rename rindex sigsetmask do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:1860: checking for $ac_func" >&5 +echo "configure:1863: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1891: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -1908,15 +1911,15 @@ else fi done - for ac_func in strcasecmp setenv strchr strdup strncasecmp strrchr strstr + for ac_func in strcasecmp setenv stpcpy stpncpy strchr strdup strncasecmp strrchr strstr do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:1915: checking for $ac_func" >&5 +echo "configure:1918: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1946: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -1966,12 +1969,12 @@ done for ac_func in strtod strtol strtoul tmpnam vasprintf vfprintf vprintf do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:1970: checking for $ac_func" >&5 +echo "configure:1973: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2001: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -2021,12 +2024,12 @@ done for ac_func in vsprintf waitpid getrusage on_exit psignal strerror strsignal do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2025: checking for $ac_func" >&5 +echo "configure:2028: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2056: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -2076,12 +2079,12 @@ done for ac_func in sysconf times sbrk gettimeofday ffs do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2080: checking for $ac_func" >&5 +echo "configure:2083: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2111: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -2131,12 +2134,12 @@ done for ac_func in pstat_getstatic pstat_getdynamic sysmp getsysinfo table sysctl do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2135: checking for $ac_func" >&5 +echo "configure:2138: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2166: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -2186,12 +2189,12 @@ done for ac_func in realpath canonicalize_file_name do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2190: checking for $ac_func" >&5 +echo "configure:2193: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2221: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -2448,7 +2451,7 @@ if test -z "${setobjs}"; then # We haven't set the list of objects yet. Use the standard autoconf # tests. This will only work if the compiler works. echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:2452: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:2455: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -2459,12 +2462,12 @@ cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF -#line 2463 "configure" +#line 2466 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:2468: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2471: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -2490,19 +2493,19 @@ if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:2494: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:2497: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross for ac_func in $funcs do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2501: checking for $ac_func" >&5 +echo "configure:2504: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2532: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -2552,12 +2555,12 @@ done echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6 -echo "configure:2556: checking whether alloca needs Cray hooks" >&5 +echo "configure:2559: checking whether alloca needs Cray hooks" >&5 if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&6 if test $ac_cv_os_cray = yes; then for ac_func in _getb67 GETB67 getb67; do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2586: checking for $ac_func" >&5 +echo "configure:2589: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2617: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -2636,7 +2639,7 @@ fi fi echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6 -echo "configure:2640: checking stack direction for C alloca" >&5 +echo "configure:2643: checking stack direction for C alloca" >&5 if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2644,7 +2647,7 @@ else ac_cv_c_stack_direction=0 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2670: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_c_stack_direction=1 else @@ -2685,17 +2688,17 @@ EOF ac_safe=`echo "vfork.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for vfork.h""... $ac_c" 1>&6 -echo "configure:2689: checking for vfork.h" >&5 +echo "configure:2692: checking for vfork.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2699: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2702: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2720,18 +2723,18 @@ else fi echo $ac_n "checking for working vfork""... $ac_c" 1>&6 -echo "configure:2724: checking for working vfork" >&5 +echo "configure:2727: checking for working vfork" >&5 if eval "test \"`echo '$''{'ac_cv_func_vfork_works'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test "$cross_compiling" = yes; then echo $ac_n "checking for vfork""... $ac_c" 1>&6 -echo "configure:2730: checking for vfork" >&5 +echo "configure:2733: checking for vfork" >&5 if eval "test \"`echo '$''{'ac_cv_func_vfork'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2761: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_vfork=yes" else @@ -2776,7 +2779,7 @@ fi ac_cv_func_vfork_works=$ac_cv_func_vfork else cat > conftest.$ac_ext < @@ -2871,7 +2874,7 @@ main() { } } EOF -if { (eval echo configure:2875: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2878: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_vfork_works=yes else @@ -2903,12 +2906,12 @@ fi for ac_func in _doprnt do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2907: checking for $ac_func" >&5 +echo "configure:2910: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2938: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -2961,12 +2964,12 @@ done for ac_func in _doprnt do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2965: checking for $ac_func" >&5 +echo "configure:2968: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2996: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3017,19 +3020,19 @@ done for v in $vars; do echo $ac_n "checking for $v""... $ac_c" 1>&6 -echo "configure:3021: checking for $v" >&5 +echo "configure:3024: checking for $v" >&5 if eval "test \"`echo '$''{'libiberty_cv_var_$v'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3036: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "libiberty_cv_var_$v=yes" else @@ -3055,12 +3058,12 @@ EOF for ac_func in $checkfuncs do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3059: checking for $ac_func" >&5 +echo "configure:3062: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3090: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3108,12 +3111,12 @@ fi done echo $ac_n "checking whether canonicalize_file_name must be declared""... $ac_c" 1>&6 -echo "configure:3112: checking whether canonicalize_file_name must be declared" >&5 +echo "configure:3115: checking whether canonicalize_file_name must be declared" >&5 if eval "test \"`echo '$''{'libiberty_cv_decl_needed_canonicalize_file_name'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3142: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* libiberty_cv_decl_needed_canonicalize_file_name=no else @@ -3171,17 +3174,17 @@ for ac_hdr in unistd.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:3175: checking for $ac_hdr" >&5 +echo "configure:3178: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3185: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3188: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -3210,12 +3213,12 @@ done for ac_func in getpagesize do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3214: checking for $ac_func" >&5 +echo "configure:3217: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3245: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3263,7 +3266,7 @@ fi done echo $ac_n "checking for working mmap""... $ac_c" 1>&6 -echo "configure:3267: checking for working mmap" >&5 +echo "configure:3270: checking for working mmap" >&5 if eval "test \"`echo '$''{'ac_cv_func_mmap_fixed_mapped'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3271,7 +3274,7 @@ else ac_cv_func_mmap_fixed_mapped=no else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3418: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_mmap_fixed_mapped=yes else @@ -3435,7 +3438,7 @@ fi echo $ac_n "checking for working strncmp""... $ac_c" 1>&6 -echo "configure:3439: checking for working strncmp" >&5 +echo "configure:3442: checking for working strncmp" >&5 if eval "test \"`echo '$''{'ac_cv_func_strncmp_works'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3443,7 +3446,7 @@ else ac_cv_func_strncmp_works=no else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3514: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_strncmp_works=yes else diff --git a/libiberty/configure.in b/libiberty/configure.in index 767d9dd794c..d6c2649feb4 100644 --- a/libiberty/configure.in +++ b/libiberty/configure.in @@ -177,6 +177,7 @@ funcs="$funcs memchr" funcs="$funcs memcmp" funcs="$funcs memcpy" funcs="$funcs memmove" +funcs="$funcs mempcpy" funcs="$funcs memset" funcs="$funcs mkstemps" funcs="$funcs putenv" @@ -185,6 +186,8 @@ funcs="$funcs rename" funcs="$funcs rindex" funcs="$funcs setenv" funcs="$funcs sigsetmask" +funcs="$funcs stpcpy" +funcs="$funcs stpncpy" funcs="$funcs strcasecmp" funcs="$funcs strchr" funcs="$funcs strdup" @@ -214,8 +217,8 @@ checkfuncs="$checkfuncs getsysinfo table sysctl" if test "x" = "y"; then AC_CHECK_FUNCS(asprintf atexit basename bcmp bcopy bsearch bzero calloc clock) AC_CHECK_FUNCS(getcwd getpagesize index insque mkstemps memchr memcmp memcpy) - AC_CHECK_FUNCS(memmove memset putenv random rename rindex sigsetmask) - AC_CHECK_FUNCS(strcasecmp setenv strchr strdup strncasecmp strrchr strstr) + AC_CHECK_FUNCS(memmove mempcpy memset putenv random rename rindex sigsetmask) + AC_CHECK_FUNCS(strcasecmp setenv stpcpy stpncpy strchr strdup strncasecmp strrchr strstr) AC_CHECK_FUNCS(strtod strtol strtoul tmpnam vasprintf vfprintf vprintf) AC_CHECK_FUNCS(vsprintf waitpid getrusage on_exit psignal strerror strsignal) AC_CHECK_FUNCS(sysconf times sbrk gettimeofday ffs) diff --git a/libiberty/functions.texi b/libiberty/functions.texi index 2c7b9e1276a..bb35549df19 100644 --- a/libiberty/functions.texi +++ b/libiberty/functions.texi @@ -398,7 +398,7 @@ and a path ending in @code{/} returns the empty string after it. Given a pointer to a string containing a pathname, returns a canonical version of the filename. Symlinks will be resolved, and ``.'' and ``..'' components will be simplified. The returned value will be allocated using -@code{xmalloc} or @code{malloc}. +@code{malloc}, or @code{NULL} will be returned on a memory allocation error. @end deftypefn @@ -476,6 +476,14 @@ Copies @var{count} bytes from memory area @var{from} to memory area @end deftypefn +@c mempcpy.c:23 +@deftypefn Supplemental void* mempcpy (void *@var{out}, const void *@var{in}, size_t @var{length}) + +Copies @var{length} bytes from memory region @var{in} to region +@var{out}. Returns a pointer to @var{out} + @var{length}. + +@end deftypefn + @c memset.c:6 @deftypefn Supplemental void* memset (void *@var{s}, int @var{c}, size_t @var{count}) @@ -674,6 +682,24 @@ valid until at least the next call. @end deftypefn +@c stpcpy.c:23 +@deftypefn Supplemental char* stpcpy (char *@var{dst}, const char *@var{src}) + +Copies the string @var{src} into @var{dst}. Returns a pointer to +@var{dst} + strlen(@var{src}). + +@end deftypefn + +@c stpncpy.c:23 +@deftypefn Supplemental char* stpncpy (char *@var{dst}, const char *@var{src}, size_t @var{len}) + +Copies the string @var{src} into @var{dst}, copying exactly @var{len} +and padding with zeros if necessary. If @var{len} < strlen(@var{src}) +then return @var{dst} + @var{len}, otherwise returns @var{dst} + +strlen(@var{src}). + +@end deftypefn + @c strcasecmp.c:15 @deftypefn Supplemental int strcasecmp (const char *@var{s1}, const char *@var{s2}) diff --git a/libiberty/mempcpy.c b/libiberty/mempcpy.c new file mode 100644 index 00000000000..b0dccfa6167 --- /dev/null +++ b/libiberty/mempcpy.c @@ -0,0 +1,48 @@ +/* Implement the mempcpy function. + Copyright (C) 2003 Free Software Foundation, Inc. + Written by Kaveh R. Ghazi . + +This file is part of the libiberty library. +Libiberty is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +Libiberty is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with libiberty; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* + +@deftypefn Supplemental void* mempcpy (void *@var{out}, const void *@var{in}, size_t @var{length}) + +Copies @var{length} bytes from memory region @var{in} to region +@var{out}. Returns a pointer to @var{out} + @var{length}. + +@end deftypefn + +*/ + +#include +#ifdef ANSI_PROTOTYPES +#include +#else +#define size_t unsigned long +#endif + +extern PTR memcpy PARAMS ((PTR, const PTR, size_t)); + +PTR +mempcpy (dst, src, len) + PTR dst; + const PTR src; + size_t len; +{ + return (char *) memcpy (dst, src, len) + len; +} diff --git a/libiberty/stpcpy.c b/libiberty/stpcpy.c new file mode 100644 index 00000000000..a589642fd88 --- /dev/null +++ b/libiberty/stpcpy.c @@ -0,0 +1,49 @@ +/* Implement the stpcpy function. + Copyright (C) 2003 Free Software Foundation, Inc. + Written by Kaveh R. Ghazi . + +This file is part of the libiberty library. +Libiberty is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +Libiberty is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with libiberty; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* + +@deftypefn Supplemental char* stpcpy (char *@var{dst}, const char *@var{src}) + +Copies the string @var{src} into @var{dst}. Returns a pointer to +@var{dst} + strlen(@var{src}). + +@end deftypefn + +*/ + +#include +#ifdef ANSI_PROTOTYPES +#include +#else +#define size_t unsigned long +#endif + +extern size_t strlen PARAMS ((const char *)); +extern PTR memcpy PARAMS ((PTR, const PTR, size_t)); + +char * +stpcpy (dst, src) + char *dst; + const char *src; +{ + const size_t len = strlen (src); + return (char *) memcpy (dst, src, len + 1) + len; +} diff --git a/libiberty/stpncpy.c b/libiberty/stpncpy.c new file mode 100644 index 00000000000..0984340ba2c --- /dev/null +++ b/libiberty/stpncpy.c @@ -0,0 +1,54 @@ +/* Implement the stpncpy function. + Copyright (C) 2003 Free Software Foundation, Inc. + Written by Kaveh R. Ghazi . + +This file is part of the libiberty library. +Libiberty is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +Libiberty is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with libiberty; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* + +@deftypefn Supplemental char* stpncpy (char *@var{dst}, const char *@var{src}, size_t @var{len}) + +Copies the string @var{src} into @var{dst}, copying exactly @var{len} +and padding with zeros if necessary. If @var{len} < strlen(@var{src}) +then return @var{dst} + @var{len}, otherwise returns @var{dst} + +strlen(@var{src}). + +@end deftypefn + +*/ + +#include +#ifdef ANSI_PROTOTYPES +#include +#else +#define size_t unsigned long +#endif + +extern size_t strlen PARAMS ((const char *)); +extern PTR strncpy PARAMS ((char *, const char *, size_t)); + +char * +stpncpy (dst, src, len) + char *dst; + const char *src; + size_t len; +{ + size_t n = strlen (src); + if (n > len) + n = len; + return strncpy (dst, src, len) + n; +} -- 2.30.2