Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] update-gnulib.sh: work around aclocal warning with Perl >= 5.16
  2015-04-08 17:19 [PATCH 0/2] Import gnulib strtok_r module Pedro Alves
  2015-04-08 17:19 ` [PATCH 2/2] Import strtok_r gnulib module Pedro Alves
@ 2015-04-08 17:19 ` Pedro Alves
  2015-04-09  9:03   ` Yao Qi
  1 sibling, 1 reply; 8+ messages in thread
From: Pedro Alves @ 2015-04-08 17:19 UTC (permalink / raw)
  To: gdb-patches

gdb/ChangeLog:
2015-04-08  Pedro Alves  <palves@redhat.com>

	* gnulib/update-gnulib.sh (aclocal version check): Filter out
	"called too early to check prototype".
---
 gdb/gnulib/update-gnulib.sh | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
 mode change 100644 => 100755 gdb/gnulib/update-gnulib.sh

diff --git a/gdb/gnulib/update-gnulib.sh b/gdb/gnulib/update-gnulib.sh
old mode 100644
new mode 100755
index 5c7238f..957c89a
--- a/gdb/gnulib/update-gnulib.sh
+++ b/gdb/gnulib/update-gnulib.sh
@@ -110,7 +110,23 @@ if [ "$ver" != "$AUTOMAKE_VERSION" ]; then
 fi
 
 # Verify that we have the correct version of aclocal.
-ver=`aclocal --version 2>&1 | head -1 | sed 's/.*) //'`
+#
+# The grep below is needed because Perl >= 5.16 dumps a "called too
+# early to check prototype" warning when running aclocal 1.11.1.  This
+# causes trouble below, because the warning is the first line output
+# by aclocal, resulting in:
+#
+# $ sh ./update-gnulib.sh ~/src/gnulib/src/
+# Error: Wrong aclocal version: called too early to check prototype at /opt/automake-1.11.1/bin/aclocal line 617.. Aborting.
+#
+# Some distros carry an automake patch for that:
+#  https://bugs.debian.org/cgi-bin/bugreport.cgi?msg=5;filename=aclocal-function-prototypes.debdiff;att=1;bug=752784
+#
+# But since we prefer pristine FSF versions of autotools, work around
+# the issue here.  This can be removed later when we bump the required
+# automake version.
+#
+ver=`aclocal --version 2>&1 | grep -v "called too early to check prototype" | head -1 | sed 's/.*) //'`
 if [ "$ver" != "$ACLOCAL_VERSION" ]; then
    echo "Error: Wrong aclocal version: $ver. Aborting."
    exit 1
-- 
1.9.3


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 2/2] Import strtok_r gnulib module
  2015-04-08 17:19 [PATCH 0/2] Import gnulib strtok_r module Pedro Alves
@ 2015-04-08 17:19 ` Pedro Alves
  2015-04-09  9:10   ` Yao Qi
  2015-04-08 17:19 ` [PATCH 1/2] update-gnulib.sh: work around aclocal warning with Perl >= 5.16 Pedro Alves
  1 sibling, 1 reply; 8+ messages in thread
From: Pedro Alves @ 2015-04-08 17:19 UTC (permalink / raw)
  To: gdb-patches

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  <palves@redhat.com>

	* 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 <string.h> 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 <stdlib.h>
+              #include <string.h>
+
+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 <http://sources.redhat.com/bugzilla/show_bug.cgi?id=5614>.
+    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 <stdlib.h>
+              #include <string.h>
+            ]],
+            [[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 <bits/string2.h> 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 <http://www.gnu.org/licenses/>.  */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <string.h>
+
+#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 \
-- 
1.9.3


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 0/2] Import gnulib strtok_r module
@ 2015-04-08 17:19 Pedro Alves
  2015-04-08 17:19 ` [PATCH 2/2] Import strtok_r gnulib module Pedro Alves
  2015-04-08 17:19 ` [PATCH 1/2] update-gnulib.sh: work around aclocal warning with Perl >= 5.16 Pedro Alves
  0 siblings, 2 replies; 8+ messages in thread
From: Pedro Alves @ 2015-04-08 17:19 UTC (permalink / raw)
  To: gdb-patches

Fix the build breakage reported here:
  https://sourceware.org/ml/gdb-patches/2015-04/msg00266.html

Comments?

Pedro Alves (2):
  update-gnulib.sh: work around aclocal warning with Perl >= 5.16
  Import strtok_r gnulib module

 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          |  19 +++++-
 11 files changed, 332 insertions(+), 7 deletions(-)
 create mode 100644 gdb/gnulib/import/m4/strtok_r.m4
 create mode 100644 gdb/gnulib/import/strtok_r.c
 mode change 100644 => 100755 gdb/gnulib/update-gnulib.sh

-- 
1.9.3


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] update-gnulib.sh: work around aclocal warning with Perl >= 5.16
  2015-04-08 17:19 ` [PATCH 1/2] update-gnulib.sh: work around aclocal warning with Perl >= 5.16 Pedro Alves
@ 2015-04-09  9:03   ` Yao Qi
  2015-04-09  9:39     ` Pedro Alves
  0 siblings, 1 reply; 8+ messages in thread
From: Yao Qi @ 2015-04-09  9:03 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

Pedro Alves <palves@redhat.com> writes:

> +# $ sh ./update-gnulib.sh ~/src/gnulib/src/
> +# Error: Wrong aclocal version: called too early to check prototype at /opt/automake-1.11.1/bin/aclocal line 617.. Aborting.

Yes, I encountered the same error when I run update-gnulib.sh last year,
but I just hacked update-gnulib.sh to workaround it every time :)

Patch is fine by me.

-- 
Yao (齐尧)


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] Import strtok_r gnulib module
  2015-04-08 17:19 ` [PATCH 2/2] Import strtok_r gnulib module Pedro Alves
@ 2015-04-09  9:10   ` Yao Qi
  2015-04-09  9:30     ` Pedro Alves
  2015-04-09  9:39     ` Pedro Alves
  0 siblings, 2 replies; 8+ messages in thread
From: Yao Qi @ 2015-04-09  9:10 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

Pedro Alves <palves@redhat.com> writes:

> 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.

Patch is OK to me.

>
> gdb/ChangeLog:
> 2015-04-08  Pedro Alves  <palves@redhat.com>
>
> 	* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add strtok_r.
> 	* gnulib/Makefile.in (aclocal_m4_deps): Add import/m4/strtok_r.m4.

Nit: gnulib/Makefile.in is regenerated, isn't?  If so, "Regenerate"
should be used too.

> 	* 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.

-- 
Yao (齐尧)


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] Import strtok_r gnulib module
  2015-04-09  9:10   ` Yao Qi
@ 2015-04-09  9:30     ` Pedro Alves
  2015-04-09  9:39     ` Pedro Alves
  1 sibling, 0 replies; 8+ messages in thread
From: Pedro Alves @ 2015-04-09  9:30 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

On 04/09/2015 10:10 AM, Yao Qi wrote:
>> > 	* gnulib/Makefile.in (aclocal_m4_deps): Add import/m4/strtok_r.m4.
> Nit: gnulib/Makefile.in is regenerated, isn't?  If so, "Regenerate"
> should be used too.
> 

Nope, that list is maintained manually.  And it looks very much out
of sync with the m4 files in the m4/ dir already, though I didn't
fix that in this patch.

Thanks,
Pedro Alves


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] update-gnulib.sh: work around aclocal warning with Perl >= 5.16
  2015-04-09  9:03   ` Yao Qi
@ 2015-04-09  9:39     ` Pedro Alves
  0 siblings, 0 replies; 8+ messages in thread
From: Pedro Alves @ 2015-04-09  9:39 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

On 04/09/2015 10:02 AM, Yao Qi wrote:
> Pedro Alves <palves@redhat.com> writes:
> 
>> +# $ sh ./update-gnulib.sh ~/src/gnulib/src/
>> +# Error: Wrong aclocal version: called too early to check prototype at /opt/automake-1.11.1/bin/aclocal line 617.. Aborting.
> 
> Yes, I encountered the same error when I run update-gnulib.sh last year,
> but I just hacked update-gnulib.sh to workaround it every time :)

:-)

> 
> Patch is fine by me.
> 

Alright, pushed.

Thanks,
Pedro Alves


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] Import strtok_r gnulib module
  2015-04-09  9:10   ` Yao Qi
  2015-04-09  9:30     ` Pedro Alves
@ 2015-04-09  9:39     ` Pedro Alves
  1 sibling, 0 replies; 8+ messages in thread
From: Pedro Alves @ 2015-04-09  9:39 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

On 04/09/2015 10:10 AM, Yao Qi wrote:
> Pedro Alves <palves@redhat.com> writes:
> 
>> 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.
> 
> Patch is OK to me.

Pushed.

Thanks,
Pedro Alves


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-04-09  9:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-08 17:19 [PATCH 0/2] Import gnulib strtok_r module Pedro Alves
2015-04-08 17:19 ` [PATCH 2/2] Import strtok_r gnulib module Pedro Alves
2015-04-09  9:10   ` Yao Qi
2015-04-09  9:30     ` Pedro Alves
2015-04-09  9:39     ` Pedro Alves
2015-04-08 17:19 ` [PATCH 1/2] update-gnulib.sh: work around aclocal warning with Perl >= 5.16 Pedro Alves
2015-04-09  9:03   ` Yao Qi
2015-04-09  9:39     ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox