From: Bruno Haible Date: Mon, 3 Dec 2007 11:50:59 +0000 (+0100) Subject: Move declarations of str{,n}casecmp from to . X-Git-Tag: v0.1~7954 X-Git-Url: http://erislabs.net/gitweb/?a=commitdiff_plain;h=a8c5982a27c78c9da038f1520c43a948e4d50e48;p=gnulib.git Move declarations of str{,n}casecmp from to . --- diff --git a/ChangeLog b/ChangeLog index 9f3f241e0..b6747ee51 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2007-12-02 Bruno Haible + + Move declarations of str{,n}casecmp from to . + * 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 , not . + Reported by Karl Berry. + 2007-12-01 Eric Blake * m4/stdio_h.m4 (gl_STDIN_LARGE_OFFSET) [__CYGWIN__]: Rewrite to diff --git a/NEWS b/NEWS index 340437beb..4da28ccb5 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,9 @@ User visible incompatible changes Date Modules Changes +2007-12-03 strcase The include file is changed from to + . + 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 diff --git a/lib/string.in.h b/lib/string.in.h index ba7ca5319..c60e2f316 100644 --- 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 @@ extern char *stpncpy (char *restrict __dst, char const *restrict __src, 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. */ diff --git a/lib/strings.in.h b/lib/strings.in.h new file mode 100644 index 000000000..d87bc417a --- /dev/null +++ b/lib/strings.in.h @@ -0,0 +1,86 @@ +/* A substitute . + + 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 */ diff --git a/m4/string_h.m4 b/m4/string_h.m4 index d811e26b8..83711799a 100644 --- a/m4/string_h.m4 +++ b/m4/string_h.m4 @@ -64,8 +64,6 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS], 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]) diff --git a/m4/strings_h.m4 b/m4/strings_h.m4 new file mode 100644 index 000000000..03ac182f3 --- /dev/null +++ b/m4/strings_h.m4 @@ -0,0 +1,33 @@ +# Configure a replacement for . + +# 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]) +]) diff --git a/modules/strcase b/modules/strcase index b638de277..0023f4679 100644 --- a/modules/strcase +++ b/modules/strcase @@ -7,7 +7,7 @@ lib/strncasecmp.c m4/strcase.m4 Depends-on: -string +strings configure.ac: gl_STRCASE @@ -15,7 +15,7 @@ gl_STRCASE Makefile.am: Include: - + License: LGPLv2+ diff --git a/modules/string b/modules/string index f53253b8c..505ae6a53 100644 --- a/modules/string +++ b/modules/string @@ -56,8 +56,6 @@ string.h: string.in.h -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' \ diff --git a/modules/strings b/modules/strings new file mode 100644 index 000000000..beddb2082 --- /dev/null +++ b/modules/strings @@ -0,0 +1,40 @@ +Description: +A substitute . + +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 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 + +License: +LGPLv2+ + +Maintainer: +all