summaryrefslogtreecommitdiff
path: root/lib/getdate.y
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1996-12-13 03:05:00 +0000
committerJim Meyering <jim@meyering.net>1996-12-13 03:05:00 +0000
commit86d6c36d09c912275d73fabf7254b10c101980a7 (patch)
tree6e5b6f3c0a01854fabe6a2ad4ab6a39b224e302f /lib/getdate.y
parenta7f5043de8e008d7beec5cd5190141962977a401 (diff)
downloadcoreutils-86d6c36d09c912275d73fabf7254b10c101980a7.tar.xz
(IN_CTYPE_DOMAIN): Rename from ISASCII.
(ISDIGIT): New definition from Paul Eggert. This one evaluates its argument exactly once. (yylex): Move increment out of ISALPHA argument. Use a comma-expression instead.
Diffstat (limited to 'lib/getdate.y')
-rw-r--r--lib/getdate.y25
1 files changed, 17 insertions, 8 deletions
diff --git a/lib/getdate.y b/lib/getdate.y
index f7040182a..9dcb93f7a 100644
--- a/lib/getdate.y
+++ b/lib/getdate.y
@@ -34,16 +34,25 @@
#include <stdio.h>
#include <ctype.h>
-#if defined (STDC_HEADERS) || !defined (isascii)
-# define ISASCII(c) 1
+#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
+# define IN_CTYPE_DOMAIN(c) 1
#else
-# define ISASCII(c) isascii(c)
+# define IN_CTYPE_DOMAIN(c) isascii(c)
#endif
-#define ISSPACE(c) (ISASCII (c) && isspace (c))
-#define ISALPHA(c) (ISASCII (c) && isalpha (c))
-#define ISUPPER(c) (ISASCII (c) && isupper (c))
-#define ISDIGIT(c) (ISASCII (c) && isdigit (c))
+#define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c))
+#define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c))
+#define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (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 (vms)
#include <types.h>
@@ -902,7 +911,7 @@ yylex ()
return sign ? tSNUMBER : tUNUMBER;
}
if (ISALPHA (c)) {
- for (p = buff; ISALPHA (c = *yyInput++) || c == '.'; )
+ for (p = buff; (c = *yyInput++, ISALPHA (c)) || c == '.'; )
if (p < &buff[sizeof buff - 1])
*p++ = c;
*p = '\0';