Use system isascii() when available under locale
authorKarl Williamson <public@khwilliamson.com>
Sun, 5 Feb 2012 00:54:01 +0000 (17:54 -0700)
committerKarl Williamson <public@khwilliamson.com>
Thu, 9 Feb 2012 17:13:59 +0000 (10:13 -0700)
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
pod/perldelta.pod
regexec.c

diff --git a/handy.h b/handy.h
index df24bf5..55428de 100644 (file)
--- 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))
index 1345581..89cc433 100644 (file)
@@ -659,6 +659,12 @@ C<SvPVutf8> now works properly with magical variables.
 
 C<SvPVbyte> now works properly non-PVs.
 
+=item *
+
+C</[[:ascii:]]/> now uses locale rules under 
+C<use locale> when the platform supports that.  Previously, it used
+the platform's native character set.
+
 =back
 
 =head1 Known Problems
index b84dcbd..81c5f1a 100644 (file)
--- 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))  ||