Skip to content

Commit 49f9ecc

Browse files
committed
handy.h: "base"' => "posix"
These internal macros were originaly called "porcelain" due to my misperception of what that term means. Commit cbc5b6f changed that to 'base'. But I realize now that the real purpose of these macros is to create an API that returns a POSIX-compliant result. Most platforms return such a value already, so the macros expand to just the platform's underlying value. But on platforms that aren't compliant, these add logic to make their results compliant. The better name then is 'posix'.
1 parent 6af0187 commit 49f9ecc

File tree

1 file changed

+62
-62
lines changed

1 file changed

+62
-62
lines changed

handy.h

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,27 +1957,27 @@ END_EXTERN_C
19571957
* The first two aren't in C89, so the fallback is to use the non-locale
19581958
* sensitive versions; these are the same for all platforms */
19591959
#if defined(HAS_ISASCII)
1960-
# define is_base_ASCII(c) isascii((U8) (c))
1960+
# define is_posix_ASCII(c) isascii((U8) (c))
19611961
#else
1962-
# define is_base_ASCII(c) isASCII(c)
1962+
# define is_posix_ASCII(c) isASCII(c)
19631963
#endif
19641964

19651965
#if defined(HAS_ISBLANK)
1966-
# define is_base_BLANK(c) isblank((U8) (c))
1966+
# define is_posix_BLANK(c) isblank((U8) (c))
19671967
#else
1968-
# define is_base_BLANK(c) isBLANK(c)
1968+
# define is_posix_BLANK(c) isBLANK(c)
19691969
#endif
19701970

19711971
/* The next few are the same in all platforms. */
1972-
#define is_base_CNTRL(c) iscntrl((U8) (c))
1973-
#define is_base_IDFIRST(c) (UNLIKELY((c) == '_') || is_base_ALPHA(c))
1974-
#define is_base_SPACE(c) isspace((U8) (c))
1975-
#define is_base_WORDCHAR(c) (UNLIKELY((c) == '_') || is_base_ALPHANUMERIC(c))
1972+
#define is_posix_CNTRL(c) iscntrl((U8) (c))
1973+
#define is_posix_IDFIRST(c) (UNLIKELY((c) == '_') || is_posix_ALPHA(c))
1974+
#define is_posix_SPACE(c) isspace((U8) (c))
1975+
#define is_posix_WORDCHAR(c) (UNLIKELY((c) == '_') || is_posix_ALPHANUMERIC(c))
19761976

19771977
/* The base-level case changing macros are also the same in all platforms */
1978-
#define to_base_LOWER(c) tolower((U8) (c))
1979-
#define to_base_UPPER(c) toupper((U8) (c))
1980-
#define to_base_FOLD(c) to_base_LOWER(c)
1978+
#define to_posix_LOWER(c) tolower((U8) (c))
1979+
#define to_posix_UPPER(c) toupper((U8) (c))
1980+
#define to_posix_FOLD(c) to_posix_LOWER(c)
19811981

19821982
#ifdef WIN32
19831983

@@ -1991,48 +1991,48 @@ END_EXTERN_C
19911991
* ispunct(), and things that are \W, like ispunct(), arent't controls. Not
19921992
* all possible weirdnesses are checked for, just ones that were detected on
19931993
* actual Microsoft code pages */
1994-
# define is_base_ALPHA(c) \
1995-
(isalpha((U8) (c)) && ! is_base_PUNCT(c))
1996-
# define is_base_ALPHANUMERIC(c) \
1997-
(isalnum((U8) (c)) && ! is_base_PUNCT(c))
1998-
# define is_base_CASED(c) \
1999-
((isupper((U8) (c)) || islower((U8) (c))) && ! is_base_PUNCT(c))
2000-
# define is_base_DIGIT(c) \
2001-
(isdigit((U8) (c)) && ! is_base_PUNCT(c))
2002-
# define is_base_GRAPH(c) \
2003-
(isgraph((U8) (c)) && ! is_base_CNTRL(c))
2004-
# define is_base_LOWER(c) \
2005-
(islower((U8) (c)) && ! is_base_PUNCT(c))
2006-
# define is_base_PRINT(c) \
2007-
(isprint((U8) (c)) && ! is_base_CNTRL(c))
2008-
# define is_base_PUNCT(c) \
2009-
(ispunct((U8) (c)) && ! is_base_CNTRL(c))
2010-
# define is_base_UPPER(c) \
2011-
(isupper((U8) (c)) && ! is_base_PUNCT(c))
2012-
# define is_base_XDIGIT(c) \
2013-
(isxdigit((U8) (c)) && ! is_base_PUNCT(c))
1994+
# define is_posix_ALPHA(c) \
1995+
(isalpha((U8) (c)) && ! is_posix_PUNCT(c))
1996+
# define is_posix_ALPHANUMERIC(c) \
1997+
(isalnum((U8) (c)) && ! is_posix_PUNCT(c))
1998+
# define is_posix_CASED(c) \
1999+
((isupper((U8) (c)) || islower((U8) (c))) && ! is_posix_PUNCT(c))
2000+
# define is_posix_DIGIT(c) \
2001+
(isdigit((U8) (c)) && ! is_posix_PUNCT(c))
2002+
# define is_posix_GRAPH(c) \
2003+
(isgraph((U8) (c)) && ! is_posix_CNTRL(c))
2004+
# define is_posix_LOWER(c) \
2005+
(islower((U8) (c)) && ! is_posix_PUNCT(c))
2006+
# define is_posix_PRINT(c) \
2007+
(isprint((U8) (c)) && ! is_posix_CNTRL(c))
2008+
# define is_posix_PUNCT(c) \
2009+
(ispunct((U8) (c)) && ! is_posix_CNTRL(c))
2010+
# define is_posix_UPPER(c) \
2011+
(isupper((U8) (c)) && ! is_posix_PUNCT(c))
2012+
# define is_posix_XDIGIT(c) \
2013+
(isxdigit((U8) (c)) && ! is_posix_PUNCT(c))
20142014
#else
20152015

20162016
/* For all other platforms, as far as we know, isdigit(), etc. work sanely
20172017
* enough */
2018-
# define is_base_ALPHA(c) isalpha((U8) (c))
2019-
# define is_base_ALPHANUMERIC(c) isalnum((U8) (c))
2020-
# define is_base_CASED(c) (islower((U8) (c)) || isupper((U8) (c)))
2021-
# define is_base_DIGIT(c) isdigit((U8) (c))
2018+
# define is_posix_ALPHA(c) isalpha((U8) (c))
2019+
# define is_posix_ALPHANUMERIC(c) isalnum((U8) (c))
2020+
# define is_posix_CASED(c) (islower((U8) (c)) || isupper((U8) (c)))
2021+
# define is_posix_DIGIT(c) isdigit((U8) (c))
20222022

20232023
/* ... But it seems that IBM products treat NBSP as both a space and a
20242024
* graphic; these are the two platforms that we have active test beds for.
20252025
*/
20262026
# if defined(OS390) || defined(_AIX)
2027-
# define is_base_GRAPH(c) (isgraph((U8) (c)) && ! isspace((U8) (c)))
2027+
# define is_posix_GRAPH(c) (isgraph((U8) (c)) && ! isspace((U8) (c)))
20282028
# else
2029-
# define is_base_GRAPH(c) isgraph((U8) (c))
2029+
# define is_posix_GRAPH(c) isgraph((U8) (c))
20302030
# endif
2031-
# define is_base_LOWER(c) islower((U8) (c))
2032-
# define is_base_PRINT(c) isprint((U8) (c))
2033-
# define is_base_PUNCT(c) ispunct((U8) (c))
2034-
# define is_base_UPPER(c) isupper((U8) (c))
2035-
# define is_base_XDIGIT(c) isxdigit((U8) (c))
2031+
# define is_posix_LOWER(c) islower((U8) (c))
2032+
# define is_posix_PRINT(c) isprint((U8) (c))
2033+
# define is_posix_PUNCT(c) ispunct((U8) (c))
2034+
# define is_posix_UPPER(c) isupper((U8) (c))
2035+
# define is_posix_XDIGIT(c) isxdigit((U8) (c))
20362036
#endif
20372037

20382038
/* Below is the next level up, which currently expands to nothing more
@@ -2047,28 +2047,28 @@ END_EXTERN_C
20472047
* (Note, proper general operation of the bare libc functons requires you to
20482048
* cast to U8. These do that for you automatically.) */
20492049

2050-
# define WRAP_U8_LC_(c, classnum, base) base(c)
2050+
# define WRAP_U8_LC_(c, classnum, posix) posix(c)
20512051

20522052
#define isU8_ALPHANUMERIC_LC(c) \
2053-
WRAP_U8_LC_((c), CC_ALPHANUMERIC_, is_base_ALPHANUMERIC)
2054-
#define isU8_ALPHA_LC(c) WRAP_U8_LC_((c), CC_ALPHA_, is_base_ALPHA)
2055-
#define isU8_ASCII_LC(c) WRAP_U8_LC_((c), CC_ASCII_, is_base_ASCII)
2056-
#define isU8_BLANK_LC(c) WRAP_U8_LC_((c), CC_BLANK_, is_base_BLANK)
2057-
#define isU8_CASED_LC(c) WRAP_U8_LC_((c), CC_CASED_, is_base_CASED)
2058-
#define isU8_CNTRL_LC(c) WRAP_U8_LC_((c), CC_CNTRL_, is_base_CNTRL)
2059-
#define isU8_DIGIT_LC(c) WRAP_U8_LC_((c), CC_DIGIT_, is_base_DIGIT)
2060-
#define isU8_GRAPH_LC(c) WRAP_U8_LC_((c), CC_GRAPH_, is_base_GRAPH)
2061-
#define isU8_IDFIRST_LC(c) WRAP_U8_LC_((c), CC_IDFIRST_, is_base_IDFIRST)
2062-
#define isU8_LOWER_LC(c) WRAP_U8_LC_((c), CC_LOWER_, is_base_LOWER)
2063-
#define isU8_PRINT_LC(c) WRAP_U8_LC_((c), CC_PRINT_, is_base_PRINT)
2064-
#define isU8_PUNCT_LC(c) WRAP_U8_LC_((c), CC_PUNCT_, is_base_PUNCT)
2065-
#define isU8_SPACE_LC(c) WRAP_U8_LC_((c), CC_SPACE_, is_base_SPACE)
2066-
#define isU8_UPPER_LC(c) WRAP_U8_LC_((c), CC_UPPER_, is_base_UPPER)
2067-
#define isU8_WORDCHAR_LC(c) WRAP_U8_LC_((c), CC_WORDCHAR_, is_base_WORDCHAR)
2068-
#define isU8_XDIGIT_LC(c) WRAP_U8_LC_((c), CC_XDIGIT_, is_base_XDIGIT)
2069-
2070-
#define toU8_LOWER_LC(c) WRAP_U8_LC_((c), CC_TOLOWER_, to_base_LOWER)
2071-
#define toU8_UPPER_LC(c) WRAP_U8_LC_((c), CC_TOUPPER_, to_base_UPPER)
2053+
WRAP_U8_LC_((c), CC_ALPHANUMERIC_, is_posix_ALPHANUMERIC)
2054+
#define isU8_ALPHA_LC(c) WRAP_U8_LC_((c), CC_ALPHA_, is_posix_ALPHA)
2055+
#define isU8_ASCII_LC(c) WRAP_U8_LC_((c), CC_ASCII_, is_posix_ASCII)
2056+
#define isU8_BLANK_LC(c) WRAP_U8_LC_((c), CC_BLANK_, is_posix_BLANK)
2057+
#define isU8_CASED_LC(c) WRAP_U8_LC_((c), CC_CASED_, is_posix_CASED)
2058+
#define isU8_CNTRL_LC(c) WRAP_U8_LC_((c), CC_CNTRL_, is_posix_CNTRL)
2059+
#define isU8_DIGIT_LC(c) WRAP_U8_LC_((c), CC_DIGIT_, is_posix_DIGIT)
2060+
#define isU8_GRAPH_LC(c) WRAP_U8_LC_((c), CC_GRAPH_, is_posix_GRAPH)
2061+
#define isU8_IDFIRST_LC(c) WRAP_U8_LC_((c), CC_IDFIRST_, is_posix_IDFIRST)
2062+
#define isU8_LOWER_LC(c) WRAP_U8_LC_((c), CC_LOWER_, is_posix_LOWER)
2063+
#define isU8_PRINT_LC(c) WRAP_U8_LC_((c), CC_PRINT_, is_posix_PRINT)
2064+
#define isU8_PUNCT_LC(c) WRAP_U8_LC_((c), CC_PUNCT_, is_posix_PUNCT)
2065+
#define isU8_SPACE_LC(c) WRAP_U8_LC_((c), CC_SPACE_, is_posix_SPACE)
2066+
#define isU8_UPPER_LC(c) WRAP_U8_LC_((c), CC_UPPER_, is_posix_UPPER)
2067+
#define isU8_WORDCHAR_LC(c) WRAP_U8_LC_((c), CC_WORDCHAR_, is_posix_WORDCHAR)
2068+
#define isU8_XDIGIT_LC(c) WRAP_U8_LC_((c), CC_XDIGIT_, is_posix_XDIGIT)
2069+
2070+
#define toU8_LOWER_LC(c) WRAP_U8_LC_((c), CC_TOLOWER_, to_posix_LOWER)
2071+
#define toU8_UPPER_LC(c) WRAP_U8_LC_((c), CC_TOUPPER_, to_posix_UPPER)
20722072
#define toU8_FOLD_LC(c) toU8_LOWER_LC(c)
20732073

20742074
/* The definitions below use the ones above to create versions in which the

0 commit comments

Comments
 (0)