]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Update from gnulib.
authorBruno Haible <bruno@clisp.org>
Fri, 15 Aug 2003 13:04:59 +0000 (13:04 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:10:49 +0000 (12:10 +0200)
gettext-tools/lib/ChangeLog
gettext-tools/lib/c-ctype.c
gettext-tools/lib/c-ctype.h

index ae4784934bf35a29539af0fe3f104b23604449ba..226aed5c9b1545278b3d692548ab247f3ea3bf61 100644 (file)
@@ -1,3 +1,11 @@
+2003-01-28  Bruno Haible  <bruno@clisp.org>
+
+       * 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  <bruno@clisp.org>
 
        * config.charset: Add support for Linux libc5. Based on data from
index b8452060de7bd6621766feb0576f9d7325f8b54f..46714d3ac891b05384fd4af58b43bbfd17123f42 100644 (file)
@@ -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)
     {
index 104d7dae2777e55fbd05d12e92f66ff1476bc41a..990997bee5c2b0bfc20ff1082835e7c88772a5a9 100644 (file)
@@ -5,7 +5,7 @@
    <ctype.h> 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 <stdbool.h>
 
 
+/* 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) \