eliminate RXf_ANCH_SINGLE
authorDavid Mitchell <davem@iabyn.com>
Fri, 27 Dec 2013 22:28:31 +0000 (22:28 +0000)
committerDavid Mitchell <davem@iabyn.com>
Fri, 7 Feb 2014 22:39:36 +0000 (22:39 +0000)
This macro defines two flag bits:

    #define PREGf_ANCH_SINGLE         (PREGf_ANCH_SBOL|PREGf_ANCH_GPOS)

but is only used twice in core (and not on CPAN),
don't really add any value, but increases cognitive complexity.

regcomp.c
regcomp.h
regexec.c

index cfc46b1..a657252 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -6957,7 +6957,7 @@ reStudy:
            r->check_substr = r->anchored_substr;
            r->check_utf8 = r->anchored_utf8;
            r->check_offset_min = r->check_offset_max = r->anchored_offset;
-            if (r->intflags & PREGf_ANCH_SINGLE)
+            if (r->intflags & (PREGf_ANCH_SBOL|PREGf_ANCH_GPOS))
                 r->intflags |= PREGf_NOSCAN;
        }
        else {
index 832ed3e..3c1e5f6 100644 (file)
--- a/regcomp.h
+++ b/regcomp.h
 #define PREGf_ANCH_SBOL         0x00001000
 #define PREGf_ANCH_GPOS         0x00002000
 
-#define PREGf_ANCH_SINGLE       ( PREGf_ANCH_SBOL | PREGf_ANCH_GPOS )
-#define PREGf_ANCH              ( PREGf_ANCH_SINGLE | PREGf_ANCH_MBOL | PREGf_ANCH_BOL )
+#define PREGf_ANCH              (PREGf_ANCH_SBOL | PREGf_ANCH_GPOS | \
+                                 PREGf_ANCH_MBOL | PREGf_ANCH_BOL )
 
 /* this is where the old regcomp.h started */
 
index 36b4bed..67b70c1 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -678,7 +678,7 @@ Perl_re_intuit_start(pTHX_
        check = prog->check_substr;
     }
     if (prog->intflags & PREGf_ANCH) { /* Match at \G, beg-of-str or after \n */
-        ml_anch = !( (prog->intflags & PREGf_ANCH_SINGLE)
+        ml_anch = !( (prog->intflags & (PREGf_ANCH_SBOL|PREGf_ANCH_GPOS))
                      || ( (prog->intflags & PREGf_ANCH_BOL)
                          && !multiline ) );    /* Check after \n? */