[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] strchrnul: work around cygwin bug
From: |
Bruno Haible |
Subject: |
Re: [PATCH] strchrnul: work around cygwin bug |
Date: |
Sat, 16 Apr 2011 12:10:41 +0200 |
User-agent: |
KMail/1.9.9 |
Hi Eric,
> A misplaced * means that cygwin 1.7.9 dereferences NULL rather
> than returning the location of the trailing NUL byte.
This bug would have been avoided if the Cygwin people had taken the unit test
from gnulib before releasing Cygwin 1.7.9. You contributed this test yourself,
three years ago.
Maybe we should advertise this more? That gnulib is not only for programmers
but also contains a test suite for part of POSIX. For example, we could mention
this in the documentation, on the web pages, and upload on ftp a testdir
created through
"gnulib-tool --create-testdir --with-tests --with-c++-tests `posix-modules`" ?
> * doc/glibc-functions/strchrnul.texi (strchrnul): Document bug.
> * m4/strchrnul.m4 (gl_FUNC_STRCHRNUL): Detect it.
> * m4/string_h.m4 (gl_HEADER_STRING_H_DEFAULTS): New witness.
> * modules/string (Makefile.am): Substitute it.
> * lib/string.in.h (strchrnul): Use it.
Thanks. A little tweaks, though:
- Doc: The term "is broken" is less precise than it could be.
- string.in.h: The arguments of _GL_FUNCDECL_RPL and _GL_FUNCDECL_SYS should
normally be the same; no need for gratuitous differences.
- gl_FUNC_STRCHRNUL: gl_PREREQ_STRCHRNUL needs to be invoked. The common idiom
is to invoke AC_LIBOBJ once only, not at two different places, to avoid this
pitfall.
- gl_FUNC_STRCHRNUL: When cross-compiling and doing decisions based on version
numbers, better say "guessing yes" instead of "yes".
2011-04-16 Bruno Haible <address@hidden>
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".
--- doc/glibc-functions/strchrnul.texi.orig Sat Apr 16 11:54:21 2011
+++ doc/glibc-functions/strchrnul.texi Sat Apr 16 11:53:51 2011
@@ -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
--- lib/string.in.h.orig Sat Apr 16 11:54:21 2011
+++ lib/string.in.h Sat Apr 16 11:36:17 2011
@@ -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
--- m4/strchrnul.m4.orig Sat Apr 16 11:54:21 2011
+++ m4/strchrnul.m4 Sat Apr 16 11:40:34 2011
@@ -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
])
--
In memoriam Iqbal Masih <http://en.wikipedia.org/wiki/Iqbal_Masih>