From 07315176ac6b656ebc6d789680513408aaa17075 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Sat, 4 Feb 2012 17:54:01 -0700 Subject: [PATCH] Use system isascii() when available under locale We have code that assumes that ASCII should be locale dependent, but it was missing its final link. This supplies that, and makes the code work as documented. I thought it better to do that then to document yet another exception. --- handy.h | 7 +++++++ pod/perldelta.pod | 6 ++++++ regexec.c | 4 ++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/handy.h b/handy.h index df24bf5..55428de 100644 --- a/handy.h +++ b/handy.h @@ -811,6 +811,7 @@ EXTCONST U32 PL_charclass[]; # define isIDFIRST_LC(c) \ (NXIsAlpha((unsigned int)(c)) || (char)(c) == '_') # define isALPHA_LC(c) NXIsAlpha((unsigned int)(c)) +# define isASCII_LC(c) isASCII((unsigned int)(c)) # define isSPACE_LC(c) NXIsSpace((unsigned int)(c)) # define isDIGIT_LC(c) NXIsDigit((unsigned int)(c)) # define isUPPER_LC(c) NXIsUpper((unsigned int)(c)) @@ -834,6 +835,11 @@ EXTCONST U32 PL_charclass[]; # define isALNUM_LC(c) (isalnum((unsigned char)(c)) || (char)(c) == '_') # define isIDFIRST_LC(c) (isalpha((unsigned char)(c)) || (char)(c) == '_') # define isALPHA_LC(c) isalpha((unsigned char)(c)) +# ifdef HAS_ISASCII +# define isASCII_LC(c) isascii((unsigned char)(c)) +# else +# define isASCII_LC(c) isASCII((unsigned char)(c)) +# endif # define isSPACE_LC(c) isspace((unsigned char)(c)) # define isDIGIT_LC(c) isdigit((unsigned char)(c)) # define isUPPER_LC(c) isupper((unsigned char)(c)) @@ -851,6 +857,7 @@ EXTCONST U32 PL_charclass[]; # define isALNUM_LC(c) (isascii(c) && (isalnum(c) || (c) == '_')) # define isIDFIRST_LC(c) (isascii(c) && (isalpha(c) || (c) == '_')) # define isALPHA_LC(c) (isascii(c) && isalpha(c)) +# define isASCII_LC(c) isascii(c) # define isSPACE_LC(c) (isascii(c) && isspace(c)) # define isDIGIT_LC(c) (isascii(c) && isdigit(c)) # define isUPPER_LC(c) (isascii(c) && isupper(c)) diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 1345581..89cc433 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -659,6 +659,12 @@ C now works properly with magical variables. C now works properly non-PVs. +=item * + +C now uses locale rules under +C when the platform supports that. Previously, it used +the platform's native character set. + =back =head1 Known Problems diff --git a/regexec.c b/regexec.c index b84dcbd..81c5f1a 100644 --- a/regexec.c +++ b/regexec.c @@ -6687,8 +6687,8 @@ S_reginclass(pTHX_ const regexp * const prog, register const regnode * const n, (ANYOF_CLASS_TEST(n, ANYOF_NALNUMC) && !isALNUMC_LC(c)) || (ANYOF_CLASS_TEST(n, ANYOF_ALPHA) && isALPHA_LC(c)) || (ANYOF_CLASS_TEST(n, ANYOF_NALPHA) && !isALPHA_LC(c)) || - (ANYOF_CLASS_TEST(n, ANYOF_ASCII) && isASCII(c)) || - (ANYOF_CLASS_TEST(n, ANYOF_NASCII) && !isASCII(c)) || + (ANYOF_CLASS_TEST(n, ANYOF_ASCII) && isASCII_LC(c)) || + (ANYOF_CLASS_TEST(n, ANYOF_NASCII) && !isASCII_LC(c)) || (ANYOF_CLASS_TEST(n, ANYOF_CNTRL) && isCNTRL_LC(c)) || (ANYOF_CLASS_TEST(n, ANYOF_NCNTRL) && !isCNTRL_LC(c)) || (ANYOF_CLASS_TEST(n, ANYOF_GRAPH) && isGRAPH_LC(c)) || -- 2.7.4