From: Jim Meyering Date: Wed, 18 Dec 1996 03:22:56 +0000 (+0000) Subject: (ISDIGIT): Replace with smaller, faster edition X-Git-Tag: FILEUTILS-3_14a~87 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=357c53621f5498b2e0eda31b3a04d98da57d7933;p=platform%2Fupstream%2Fcoreutils.git (ISDIGIT): Replace with smaller, faster edition that yields nonzero only on ASCII digits. (ISDIGIT_LOCALE): New macro, with same meaning that ISDIGIT used to have. From Paul Eggert. --- diff --git a/src/system.h b/src/system.h index c46451f..13634fe 100644 --- a/src/system.h +++ b/src/system.h @@ -338,7 +338,6 @@ char *alloca (); #endif #define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c)) -#define ISDIGIT(c) (IN_CTYPE_DOMAIN (c) && isdigit (c)) #define ISALNUM(c) (IN_CTYPE_DOMAIN (c) && isalnum (c)) #define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c)) #define ISCNTRL(c) (IN_CTYPE_DOMAIN (c) && iscntrl (c)) @@ -347,6 +346,17 @@ char *alloca (); #define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c)) #define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (c)) #define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit (c)) +#define ISDIGIT_LOCALE(c) (IN_CTYPE_DOMAIN (c) && isdigit (c)) + +/* ISDIGIT differs from ISDIGIT_LOCALE, as follows: + - Its arg may be any int or unsigned int; it need not be an unsigned char. + - It's guaranteed to evaluate its argument exactly once. + - It's typically faster. + Posix 1003.2-1992 section 2.5.2.1 page 50 lines 1556-1558 says that + only '0' through '9' are digits. Prefer ISDIGIT to ISDIGIT_LOCALE unless + it's important to use the locale's definition of `digit' even when the + host does not conform to Posix. */ +#define ISDIGIT(c) ((unsigned) (c) - '0' <= 9) #ifndef __P #if defined (__GNUC__) || (defined (__STDC__) && __STDC__)