diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-09-18 16:03:01 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-09-18 16:03:01 +0000 |
commit | c7babc8defee55e492af641a5a556db521c08dfa (patch) | |
tree | e4924912fd85dad90b6a534928ada8aac3840841 /libiberty | |
parent | 360d95d3597873aa977dec5595964c330c8c39a5 (diff) | |
download | gcc-c7babc8defee55e492af641a5a556db521c08dfa.tar.gz |
* strnlen.c: New file.
* configure.ac: Check for strnlen, add it to AC_LIBOBJ if it's not
present.
* Makefile.in: Rebuild dependencies.
(CFILES): Add strnlen.c.
(CONFIGURED_OFILES): Add ./strnlen.$(objext).
* configure, config.in, functions.texi: Rebuild.
* maint-tool: Accept .def files in the include directory.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@191432 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libiberty')
-rw-r--r-- | libiberty/ChangeLog | 12 | ||||
-rw-r--r-- | libiberty/Makefile.in | 25 | ||||
-rw-r--r-- | libiberty/config.in | 3 | ||||
-rwxr-xr-x | libiberty/configure | 13 | ||||
-rw-r--r-- | libiberty/configure.ac | 8 | ||||
-rw-r--r-- | libiberty/functions.texi | 70 | ||||
-rw-r--r-- | libiberty/maint-tool | 2 | ||||
-rw-r--r-- | libiberty/strnlen.c | 30 |
8 files changed, 141 insertions, 22 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index 9540b4808c5..3f601a8546e 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,15 @@ +2012-09-18 Ian Lance Taylor <iant@google.com> + + * strnlen.c: New file. + * configure.ac: Check for strnlen, add it to AC_LIBOBJ if it's not + present. + * Makefile.in: Rebuild dependencies. + (CFILES): Add strnlen.c. + (CONFIGURED_OFILES): Add ./strnlen.$(objext). + * configure, config.in, functions.texi: Rebuild. + + * maint-tool: Accept .def files in the include directory. + 2012-09-18 Florian Weimer <fweimer@redhat.com> PR other/54411 diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in index 0a5da3178b1..1ba8cf1ccb2 100644 --- a/libiberty/Makefile.in +++ b/libiberty/Makefile.in @@ -151,7 +151,7 @@ CFILES = alloca.c argv.c asprintf.c atexit.c \ spaces.c splay-tree.c stack-limit.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 strndup.c strverscmp.c \ + strtoul.c strndup.c strnlen.c strverscmp.c \ timeval-utils.c tmpnam.c \ unlink-if-ordinary.c \ vasprintf.c vfork.c vfprintf.c vprintf.c vsnprintf.c vsprintf.c \ @@ -215,9 +215,9 @@ CONFIGURED_OFILES = ./asprintf.$(objext) ./atexit.$(objext) \ ./sigsetmask.$(objext) ./snprintf.$(objext) \ ./stpcpy.$(objext) ./stpncpy.$(objext) ./strcasecmp.$(objext) \ ./strchr.$(objext) ./strdup.$(objext) ./strncasecmp.$(objext) \ - ./strncmp.$(objext) ./strndup.$(objext) ./strrchr.$(objext) \ - ./strstr.$(objext) ./strtod.$(objext) ./strtol.$(objext) \ - ./strtoul.$(objext) ./strverscmp.$(objext) \ + ./strncmp.$(objext) ./strndup.$(objext) ./strnlen.$(objext) \ + ./strrchr.$(objext) ./strstr.$(objext) ./strtod.$(objext) \ + ./strtol.$(objext) ./strtoul.$(objext) ./strverscmp.$(objext) \ ./tmpnam.$(objext) \ ./vasprintf.$(objext) ./vfork.$(objext) ./vfprintf.$(objext) \ ./vprintf.$(objext) ./vsnprintf.$(objext) ./vsprintf.$(objext) \ @@ -622,8 +622,8 @@ $(CONFIGURED_OFILES): stamp-picdir else true; fi $(COMPILE.c) $(srcdir)/crc32.c $(OUTPUT_OPTION) -./dwarfnames.$(objext): $(srcdir)/dwarfnames.c $(INCDIR)/dwarf2.h \ - $(INCDIR)/dwarf2.def +./dwarfnames.$(objext): $(srcdir)/dwarfnames.c $(INCDIR)/dwarf2.def \ + $(INCDIR)/dwarf2.h if [ x"$(PICFLAG)" != x ]; then \ $(COMPILE.c) $(PICFLAG) $(srcdir)/dwarfnames.c -o pic/$@; \ else true; fi @@ -656,7 +656,8 @@ $(CONFIGURED_OFILES): stamp-picdir else true; fi $(COMPILE.c) $(srcdir)/fibheap.c $(OUTPUT_OPTION) -./filename_cmp.$(objext): $(srcdir)/filename_cmp.c config.h $(INCDIR)/filenames.h \ +./filename_cmp.$(objext): $(srcdir)/filename_cmp.c config.h $(INCDIR)/ansidecl.h \ + $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \ $(INCDIR)/safe-ctype.h if [ x"$(PICFLAG)" != x ]; then \ $(COMPILE.c) $(PICFLAG) $(srcdir)/filename_cmp.c -o pic/$@; \ @@ -757,7 +758,7 @@ $(CONFIGURED_OFILES): stamp-picdir $(COMPILE.c) $(srcdir)/insque.c $(OUTPUT_OPTION) ./lbasename.$(objext): $(srcdir)/lbasename.c config.h $(INCDIR)/ansidecl.h \ - $(INCDIR)/filenames.h $(INCDIR)/libiberty.h \ + $(INCDIR)/filenames.h $(INCDIR)/hashtab.h $(INCDIR)/libiberty.h \ $(INCDIR)/safe-ctype.h if [ x"$(PICFLAG)" != x ]; then \ $(COMPILE.c) $(PICFLAG) $(srcdir)/lbasename.c -o pic/$@; \ @@ -1043,7 +1044,7 @@ $(CONFIGURED_OFILES): stamp-picdir else true; fi $(COMPILE.c) $(srcdir)/splay-tree.c $(OUTPUT_OPTION) -./stack-limit.$(objext): $(srcdir)/stack-limit.c config.h +./stack-limit.$(objext): $(srcdir)/stack-limit.c config.h $(INCDIR)/ansidecl.h if [ x"$(PICFLAG)" != x ]; then \ $(COMPILE.c) $(PICFLAG) $(srcdir)/stack-limit.c -o pic/$@; \ else true; fi @@ -1104,6 +1105,12 @@ $(CONFIGURED_OFILES): stamp-picdir else true; fi $(COMPILE.c) $(srcdir)/strndup.c $(OUTPUT_OPTION) +./strnlen.$(objext): $(srcdir)/strnlen.c config.h + if [ x"$(PICFLAG)" != x ]; then \ + $(COMPILE.c) $(PICFLAG) $(srcdir)/strnlen.c -o pic/$@; \ + else true; fi + $(COMPILE.c) $(srcdir)/strnlen.c $(OUTPUT_OPTION) + ./strrchr.$(objext): $(srcdir)/strrchr.c $(INCDIR)/ansidecl.h if [ x"$(PICFLAG)" != x ]; then \ $(COMPILE.c) $(PICFLAG) $(srcdir)/strrchr.c -o pic/$@; \ diff --git a/libiberty/config.in b/libiberty/config.in index 17c4c2e4414..1cf9c11b6ee 100644 --- a/libiberty/config.in +++ b/libiberty/config.in @@ -262,6 +262,9 @@ /* Define to 1 if you have the `strndup' function. */ #undef HAVE_STRNDUP +/* Define to 1 if you have the `strnlen' function. */ +#undef HAVE_STRNLEN + /* Define to 1 if you have the `strrchr' function. */ #undef HAVE_STRRCHR diff --git a/libiberty/configure b/libiberty/configure index 6e98352f356..536702742dd 100755 --- a/libiberty/configure +++ b/libiberty/configure @@ -5340,6 +5340,7 @@ funcs="$funcs strchr" funcs="$funcs strdup" funcs="$funcs strncasecmp" funcs="$funcs strndup" +funcs="$funcs strnlen" funcs="$funcs strrchr" funcs="$funcs strstr" funcs="$funcs strtod" @@ -5380,8 +5381,8 @@ if test "x" = "y"; then random realpath rename rindex \ sbrk setenv setproctitle setrlimit sigsetmask snprintf spawnve spawnvpe \ stpcpy stpncpy strcasecmp strchr strdup \ - strerror strncasecmp strndup strrchr strsignal strstr strtod strtol \ - strtoul strverscmp sysconf sysctl sysmp \ + strerror strncasecmp strndup strnlen strrchr strsignal strstr strtod \ + strtol strtoul strverscmp sysconf sysctl sysmp \ table times tmpnam \ vasprintf vfprintf vprintf vsprintf \ wait3 wait4 waitpid @@ -5663,6 +5664,12 @@ esac esac case " $LIBOBJS " in + *" strnlen.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS strnlen.$ac_objext" + ;; +esac + + case " $LIBOBJS " in *" strverscmp.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strverscmp.$ac_objext" ;; @@ -5683,7 +5690,7 @@ esac for f in $funcs; do case "$f" in - asprintf | basename | bcmp | bcopy | bzero | clock | ffs | getpagesize | index | insque | mempcpy | mkstemps | random | rindex | sigsetmask | stpcpy | stpncpy | strdup | strndup | strverscmp | vasprintf | waitpid) + asprintf | basename | bcmp | bcopy | bzero | clock | ffs | getpagesize | index | insque | mempcpy | mkstemps | random | rindex | sigsetmask | stpcpy | stpncpy | strdup | strndup | strnlen | strverscmp | vasprintf | waitpid) ;; *) n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` diff --git a/libiberty/configure.ac b/libiberty/configure.ac index 754b66a0619..c7638942644 100644 --- a/libiberty/configure.ac +++ b/libiberty/configure.ac @@ -322,6 +322,7 @@ funcs="$funcs strchr" funcs="$funcs strdup" funcs="$funcs strncasecmp" funcs="$funcs strndup" +funcs="$funcs strnlen" funcs="$funcs strrchr" funcs="$funcs strstr" funcs="$funcs strtod" @@ -362,8 +363,8 @@ if test "x" = "y"; then random realpath rename rindex \ sbrk setenv setproctitle setrlimit sigsetmask snprintf spawnve spawnvpe \ stpcpy stpncpy strcasecmp strchr strdup \ - strerror strncasecmp strndup strrchr strsignal strstr strtod strtol \ - strtoul strverscmp sysconf sysctl sysmp \ + strerror strncasecmp strndup strnlen strrchr strsignal strstr strtod \ + strtol strtoul strverscmp sysconf sysctl sysmp \ table times tmpnam \ vasprintf vfprintf vprintf vsprintf \ wait3 wait4 waitpid) @@ -442,13 +443,14 @@ if test -n "${with_target_subdir}"; then AC_LIBOBJ([stpcpy]) AC_LIBOBJ([stpncpy]) AC_LIBOBJ([strndup]) + AC_LIBOBJ([strnlen]) AC_LIBOBJ([strverscmp]) AC_LIBOBJ([vasprintf]) AC_LIBOBJ([waitpid]) for f in $funcs; do case "$f" in - asprintf | basename | bcmp | bcopy | bzero | clock | ffs | getpagesize | index | insque | mempcpy | mkstemps | random | rindex | sigsetmask | stpcpy | stpncpy | strdup | strndup | strverscmp | vasprintf | waitpid) + asprintf | basename | bcmp | bcopy | bzero | clock | ffs | getpagesize | index | insque | mempcpy | mkstemps | random | rindex | sigsetmask | stpcpy | stpncpy | strdup | strndup | strnlen | strverscmp | vasprintf | waitpid) ;; *) n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` diff --git a/libiberty/functions.texi b/libiberty/functions.texi index c9df186be0f..9323ff9f2e4 100644 --- a/libiberty/functions.texi +++ b/libiberty/functions.texi @@ -84,7 +84,7 @@ is respectively less than, matching, or greater than the array member. @end deftypefn -@c argv.c:142 +@c argv.c:135 @deftypefn Extension char** buildargv (char *@var{sp}) Given a pointer to a string, parse the string extracting fields @@ -95,7 +95,7 @@ remains unchanged. The last element of the vector is followed by a @code{NULL} element. All of the memory for the pointer array and copies of the string -is obtained from @code{malloc}. All of the memory can be returned to the +is obtained from @code{xmalloc}. All of the memory can be returned to the system with the single function call @code{freeargv}, which takes the returned result of @code{buildargv}, as it's argument. @@ -166,6 +166,14 @@ pointer encountered. Pointers to empty strings are ignored. @end deftypefn +@c argv.c:470 +@deftypefn Extension int countargv (char **@var{argv}) + +Return the number of elements in @var{argv}. +Returns zero if @var{argv} is NULL. + +@end deftypefn + @c crc32.c:141 @deftypefn Extension {unsigned int} crc32 (const unsigned char *@var{buf}, @ int @var{len}, unsigned int @var{init}) @@ -224,7 +232,7 @@ symbolic name or message. @end deftypefn -@c argv.c:361 +@c argv.c:341 @deftypefn Extension void expandargv (int *@var{argcp}, char ***@var{argvp}) The @var{argcp} and @code{argvp} arguments are pointers to the usual @@ -296,7 +304,24 @@ and backward slashes are equal. @end deftypefn -@c filename_cmp.c:81 +@c filename_cmp.c:178 +@deftypefn Extension int filename_eq (const void *@var{s1}, const void *@var{s2}) + +Return non-zero if file names @var{s1} and @var{s2} are equivalent. +This function is for use with hashtab.c hash tables. + +@end deftypefn + +@c filename_cmp.c:147 +@deftypefn Extension hashval_t filename_hash (const void *@var{s}) + +Return the hash value for file name @var{s} that will be compared +using filename_cmp. +This function is for use with hashtab.c hash tables. + +@end deftypefn + +@c filename_cmp.c:89 @deftypefn Extension int filename_ncmp (const char *@var{s1}, const char *@var{s2}, size_t @var{n}) Return zero if the two file names @var{s1} and @var{s2} are equivalent @@ -376,7 +401,7 @@ unchanged. @end deftypefn -@c argv.c:97 +@c argv.c:90 @deftypefn Extension void freeargv (char **@var{vector}) Free an argument vector that was built using @code{buildargv}. Simply @@ -1465,6 +1490,13 @@ deallocate values. @end deftypefn +@c stack-limit.c:28 +@deftypefn Extension void stack_limit_increase (unsigned long @var{pref}) + +Attempt to increase stack size limit to @var{pref} bytes if possible. + +@end deftypefn + @c stpcpy.c:23 @deftypefn Supplemental char* stpcpy (char *@var{dst}, const char *@var{src}) @@ -1574,6 +1606,16 @@ memory was available. The result is always NUL terminated. @end deftypefn +@c strnlen.c:6 +@deftypefn Supplemental size_t strnlen (const char *@var{s}, size_t @var{maxlen}) + +Returns the length of @var{s}, as with @code{strlen}, but never looks +past the first @var{maxlen} characters in the string. If there is no +'\0' character in the first @var{maxlen} characters, returns +@var{maxlen}. + +@end deftypefn + @c strrchr.c:6 @deftypefn Supplemental char* strrchr (const char *@var{s}, int @var{c}) @@ -1728,6 +1770,22 @@ This function is especially useful when dealing with filename sorting, because filenames frequently hold indices/version numbers. @end deftypefun +@c timeval-utils.c:43 +@deftypefn Extension void timeval_add (struct timeval *@var{a}, @ + struct timeval *@var{b}, struct timeval *@var{result}) + +Adds @var{a} to @var{b} and stores the result in @var{result}. + +@end deftypefn + +@c timeval-utils.c:67 +@deftypefn Extension void timeval_sub (struct timeval *@var{a}, @ + struct timeval *@var{b}, struct timeval *@var{result}) + +Subtracts @var{b} from @var{a} and stores the result in @var{result}. + +@end deftypefn + @c tmpnam.c:3 @deftypefn Supplemental char* tmpnam (char *@var{s}) @@ -1829,7 +1887,7 @@ does the return value. The third argument is unused in @libib{}. @end deftypefn -@c argv.c:306 +@c argv.c:286 @deftypefn Extension int writeargv (const char **@var{argv}, FILE *@var{file}) Write each member of ARGV, handling all necessary quoting, to the file diff --git a/libiberty/maint-tool b/libiberty/maint-tool index 36b92034f33..d50f8959a38 100644 --- a/libiberty/maint-tool +++ b/libiberty/maint-tool @@ -222,7 +222,7 @@ sub deps { opendir(INC, $incdir); while ($f = readdir INC) { - next unless $f =~ /\.h$/; + next unless $f =~ /\.h$/ || $f =~ /\.def$/; $mine{$f} = "\$(INCDIR)/$f"; $deps{$f} = join(' ', &deps_for("$incdir/$f")); } diff --git a/libiberty/strnlen.c b/libiberty/strnlen.c new file mode 100644 index 00000000000..4934973adca --- /dev/null +++ b/libiberty/strnlen.c @@ -0,0 +1,30 @@ +/* Portable version of strnlen. + This function is in the public domain. */ + +/* + +@deftypefn Supplemental size_t strnlen (const char *@var{s}, size_t @var{maxlen}) + +Returns the length of @var{s}, as with @code{strlen}, but never looks +past the first @var{maxlen} characters in the string. If there is no +'\0' character in the first @var{maxlen} characters, returns +@var{maxlen}. + +@end deftypefn + +*/ + +#include "config.h" + +#include <stddef.h> + +size_t +strnlen (const char *s, size_t maxlen) +{ + size_t i; + + for (i = 0; i < maxlen; ++i) + if (s[i] == '\0') + break; + return i; +} |