summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--lib/string.in.h397
-rw-r--r--modules/string4
3 files changed, 305 insertions, 106 deletions
diff --git a/ChangeLog b/ChangeLog
index 22b2a2f73e..7215062c27 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2010-03-07 Bruno Haible <bruno@clisp.org>
+ string: Avoid #define replacements in C++ mode.
+ * lib/string.in.h: Include c++defs.h.
+ (stpncpy): Define to rpl_stpncpy, not gnu_stpncpy.
+ (memchr, memmem, mempcpy, memrchr, rawmemchr, stpcpy, stpncpy,
+ strchrnul, strdup, strndup, strnlen, strpbrk, strsep, strstr,
+ strcasestr, strtok_r, mbslen, mbschr, mbsrchr, mbspbrk, strerror,
+ strsignal, strverscmp): In C++, define a namespaced alias symbol.
+ * modules/string (Depends-on): Add c++defs.
+ (Makefile.am): Update string.h rule.
+
stdlib: Avoid #define replacements in C++ mode.
* lib/stdlib.in.h: Include c++defs.h.
(atoll, calloc, canonicalize_file_name, getloadavg, getsubopt, malloc,
diff --git a/lib/string.in.h b/lib/string.in.h
index 8749f73de2..8b12dc04e5 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -48,23 +48,39 @@
#endif
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
+
/* The definition of _GL_ARG_NONNULL is copied here. */
/* The definition of _GL_WARN_ON_USE is copied here. */
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
/* Return the first instance of C within N bytes of S, or NULL. */
#if @GNULIB_MEMCHR@
# if @REPLACE_MEMCHR@
-# define memchr rpl_memchr
-extern void *memchr (void const *__s, int __c, size_t __n)
- __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
-# endif
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define memchr rpl_memchr
+# endif
+_GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n)
+ __attribute__ ((__pure__))
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n));
+# else
+# if defined __SUNPRO_CC
+ /* This compiler defines an overloaded function
+ extern "C" { const void * std::memchr (const void *, int, size_t); }
+ extern "C++" { inline void * std::memchr (void *, int, size_t); }
+ and diagnoses an error
+ "Error: Could not find a match for std::memchr(const void*, int, unsigned)"
+ */
+_GL_CXXALIAS_SYS_CAST2 (memchr,
+ void *, (void const *__s, int __c, size_t __n),
+ void const *, (void const *__s, int __c, size_t __n));
+# else
+_GL_CXXALIAS_SYS (memchr, void *, (void const *__s, int __c, size_t __n));
+# endif
+# endif
+_GL_CXXALIASWARN (memchr);
#elif defined GNULIB_POSIXCHECK
# undef memchr
/* Assume memchr is always declared. */
@@ -75,13 +91,28 @@ _GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - "
/* Return the first occurrence of NEEDLE in HAYSTACK. */
#if @GNULIB_MEMMEM@
# if @REPLACE_MEMMEM@
-# define memmem rpl_memmem
-# endif
-# if ! @HAVE_DECL_MEMMEM@ || @REPLACE_MEMMEM@
-extern void *memmem (void const *__haystack, size_t __haystack_len,
- void const *__needle, size_t __needle_len)
- __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 3));
-# endif
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define memmem rpl_memmem
+# endif
+_GL_FUNCDECL_RPL (memmem, void *,
+ (void const *__haystack, size_t __haystack_len,
+ void const *__needle, size_t __needle_len)
+ __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 3)));
+_GL_CXXALIAS_RPL (memmem, void *,
+ (void const *__haystack, size_t __haystack_len,
+ void const *__needle, size_t __needle_len));
+# else
+# if ! @HAVE_DECL_MEMMEM@
+_GL_FUNCDECL_SYS (memmem, void *,
+ (void const *__haystack, size_t __haystack_len,
+ void const *__needle, size_t __needle_len)
+ __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 3)));
+# endif
+_GL_CXXALIAS_SYS (memmem, void *,
+ (void const *__haystack, size_t __haystack_len,
+ void const *__needle, size_t __needle_len));
+# endif
+_GL_CXXALIASWARN (memmem);
#elif defined GNULIB_POSIXCHECK
# undef memmem
# if HAVE_RAW_DECL_MEMMEM
@@ -95,10 +126,15 @@ _GL_WARN_ON_USE (memmem, "memmem is unportable and often quadratic - "
last written byte. */
#if @GNULIB_MEMPCPY@
# if ! @HAVE_MEMPCPY@
-extern void *mempcpy (void *restrict __dest, void const *restrict __src,
- size_t __n)
- _GL_ARG_NONNULL ((1, 2));
-# endif
+_GL_FUNCDECL_SYS (mempcpy, void *,
+ (void *restrict __dest, void const *restrict __src,
+ size_t __n)
+ _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (mempcpy, void *,
+ (void *restrict __dest, void const *restrict __src,
+ size_t __n));
+_GL_CXXALIASWARN (mempcpy);
#elif defined GNULIB_POSIXCHECK
# undef mempcpy
# if HAVE_RAW_DECL_MEMPCPY
@@ -110,9 +146,12 @@ _GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - "
/* Search backwards through a block for a byte (specified as an int). */
#if @GNULIB_MEMRCHR@
# if ! @HAVE_DECL_MEMRCHR@
-extern void *memrchr (void const *, int, size_t)
- __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
+_GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t)
+ __attribute__ ((__pure__))
+ _GL_ARG_NONNULL ((1)));
# endif
+_GL_CXXALIAS_SYS (memrchr, void *, (void const *, int, size_t));
+_GL_CXXALIASWARN (memrchr);
#elif defined GNULIB_POSIXCHECK
# undef memrchr
# if HAVE_RAW_DECL_MEMRCHR
@@ -126,9 +165,12 @@ _GL_WARN_ON_USE (memrchr, "memrchr is unportable - "
occur within N bytes. */
#if @GNULIB_RAWMEMCHR@
# if ! @HAVE_RAWMEMCHR@
-extern void *rawmemchr (void const *__s, int __c_in)
- __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
+_GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in)
+ __attribute__ ((__pure__))
+ _GL_ARG_NONNULL ((1)));
# endif
+_GL_CXXALIAS_SYS (rawmemchr, void *, (void const *__s, int __c_in));
+_GL_CXXALIASWARN (rawmemchr);
#elif defined GNULIB_POSIXCHECK
# undef rawmemchr
# if HAVE_RAW_DECL_RAWMEMCHR
@@ -140,9 +182,13 @@ _GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - "
/* Copy SRC to DST, returning the address of the terminating '\0' in DST. */
#if @GNULIB_STPCPY@
# if ! @HAVE_STPCPY@
-extern char *stpcpy (char *restrict __dst, char const *restrict __src)
- _GL_ARG_NONNULL ((1, 2));
+_GL_FUNCDECL_SYS (stpcpy, char *,
+ (char *restrict __dst, char const *restrict __src)
+ _GL_ARG_NONNULL ((1, 2)));
# endif
+_GL_CXXALIAS_SYS (stpcpy, char *,
+ (char *restrict __dst, char const *restrict __src));
+_GL_CXXALIASWARN (stpcpy);
#elif defined GNULIB_POSIXCHECK
# undef stpcpy
# if HAVE_RAW_DECL_STPCPY
@@ -155,11 +201,22 @@ _GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - "
last non-NUL byte written into DST. */
#if @GNULIB_STPNCPY@
# if ! @HAVE_STPNCPY@
-# define stpncpy gnu_stpncpy
-extern char *stpncpy (char *restrict __dst, char const *restrict __src,
- size_t __n)
- _GL_ARG_NONNULL ((1, 2));
-# endif
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define stpncpy rpl_stpncpy
+# endif
+_GL_FUNCDECL_RPL (stpncpy, char *,
+ (char *restrict __dst, char const *restrict __src,
+ size_t __n)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (stpncpy, char *,
+ (char *restrict __dst, char const *restrict __src,
+ size_t __n));
+# else
+_GL_CXXALIAS_SYS (stpncpy, char *,
+ (char *restrict __dst, char const *restrict __src,
+ size_t __n));
+# endif
+_GL_CXXALIASWARN (stpncpy);
#elif defined GNULIB_POSIXCHECK
# undef stpncpy
# if HAVE_RAW_DECL_STPNCPY
@@ -181,9 +238,12 @@ _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@
-extern char *strchrnul (char const *__s, int __c_in)
- __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
+_GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in)
+ __attribute__ ((__pure__))
+ _GL_ARG_NONNULL ((1)));
# endif
+_GL_CXXALIAS_SYS (strchrnul, char *, (char const *__s, int __c_in));
+_GL_CXXALIASWARN (strchrnul);
#elif defined GNULIB_POSIXCHECK
# undef strchrnul
# if HAVE_RAW_DECL_STRCHRNUL
@@ -195,12 +255,19 @@ _GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - "
/* Duplicate S, returning an identical malloc'd string. */
#if @GNULIB_STRDUP@
# if @REPLACE_STRDUP@
-# undef strdup
-# define strdup rpl_strdup
-# endif
-# if !(@HAVE_DECL_STRDUP@ || defined strdup) || @REPLACE_STRDUP@
-extern char *strdup (char const *__s) _GL_ARG_NONNULL ((1));
-# endif
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef strdup
+# define strdup rpl_strdup
+# endif
+_GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (strdup, char *, (char const *__s));
+# else
+# if !(@HAVE_DECL_STRDUP@ || defined strdup)
+_GL_FUNCDECL_SYS (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (strdup, char *, (char const *__s));
+# endif
+_GL_CXXALIASWARN (strdup);
#elif defined GNULIB_POSIXCHECK
# undef strdup
# if HAVE_RAW_DECL_STRDUP
@@ -212,12 +279,21 @@ _GL_WARN_ON_USE (strdup, "strdup is unportable - "
/* Return a newly allocated copy of at most N bytes of STRING. */
#if @GNULIB_STRNDUP@
# if @REPLACE_STRNDUP@
-# undef strndup
-# define strndup rpl_strndup
-# endif
-# if @REPLACE_STRNDUP@ || ! @HAVE_DECL_STRNDUP@
-extern char *strndup (char const *__string, size_t __n) _GL_ARG_NONNULL ((1));
-# endif
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef strndup
+# define strndup rpl_strndup
+# endif
+_GL_FUNCDECL_RPL (strndup, char *, (char const *__string, size_t __n)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (strndup, char *, (char const *__string, size_t __n));
+# else
+# if ! @HAVE_DECL_STRNDUP@
+_GL_FUNCDECL_SYS (strndup, char *, (char const *__string, size_t __n)
+ _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (strndup, char *, (char const *__string, size_t __n));
+# endif
+_GL_CXXALIASWARN (strndup);
#elif defined GNULIB_POSIXCHECK
# undef strndup
# if HAVE_RAW_DECL_STRNDUP
@@ -231,9 +307,12 @@ _GL_WARN_ON_USE (strndup, "strndup is unportable - "
return MAXLEN. */
#if @GNULIB_STRNLEN@
# if ! @HAVE_DECL_STRNLEN@
-extern size_t strnlen (char const *__string, size_t __maxlen)
- __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
+_GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)
+ __attribute__ ((__pure__))
+ _GL_ARG_NONNULL ((1)));
# endif
+_GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen));
+_GL_CXXALIASWARN (strnlen);
#elif defined GNULIB_POSIXCHECK
# undef strnlen
# if HAVE_RAW_DECL_STRNLEN
@@ -257,9 +336,24 @@ _GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings "
/* Find the first occurrence in S of any character in ACCEPT. */
#if @GNULIB_STRPBRK@
# if ! @HAVE_STRPBRK@
-extern char *strpbrk (char const *__s, char const *__accept)
- __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2));
-# endif
+_GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept)
+ __attribute__ ((__pure__))
+ _GL_ARG_NONNULL ((1, 2)));
+# endif
+# if defined __SUNPRO_CC
+ /* This compiler defines an overloaded function
+ extern "C" { const char * strpbrk (const char *, const char *); }
+ extern "C++" { inline char * strpbrk (char *, const char *); }
+ and diagnoses an error
+ "Error: Could not find a match for std::strpbrk(const char*, const char*)"
+ */
+_GL_CXXALIAS_SYS_CAST2 (strpbrk,
+ char *, (char const *__s, char const *__accept),
+ const char *, (char const *__s, char const *__accept));
+# else
+_GL_CXXALIAS_SYS (strpbrk, char *, (char const *__s, char const *__accept));
+# endif
+_GL_CXXALIASWARN (strpbrk);
# if defined GNULIB_POSIXCHECK
/* strpbrk() assumes the second argument is a list of single-byte characters.
Even in this simple case, it does not work with multibyte strings if the
@@ -316,9 +410,13 @@ _GL_WARN_ON_USE (strrchr, "strrchr cannot work correctly on character strings "
See also strtok_r(). */
#if @GNULIB_STRSEP@
# if ! @HAVE_STRSEP@
-extern char *strsep (char **restrict __stringp, char const *restrict __delim)
- _GL_ARG_NONNULL ((1, 2));
+_GL_FUNCDECL_SYS (strsep, char *,
+ (char **restrict __stringp, char const *restrict __delim)
+ _GL_ARG_NONNULL ((1, 2)));
# endif
+_GL_CXXALIAS_SYS (strsep, char *,
+ (char **restrict __stringp, char const *restrict __delim));
+_GL_CXXALIASWARN (strsep);
# if defined GNULIB_POSIXCHECK
# undef strsep
_GL_WARN_ON_USE (strsep, "strsep cannot work correctly on character strings "
@@ -335,10 +433,17 @@ _GL_WARN_ON_USE (strsep, "strsep is unportable - "
#if @GNULIB_STRSTR@
# if @REPLACE_STRSTR@
-# define strstr rpl_strstr
-extern char *strstr (const char *haystack, const char *needle)
- __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2));
-# endif
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define strstr rpl_strstr
+# endif
+_GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle)
+ __attribute__ ((__pure__))
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle));
+# else
+_GL_CXXALIAS_SYS (strstr, char *, (const char *haystack, const char *needle));
+# endif
+_GL_CXXALIASWARN (strstr);
#elif defined GNULIB_POSIXCHECK
/* strstr() does not work with multibyte strings if the locale encoding is
different from UTF-8:
@@ -357,12 +462,24 @@ _GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot "
comparison. */
#if @GNULIB_STRCASESTR@
# if @REPLACE_STRCASESTR@
-# define strcasestr rpl_strcasestr
-# endif
-# if ! @HAVE_STRCASESTR@ || @REPLACE_STRCASESTR@
-extern char *strcasestr (const char *haystack, const char *needle)
- __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2));
-# endif
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define strcasestr rpl_strcasestr
+# endif
+_GL_FUNCDECL_RPL (strcasestr, char *,
+ (const char *haystack, const char *needle)
+ __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (strcasestr, char *,
+ (const char *haystack, const char *needle));
+# else
+# if ! @HAVE_STRCASESTR@
+_GL_FUNCDECL_SYS (strcasestr, char *,
+ (const char *haystack, const char *needle)
+ __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (strcasestr, char *,
+ (const char *haystack, const char *needle));
+# endif
+_GL_CXXALIASWARN (strcasestr);
#elif defined GNULIB_POSIXCHECK
/* strcasestr() does not work with multibyte strings:
It is a glibc extension, and glibc implements it only for unibyte
@@ -401,16 +518,32 @@ _GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character "
See also strsep(). */
#if @GNULIB_STRTOK_R@
# if @REPLACE_STRTOK_R@
-# undef strtok_r
-# define strtok_r rpl_strtok_r
-# elif @UNDEFINE_STRTOK_R@ || defined GNULIB_POSIXCHECK
-# undef strtok_r
-# endif
-# if ! @HAVE_DECL_STRTOK_R@ || @REPLACE_STRTOK_R@
-extern char *strtok_r (char *restrict s, char const *restrict delim,
- char **restrict save_ptr)
- _GL_ARG_NONNULL ((2, 3));
-# endif
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef strtok_r
+# define strtok_r rpl_strtok_r
+# endif
+_GL_FUNCDECL_RPL (strtok_r, char *,
+ (char *restrict s, char const *restrict delim,
+ char **restrict save_ptr)
+ _GL_ARG_NONNULL ((2, 3)));
+_GL_CXXALIAS_RPL (strtok_r, char *,
+ (char *restrict s, char const *restrict delim,
+ char **restrict save_ptr));
+# else
+# if @UNDEFINE_STRTOK_R@ || defined GNULIB_POSIXCHECK
+# undef strtok_r
+# endif
+# if ! @HAVE_DECL_STRTOK_R@
+_GL_FUNCDECL_SYS (strtok_r, char *,
+ (char *restrict s, char const *restrict delim,
+ char **restrict save_ptr)
+ _GL_ARG_NONNULL ((2, 3)));
+# endif
+_GL_CXXALIAS_SYS (strtok_r, char *,
+ (char *restrict s, char const *restrict delim,
+ char **restrict save_ptr));
+# endif
+_GL_CXXALIASWARN (strtok_r);
# if defined GNULIB_POSIXCHECK
_GL_WARN_ON_USE (strtok_r, "strtok_r cannot work correctly on character "
"strings in multibyte locales - "
@@ -435,15 +568,23 @@ _GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - "
# undef mbslen
# endif
# if @HAVE_MBSLEN@ /* AIX, OSF/1, MirBSD define mbslen already in libc. */
-# define mbslen rpl_mbslen
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define mbslen rpl_mbslen
+# endif
+_GL_FUNCDECL_RPL (mbslen, size_t, (const char *string) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (mbslen, size_t, (const char *string));
+# else
+_GL_FUNCDECL_SYS (mbslen, size_t, (const char *string) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_SYS (mbslen, size_t, (const char *string));
# endif
-extern size_t mbslen (const char *string) _GL_ARG_NONNULL ((1));
+_GL_CXXALIASWARN (mbslen);
#endif
#if @GNULIB_MBSNLEN@
/* Return the number of multibyte characters in the character string starting
at STRING and ending at STRING + LEN. */
-extern size_t mbsnlen (const char *string, size_t len) _GL_ARG_NONNULL ((1));
+_GL_EXTERN_C size_t mbsnlen (const char *string, size_t len)
+ _GL_ARG_NONNULL ((1));
#endif
#if @GNULIB_MBSCHR@
@@ -451,8 +592,19 @@ extern size_t mbsnlen (const char *string, size_t len) _GL_ARG_NONNULL ((1));
and return a pointer to it. Return NULL if C is not found in STRING.
Unlike strchr(), this function works correctly in multibyte locales with
encodings such as GB18030. */
-# define mbschr rpl_mbschr /* avoid collision with HP-UX function */
-extern char * mbschr (const char *string, int c) _GL_ARG_NONNULL ((1));
+# if defined __hpux
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define mbschr rpl_mbschr /* avoid collision with HP-UX function */
+# endif
+_GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c));
+# else
+_GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c));
+# endif
+_GL_CXXALIASWARN (mbschr);
#endif
#if @GNULIB_MBSRCHR@
@@ -460,8 +612,19 @@ extern char * mbschr (const char *string, int c) _GL_ARG_NONNULL ((1));
and return a pointer to it. Return NULL if C is not found in STRING.
Unlike strrchr(), this function works correctly in multibyte locales with
encodings such as GB18030. */
-# define mbsrchr rpl_mbsrchr /* avoid collision with HP-UX function */
-extern char * mbsrchr (const char *string, int c) _GL_ARG_NONNULL ((1));
+# if defined __hpux
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define mbsrchr rpl_mbsrchr /* avoid collision with HP-UX function */
+# endif
+_GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c));
+# else
+_GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c));
+# endif
+_GL_CXXALIASWARN (mbsrchr);
#endif
#if @GNULIB_MBSSTR@
@@ -469,7 +632,7 @@ extern char * mbsrchr (const char *string, int c) _GL_ARG_NONNULL ((1));
string HAYSTACK. Return NULL if NEEDLE is not found in HAYSTACK.
Unlike strstr(), this function works correctly in multibyte locales with
encodings different from UTF-8. */
-extern char * mbsstr (const char *haystack, const char *needle)
+_GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle)
_GL_ARG_NONNULL ((1, 2));
#endif
@@ -480,7 +643,7 @@ extern char * mbsstr (const char *haystack, const char *needle)
Note: This function may, in multibyte locales, return 0 for strings of
different lengths!
Unlike strcasecmp(), this function works correctly in multibyte locales. */
-extern int mbscasecmp (const char *s1, const char *s2)
+_GL_EXTERN_C int mbscasecmp (const char *s1, const char *s2)
_GL_ARG_NONNULL ((1, 2));
#endif
@@ -494,7 +657,7 @@ extern int mbscasecmp (const char *s1, const char *s2)
of different lengths!
Unlike strncasecmp(), this function works correctly in multibyte locales.
But beware that N is not a byte count but a character count! */
-extern int mbsncasecmp (const char *s1, const char *s2, size_t n)
+_GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n)
_GL_ARG_NONNULL ((1, 2));
#endif
@@ -508,7 +671,7 @@ extern int mbsncasecmp (const char *s1, const char *s2, size_t n)
smaller length than PREFIX!
Unlike strncasecmp(), this function works correctly in multibyte
locales. */
-extern char * mbspcasecmp (const char *string, const char *prefix)
+_GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix)
_GL_ARG_NONNULL ((1, 2));
#endif
@@ -518,7 +681,7 @@ extern char * mbspcasecmp (const char *string, const char *prefix)
Note: This function may, in multibyte locales, return success even if
strlen (haystack) < strlen (needle) !
Unlike strcasestr(), this function works correctly in multibyte locales. */
-extern char * mbscasestr (const char *haystack, const char *needle)
+_GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle)
_GL_ARG_NONNULL ((1, 2));
#endif
@@ -528,7 +691,7 @@ extern char * mbscasestr (const char *haystack, const char *needle)
beginning of the string to this occurrence, or to the end of the string
if none exists.
Unlike strcspn(), this function works correctly in multibyte locales. */
-extern size_t mbscspn (const char *string, const char *accept)
+_GL_EXTERN_C size_t mbscspn (const char *string, const char *accept)
_GL_ARG_NONNULL ((1, 2));
#endif
@@ -537,9 +700,19 @@ extern size_t mbscspn (const char *string, const char *accept)
in the character string ACCEPT. Return the pointer to it, or NULL if none
exists.
Unlike strpbrk(), this function works correctly in multibyte locales. */
-# define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */
-extern char * mbspbrk (const char *string, const char *accept)
- _GL_ARG_NONNULL ((1, 2));
+# if defined __hpux
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */
+# endif
+_GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept));
+# else
+_GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept));
+# endif
+_GL_CXXALIASWARN (mbspbrk);
#endif
#if @GNULIB_MBSSPN@
@@ -548,7 +721,7 @@ extern char * mbspbrk (const char *string, const char *accept)
beginning of the string to this occurrence, or to the end of the string
if none exists.
Unlike strspn(), this function works correctly in multibyte locales. */
-extern size_t mbsspn (const char *string, const char *reject)
+_GL_EXTERN_C size_t mbsspn (const char *string, const char *reject)
_GL_ARG_NONNULL ((1, 2));
#endif
@@ -567,7 +740,7 @@ extern size_t mbsspn (const char *string, const char *reject)
Caveat: The identity of the delimiting character is lost.
See also mbstok_r(). */
-extern char * mbssep (char **stringp, const char *delim)
+_GL_EXTERN_C char * mbssep (char **stringp, const char *delim)
_GL_ARG_NONNULL ((1, 2));
#endif
@@ -588,17 +761,23 @@ extern char * mbssep (char **stringp, const char *delim)
Caveat: The identity of the delimiting character is lost.
See also mbssep(). */
-extern char * mbstok_r (char *string, const char *delim, char **save_ptr)
+_GL_EXTERN_C char * mbstok_r (char *string, const char *delim, char **save_ptr)
_GL_ARG_NONNULL ((2, 3));
#endif
/* Map any int, typically from errno, into an error message. */
#if @GNULIB_STRERROR@
# if @REPLACE_STRERROR@
-# undef strerror
-# define strerror rpl_strerror
-extern char *strerror (int);
-# endif
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef strerror
+# define strerror rpl_strerror
+# endif
+_GL_FUNCDECL_RPL (strerror, char *, (int));
+_GL_CXXALIAS_RPL (strerror, char *, (int));
+# else
+_GL_CXXALIAS_SYS (strerror, char *, (int));
+# endif
+_GL_CXXALIASWARN (strerror);
#elif defined GNULIB_POSIXCHECK
# undef strerror
/* Assume strerror is always declared. */
@@ -608,11 +787,20 @@ _GL_WARN_ON_USE (strerror, "strerror is unportable - "
#if @GNULIB_STRSIGNAL@
# if @REPLACE_STRSIGNAL@
-# define strsignal rpl_strsignal
-# endif
-# if ! @HAVE_DECL_STRSIGNAL@ || @REPLACE_STRSIGNAL@
-extern char *strsignal (int __sig);
-# endif
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define strsignal rpl_strsignal
+# endif
+_GL_FUNCDECL_RPL (strsignal, char *, (int __sig));
+_GL_CXXALIAS_RPL (strsignal, char *, (int __sig));
+# else
+# if ! @HAVE_DECL_STRSIGNAL@
+_GL_FUNCDECL_SYS (strsignal, char *, (int __sig));
+# endif
+/* Need to cast, because on Cygwin 1.5.x systems, the return type is
+ 'const char *'. */
+_GL_CXXALIAS_SYS_CAST (strsignal, char *, (int __sig));
+# endif
+_GL_CXXALIASWARN (strsignal);
#elif defined GNULIB_POSIXCHECK
# undef strsignal
# if HAVE_RAW_DECL_STRSIGNAL
@@ -623,8 +811,11 @@ _GL_WARN_ON_USE (strsignal, "strsignal is unportable - "
#if @GNULIB_STRVERSCMP@
# if !@HAVE_STRVERSCMP@
-extern int strverscmp (const char *, const char *) _GL_ARG_NONNULL ((1, 2));
+_GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *)
+ _GL_ARG_NONNULL ((1, 2)));
# endif
+_GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *));
+_GL_CXXALIASWARN (strverscmp);
#elif defined GNULIB_POSIXCHECK
# undef strverscmp
# if HAVE_RAW_DECL_STRVERSCMP
@@ -634,9 +825,5 @@ _GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - "
#endif
-#ifdef __cplusplus
-}
-#endif
-
#endif /* _GL_STRING_H */
#endif /* _GL_STRING_H */
diff --git a/modules/string b/modules/string
index e4cf6b6b55..2ec71f5561 100644
--- a/modules/string
+++ b/modules/string
@@ -7,6 +7,7 @@ m4/string_h.m4
Depends-on:
arg-nonnull
+c++defs
extensions
include_next
stddef
@@ -20,7 +21,7 @@ BUILT_SOURCES += string.h
# We need the following in order to create <string.h> when the system
# doesn't have one that works with the given compiler.
-string.h: string.in.h $(WARN_ON_USE_H) $(ARG_NONNULL_H)
+string.h: string.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -88,6 +89,7 @@ string.h: string.in.h $(WARN_ON_USE_H) $(ARG_NONNULL_H)
-e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \
-e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \
-e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
< $(srcdir)/string.in.h; \