summaryrefslogtreecommitdiff
path: root/lib/string.in.h
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2011-04-15 13:53:50 -0600
committerEric Blake <eblake@redhat.com>2011-04-15 13:53:50 -0600
commit2aa729ac6af316bc30111144684a51c4650d5c44 (patch)
tree695c7e8b5f88fe22a9ee869159a204f587e853d7 /lib/string.in.h
parent61a6a26974843b935539a6fb0098d802195a7383 (diff)
downloadgnulib-2aa729ac6af316bc30111144684a51c4650d5c44.tar.gz
strchrnul: work around cygwin bug
A misplaced * means that cygwin 1.7.9 dereferences NULL rather than returning the location of the trailing NUL byte. * 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. Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'lib/string.in.h')
-rw-r--r--lib/string.in.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/string.in.h b/lib/string.in.h
index 652c9407bc..7f156aa453 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -277,17 +277,29 @@ _GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings "
/* Find the first occurrence of C in S or the final NUL byte. */
#if @GNULIB_STRCHRNUL@
-# if ! @HAVE_STRCHRNUL@
+# if @REPLACE_STRCHRNUL@
+# 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_CXXALIAS_RPL (strchrnul, char *,
+ (const char *str, int ch));
+# else
+# if ! @HAVE_STRCHRNUL@
_GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in)
_GL_ATTRIBUTE_PURE
_GL_ARG_NONNULL ((1)));
-# endif
+# endif
/* On some systems, this function is defined as an overloaded function:
extern "C++" { const char * std::strchrnul (const char *, int); }
extern "C++" { char * std::strchrnul (char *, int); } */
_GL_CXXALIAS_SYS_CAST2 (strchrnul,
char *, (char const *__s, int __c_in),
char const *, (char const *__s, int __c_in));
+# endif
# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
_GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in));