From 86d6c36d09c912275d73fabf7254b10c101980a7 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 13 Dec 1996 03:05:00 +0000 Subject: [PATCH] (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. --- lib/getdate.y | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/getdate.y b/lib/getdate.y index f704018..9dcb93f 100644 --- a/lib/getdate.y +++ b/lib/getdate.y @@ -34,16 +34,25 @@ #include #include -#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 @@ -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'; -- 2.7.4