Skip to content

Commit

Permalink
No locales => don't use isspace(), toLower() etc.
Browse files Browse the repository at this point in the history
This commit changes what happens on platforms without locale handling to
use our precomputed definitions of what the various character class
definitions and case changing operations are.  Previously, it just
called the libc locale-dependent functions and made sure the result was
ASCII.  I think this is a holdover from before we had the precomputed
definitions
  • Loading branch information
khwilliamson committed May 6, 2021
1 parent 73fcd65 commit 8c20d4f
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions handy.h
Expand Up @@ -2000,22 +2000,22 @@ END_EXTERN_C
# endif
#else /* The final fallback position */

# define isALPHA_LC(c) (isascii(c) && isalpha(c))
# define isALPHANUMERIC_LC(c) (isascii(c) && isalnum(c))
# define isCNTRL_LC(c) (isascii(c) && iscntrl(c))
# define isDIGIT_LC(c) (isascii(c) && isdigit(c))
# define isGRAPH_LC(c) (isascii(c) && isgraph(c))
# define isLOWER_LC(c) (isascii(c) && islower(c))
# define isPRINT_LC(c) (isascii(c) && isprint(c))
# define isPUNCT_LC(c) (isascii(c) && ispunct(c))
# define isSPACE_LC(c) (isascii(c) && isspace(c))
# define isUPPER_LC(c) (isascii(c) && isupper(c))
# define isWORDCHAR_LC(c) (isascii(c) && (isalnum(c) || (c) == '_'))
# define isXDIGIT_LC(c) (isascii(c) && isxdigit(c))

# define toLOWER_LC(c) (isascii(c) ? tolower(c) : (c))
# define toUPPER_LC(c) (isascii(c) ? toupper(c) : (c))
# define toFOLD_LC(c) toLOWER_LC(c)
# define isALPHA_LC(c) generic_isCC_A_(c, CC_ALPHA_)
# define isALPHANUMERIC_LC(c) generic_isCC_A_(c, CC_ALPHANUMERIC_)
# define isCNTRL_LC(c) generic_isCC_A_(c, CC_CNTRL_)
# define isDIGIT_LC(c) generic_isCC_A_(c, CC_DIGIT_)
# define isGRAPH_LC(c) generic_isCC_A_(c, CC_GRAPH_)
# define isLOWER_LC(c) generic_isCC_A_(c, CC_LOWER_)
# define isPRINT_LC(c) generic_isCC_A_(c, CC_PRINT_)
# define isPUNCT_LC(c) generic_isCC_A_(c, CC_PUNCT_)
# define isSPACE_LC(c) generic_isCC_A_(c, CC_SPACE_)
# define isUPPER_LC(c) generic_isCC_A_(c, CC_UPPER_)
# define isWORDCHAR_LC(c) (UNLIKELY((c) == '_') || isALPHANUMERIC_LC(c))
# define isXDIGIT_LC(c) generic_isCC_A_(c, CC_XDIGIT_)

# define toLOWER_LC(c) toLOWER_A(c)
# define toUPPER_LC(c) toUPPER_A(c)
# define toFOLD_LC(c) toFOLD_A(c)

#endif

Expand Down

0 comments on commit 8c20d4f

Please sign in to comment.