regexec.c: Fix locale and \s
authorKarl Williamson <public@khwilliamson.com>
Mon, 6 Dec 2010 19:16:24 +0000 (12:16 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Wed, 8 Dec 2010 02:52:43 +0000 (18:52 -0800)
The handling for locale \s and \S both assume that the character in
ASCII platforms at 0x20 is a space.  This is not necessarily so.

I'm guessing that the code was originally just copied and pasted from
the non-locale space handling code without thinking.  That code hard-coded
in the space character, probably to avoid an expensive swash fetch for a
common situation.

regexec.c

index b04bead..c1f1ae2 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -1645,7 +1645,7 @@ S_find_byclass(pTHX_ regexp * prog, const regnode *c, char *s,
            );
        case SPACEL:
            REXEC_FBC_CSCAN_TAINT(
-               *s == ' ' || isSPACE_LC_utf8((U8*)s),
+               isSPACE_LC_utf8((U8*)s),
                isSPACE_LC(*s)
            );
        case NSPACE:
@@ -1656,7 +1656,7 @@ S_find_byclass(pTHX_ regexp * prog, const regnode *c, char *s,
            );
        case NSPACEL:
            REXEC_FBC_CSCAN_TAINT(
-               !(*s == ' ' || isSPACE_LC_utf8((U8*)s)),
+               !isSPACE_LC_utf8((U8*)s),
                !isSPACE_LC(*s)
            );
        case DIGIT:
@@ -6036,7 +6036,7 @@ S_regrepeat(pTHX_ const regexp *prog, const regnode *p, I32 max, int depth)
        if (utf8_target) {
            loceol = PL_regeol;
            while (hardcount < max && scan < loceol &&
-                  (*scan == ' ' || isSPACE_LC_utf8((U8*)scan))) {
+                  isSPACE_LC_utf8((U8*)scan)) {
                scan += UTF8SKIP(scan);
                hardcount++;
            }
@@ -6071,7 +6071,7 @@ S_regrepeat(pTHX_ const regexp *prog, const regnode *p, I32 max, int depth)
        if (utf8_target) {
            loceol = PL_regeol;
            while (hardcount < max && scan < loceol &&
-                  !(*scan == ' ' || isSPACE_LC_utf8((U8*)scan))) {
+                  !isSPACE_LC_utf8((U8*)scan)) {
                scan += UTF8SKIP(scan);
                hardcount++;
            }