Mercurial > hg > octave-nkf > gnulib-hg
changeset 811:193f7d202848
(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.
author | Jim Meyering <jim@meyering.net> |
---|---|
date | Fri, 13 Dec 1996 03:05:00 +0000 |
parents | 84de117a2c81 |
children | 9374a785572a |
files | lib/getdate.y |
diffstat | 1 files changed, 17 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- 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 @@ 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';