From: Bruno Haible Date: Wed, 12 Jan 2005 13:08:27 +0000 (+0000) Subject: Update 'strcase' module from gnulib. X-Git-Tag: v0.14.2~159 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c2a3c5e964b87f871f0e60f925d4c76bafe5ddc9;p=thirdparty%2Fgettext.git Update 'strcase' module from gnulib. --- diff --git a/gettext-tools/ChangeLog b/gettext-tools/ChangeLog index 3dee51f53..26708eb1e 100644 --- a/gettext-tools/ChangeLog +++ b/gettext-tools/ChangeLog @@ -1,3 +1,8 @@ +2005-01-06 Bruno Haible + + * configure.ac: Invoke gl_STRCASE. Don't test for strcasecmp and + strncasecmp here. + 2005-01-06 Bruno Haible * configure.ac: Invoke gl_FUNC_STPNCPY. diff --git a/gettext-tools/configure.ac b/gettext-tools/configure.ac index 458d0015e..fd54a081e 100644 --- a/gettext-tools/configure.ac +++ b/gettext-tools/configure.ac @@ -122,7 +122,7 @@ AC_FUNC_VPRINTF AC_CHECK_FUNCS([chown getcwd posix_spawn raise select strerror strtoul uname \ utime utimes waitid]) AC_REPLACE_FUNCS([atexit memmove memset stpcpy strcspn \ -strcasecmp strncasecmp strpbrk strstr vasprintf]) +strpbrk strstr vasprintf]) AM_FUNC_GETLINE if test $am_cv_func_working_getline != yes; then AC_CHECK_FUNCS(getdelim) @@ -132,6 +132,7 @@ gl_FUNC_FNMATCH_POSIX gl_GETOPT gl_FUNC_EACCESS gl_FUNC_STPNCPY +gl_STRCASE gl_MBSWIDTH gt_PREREQ_BACKUPFILE AC_FUNC_VFORK diff --git a/gettext-tools/lib/ChangeLog b/gettext-tools/lib/ChangeLog index 0d26f0564..f717a61a8 100644 --- a/gettext-tools/lib/ChangeLog +++ b/gettext-tools/lib/ChangeLog @@ -1,3 +1,8 @@ +2005-01-06 Bruno Haible + + * strcasecmp.c: Update from gnulib. + * strncasecmp.c: Update from gnulib. + 2005-01-06 Bruno Haible * stpncpy.h: Update from gnulib. diff --git a/gettext-tools/lib/strcasecmp.c b/gettext-tools/lib/strcasecmp.c index 8f85d1589..cf4ab88db 100644 --- a/gettext-tools/lib/strcasecmp.c +++ b/gettext-tools/lib/strcasecmp.c @@ -1,12 +1,10 @@ -/* Copyright (C) 1991-1992, 1995-1997, 2002 Free Software Foundation, Inc. +/* strcasecmp.c -- case insensitive string comparator + Copyright (C) 1998, 1999 Free Software Foundation, Inc. - NOTE: The canonical source of this file is maintained with the GNU C Library. - Bugs can be reported to bug-glibc@gnu.org. - - 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 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 @@ -14,59 +12,55 @@ 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifdef HAVE_CONFIG_H +#if HAVE_CONFIG_H # include #endif -#include -#include - -#ifndef weak_alias -# define __strcasecmp strcasecmp -# define TOLOWER(Ch) tolower (Ch) +#ifdef LENGTH_LIMIT +# define STRXCASECMP_FUNCTION strncasecmp +# define STRXCASECMP_DECLARE_N , size_t n +# define LENGTH_LIMIT_EXPR(Expr) Expr #else -# ifdef USE_IN_EXTENDED_LOCALE_MODEL -# define __strcasecmp __strcasecmp_l -# define TOLOWER(Ch) __tolower_l ((Ch), loc) -# else -# define TOLOWER(Ch) tolower (Ch) -# endif +# define STRXCASECMP_FUNCTION strcasecmp +# define STRXCASECMP_DECLARE_N /* empty */ +# define LENGTH_LIMIT_EXPR(Expr) 0 #endif -#ifdef USE_IN_EXTENDED_LOCALE_MODEL -# define LOCALE_PARAM , __locale_t loc -#else -# define LOCALE_PARAM -#endif +#include +#include + +#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch)) + +/* Compare {{no more than N characters 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. */ -/* Compare 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. */ int -__strcasecmp (const char *s1, const char *s2 LOCALE_PARAM) +STRXCASECMP_FUNCTION (const char *s1, const char *s2 STRXCASECMP_DECLARE_N) { - const unsigned char *p1 = (const unsigned char *) s1; - const unsigned char *p2 = (const unsigned char *) s2; + register const unsigned char *p1 = (const unsigned char *) s1; + register const unsigned char *p2 = (const unsigned char *) s2; unsigned char c1, c2; - if (p1 == p2) + if (p1 == p2 || LENGTH_LIMIT_EXPR (n == 0)) return 0; do { - c1 = TOLOWER (*p1++); - c2 = TOLOWER (*p2++); - if (c1 == '\0') + c1 = TOLOWER (*p1); + c2 = TOLOWER (*p2); + + if (LENGTH_LIMIT_EXPR (--n == 0) || c1 == '\0') break; + + ++p1; + ++p2; } while (c1 == c2); return c1 - c2; } -#ifndef __strcasecmp -weak_alias (__strcasecmp, strcasecmp) -#endif diff --git a/gettext-tools/lib/strncasecmp.c b/gettext-tools/lib/strncasecmp.c index 0cdbabe93..68d95aacc 100644 --- a/gettext-tools/lib/strncasecmp.c +++ b/gettext-tools/lib/strncasecmp.c @@ -1,74 +1,2 @@ -/* Compare at most N characters of two strings without taking care for - the case. - Copyright (C) 1992, 1996-1997, 2002 Free Software Foundation, Inc. - - NOTE: The canonical source of this file is maintained with the GNU C Library. - Bugs can be reported to bug-glibc@gnu.org. - - 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include - -#ifndef weak_alias -# define __strncasecmp strncasecmp -# define TOLOWER(Ch) tolower (Ch) -#else -# ifdef USE_IN_EXTENDED_LOCALE_MODEL -# define __strncasecmp __strncasecmp_l -# define TOLOWER(Ch) __tolower_l ((Ch), loc) -# else -# define TOLOWER(Ch) tolower (Ch) -# endif -#endif - -#ifdef USE_IN_EXTENDED_LOCALE_MODEL -# define LOCALE_PARAM , __locale_t loc -#else -# define LOCALE_PARAM -#endif - -/* Compare no more than N characters of 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. */ -int -__strncasecmp (const char *s1, const char *s2, size_t n LOCALE_PARAM) -{ - const unsigned char *p1 = (const unsigned char *) s1; - const unsigned char *p2 = (const unsigned char *) s2; - unsigned char c1, c2; - - if (p1 == p2 || n == 0) - return 0; - - do - { - c1 = TOLOWER (*p1++); - c2 = TOLOWER (*p2++); - if (c1 == '\0' || c1 != c2) - break; - } while (--n > 0); - - return c1 - c2; -} -#ifndef __strncasecmp -weak_alias (__strncasecmp, strncasecmp) -#endif +#define LENGTH_LIMIT +#include "strcasecmp.c" diff --git a/gettext-tools/m4/ChangeLog b/gettext-tools/m4/ChangeLog index 757b99ea0..2728c7e04 100644 --- a/gettext-tools/m4/ChangeLog +++ b/gettext-tools/m4/ChangeLog @@ -1,3 +1,8 @@ +2005-01-06 Bruno Haible + + * strcase.m4: New file, from gnulib. + * Makefile.am (EXTRA_DIST): Add it. + 2005-01-06 Bruno Haible * stpncpy.m4: New file, from gnulib. diff --git a/gettext-tools/m4/Makefile.am b/gettext-tools/m4/Makefile.am index 7df158932..7bf11a8dd 100644 --- a/gettext-tools/m4/Makefile.am +++ b/gettext-tools/m4/Makefile.am @@ -84,6 +84,7 @@ signalblocking.m4 \ ssize_t.m4 \ stdbool.m4 \ stpncpy.m4 \ +strcase.m4 \ strerror.m4 \ strerror_r.m4 \ tmpdir.m4 \