Enforce the use of gnulib modules for unportable <string.h> functions.
[gnulib.git] / lib / string_.h
index 94d991c..86701d4 100644 (file)
@@ -26,34 +26,54 @@ extern "C" {
 #endif
 
 /* Return the first occurrence of NEEDLE in HAYSTACK.  */
-#if ! @HAVE_DECL_MEMMEM@
+#if @GNULIB_MEMMEM@
+# if ! @HAVE_DECL_MEMMEM@
 extern void *memmem (void const *__haystack, size_t __haystack_len,
                     void const *__needle, size_t __needle_len);
+# endif
+#else
+# define memmem memmem_is_unportable__use_gnulib_module_memmem_for_portability
 #endif
 
 /* Copy N bytes of SRC to DEST, return pointer to bytes after the
    last written byte.  */
-#if ! @HAVE_MEMPCPY@
+#if @GNULIB_MEMPCPY@
+# if ! @HAVE_MEMPCPY@
 extern void *mempcpy (void *restrict __dest, void const *restrict __src,
                      size_t __n);
+# endif
+#else
+# define mempcpy mempcpy_is_unportable__use_gnulib_module_mempcpy_for_portability
 #endif
 
 /* Search backwards through a block for a byte (specified as an int).  */
-#if ! @HAVE_DECL_MEMRCHR@
+#if @GNULIB_MEMRCHR@
+# if ! @HAVE_DECL_MEMRCHR@
 extern void *memrchr (void const *, int, size_t);
+# endif
+#else
+# define memrchr memrchr_is_unportable__use_gnulib_module_memrchr_for_portability
 #endif
 
 /* Copy SRC to DST, returning the address of the terminating '\0' in DST.  */
-#if ! @HAVE_STPCPY@
+#if @GNULIB_STPCPY@
+# if ! @HAVE_STPCPY@
 extern char *stpcpy (char *restrict __dst, char const *restrict __src);
+# endif
+#else
+# define stpcpy stpcpy_is_unportable__use_gnulib_module_stpcpy_for_portability
 #endif
 
 /* Copy no more than N bytes of SRC to DST, returning a pointer past the
    last non-NUL byte written into DST.  */
-#if ! @HAVE_STPNCPY@
-# define stpncpy gnu_stpncpy
+#if @GNULIB_STPNCPY@
+# if ! @HAVE_STPNCPY@
+#  define stpncpy gnu_stpncpy
 extern char *stpncpy (char *restrict __dst, char const *restrict __src,
                      size_t __n);
+# endif
+#else
+# define stpncpy stpncpy_is_unportable__use_gnulib_module_stpncpy_for_portability
 #endif
 
 /* Compare strings S1 and S2, ignoring case, returning less than, equal to or
@@ -64,48 +84,76 @@ extern char *stpncpy (char *restrict __dst, char const *restrict __src,
    No known system has a strcasecmp() function that works correctly in
    multibyte locales.  Therefore use our version always, if the
    strcase module is available.  */
-#if @REPLACE_STRCASECMP@
-# define strcasecmp rpl_strcasecmp
+#if @GNULIB_STRCASE@
+# if @REPLACE_STRCASECMP@
+#  define strcasecmp rpl_strcasecmp
 extern int strcasecmp (char const *__s1, char const *__s2);
+# endif
+#else
+# define strcasecmp strcasecmp_is_unportable__use_gnulib_module_strcase_for_portability
 #endif
 
 /* Compare no more than N bytes of strings S1 and S2, ignoring case,
    returning less than, equal to or greater than zero if S1 is
    lexicographically less than, equal to or greater than S2.
    Note: This function cannot work correctly in multibyte locales.  */
-#if ! @HAVE_DECL_STRNCASECMP@
+#if @GNULIB_STRCASE@
+# if ! @HAVE_DECL_STRNCASECMP@
 extern int strncasecmp (char const *__s1, char const *__s2, size_t __n);
+# endif
+#else
+# define strncasecmp strncasecmp_is_unportable__use_gnulib_module_strcase_for_portability
 #endif
 
 /* Find the first occurrence of C in S or the final NUL byte.  */
-#if ! @HAVE_STRCHRNUL@
+#if @GNULIB_STRCHRNUL@
+# if ! @HAVE_STRCHRNUL@
 extern char *strchrnul (char const *__s, int __c_in);
+# endif
+#else
+# define strchrnul strchrnul_is_unportable__use_gnulib_module_strchrnul_for_portability
 #endif
 
 /* Duplicate S, returning an identical malloc'd string.  */
-#if ! @HAVE_DECL_STRDUP@ && ! defined strdup
+#if @GNULIB_STRDUP@
+# if ! @HAVE_DECL_STRDUP@ && ! defined strdup
 extern char *strdup (char const *__s);
+# endif
+#else
+# define strdup strdup_is_unportable__use_gnulib_module_strdup_for_portability
 #endif
 
 /* Return a newly allocated copy of at most N bytes of STRING.  */
-#if ! @HAVE_STRNDUP@
-# undef strndup
-# define strndup rpl_strndup
-# if ! @HAVE_DECL_STRNDUP@
+#if @GNULIB_STRNDUP@
+# if ! @HAVE_STRNDUP@
+#  undef strndup
+#  define strndup rpl_strndup
+#  if ! @HAVE_DECL_STRNDUP@
 extern char *strndup (char const *__string, size_t __n);
+#  endif
 # endif
+#else
+# define strndup strndup_is_unportable__use_gnulib_module_strndup_for_portability
 #endif
 
 /* Find the length (number of bytes) of STRING, but scan at most
    MAXLEN bytes.  If no '\0' terminator is found in that many bytes,
    return MAXLEN.  */
-#if ! @HAVE_DECL_STRNLEN@
+#if @GNULIB_STRNLEN@
+# if ! @HAVE_DECL_STRNLEN@
 extern size_t strnlen (char const *__string, size_t __maxlen);
+# endif
+#else
+# define strnlen strnlen_is_unportable__use_gnulib_module_strnlen_for_portability
 #endif
 
 /* Find the first occurrence in S of any character in ACCEPT.  */
-#if ! @HAVE_STRPBRK@
+#if @GNULIB_STRPBRK@
+# if ! @HAVE_STRPBRK@
 extern char *strpbrk (char const *__s, char const *__accept);
+# endif
+#else
+# define strpbrk strpbrk_is_unportable__use_gnulib_module_strpbrk_for_portability
 #endif
 
 /* Search the next delimiter (char listed in DELIM) starting at *STRINGP.
@@ -124,28 +172,40 @@ extern char *strpbrk (char const *__s, char const *__accept);
            characters are ASCII characters < 0x30.
 
    See also strtok_r().  */
-#if ! @HAVE_STRSEP@
+#if @GNULIB_STRSEP@
+# if ! @HAVE_STRSEP@
 extern char *strsep (char **restrict __stringp, char const *restrict __delim);
+# endif
+#else
+# define strsep strsep_is_unportable__use_gnulib_module_strsep_for_portability
 #endif
 
 /* Find the first occurrence of NEEDLE in HAYSTACK.
    No known system has a strstr() function that works correctly in
    multibyte locales.  Therefore use our version always, if the strstr
    module is available.  */
-#if @REPLACE_STRSTR@
-# undef strstr
-# define strstr rpl_strstr
+#if @GNULIB_STRSTR@
+# if @REPLACE_STRSTR@
+#  undef strstr
+#  define strstr rpl_strstr
 extern char *strstr (char const *__haystack, char const *__needle);
+# endif
+#else
+# define strstr strstr_is_unportable__use_gnulib_module_strstr_for_portability
 #endif
 
 /* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive
    comparison.
    Note: This function may, in multibyte locales, return success even if
    strlen (haystack) < strlen (needle) !  */
-#if @REPLACE_STRCASESTR@
-# undef strcasestr
-# define strcasestr rpl_strcasestr
+#if @GNULIB_STRCASESTR@
+# if @REPLACE_STRCASESTR@
+#  undef strcasestr
+#  define strcasestr rpl_strcasestr
 extern char *strcasestr (const char *haystack, const char *needle);
+# endif
+#else
+# define strcasestr strcasestr_is_unportable__use_gnulib_module_strcasestr_for_portability
 #endif
 
 /* Parse S into tokens separated by characters in DELIM.
@@ -170,9 +230,13 @@ extern char *strcasestr (const char *haystack, const char *needle);
            characters are ASCII characters < 0x30.
 
    See also strsep().  */
-#if ! @HAVE_DECL_STRTOK_R@
+#if @GNULIB_STRTOK_R@
+# if ! @HAVE_DECL_STRTOK_R@
 extern char *strtok_r (char *restrict __s, char const *restrict __sep,
                       char **restrict __lasts);
+# endif
+#else
+# define strtok_r strtok_r_is_unportable__use_gnulib_module_strtok_r_for_portability
 #endif
 
 #ifdef __cplusplus