Up regex flags limit for (??{})
authorKarl Williamson <khw@cpan.org>
Wed, 17 Sep 2014 18:16:12 +0000 (12:16 -0600)
committerKarl Williamson <khw@cpan.org>
Mon, 29 Sep 2014 17:07:40 +0000 (11:07 -0600)
Previously the regex pattern compilation flags needed for this construct
would fit into an 8-bit byte.  This conveniently fits into the flags
structure element of a regnode.  There are changes coming that require
more than 8 bits, so in preparation, this commit adds an argument to the
node that implements (??{}) (31-bits usable for flags), and moves the
storage to that.

op_reg_common.h
pod/perldebguts.pod
regcomp.c
regcomp.sym
regexec.c
regnodes.h

index 9dcdaae..108589e 100644 (file)
@@ -98,8 +98,11 @@ get_regex_charset(const U32 flags)
 #define RXf_PMf_COMPILETIME    (RXf_PMf_MULTILINE|RXf_PMf_SINGLELINE|RXf_PMf_FOLD|RXf_PMf_EXTENDED|RXf_PMf_KEEPCOPY|RXf_PMf_CHARSET)
 #define RXf_PMf_FLAGCOPYMASK   (RXf_PMf_MULTILINE|RXf_PMf_SINGLELINE|RXf_PMf_FOLD|RXf_PMf_EXTENDED|RXf_PMf_KEEPCOPY|RXf_PMf_CHARSET|RXf_PMf_SPLIT)
 
-#if RXf_PMf_COMPILETIME > 255
-#  error RXf_PMf_COMPILETIME wont fit in U8 flags field of eval node
+    /* Exclude win32 because it can't cope with I32_MAX definition */
+#ifndef WIN32
+#   if RXf_PMf_COMPILETIME > I32_MAX
+#     error RXf_PMf_COMPILETIME wont fit in arg2 field of eval node
+#   endif
 #endif
 
 /* These copies need to be numerical or defsubs_h.PL won't know about them. */
index 814949d..59d27b0 100644 (file)
@@ -716,7 +716,8 @@ will be lost.
 
  # The heavy worker
 
- EVAL            evl 1      Execute some Perl code.
+ EVAL            evl/flags  Execute some Perl code.
+                 2L
 
  # Modifiers
 
index fa563a4..33971f4 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -10005,17 +10005,22 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp,U32 depth)
                if (is_logical) {
                     regnode *eval;
                    ret = reg_node(pRExC_state, LOGICAL);
-                    eval = reganode(pRExC_state, EVAL, n);
+
+                    eval = reg2Lanode(pRExC_state, EVAL,
+                                       n,
+
+                                       /* for later propagation into (??{})
+                                        * return value */
+                                       RExC_flags & RXf_PMf_COMPILETIME
+                                      );
                    if (!SIZE_ONLY) {
                        ret->flags = 2;
-                        /* for later propagation into (??{}) return value */
-                        eval->flags = (U8) (RExC_flags & RXf_PMf_COMPILETIME);
                     }
                     REGTAIL(pRExC_state, ret, eval);
                     /* deal with the length of this later - MJD */
                    return ret;
                }
-               ret = reganode(pRExC_state, EVAL, n);
+               ret = reg2Lanode(pRExC_state, EVAL, n, 0);
                Set_Node_Length(ret, RExC_parse - parse_start + 1);
                Set_Node_Offset(ret, parse_start);
                return ret;
@@ -15501,7 +15506,7 @@ S_reg2Lanode(pTHX_ RExC_state_t *pRExC_state, const U8 op, const U32 arg1, const
 {
     /* emit a node with U32 and I32 arguments */
 
-    regnode * const ret = regnode_guts(pRExC_state, op, regarglen[op], "rega2Lnode");
+    regnode * const ret = regnode_guts(pRExC_state, op, regarglen[op], "reg2Lanode");
 
     PERL_ARGS_ASSERT_REG2LANODE;
 
index 9301992..2178503 100644 (file)
@@ -165,7 +165,7 @@ GROUPP      GROUPP,     num 1     ; Whether the group matched.
 
 #*The heavy worker
 
-EVAL        EVAL,       evl 1     ; Execute some Perl code.
+EVAL        EVAL,       evl/flags 2L ; Execute some Perl code.
 
 #*Modifiers
 
index e44691e..3af3e37 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -5448,7 +5448,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)
                        re_sv = rex->engine->op_comp(aTHX_ &ret, 1, NULL,
                                    rex->engine, NULL, NULL,
                                     /* copy /msix etc to inner pattern */
-                                    scan->flags,
+                                    ARG2L(scan),
                                     pm_flags);
 
                        if (!(SvFLAGS(ret)
index 3feb312..73b81a1 100644 (file)
@@ -357,7 +357,7 @@ static const U8 regarglen[] = {
        EXTRA_SIZE(struct regnode_1),           /* SUSPEND      */
        EXTRA_SIZE(struct regnode_1),           /* IFTHEN       */
        EXTRA_SIZE(struct regnode_1),           /* GROUPP       */
-       EXTRA_SIZE(struct regnode_1),           /* EVAL         */
+       EXTRA_SIZE(struct regnode_2L),          /* EVAL         */
        0,                                      /* MINMOD       */
        0,                                      /* LOGICAL      */
        EXTRA_SIZE(struct regnode_1),           /* RENUM        */