summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1996-12-18 03:22:56 +0000
committerJim Meyering <jim@meyering.net>1996-12-18 03:22:56 +0000
commit357c53621f5498b2e0eda31b3a04d98da57d7933 (patch)
tree5c25212d9da7ce5121622181ffb4706ae76e63b3 /src
parentfd688bcc5fe15469e8a2ebaf7eddaba974aeab23 (diff)
downloadcoreutils-357c53621f5498b2e0eda31b3a04d98da57d7933.tar.xz
(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.
Diffstat (limited to 'src')
-rw-r--r--src/system.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/system.h b/src/system.h
index c46451fc0..13634fe66 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__)