-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to Paul Eggert on 11/6/2005 3:59 AM: >>My approach was to add a dependency on the c-ctype module to use c_isalpha > > That seems a bit overkill here, since you can assume ASCII and DOS. > Why not use this instead? > > #define c_isalpha(c) (((unsigned int) (c) | ('a' - 'A')) - 'a' <= 'z' - 'a')
This is a slick definition, but it is different than what c-ctype.h provided, and that definition was not guarded. Bruno, would you accept the following patch to c-ctype, so that the order between "c-ctype.h" and my patched "dirname.h" won't matter? An alternative to editing c-ctype is naming the dirname.h version IS_DRIVE_LETTER instead of c_isalpha. 2005-11-08 Eric Blake <[EMAIL PROTECTED]> * c-ctype.h: Indent preprocessor directives. (c_isalpha) [C_CTYPE_ASCII]: Guard against redefinition. - -- Life is short - so eat dessert first! Eric Blake [EMAIL PROTECTED] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFDcYBP84KuGfSFAYARAvrdAKCBWxUfBgocL8pd1KWP8/Zq6TVGzgCeOHrm GJFW4s+QpAyb9Y4a1dryCoo= =fMH7 -----END PGP SIGNATURE-----
Index: lib/c-ctype.h =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/c-ctype.h,v retrieving revision 1.3 diff -u -p -r1.3 c-ctype.h --- lib/c-ctype.h 14 May 2005 06:03:57 -0000 1.3 +++ lib/c-ctype.h 9 Nov 2005 04:48:27 -0000 @@ -5,7 +5,7 @@ <ctype.h> functions' behaviour depends on the current locale set via setlocale. - Copyright (C) 2000-2003 Free Software Foundation, Inc. + Copyright (C) 2000-2003, 2005 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 @@ -22,9 +22,9 @@ along with this program; if not, write t Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef C_CTYPE_H -#define C_CTYPE_H +# define C_CTYPE_H -#include <stdbool.h> +# include <stdbool.h> /* The functions defined in this file assume the "C" locale and a character @@ -39,9 +39,9 @@ Foundation, Inc., 51 Franklin Street, Fi /* 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 +# define C_CTYPE_CONSECUTIVE_DIGITS 1 -#if ('A' <= 'Z') \ +# if ('A' <= 'Z') \ && ('A' + 1 == 'B') && ('B' + 1 == 'C') && ('C' + 1 == 'D') \ && ('D' + 1 == 'E') && ('E' + 1 == 'F') && ('F' + 1 == 'G') \ && ('G' + 1 == 'H') && ('H' + 1 == 'I') && ('I' + 1 == 'J') \ @@ -51,10 +51,10 @@ Foundation, Inc., 51 Franklin Street, Fi && ('S' + 1 == 'T') && ('T' + 1 == 'U') && ('U' + 1 == 'V') \ && ('V' + 1 == 'W') && ('W' + 1 == 'X') && ('X' + 1 == 'Y') \ && ('Y' + 1 == 'Z') -#define C_CTYPE_CONSECUTIVE_UPPERCASE 1 -#endif +# define C_CTYPE_CONSECUTIVE_UPPERCASE 1 +# endif -#if ('a' <= 'z') \ +# if ('a' <= 'z') \ && ('a' + 1 == 'b') && ('b' + 1 == 'c') && ('c' + 1 == 'd') \ && ('d' + 1 == 'e') && ('e' + 1 == 'f') && ('f' + 1 == 'g') \ && ('g' + 1 == 'h') && ('h' + 1 == 'i') && ('i' + 1 == 'j') \ @@ -64,10 +64,10 @@ Foundation, Inc., 51 Franklin Street, Fi && ('s' + 1 == 't') && ('t' + 1 == 'u') && ('u' + 1 == 'v') \ && ('v' + 1 == 'w') && ('w' + 1 == 'x') && ('x' + 1 == 'y') \ && ('y' + 1 == 'z') -#define C_CTYPE_CONSECUTIVE_LOWERCASE 1 -#endif +# define C_CTYPE_CONSECUTIVE_LOWERCASE 1 +# endif -#if (' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ +# if (' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \ && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \ @@ -92,8 +92,8 @@ Foundation, Inc., 51 Franklin Street, Fi && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126) /* 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 +# define C_CTYPE_ASCII 1 +# endif /* Function declarations. */ @@ -117,136 +117,138 @@ extern int c_tolower (int c); extern int c_toupper (int c); -#if defined __GNUC__ && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__ +# if defined __GNUC__ && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__ /* ASCII optimizations. */ -#define c_isascii(c) \ +# define c_isascii(c) \ ({ int __c = (c); \ (__c >= 0x00 && __c <= 0x7f); \ }) -#if C_CTYPE_CONSECUTIVE_DIGITS \ +# if C_CTYPE_CONSECUTIVE_DIGITS \ && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE -#if C_CTYPE_ASCII -#define c_isalnum(c) \ +# 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) \ +# else +# define c_isalnum(c) \ ({ int __c = (c); \ ((__c >= '0' && __c <= '9') \ || (__c >= 'A' && __c <= 'Z') \ || (__c >= 'a' && __c <= 'z')); \ }) -#endif -#endif +# endif +# endif -#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE -#if C_CTYPE_ASCII -#define c_isalpha(c) \ +# if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE +# if C_CTYPE_ASCII +# ifndef c_isalpha +# define c_isalpha(c) \ ({ int __c = (c); \ ((__c & ~0x20) >= 'A' && (__c & ~0x20) <= 'Z'); \ }) -#else -#define c_isalpha(c) \ +# endif +# else +# define c_isalpha(c) \ ({ int __c = (c); \ ((__c >= 'A' && __c <= 'Z') || (__c >= 'a' && __c <= 'z')); \ }) -#endif -#endif +# endif +# endif -#define c_isblank(c) \ +# define c_isblank(c) \ ({ int __c = (c); \ (__c == ' ' || __c == '\t'); \ }) -#if C_CTYPE_ASCII -#define c_iscntrl(c) \ +# if C_CTYPE_ASCII +# define c_iscntrl(c) \ ({ int __c = (c); \ ((__c & ~0x1f) == 0 || __c == 0x7f); \ }) -#endif +# endif -#if C_CTYPE_CONSECUTIVE_DIGITS -#define c_isdigit(c) \ +# if C_CTYPE_CONSECUTIVE_DIGITS +# define c_isdigit(c) \ ({ int __c = (c); \ (__c >= '0' && __c <= '9'); \ }) -#endif +# endif -#if C_CTYPE_CONSECUTIVE_LOWERCASE -#define c_islower(c) \ +# if C_CTYPE_CONSECUTIVE_LOWERCASE +# define c_islower(c) \ ({ int __c = (c); \ (__c >= 'a' && __c <= 'z'); \ }) -#endif +# endif -#if C_CTYPE_ASCII -#define c_isgraph(c) \ +# if C_CTYPE_ASCII +# define c_isgraph(c) \ ({ int __c = (c); \ (__c >= '!' && __c <= '~'); \ }) -#endif +# endif -#if C_CTYPE_ASCII -#define c_isprint(c) \ +# if C_CTYPE_ASCII +# define c_isprint(c) \ ({ int __c = (c); \ (__c >= ' ' && __c <= '~'); \ }) -#endif +# endif -#if C_CTYPE_ASCII -#define c_ispunct(c) \ +# if C_CTYPE_ASCII +# define c_ispunct(c) \ ({ int _c = (c); \ (c_isgraph (_c) && ! c_isalnum (_c)); \ }) -#endif +# endif -#define c_isspace(c) \ +# define c_isspace(c) \ ({ int __c = (c); \ (__c == ' ' || __c == '\t' \ || __c == '\n' || __c == '\v' || __c == '\f' || __c == '\r'); \ }) -#if C_CTYPE_CONSECUTIVE_UPPERCASE -#define c_isupper(c) \ +# if C_CTYPE_CONSECUTIVE_UPPERCASE +# define c_isupper(c) \ ({ int __c = (c); \ (__c >= 'A' && __c <= 'Z'); \ }) -#endif +# endif -#if C_CTYPE_CONSECUTIVE_DIGITS \ +# if C_CTYPE_CONSECUTIVE_DIGITS \ && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE -#if C_CTYPE_ASCII -#define c_isxdigit(c) \ +# 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) \ +# else +# define c_isxdigit(c) \ ({ int __c = (c); \ ((__c >= '0' && __c <= '9') \ || (__c >= 'A' && __c <= 'F') \ || (__c >= 'a' && __c <= 'f')); \ }) -#endif -#endif +# endif +# endif -#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE -#define c_tolower(c) \ +# if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE +# define c_tolower(c) \ ({ int __c = (c); \ (__c >= 'A' && __c <= 'Z' ? __c - 'A' + 'a' : __c); \ }) -#define c_toupper(c) \ +# define c_toupper(c) \ ({ int __c = (c); \ (__c >= 'a' && __c <= 'z' ? __c - 'a' + 'A' : __c); \ }) -#endif +# endif -#endif /* optimizing for speed */ +# endif /* optimizing for speed */ #endif /* C_CTYPE_H */
_______________________________________________ bug-gnulib mailing list bug-gnulib@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnulib