summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1996-12-18 03:30:20 +0000
committerJim Meyering <jim@meyering.net>1996-12-18 03:30:20 +0000
commit72f95044eb4fe9f1e22c2de876850d6b988f8a7b (patch)
treee5d2ee29f6f046356653537f20d9cb97fed9baa9 /lib
parent859f8587f822517d64c7298cd61bc04218c280c1 (diff)
downloadcoreutils-72f95044eb4fe9f1e22c2de876850d6b988f8a7b.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 'lib')
-rw-r--r--lib/backupfile.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/backupfile.c b/lib/backupfile.c
index 1698c3474..2ca512532 100644
--- a/lib/backupfile.c
+++ b/lib/backupfile.c
@@ -68,8 +68,17 @@ char *malloc ();
# define IN_CTYPE_DOMAIN(c) isascii(c)
#endif
-#define ISDIGIT(c) (IN_CTYPE_DOMAIN ((unsigned char) (c)) \
- && isdigit ((unsigned char) (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)
#if defined (HAVE_UNISTD_H)
#include <unistd.h>