#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>
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';