From patchwork Wed Apr 8 17:19:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 6090 Received: (qmail 57206 invoked by alias); 8 Apr 2015 17:19:58 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 57125 invoked by uid 89); 8 Apr 2015 17:19:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.0 required=5.0 tests=AWL, BAYES_50, KAM_LINEPADDING, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 08 Apr 2015 17:19:52 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t38HJpdA028797 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 8 Apr 2015 13:19:51 -0400 Received: from brno.lan (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t38HJm9c019273 for ; Wed, 8 Apr 2015 13:19:50 -0400 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 2/2] Import strtok_r gnulib module Date: Wed, 8 Apr 2015 18:19:47 +0100 Message-Id: <1428513587-8471-3-git-send-email-palves@redhat.com> In-Reply-To: <1428513587-8471-1-git-send-email-palves@redhat.com> References: <1428513587-8471-1-git-send-email-palves@redhat.com> gdb/linux-tdep.c recently gained a strtok_r use. That broke --enable-targets=all with some versions of mingw64, which don't have strtok_r: https://sourceware.org/ml/gdb-patches/2015-04/msg00266.html Fix that by importing the strtok_r gnulib module. gdb/ChangeLog: 2015-04-08 Pedro Alves * gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add strtok_r. * gnulib/Makefile.in (aclocal_m4_deps): Add import/m4/strtok_r.m4. * gnulib/configure, gnulib/config.in, gnulib/aclocal.m4: Regenerate. * gnulib/import/Makefile.am: Update. * gnulib/import/Makefile.in: Update. * gnulib/import/m4/gnulib-cache.m4: Update. * gnulib/import/m4/gnulib-comp.m4: Update. * gnulib/import/m4/strtok_r.m4: New file. * gnulib/import/strtok_r.c: New file. --- gdb/gnulib/Makefile.in | 1 + gdb/gnulib/aclocal.m4 | 1 + gdb/gnulib/config.in | 10 +++ gdb/gnulib/configure | 125 +++++++++++++++++++++++++++++++++++ gdb/gnulib/import/Makefile.am | 11 ++- gdb/gnulib/import/Makefile.in | 10 +-- gdb/gnulib/import/m4/gnulib-cache.m4 | 3 +- gdb/gnulib/import/m4/gnulib-comp.m4 | 9 +++ gdb/gnulib/import/m4/strtok_r.m4 | 74 +++++++++++++++++++++ gdb/gnulib/import/strtok_r.c | 76 +++++++++++++++++++++ gdb/gnulib/update-gnulib.sh | 1 + 11 files changed, 315 insertions(+), 6 deletions(-) create mode 100644 gdb/gnulib/import/m4/strtok_r.m4 create mode 100644 gdb/gnulib/import/strtok_r.c diff --git a/gdb/gnulib/Makefile.in b/gdb/gnulib/Makefile.in index f385ee8..921d2ba 100644 --- a/gdb/gnulib/Makefile.in +++ b/gdb/gnulib/Makefile.in @@ -242,6 +242,7 @@ aclocal_m4_deps = \ import/m4/stddef_h.m4 \ import/m4/stdint.m4 \ import/m4/string_h.m4 \ + import/m4/strtok_r.m4 \ import/m4/sys_types_h.m4 \ import/m4/unistd_h.m4 \ import/m4/warn-on-use.m4 \ diff --git a/gdb/gnulib/aclocal.m4 b/gdb/gnulib/aclocal.m4 index 76fb3f0..8341de9 100644 --- a/gdb/gnulib/aclocal.m4 +++ b/gdb/gnulib/aclocal.m4 @@ -1074,6 +1074,7 @@ m4_include([import/m4/stdio_h.m4]) m4_include([import/m4/stdlib_h.m4]) m4_include([import/m4/string_h.m4]) m4_include([import/m4/strstr.m4]) +m4_include([import/m4/strtok_r.m4]) m4_include([import/m4/sys_stat_h.m4]) m4_include([import/m4/sys_types_h.m4]) m4_include([import/m4/time_h.m4]) diff --git a/gdb/gnulib/config.in b/gdb/gnulib/config.in index 5d8018d..8201b6d 100644 --- a/gdb/gnulib/config.in +++ b/gdb/gnulib/config.in @@ -117,6 +117,9 @@ /* Define to 1 when the gnulib module strstr should be tested. */ #undef GNULIB_TEST_STRSTR +/* Define to 1 when the gnulib module strtok_r should be tested. */ +#undef GNULIB_TEST_STRTOK_R + /* Define to 1 if you have the `alarm' function. */ #undef HAVE_ALARM @@ -165,6 +168,10 @@ */ #undef HAVE_DECL_MEMMEM +/* Define to 1 if you have the declaration of `strtok_r', and to 0 if you + don't. */ +#undef HAVE_DECL_STRTOK_R + /* Define to 1 if you have the declaration of `towlower', and to 0 if you don't. */ #undef HAVE_DECL_TOWLOWER @@ -1062,6 +1069,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H +/* Define to 1 if you have the `strtok_r' function. */ +#undef HAVE_STRTOK_R + /* Define to 1 if you have the `symlink' function. */ #undef HAVE_SYMLINK diff --git a/gdb/gnulib/configure b/gdb/gnulib/configure index 29e49b9..e88e7c7 100644 --- a/gdb/gnulib/configure +++ b/gdb/gnulib/configure @@ -5250,6 +5250,7 @@ fi # Code from module strnlen1: # Code from module strstr: # Code from module strstr-simple: + # Code from module strtok_r: # Code from module sys_stat: # Code from module sys_types: # Code from module time: @@ -11059,6 +11060,17 @@ $as_echo "$gl_cv_func_strstr_works_always" >&6; } esac fi +ac_fn_c_check_decl "$LINENO" "strtok_r" "ac_cv_have_decl_strtok_r" "$ac_includes_default" +if test "x$ac_cv_have_decl_strtok_r" = x""yes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_STRTOK_R $ac_have_decl +_ACEOF + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stat file-mode macros are broken" >&5 $as_echo_n "checking whether stat file-mode macros are broken... " >&6; } if test "${ac_cv_header_stat_broken+set}" = set; then : @@ -16597,6 +16609,119 @@ $as_echo "#define GNULIB_TEST_STRSTR 1" >>confdefs.h + for ac_func in strtok_r +do : + ac_fn_c_check_func "$LINENO" "strtok_r" "ac_cv_func_strtok_r" +if test "x$ac_cv_func_strtok_r" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_STRTOK_R 1 +_ACEOF + +fi +done + + if test $ac_cv_func_strtok_r = yes; then + HAVE_STRTOK_R=1 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether strtok_r works" >&5 +$as_echo_n "checking whether strtok_r works... " >&6; } +if test "${gl_cv_func_strtok_r_works+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + + case "$host_os" in + # Guess no on glibc systems. + *-gnu*) gl_cv_func_strtok_r_works="guessing no";; + *) gl_cv_func_strtok_r_works="guessing yes";; + esac + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #ifndef __OPTIMIZE__ + # define __OPTIMIZE__ 1 + #endif + #undef __OPTIMIZE_SIZE__ + #undef __NO_INLINE__ + #include + #include + +int +main () +{ +static const char dummy[] = "\177\01a"; + char delimiters[] = "xxxxxxxx"; + char *save_ptr = (char *) dummy; + strtok_r (delimiters, "x", &save_ptr); + strtok_r (NULL, "x", &save_ptr); + return 0; + + ; + return 0; +} + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_strtok_r_works=yes +else + gl_cv_func_strtok_r_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_strtok_r_works" >&5 +$as_echo "$gl_cv_func_strtok_r_works" >&6; } + case "$gl_cv_func_strtok_r_works" in + *no) + UNDEFINE_STRTOK_R=1 + ;; + esac + else + HAVE_STRTOK_R=0 + fi + + if test $ac_cv_have_decl_strtok_r = no; then + HAVE_DECL_STRTOK_R=0 + fi + + if test $HAVE_STRTOK_R = 0 || test $REPLACE_STRTOK_R = 1; then + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS strtok_r.$ac_objext" + + + : + + fi + + + + + + GNULIB_STRTOK_R=1 + + + + + +$as_echo "#define GNULIB_TEST_STRTOK_R 1" >>confdefs.h + + + + + + + diff --git a/gdb/gnulib/import/Makefile.am b/gdb/gnulib/import/Makefile.am index f1f14ef..d25231a 100644 --- a/gdb/gnulib/import/Makefile.am +++ b/gdb/gnulib/import/Makefile.am @@ -21,7 +21,7 @@ # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=import --m4-base=import/m4 --doc-base=doc --tests-base=tests --aux-dir=import/extra --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca canonicalize-lgpl dirent dirfd errno fnmatch-gnu frexpl inttypes lstat memchr memmem pathmax readlink rename strstr sys_stat unistd update-copyright wchar wctype-h +# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=import --m4-base=import/m4 --doc-base=doc --tests-base=tests --aux-dir=import/extra --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca canonicalize-lgpl dirent dirfd errno fnmatch-gnu frexpl inttypes lstat memchr memmem pathmax readlink rename strstr strtok_r sys_stat unistd update-copyright wchar wctype-h AUTOMAKE_OPTIONS = 1.5 gnits @@ -1401,6 +1401,15 @@ EXTRA_libgnu_a_SOURCES += strstr.c ## end gnulib module strstr-simple +## begin gnulib module strtok_r + + +EXTRA_DIST += strtok_r.c + +EXTRA_libgnu_a_SOURCES += strtok_r.c + +## end gnulib module strtok_r + ## begin gnulib module sys_stat BUILT_SOURCES += sys/stat.h diff --git a/gdb/gnulib/import/Makefile.in b/gdb/gnulib/import/Makefile.in index 3dfd74e..97c6963 100644 --- a/gdb/gnulib/import/Makefile.in +++ b/gdb/gnulib/import/Makefile.in @@ -36,7 +36,7 @@ # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=import --m4-base=import/m4 --doc-base=doc --tests-base=tests --aux-dir=import/extra --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca canonicalize-lgpl dirent dirfd errno fnmatch-gnu frexpl inttypes lstat memchr memmem pathmax readlink rename strstr sys_stat unistd update-copyright wchar wctype-h +# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=import --m4-base=import/m4 --doc-base=doc --tests-base=tests --aux-dir=import/extra --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca canonicalize-lgpl dirent dirfd errno fnmatch-gnu frexpl inttypes lstat memchr memmem pathmax readlink rename strstr strtok_r sys_stat unistd update-copyright wchar wctype-h @@ -125,6 +125,7 @@ am__aclocal_m4_deps = $(top_srcdir)/import/m4/00gnulib.m4 \ $(top_srcdir)/import/m4/stdlib_h.m4 \ $(top_srcdir)/import/m4/string_h.m4 \ $(top_srcdir)/import/m4/strstr.m4 \ + $(top_srcdir)/import/m4/strtok_r.m4 \ $(top_srcdir)/import/m4/sys_stat_h.m4 \ $(top_srcdir)/import/m4/sys_types_h.m4 \ $(top_srcdir)/import/m4/time_h.m4 \ @@ -1235,8 +1236,8 @@ EXTRA_DIST = m4/gnulib-cache.m4 alloca.c alloca.in.h \ $(top_srcdir)/import/extra/snippet/c++defs.h \ $(top_srcdir)/import/extra/snippet/warn-on-use.h stat.c \ stdbool.in.h stddef.in.h stdint.in.h stdio.in.h stdlib.in.h \ - streq.h string.in.h str-two-way.h strstr.c sys_stat.in.h \ - sys_types.in.h time.in.h unistd.in.h \ + streq.h string.in.h str-two-way.h strstr.c strtok_r.c \ + sys_stat.in.h sys_types.in.h time.in.h unistd.in.h \ $(top_srcdir)/import/extra/update-copyright verify.h \ wchar.in.h wctype.in.h @@ -1280,7 +1281,7 @@ EXTRA_libgnu_a_SOURCES = alloca.c canonicalize-lgpl.c dirfd.c float.c \ itold.c fnmatch.c fnmatch_loop.c frexp.c frexp.c frexpl.c \ isnan.c isnand.c isnan.c isnanl.c lstat.c malloc.c mbrtowc.c \ mbsinit.c mbsrtowcs-state.c mbsrtowcs.c memchr.c memmem.c \ - readlink.c rename.c rmdir.c stat.c strstr.c + readlink.c rename.c rmdir.c stat.c strstr.c strtok_r.c charset_alias = $(DESTDIR)$(libdir)/charset.alias charset_tmp = $(DESTDIR)$(libdir)/charset.tmp @@ -1383,6 +1384,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stripslash.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strnlen1.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strstr.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strtok_r.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unistd.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wctype-h.Po@am__quote@ diff --git a/gdb/gnulib/import/m4/gnulib-cache.m4 b/gdb/gnulib/import/m4/gnulib-cache.m4 index 7cc681a..959cdb6 100644 --- a/gdb/gnulib/import/m4/gnulib-cache.m4 +++ b/gdb/gnulib/import/m4/gnulib-cache.m4 @@ -27,7 +27,7 @@ # Specification in the form of a command-line invocation: -# gnulib-tool --import --dir=. --lib=libgnu --source-base=import --m4-base=import/m4 --doc-base=doc --tests-base=tests --aux-dir=import/extra --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca canonicalize-lgpl dirent dirfd errno fnmatch-gnu frexpl inttypes lstat memchr memmem pathmax readlink rename strstr sys_stat unistd update-copyright wchar wctype-h +# gnulib-tool --import --dir=. --lib=libgnu --source-base=import --m4-base=import/m4 --doc-base=doc --tests-base=tests --aux-dir=import/extra --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca canonicalize-lgpl dirent dirfd errno fnmatch-gnu frexpl inttypes lstat memchr memmem pathmax readlink rename strstr strtok_r sys_stat unistd update-copyright wchar wctype-h # Specification in the form of a few gnulib-tool.m4 macro invocations: gl_LOCAL_DIR([]) @@ -47,6 +47,7 @@ gl_MODULES([ readlink rename strstr + strtok_r sys_stat unistd update-copyright diff --git a/gdb/gnulib/import/m4/gnulib-comp.m4 b/gdb/gnulib/import/m4/gnulib-comp.m4 index f280cf2..29f8f73 100644 --- a/gdb/gnulib/import/m4/gnulib-comp.m4 +++ b/gdb/gnulib/import/m4/gnulib-comp.m4 @@ -101,6 +101,7 @@ AC_DEFUN([gl_EARLY], # Code from module strnlen1: # Code from module strstr: # Code from module strstr-simple: + # Code from module strtok_r: # Code from module sys_stat: # Code from module sys_types: # Code from module time: @@ -278,6 +279,12 @@ AC_DEFUN([gl_INIT], AC_LIBOBJ([strstr]) fi gl_STRING_MODULE_INDICATOR([strstr]) + gl_FUNC_STRTOK_R + if test $HAVE_STRTOK_R = 0 || test $REPLACE_STRTOK_R = 1; then + AC_LIBOBJ([strtok_r]) + gl_PREREQ_STRTOK_R + fi + gl_STRING_MODULE_INDICATOR([strtok_r]) gl_HEADER_SYS_STAT_H AC_PROG_MKDIR_P gl_SYS_TYPES_H @@ -496,6 +503,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/strnlen1.c lib/strnlen1.h lib/strstr.c + lib/strtok_r.c lib/sys_stat.in.h lib/sys_types.in.h lib/time.in.h @@ -566,6 +574,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/stdlib_h.m4 m4/string_h.m4 m4/strstr.m4 + m4/strtok_r.m4 m4/sys_stat_h.m4 m4/sys_types_h.m4 m4/time_h.m4 diff --git a/gdb/gnulib/import/m4/strtok_r.m4 b/gdb/gnulib/import/m4/strtok_r.m4 new file mode 100644 index 0000000..60e33a6 --- /dev/null +++ b/gdb/gnulib/import/m4/strtok_r.m4 @@ -0,0 +1,74 @@ +# strtok_r.m4 serial 13 +dnl Copyright (C) 2002-2004, 2006-2007, 2009-2012 Free Software Foundation, +dnl Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_STRTOK_R], +[ + dnl The strtok_r() declaration in lib/string.in.h uses 'restrict'. + AC_REQUIRE([AC_C_RESTRICT]) + + AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CHECK_FUNCS([strtok_r]) + if test $ac_cv_func_strtok_r = yes; then + HAVE_STRTOK_R=1 + dnl glibc 2.7 has a bug in strtok_r that causes a segmentation fault + dnl when the second argument to strtok_r is a constant string that has + dnl exactly one byte and compiling with optimization. This bug is, for + dnl example, present in the glibc 2.7-18 package in Debian "lenny". + dnl See . + AC_CACHE_CHECK([whether strtok_r works], [gl_cv_func_strtok_r_works], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM([[ + #ifndef __OPTIMIZE__ + # define __OPTIMIZE__ 1 + #endif + #undef __OPTIMIZE_SIZE__ + #undef __NO_INLINE__ + #include + #include + ]], + [[static const char dummy[] = "\177\01a"; + char delimiters[] = "xxxxxxxx"; + char *save_ptr = (char *) dummy; + strtok_r (delimiters, "x", &save_ptr); + strtok_r (NULL, "x", &save_ptr); + return 0; + ]]) + ], + [gl_cv_func_strtok_r_works=yes], + [gl_cv_func_strtok_r_works=no], + [ +changequote(,)dnl + case "$host_os" in + # Guess no on glibc systems. + *-gnu*) gl_cv_func_strtok_r_works="guessing no";; + *) gl_cv_func_strtok_r_works="guessing yes";; + esac +changequote([,])dnl + ]) + ]) + case "$gl_cv_func_strtok_r_works" in + *no) + dnl We could set REPLACE_STRTOK_R=1 here, but it's only the macro + dnl version in which is wrong. The code compiled + dnl into libc is fine. + UNDEFINE_STRTOK_R=1 + ;; + esac + else + HAVE_STRTOK_R=0 + fi + AC_CHECK_DECLS_ONCE([strtok_r]) + if test $ac_cv_have_decl_strtok_r = no; then + HAVE_DECL_STRTOK_R=0 + fi +]) + +# Prerequisites of lib/strtok_r.c. +AC_DEFUN([gl_PREREQ_STRTOK_R], [ + : +]) diff --git a/gdb/gnulib/import/strtok_r.c b/gdb/gnulib/import/strtok_r.c new file mode 100644 index 0000000..e1499bc --- /dev/null +++ b/gdb/gnulib/import/strtok_r.c @@ -0,0 +1,76 @@ +/* Reentrant string tokenizer. Generic version. + Copyright (C) 1991, 1996-1999, 2001, 2004, 2007, 2009-2012 Free Software + Foundation, Inc. + This file is part of the GNU C Library. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include + +#ifdef _LIBC +# undef strtok_r +# undef __strtok_r +#else +# define __strtok_r strtok_r +# define __rawmemchr strchr +#endif + +/* Parse S into tokens separated by characters in DELIM. + If S is NULL, the saved pointer in SAVE_PTR is used as + the next starting point. For example: + char s[] = "-abc-=-def"; + char *sp; + x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def" + x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL + x = strtok_r(NULL, "=", &sp); // x = NULL + // s = "abc\0-def\0" +*/ +char * +__strtok_r (char *s, const char *delim, char **save_ptr) +{ + char *token; + + if (s == NULL) + s = *save_ptr; + + /* Scan leading delimiters. */ + s += strspn (s, delim); + if (*s == '\0') + { + *save_ptr = s; + return NULL; + } + + /* Find the end of the token. */ + token = s; + s = strpbrk (token, delim); + if (s == NULL) + /* This token finishes the string. */ + *save_ptr = __rawmemchr (token, '\0'); + else + { + /* Terminate the token and make *SAVE_PTR point past it. */ + *s = '\0'; + *save_ptr = s + 1; + } + return token; +} +#ifdef weak_alias +libc_hidden_def (__strtok_r) +weak_alias (__strtok_r, strtok_r) +#endif diff --git a/gdb/gnulib/update-gnulib.sh b/gdb/gnulib/update-gnulib.sh index 957c89a..f85b71e 100755 --- a/gdb/gnulib/update-gnulib.sh +++ b/gdb/gnulib/update-gnulib.sh @@ -45,6 +45,7 @@ IMPORTED_GNULIB_MODULES="\ readlink \ rename \ strstr \ + strtok_r \ sys_stat \ unistd \ update-copyright \