changeset 9496:d7da1f241448

Move declarations of str{,n}casecmp from <string.h> to <strings.h>.
author Bruno Haible <bruno@clisp.org>
date Mon, 03 Dec 2007 12:50:59 +0100
parents c10236f27515
children e5ba9ffae779
files ChangeLog NEWS lib/string.in.h lib/strings.in.h m4/string_h.m4 m4/strings_h.m4 modules/strcase modules/string modules/strings
diffstat 9 files changed, 178 insertions(+), 50 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2007-12-02  Bruno Haible  <bruno@clisp.org>
+
+	Move declarations of str{,n}casecmp from <string.h> to <strings.h>.
+	* lib/strings.in.h: New file.
+	* lib/string.in.h (strcasecmp, strncasecmp): Remove declarations.
+	* m4/strings_h.m4: New file.
+	* m4/string_h.m4 (gl_HEADER_STRING_H_DEFAULTS): Remove initialization
+	of HAVE_STRCASECMP, HAVE_DECL_STRNCASECMP.
+	* modules/strings: New file.
+	* modules/string (Makefile.am): Update.
+	* modules/strcase (Include): Mention <strings.h>, not <string.h>.
+	Reported by Karl Berry.
+
 2007-12-01  Eric Blake  <ebb9@byu.net>
 
 	* m4/stdio_h.m4 (gl_STDIN_LARGE_OFFSET) [__CYGWIN__]: Rewrite to
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,9 @@
 
 Date        Modules         Changes
 
+2007-12-03  strcase         The include file is changed from <string.h> to
+                            <strings.h>.
+
 2007-10-07  most modules    The license for most modules has changed from
                             GPLv2+ to GPLv3+, and from LGPLv2+ to LGPLv3+.
                             A few modules are still under LGPLv2+; see the
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -32,6 +32,7 @@
 extern "C" {
 #endif
 
+
 /* Return the first occurrence of NEEDLE in HAYSTACK.  */
 #if @GNULIB_MEMMEM@
 # if ! @HAVE_DECL_MEMMEM@
@@ -103,50 +104,6 @@
      stpncpy (a, b, n))
 #endif
 
-/* Compare 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 does not work in multibyte locales.  */
-#if ! @HAVE_STRCASECMP@
-extern int strcasecmp (char const *s1, char const *s2);
-#endif
-#if defined GNULIB_POSIXCHECK
-/* strcasecmp() does not work with multibyte strings:
-   POSIX says that it operates on "strings", and "string" in POSIX is defined
-   as a sequence of bytes, not of characters.   */
-# undef strcasecmp
-# define strcasecmp(a,b) \
-    (GL_LINK_WARNING ("strcasecmp cannot work correctly on character strings " \
-                      "in multibyte locales - " \
-                      "use mbscasecmp if you care about " \
-                      "internationalization, or use c_strcasecmp (from " \
-                      "gnulib module c-strcase) if you want a locale " \
-                      "independent function"), \
-     strcasecmp (a, b))
-#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@
-extern int strncasecmp (char const *s1, char const *s2, size_t n);
-#endif
-#if defined GNULIB_POSIXCHECK
-/* strncasecmp() does not work with multibyte strings:
-   POSIX says that it operates on "strings", and "string" in POSIX is defined
-   as a sequence of bytes, not of characters.  */
-# undef strncasecmp
-# define strncasecmp(a,b,n) \
-    (GL_LINK_WARNING ("strncasecmp cannot work correctly on character " \
-                      "strings in multibyte locales - " \
-                      "use mbsncasecmp or mbspcasecmp if you care about " \
-                      "internationalization, or use c_strncasecmp (from " \
-                      "gnulib module c-strcase) if you want a locale " \
-                      "independent function"), \
-     strncasecmp (a, b, n))
-#endif
-
 #if defined GNULIB_POSIXCHECK
 /* strchr() does not work with multibyte strings if the locale encoding is
    GB18030 and the character to be searched is a digit.  */
new file mode 100644
--- /dev/null
+++ b/lib/strings.in.h
@@ -0,0 +1,86 @@
+/* A substitute <strings.h>.
+
+   Copyright (C) 2007 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#ifndef _GL_STRINGS_H
+
+/* The include_next requires a split double-inclusion guard.  */
+#@INCLUDE_NEXT@ @NEXT_STRINGS_H@
+
+#ifndef _GL_STRINGS_H
+#define _GL_STRINGS_H
+
+
+/* The definition of GL_LINK_WARNING is copied here.  */
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Compare 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 does not work in multibyte locales.  */
+#if ! @HAVE_STRCASECMP@
+extern int strcasecmp (char const *s1, char const *s2);
+#endif
+#if defined GNULIB_POSIXCHECK
+/* strcasecmp() does not work with multibyte strings:
+   POSIX says that it operates on "strings", and "string" in POSIX is defined
+   as a sequence of bytes, not of characters.   */
+# undef strcasecmp
+# define strcasecmp(a,b) \
+    (GL_LINK_WARNING ("strcasecmp cannot work correctly on character strings " \
+                      "in multibyte locales - " \
+                      "use mbscasecmp if you care about " \
+                      "internationalization, or use c_strcasecmp (from " \
+                      "gnulib module c-strcase) if you want a locale " \
+                      "independent function"), \
+     strcasecmp (a, b))
+#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@
+extern int strncasecmp (char const *s1, char const *s2, size_t n);
+#endif
+#if defined GNULIB_POSIXCHECK
+/* strncasecmp() does not work with multibyte strings:
+   POSIX says that it operates on "strings", and "string" in POSIX is defined
+   as a sequence of bytes, not of characters.  */
+# undef strncasecmp
+# define strncasecmp(a,b,n) \
+    (GL_LINK_WARNING ("strncasecmp cannot work correctly on character " \
+                      "strings in multibyte locales - " \
+                      "use mbsncasecmp or mbspcasecmp if you care about " \
+                      "internationalization, or use c_strncasecmp (from " \
+                      "gnulib module c-strcase) if you want a locale " \
+                      "independent function"), \
+     strncasecmp (a, b, n))
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _GL_STRING_H */
+#endif /* _GL_STRING_H */
--- a/m4/string_h.m4
+++ b/m4/string_h.m4
@@ -64,8 +64,6 @@
   HAVE_DECL_MEMRCHR=1;		AC_SUBST([HAVE_DECL_MEMRCHR])
   HAVE_STPCPY=1;		AC_SUBST([HAVE_STPCPY])
   HAVE_STPNCPY=1;		AC_SUBST([HAVE_STPNCPY])
-  HAVE_STRCASECMP=1;		AC_SUBST([HAVE_STRCASECMP])
-  HAVE_DECL_STRNCASECMP=1;	AC_SUBST([HAVE_DECL_STRNCASECMP])
   HAVE_STRCHRNUL=1;		AC_SUBST([HAVE_STRCHRNUL])
   HAVE_DECL_STRDUP=1;		AC_SUBST([HAVE_DECL_STRDUP])
   HAVE_STRNDUP=1;		AC_SUBST([HAVE_STRNDUP])
new file mode 100644
--- /dev/null
+++ b/m4/strings_h.m4
@@ -0,0 +1,33 @@
+# Configure a replacement for <string.h>.
+
+# Copyright (C) 2007 Free Software Foundation, Inc.
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_HEADER_STRINGS_H],
+[
+  dnl Use AC_REQUIRE here, so that the default behavior below is expanded
+  dnl once only, before all statements that occur in other macros.
+  AC_REQUIRE([gl_HEADER_STRINGS_H_BODY])
+])
+
+AC_DEFUN([gl_HEADER_STRINGS_H_BODY],
+[
+  AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS])
+  gl_CHECK_NEXT_HEADERS([strings.h])
+])
+
+AC_DEFUN([gl_STRINGS_MODULE_INDICATOR],
+[
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+  AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS])
+  GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
+])
+
+AC_DEFUN([gl_HEADER_STRINGS_H_DEFAULTS],
+[
+  dnl Assume proper GNU behavior unless another module says otherwise.
+  HAVE_STRCASECMP=1;       AC_SUBST([HAVE_STRCASECMP])
+  HAVE_DECL_STRNCASECMP=1; AC_SUBST([HAVE_DECL_STRNCASECMP])
+])
--- a/modules/strcase
+++ b/modules/strcase
@@ -7,7 +7,7 @@
 m4/strcase.m4
 
 Depends-on:
-string
+strings
 
 configure.ac:
 gl_STRCASE
@@ -15,7 +15,7 @@
 Makefile.am:
 
 Include:
-<string.h>
+<strings.h>
 
 License:
 LGPLv2+
--- a/modules/string
+++ b/modules/string
@@ -56,8 +56,6 @@
 	      -e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \
 	      -e 's|@''HAVE_STPCPY''@|$(HAVE_STPCPY)|g' \
 	      -e 's|@''HAVE_STPNCPY''@|$(HAVE_STPNCPY)|g' \
-	      -e 's|@''HAVE_STRCASECMP''@|$(HAVE_STRCASECMP)|g' \
-	      -e 's|@''HAVE_DECL_STRNCASECMP''@|$(HAVE_DECL_STRNCASECMP)|g' \
 	      -e 's|@''HAVE_STRCHRNUL''@|$(HAVE_STRCHRNUL)|g' \
 	      -e 's|@''HAVE_DECL_STRDUP''@|$(HAVE_DECL_STRDUP)|g' \
 	      -e 's|@''HAVE_STRNDUP''@|$(HAVE_STRNDUP)|g' \
new file mode 100644
--- /dev/null
+++ b/modules/strings
@@ -0,0 +1,40 @@
+Description:
+A substitute <strings.h>.
+
+Files:
+lib/strings.in.h
+m4/strings_h.m4
+
+Depends-on:
+include_next
+link-warning
+
+configure.ac:
+gl_HEADER_STRINGS_H
+
+Makefile.am:
+BUILT_SOURCES += strings.h
+
+# We need the following in order to create <strings.h> when the system
+# doesn't have one that works with the given compiler.
+strings.h: strings.in.h
+	rm -f $@-t $@
+	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+	  sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \
+	      -e 's|@''NEXT_STRINGS_H''@|$(NEXT_STRINGS_H)|g' \
+	      -e 's|@''HAVE_STRCASECMP''@|$(HAVE_STRCASECMP)|g' \
+	      -e 's|@''HAVE_DECL_STRNCASECMP''@|$(HAVE_DECL_STRNCASECMP)|g' \
+	      -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+	      < $(srcdir)/strings.in.h; \
+	} > $@-t
+	mv $@-t $@
+MOSTLYCLEANFILES += strings.h strings.h-t
+
+Include:
+#include <strings.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+all