changeset 14586:e60c0a94bedd

strchrnul: Tweak last commit. * doc/glibc-functions/strchrnul.texi: Add more details about Cygwin bug. * lib/string.in.h (strchrnul): Use same arguments in _GL_FUNCDECL_RPL as in _GL_FUNCDECL_SYS. * m4/strchrnul.m4 (gl_FUNC_STRCHRNUL): Invoke gl_PREREQ_STRCHRNUL after AC_LIBOBJ. When cross-compiling, say "guessing yes" not "yes".
author Bruno Haible <bruno@clisp.org>
date Sat, 16 Apr 2011 12:10:16 +0200
parents 1eab1082a832
children 96e891489d99
files ChangeLog doc/glibc-functions/strchrnul.texi lib/string.in.h m4/strchrnul.m4
diffstat 4 files changed, 25 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2011-04-16  Bruno Haible  <bruno@clisp.org>
+
+	strchrnul: Tweak last commit.
+	* doc/glibc-functions/strchrnul.texi: Add more details about Cygwin
+	bug.
+	* lib/string.in.h (strchrnul): Use same arguments in _GL_FUNCDECL_RPL
+	as in _GL_FUNCDECL_SYS.
+	* m4/strchrnul.m4 (gl_FUNC_STRCHRNUL): Invoke gl_PREREQ_STRCHRNUL after
+	AC_LIBOBJ. When cross-compiling, say "guessing yes" not "yes".
+
 2011-04-15  Eric Blake  <eblake@redhat.com>
 
 	strchrnul: work around cygwin bug
--- a/doc/glibc-functions/strchrnul.texi
+++ b/doc/glibc-functions/strchrnul.texi
@@ -12,7 +12,7 @@
 IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.7.8, mingw, Interix 3.5,
 BeOS.
 @item
-This function is broken on some platforms:
+This function crashes when no occurrence is found on some platforms:
 Cygwin 1.7.9.
 @end itemize
 
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -281,10 +281,9 @@
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #   define strchrnul rpl_strchrnul
 #  endif
-_GL_FUNCDECL_RPL (strchrnul, char *,
-                  (const char *str, int ch)
-                  _GL_ATTRIBUTE_PURE
-                  _GL_ARG_NONNULL ((1)));
+_GL_FUNCDECL_RPL (strchrnul, char *, (const char *__s, int __c_in)
+                                     _GL_ATTRIBUTE_PURE
+                                     _GL_ARG_NONNULL ((1)));
 _GL_CXXALIAS_RPL (strchrnul, char *,
                   (const char *str, int ch));
 # else
--- a/m4/strchrnul.m4
+++ b/m4/strchrnul.m4
@@ -10,17 +10,16 @@
   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
 
   AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
-  AC_REPLACE_FUNCS([strchrnul])
+  AC_CHECK_FUNCS([strchrnul])
   if test $ac_cv_func_strchrnul = no; then
     HAVE_STRCHRNUL=0
-    gl_PREREQ_STRCHRNUL
   else
     AC_CACHE_CHECK([whether strchrnul works],
       [gl_cv_func_strchrnul_works],
       [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
 #include <string.h> /* for strchrnul */
 ]], [[const char *buf = "a";
-      return strchrnul(buf, 'b') != buf + 1;
+      return strchrnul (buf, 'b') != buf + 1;
     ]])],
         [gl_cv_func_strchrnul_works=yes],
         [gl_cv_func_strchrnul_works=no],
@@ -36,14 +35,18 @@
   Lucky user
 #endif
            ],
-           [gl_cv_func_strchrnul_works=yes],
+           [gl_cv_func_strchrnul_works="guessing yes"],
            [gl_cv_func_strchrnul_works="guessing no"])
         ])
       ])
-    if test "$gl_cv_func_strchrnul_works" != yes; then
-      REPLACE_STRCHRNUL=1
-      AC_LIBOBJ([strchrnul])
-    fi
+    case "$gl_cv_func_strchrnul_works" in
+      *yes) ;;
+      *) REPLACE_STRCHRNUL=1 ;;
+    esac
+  fi
+  if test $HAVE_STRCHRNUL = 0 || test $REPLACE_STRCHRNUL = 1; then
+    AC_LIBOBJ([strchrnul])
+    gl_PREREQ_STRCHRNUL
   fi
 ])