move RXf_GPOS_SEEN and RXf_GPOS_FLOAT to intflags
authorYves Orton <yves.orton@booking.com>
Thu, 30 Jan 2014 10:35:02 +0000 (18:35 +0800)
committerYves Orton <yves.orton@booking.com>
Thu, 30 Jan 2014 17:45:34 +0000 (01:45 +0800)
This required removing the RXf_GPOS_CHECK mask as it uses one flag
that will stay in extflags for now (RXf_ANCH_GPOS), and one flag that
moves to intflags (RXf_GPOS_SEEN). This mask is strange however, as
you cant have RXf_ANCH_GPOS without having RXf_GPOS_SEEN so I dont
know why we test both. Further investigation required.

dump.c
regcomp.c
regcomp.h
regexec.c
regexp.h
regnodes.h

diff --git a/dump.c b/dump.c
index ab0f595..eb050b3 100644 (file)
--- a/dump.c
+++ b/dump.c
@@ -1555,8 +1555,6 @@ const struct flag_to_name regexp_extflags_names[] = {
     {RXf_ANCH_MBOL,       "ANCH_MBOL,"},
     {RXf_ANCH_SBOL,       "ANCH_SBOL,"},
     {RXf_ANCH_GPOS,       "ANCH_GPOS,"},
-    {RXf_GPOS_SEEN,       "GPOS_SEEN,"},
-    {RXf_GPOS_FLOAT,      "GPOS_FLOAT,"},
     {RXf_NO_INPLACE_SUBST, "NO_INPLACE_SUBST,"},
     {RXf_EVAL_SEEN,       "EVAL_SEEN,"},
     {RXf_CHECK_ALL,       "CHECK_ALL,"},
@@ -1586,6 +1584,8 @@ const struct flag_to_name regexp_core_intflags_names[] = {
     {PREGf_USE_RE_EVAL,     "USE_RE_EVAL,"},
     {PREGf_NOSCAN,          "NOSCAN,"},
     {PREGf_CANY_SEEN,       "CANY_SEEN,"},
+    {PREGf_GPOS_SEEN,       "GPOS_SEEN,"},
+    {PREGf_GPOS_FLOAT,      "GPOS_FLOAT,"},
 };
 
 void
index 894cb59..d05df22 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -5180,7 +5180,7 @@ PerlIO_printf(Perl_debug_log, "LHS=%"UVdf" RHS=%"UVdf"\n",
                flags &= ~SCF_DO_STCLASS;
        }
        else if (OP(scan) == GPOS) {
-           if (!(RExC_rx->extflags & RXf_GPOS_FLOAT) &&
+            if (!(RExC_rx->intflags & PREGf_GPOS_FLOAT) &&
                !(delta || is_inf || (data && data->pos_delta)))
            {
                if (!(RExC_rx->extflags & RXf_ANCH) && (flags & SCF_DO_SUBSTR))
@@ -5188,7 +5188,7 @@ PerlIO_printf(Perl_debug_log, "LHS=%"UVdf" RHS=%"UVdf"\n",
                if (RExC_rx->gofs < (STRLEN)min)
                    RExC_rx->gofs = min;
             } else {
-                RExC_rx->extflags |= RXf_GPOS_FLOAT;
+                RExC_rx->intflags |= PREGf_GPOS_FLOAT;
                 RExC_rx->gofs = 0;
             }
        }
@@ -7016,7 +7016,7 @@ reStudy:
         r->minlen = minlen;
 
     if (RExC_seen & REG_SEEN_GPOS)
-       r->extflags |= RXf_GPOS_SEEN;
+        r->intflags |= PREGf_GPOS_SEEN;
     if (RExC_seen & REG_SEEN_LOOKBEHIND)
         r->extflags |= RXf_NO_INPLACE_SUBST; /* inplace might break the
                                                 lookbehind */
@@ -15414,7 +15414,7 @@ Perl_regdump(pTHX_ const regexp *r)
            PerlIO_printf(Perl_debug_log, "(GPOS)");
        PerlIO_putc(Perl_debug_log, ' ');
     }
-    if (r->extflags & RXf_GPOS_SEEN)
+    if (r->intflags & PREGf_GPOS_SEEN)
        PerlIO_printf(Perl_debug_log, "GPOS:%"UVuf" ", (UV)r->gofs);
     if (r->intflags & PREGf_SKIP)
        PerlIO_printf(Perl_debug_log, "plus ");
index 5dbc1f3..a5f04fa 100644 (file)
--- a/regcomp.h
+++ b/regcomp.h
 #define PREGf_USE_RE_EVAL      0x00000020 /* compiled with "use re 'eval'" */
 /* these used to be extflags, but are now intflags */
 #define PREGf_NOSCAN            0x00000040
-#define PREGf_CANY_SEEN           0x00000080
+#define PREGf_CANY_SEEN         0x00000080
+#define PREGf_GPOS_SEEN           0x00000100
+#define PREGf_GPOS_FLOAT          0x00000200
 
 
 /* this is where the old regcomp.h started */
index cc09994..666a280 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -2278,7 +2278,7 @@ Perl_regexec_flags(pTHX_ REGEXP * const rx, char *stringarg, char *strend,
 
     startpos = stringarg;
 
-    if (prog->extflags & RXf_GPOS_SEEN) {
+    if (prog->intflags & PREGf_GPOS_SEEN) {
         MAGIC *mg;
 
         /* set reginfo->ganch, the position where \G can match */
@@ -2320,7 +2320,7 @@ Perl_regexec_flags(pTHX_ REGEXP * const rx, char *stringarg, char *strend,
             else
                 startpos -= prog->gofs;
         }
-        else if (prog->extflags & RXf_GPOS_FLOAT)
+        else if (prog->intflags & PREGf_GPOS_FLOAT)
             startpos = strbeg;
     }
 
@@ -2360,7 +2360,7 @@ Perl_regexec_flags(pTHX_ REGEXP * const rx, char *stringarg, char *strend,
                     && (s < stringarg))
             {
                 /* this should only be possible under \G */
-                assert(prog->extflags & RXf_GPOS_SEEN);
+                assert(prog->intflags & PREGf_GPOS_SEEN);
                 DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log,
                     "matched, but failing for REXEC_FAIL_ON_UNDERFLOW\n"));
                 goto phooey;
@@ -2573,8 +2573,11 @@ Perl_regexec_flags(pTHX_ REGEXP * const rx, char *stringarg, char *strend,
            } /* end search for newline */
        } /* end anchored/multiline check string search */
        goto phooey;
-    } else if (RXf_GPOS_CHECK == (prog->extflags & RXf_GPOS_CHECK)) 
+    } else if ((prog->intflags & PREGf_GPOS_SEEN) && (prog->extflags & RXf_ANCH_GPOS))
     {
+        /* XXX: Why do we check both PREGf_GPOS_SEEN && RXf_ANCH_GPOS the
+         * latter can't be true unless the former is too as far as I know.
+         * Needs further investigation - Yves */
         /* For anchored \G, the only position it can match from is
          * (ganch-gofs); we already set startpos to this above; if intuit
          * moved us on from there, we can't possibly succeed */
@@ -2890,7 +2893,7 @@ got_it:
             && (prog->offs[0].start < stringarg - strbeg))
     {
         /* this should only be possible under \G */
-        assert(prog->extflags & RXf_GPOS_SEEN);
+        assert(prog->intflags & PREGf_GPOS_SEEN);
         DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log,
             "matched, but failing for REXEC_FAIL_ON_UNDERFLOW\n"));
         goto phooey;
index 24a874f..1c063ab 100644 (file)
--- a/regexp.h
+++ b/regexp.h
@@ -389,20 +389,19 @@ get_regex_charset_name(const U32 flags, STRLEN* const lenp)
 #define RXf_ANCH_MBOL          (1<<(RXf_BASE_SHIFT+1))
 #define RXf_ANCH_SBOL          (1<<(RXf_BASE_SHIFT+2))
 #define RXf_ANCH_GPOS          (1<<(RXf_BASE_SHIFT+3))
-#define RXf_GPOS_SEEN          (1<<(RXf_BASE_SHIFT+4))
-#define RXf_GPOS_FLOAT         (1<<(RXf_BASE_SHIFT+5))
+#define RXf_UNUSED1                   (1<<(RXf_BASE_SHIFT+4))
+#define RXf_UNUSED2                  (1<<(RXf_BASE_SHIFT+5))
 /* two bits here */
 #define RXf_ANCH               (RXf_ANCH_BOL|RXf_ANCH_MBOL|RXf_ANCH_GPOS|RXf_ANCH_SBOL)
-#define RXf_GPOS_CHECK          (RXf_GPOS_SEEN|RXf_ANCH_GPOS)
 #define RXf_ANCH_SINGLE         (RXf_ANCH_SBOL|RXf_ANCH_GPOS)
 
 /* What we have seen */
 #define RXf_NO_INPLACE_SUBST    (1<<(RXf_BASE_SHIFT+6))
 #define RXf_EVAL_SEEN          (1<<(RXf_BASE_SHIFT+7))
-#define RXf_UNUSED1                   (1<<(RXf_BASE_SHIFT+8))
+#define RXf_UNUSED3             (1<<(RXf_BASE_SHIFT+8))
 
 /* Special */
-#define RXf_UNUSED2             (1<<(RXf_BASE_SHIFT+9))
+#define RXf_UNUSED4             (1<<(RXf_BASE_SHIFT+9))
 #define RXf_CHECK_ALL          (1<<(RXf_BASE_SHIFT+10))
 
 /* UTF8 related */
index 82b3f98..9e17e88 100644 (file)
@@ -654,12 +654,12 @@ EXTCONST char * const PL_reg_extflags_name[] = {
        "ANCH_MBOL",        /* 0x00000400 */
        "ANCH_SBOL",        /* 0x00000800 */
        "ANCH_GPOS",        /* 0x00001000 */
-       "GPOS_SEEN",        /* 0x00002000 */
-       "GPOS_FLOAT",       /* 0x00004000 */
+       "UNUSED1",          /* 0x00002000 */
+       "UNUSED2",          /* 0x00004000 */
        "NO_INPLACE_SUBST", /* 0x00008000 */
        "EVAL_SEEN",        /* 0x00010000 */
-        "UNUSED1",          /* 0x00020000 */
-        "UNUSED2",          /* 0x00040000 */
+       "UNUSED3",          /* 0x00020000 */
+       "UNUSED4",          /* 0x00040000 */
        "CHECK_ALL",        /* 0x00080000 */
        "MATCH_UTF8",       /* 0x00100000 */
        "USE_INTUIT_NOML",  /* 0x00200000 */
@@ -688,8 +688,10 @@ EXTCONST char * const PL_reg_intflags_name[] = {
        "VERBARG_SEEN",               /* 0x00000008 - PREGf_VERBARG_SEEN */
        "CUTGROUP_SEEN",              /* 0x00000010 - PREGf_CUTGROUP_SEEN */
        "USE_RE_EVAL",                /* 0x00000020 - PREGf_USE_RE_EVAL -  compiled with "use re 'eval'"  */
-        "NOSCAN",                     /* 0x00000040 - PREGf_NOSCAN */
-        "CANY_SEEN",                  /* 0x00000080 - PREGf_CANY_SEEN */
+       "NOSCAN",                     /* 0x00000040 - PREGf_NOSCAN */
+       "CANY_SEEN",                  /* 0x00000080 - PREGf_CANY_SEEN */
+       "GPOS_SEEN",                  /* 0x00000100 - PREGf_GPOS_SEEN */
+       "GPOS_FLOAT",                 /* 0x00000200 - PREGf_GPOS_FLOAT */
 };
 #endif /* DOINIT */