From: Bruno Haible Date: Fri, 15 Aug 2003 13:04:59 +0000 (+0000) Subject: Update from gnulib. X-Git-Tag: v0.13~364 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=404282bb64a7345aa63fd51e87b3d5245e0d0dec;p=thirdparty%2Fgettext.git Update from gnulib. --- diff --git a/gettext-tools/lib/ChangeLog b/gettext-tools/lib/ChangeLog index ae4784934..226aed5c9 100644 --- a/gettext-tools/lib/ChangeLog +++ b/gettext-tools/lib/ChangeLog @@ -1,3 +1,11 @@ +2003-01-28 Bruno Haible + + * c-ctype.h: Assume C_CTYPE_CONSECUTIVE_DIGITS. + (c_isascii, c_isalnum, c_isalpha, c_isxdigit): Optimize. + * c-ctype.c (c_isascii, c_isalnum, c_isalpha, c_ispunct, c_isxdigit): + Optimize. + Suggested by Paul Eggert. + 2003-08-14 Bruno Haible * config.charset: Add support for Linux libc5. Based on data from diff --git a/gettext-tools/lib/c-ctype.c b/gettext-tools/lib/c-ctype.c index b8452060d..46714d3ac 100644 --- a/gettext-tools/lib/c-ctype.c +++ b/gettext-tools/lib/c-ctype.c @@ -1,6 +1,6 @@ /* Character handling in C locale. - Copyright 2000-2002 Free Software Foundation, Inc. + Copyright 2000-2003 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 @@ -40,7 +40,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ bool c_isascii (int c) { - return ((c & ~0x7f) == 0); + return (c >= 0x00 && c <= 0x7f); } bool @@ -48,9 +48,14 @@ c_isalnum (int c) { #if C_CTYPE_CONSECUTIVE_DIGITS \ && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE +#if C_CTYPE_ASCII + return ((c >= '0' && c <= '9') + || ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z')); +#else return ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')); +#endif #else switch (c) { @@ -77,7 +82,11 @@ bool c_isalpha (int c) { #if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE +#if C_CTYPE_ASCII + return ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z'); +#else return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')); +#endif #else switch (c) { @@ -249,8 +258,7 @@ c_ispunct (int c) #if C_CTYPE_ASCII return ((c >= '!' && c <= '~') && !((c >= '0' && c <= '9') - || (c >= 'A' && c <= 'Z') - || (c >= 'a' && c <= 'z'))); + || ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z'))); #else switch (c) { @@ -300,9 +308,14 @@ c_isxdigit (int c) { #if C_CTYPE_CONSECUTIVE_DIGITS \ && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE +#if C_CTYPE_ASCII + return ((c >= '0' && c <= '9') + || ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'F')); +#else return ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f')); +#endif #else switch (c) { diff --git a/gettext-tools/lib/c-ctype.h b/gettext-tools/lib/c-ctype.h index 104d7dae2..990997bee 100644 --- a/gettext-tools/lib/c-ctype.h +++ b/gettext-tools/lib/c-ctype.h @@ -5,7 +5,7 @@ functions' behaviour depends on the current locale set via setlocale. - Copyright (C) 2000-2002 Free Software Foundation, Inc. + Copyright (C) 2000-2003 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 @@ -27,14 +27,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include +/* The functions defined in this file assume the "C" locale and a character + set without diacritics (ASCII-US or EBCDIC-US or something like that). + Even if the "C" locale on a particular system is an extension of the ASCII + character set (like on BeOS, where it is UTF-8, or on AmigaOS, where it + is ISO-8859-1), the functions in this file recognize only the ASCII + characters. */ + + /* Check whether the ASCII optimizations apply. */ -#if ('0' <= '9') \ - && ('0' + 1 == '1') && ('1' + 1 == '2') && ('2' + 1 == '3') \ - && ('3' + 1 == '4') && ('4' + 1 == '5') && ('5' + 1 == '6') \ - && ('6' + 1 == '7') && ('7' + 1 == '8') && ('8' + 1 == '9') +/* ANSI C89 (and ISO C99 5.2.1.3 too) already guarantees that + '0', '1', ..., '9' have consecutive integer values. */ #define C_CTYPE_CONSECUTIVE_DIGITS 1 -#endif #if ('A' <= 'Z') \ && ('A' + 1 == 'B') && ('B' + 1 == 'C') && ('C' + 1 == 'D') \ @@ -85,7 +90,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \ && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126) -/* The character set is ISO-646, not EBCDIC. */ +/* The character set is ASCII or one of its variants or extensions, not EBCDIC. + Testing the value of '\n' and '\r' is not relevant. */ #define C_CTYPE_ASCII 1 #endif @@ -117,11 +123,18 @@ extern int c_toupper (int c); #define c_isascii(c) \ ({ int __c = (c); \ - ((__c & ~0x7f) == 0); \ + (__c >= 0x00 && __c <= 0x7f); \ }) #if C_CTYPE_CONSECUTIVE_DIGITS \ && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE +#if C_CTYPE_ASCII +#define c_isalnum(c) \ + ({ int __c = (c); \ + ((__c >= '0' && __c <= '9') \ + || ((__c & ~0x20) >= 'A' && (__c & ~0x20) <= 'Z')); \ + }) +#else #define c_isalnum(c) \ ({ int __c = (c); \ ((__c >= '0' && __c <= '9') \ @@ -129,13 +142,21 @@ extern int c_toupper (int c); || (__c >= 'a' && __c <= 'z')); \ }) #endif +#endif #if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE +#if C_CTYPE_ASCII +#define c_isalpha(c) \ + ({ int __c = (c); \ + ((__c & ~0x20) >= 'A' && (__c & ~0x20) <= 'Z'); \ + }) +#else #define c_isalpha(c) \ ({ int __c = (c); \ ((__c >= 'A' && __c <= 'Z') || (__c >= 'a' && __c <= 'z')); \ }) #endif +#endif #define c_isblank(c) \ ({ int __c = (c); \ @@ -199,6 +220,13 @@ extern int c_toupper (int c); #if C_CTYPE_CONSECUTIVE_DIGITS \ && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE +#if C_CTYPE_ASCII +#define c_isxdigit(c) \ + ({ int __c = (c); \ + ((__c >= '0' && __c <= '9') \ + || ((__c & ~0x20) >= 'A' && (__c & ~0x20) <= 'F')); \ + }) +#else #define c_isxdigit(c) \ ({ int __c = (c); \ ((__c >= '0' && __c <= '9') \ @@ -206,6 +234,7 @@ extern int c_toupper (int c); || (__c >= 'a' && __c <= 'f')); \ }) #endif +#endif #if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE #define c_tolower(c) \