New module 'mbscspn'.
authorBruno Haible <bruno@clisp.org>
Mon, 5 Feb 2007 03:06:40 +0000 (03:06 +0000)
committerBruno Haible <bruno@clisp.org>
Mon, 5 Feb 2007 03:06:40 +0000 (03:06 +0000)
ChangeLog
MODULES.html.sh
lib/string_.h
m4/string_h.m4
modules/string

index 2fc21db6250438cca9de68d8925867c03f2af8bb..1da2d79c7e7bba61fe0df56fe53fa6ea66705ff5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2007-02-04  Bruno Haible  <bruno@clisp.org>
+
+       New module mbscspn.
+       * modules/mbscspn: New file.
+       * lib/mbscspn.c: New file.
+       * lib/string_.h (strcspn): Add a conditional link warning.
+       (mbscspn): New declaration.
+       * m4/mbscspn.m4: New file.
+       * m4/string_h.m4 (gl_STRING_MODULE_INDICATOR_DEFAULTS): Initialize
+       GNULIB_MBSCSPN.
+       * modules/string (string.h): Also substitute GNULIB_MBSCSPN.
+       * MODULES.html.sh (Internationalization functions): Add mbscspn.
+
 2007-02-04  Bruno Haible  <bruno@clisp.org>
 
        New module mbscasestr, reduced goal of strcasestr.
index 715bc9dc0349bec3c4cd5d4b2c25b350f4e3d135..5cf44b97e4bf0b28afbde995bb049ca1eccf935b 100755 (executable)
@@ -2165,6 +2165,7 @@ func_all_modules ()
   func_module mbsstr
   func_module mbscasecmp
   func_module mbscasestr
+  func_module mbscspn
   func_module mbswidth
   func_module memcasecmp
   func_module memcoll
index 118a2d4a264fb10a376f2b2bf8884b4c7a1cfc70..50ab672e10b216b96d00b86c58bc8c304718cbae 100644 (file)
@@ -201,6 +201,17 @@ extern size_t strnlen (char const *__string, size_t __maxlen);
 # define strnlen strnlen_is_unportable__use_gnulib_module_strnlen_for_portability
 #endif
 
+#if defined GNULIB_POSIXCHECK
+/* strcspn() 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
+   locale encoding is GB18030 and one of the characters to be searched is a
+   digit.  */
+# undef strcspn
+# define strcspn(s,a) \
+    (GL_LINK_WARNING ("strcspn cannot work correctly on character strings in multibyte locales - use mbscspn if you care about internationalization"), \
+     strcspn (s, a))
+#endif
+
 /* Find the first occurrence in S of any character in ACCEPT.  */
 #if @GNULIB_STRPBRK@
 # if ! @HAVE_STRPBRK@
@@ -352,6 +363,15 @@ extern int mbscasecmp (const char *s1, const char *s2);
 extern char * mbscasestr (const char *haystack, const char *needle);
 #endif
 
+#if @GNULIB_MBSCSPN@
+/* Find the first occurrence in the character string STRING of any character
+   in the character string ACCEPT.  Return the number of bytes from the
+   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);
+#endif
+
 
 #ifdef __cplusplus
 }
index f89046ac48efb2c8b93e16b9dce298ca842b9a78..ed06b9d19a067d84614839d7814c12379cddc4c5 100644 (file)
@@ -72,4 +72,5 @@ AC_DEFUN([gl_STRING_MODULE_INDICATOR_DEFAULTS],
   GNULIB_MBSSTR=0;      AC_SUBST([GNULIB_MBSSTR])
   GNULIB_MBSCASECMP=0;  AC_SUBST([GNULIB_MBSCASECMP])
   GNULIB_MBSCASESTR=0;  AC_SUBST([GNULIB_MBSCASESTR])
+  GNULIB_MBSCSPN=0;     AC_SUBST([GNULIB_MBSCSPN])
 ])
index 573c2c17780d35ce8244d342d18b1f0a3995e247..561eaef9402c35807525092be114f95780babd19 100644 (file)
@@ -26,6 +26,7 @@ string.h: string_.h
              -e 's|@''GNULIB_MBSSTR''@|$(GNULIB_MBSSTR)|g' \
              -e 's|@''GNULIB_MBSCASECMP''@|$(GNULIB_MBSCASECMP)|g' \
              -e 's|@''GNULIB_MBSCASESTR''@|$(GNULIB_MBSCASESTR)|g' \
+             -e 's|@''GNULIB_MBSCSPN''@|$(GNULIB_MBSCSPN)|g' \
              -e 's|@''GNULIB_MEMMEM''@|$(GNULIB_MEMMEM)|g' \
              -e 's|@''GNULIB_MEMPCPY''@|$(GNULIB_MEMPCPY)|g' \
              -e 's|@''GNULIB_MEMRCHR''@|$(GNULIB_MEMRCHR)|g' \