regcomp.c: Test for having /u earlier for \p{}
authorKarl Williamson <khw@cpan.org>
Fri, 19 Oct 2018 01:02:51 +0000 (19:02 -0600)
committerKarl Williamson <khw@cpan.org>
Sat, 20 Oct 2018 06:09:56 +0000 (00:09 -0600)
When \p{} or \p{} are encountered during parsing, that indicates that
the pattern should be compiled not under /d, but under /u, as these are
Unicode constructs.  This commit moves the test for that to somewhat
earlier.  This saves only a little work currently, but in a future
commit it saves a lot more wasted work.

regcomp.c

index 961666a..58a50e3 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -16856,6 +16856,10 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth,
                                       |_CORE_SWASH_INIT_ACCEPT_INVLIST;
 
                 SvREFCNT_dec(swash); /* Free any left-overs */
+
+               /* \p means they want Unicode semantics */
+               REQUIRE_UNI_RULES(flagp, 0);
+
                if (RExC_parse >= RExC_end)
                    vFAIL2("Empty \\%c", (U8)value);
                if (*RExC_parse == '{') {
@@ -17101,9 +17105,6 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth,
                RExC_parse = e + 1;
                 namedclass = ANYOF_UNIPROP;  /* no official name, but it's
                                                 named */
-
-               /* \p means they want Unicode semantics */
-               REQUIRE_UNI_RULES(flagp, 0);
                }
                break;
            case 'n':   value = '\n';                   break;