This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Allow [[:blank:]] to work under locale
authorKarl Williamson <public@khwilliamson.com>
Sun, 5 Feb 2012 22:36:08 +0000 (15:36 -0700)
committerKarl Williamson <public@khwilliamson.com>
Thu, 9 Feb 2012 17:13:59 +0000 (10:13 -0700)
This takes advantage of the recently added Configure probe, and if the
platform has an isblank library function, calls that under locale.  This
now matches the documentation

handy.h
pod/perldelta.pod
regexec.c

diff --git a/handy.h b/handy.h
index 55428de..7a443df 100644 (file)
--- a/handy.h
+++ b/handy.h
@@ -812,6 +812,7 @@ EXTCONST U32 PL_charclass[];
        (NXIsAlpha((unsigned int)(c)) || (char)(c) == '_')
 #  define isALPHA_LC(c)                NXIsAlpha((unsigned int)(c))
 #  define isASCII_LC(c)                isASCII((unsigned int)(c))
+#  define isBLANK_LC(c)                isBLANK((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))
@@ -840,6 +841,11 @@ EXTCONST U32 PL_charclass[];
 #    else
 #      define isASCII_LC(c)    isASCII((unsigned char)(c))
 #    endif
+#    ifdef HAS_ISBLANK
+#      define isBLANK_LC(c)    isblank((unsigned char)(c))
+#    else
+#      define isBLANK_LC(c)    isBLANK((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))
@@ -858,6 +864,11 @@ EXTCONST U32 PL_charclass[];
 #    define isIDFIRST_LC(c)    (isascii(c) && (isalpha(c) || (c) == '_'))
 #    define isALPHA_LC(c)      (isascii(c) && isalpha(c))
 #    define isASCII_LC(c)      isascii(c)
+#    ifdef HAS_ISBLANK
+#      define isBLANK_LC(c)    (isascii(c) && isblank(c))
+#    else
+#      define isBLANK_LC(c)    isBLANK(c)
+#    endif
 #    define isSPACE_LC(c)      (isascii(c) && isspace(c))
 #    define isDIGIT_LC(c)      (isascii(c) && isdigit(c))
 #    define isUPPER_LC(c)      (isascii(c) && isupper(c))
@@ -874,7 +885,6 @@ EXTCONST U32 PL_charclass[];
 #endif /* USE_NEXT_CTYPE */
 
 #define isPSXSPC_LC(c)         (isSPACE_LC(c) || (c) == '\v')
-#define isBLANK_LC(c)          isBLANK(c) /* could be wrong */
 
 /* For use in the macros just below.  If the input is Latin1, use the Latin1
  * (_L1) version of the macro; otherwise use the function.  Won't compile if
index 89cc433..56825e6 100644 (file)
@@ -661,8 +661,8 @@ 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
+C</[[:ascii:]]/> and C</[[:blank:]]/> now use locale rules under
+C<use locale> when the platform supports that.  Previously, they used
 the platform's native character set.
 
 =back
index 81c5f1a..76eb7f9 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -6705,8 +6705,8 @@ S_reginclass(pTHX_ const regexp * const prog, register const regnode * const n,
                      (ANYOF_CLASS_TEST(n, ANYOF_NXDIGIT) && !isXDIGIT(c))    ||
                      (ANYOF_CLASS_TEST(n, ANYOF_PSXSPC)  &&  isPSXSPC(c))    ||
                      (ANYOF_CLASS_TEST(n, ANYOF_NPSXSPC) && !isPSXSPC(c))    ||
-                     (ANYOF_CLASS_TEST(n, ANYOF_BLANK)   &&  isBLANK(c))     ||
-                     (ANYOF_CLASS_TEST(n, ANYOF_NBLANK)  && !isBLANK(c))
+                     (ANYOF_CLASS_TEST(n, ANYOF_BLANK)   &&  isBLANK_LC(c))  ||
+                     (ANYOF_CLASS_TEST(n, ANYOF_NBLANK)  && !isBLANK_LC(c))
                     ) /* How's that for a conditional? */
            ) {
                match = TRUE;