From 2a41a72b8cfd05b9d6b050194ea6e1c877b9fd3b Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Tue, 28 Dec 2021 19:33:23 +0100 Subject: [PATCH] Use standard isspace(3), isalpha(3), and isupper(3) Due to the recent removal of IN_CTYPE_DOMAIN(), the uppercase macros that wrapped these standard calls are now defined to be equivalent. Therefore, there's no need for the wrappers, and it is much more readable to use the standard calls directly. However, hold on with ISDIGIT*(), since it's not so obvious what to do with it. Signed-off-by: Alejandro Colomar --- libmisc/getdate.y | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/libmisc/getdate.y b/libmisc/getdate.y index ce2235fd..4d282edc 100644 --- a/libmisc/getdate.y +++ b/libmisc/getdate.y @@ -31,9 +31,6 @@ #include #include -#define ISSPACE(c) isspace (c) -#define ISALPHA(c) isalpha (c) -#define ISUPPER(c) isupper (c) #define ISDIGIT_LOCALE(c) isdigit (c) /* ISDIGIT differs from ISDIGIT_LOCALE, as follows: @@ -643,7 +640,7 @@ static int LookupWord (char *buff) /* Make it lowercase. */ for (p = buff; '\0' != *p; p++) - if (ISUPPER (*p)) + if (isupper (*p)) *p = tolower (*p); if (strcmp (buff, "am") == 0 || strcmp (buff, "a.m.") == 0) @@ -724,7 +721,7 @@ static int LookupWord (char *buff) } /* Military timezones. */ - if (buff[1] == '\0' && ISALPHA (*buff)) + if (buff[1] == '\0' && isalpha (*buff)) { for (tp = MilitaryTable; tp->name; tp++) if (strcmp (buff, tp->name) == 0) @@ -763,7 +760,7 @@ yylex (void) for (;;) { - while (ISSPACE (*yyInput)) + while (isspace (*yyInput)) yyInput++; if (ISDIGIT (c = *yyInput) || c == '-' || c == '+') @@ -784,9 +781,9 @@ yylex (void) yylval.Number = -yylval.Number; return (0 != sign) ? tSNUMBER : tUNUMBER; } - if (ISALPHA (c)) + if (isalpha (c)) { - for (p = buff; (c = *yyInput++, ISALPHA (c)) || c == '.';) + for (p = buff; (c = *yyInput++, isalpha (c)) || c == '.';) if (p < &buff[sizeof buff - 1]) *p++ = c; *p = '\0';