This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Test preamble: unify chdir 't' if -d 't';
[perl5.git] / regexec.c
index f098155..9297d76 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -772,7 +772,7 @@ Perl_re_intuit_start(pTHX_
              * be too fiddly (e.g. REXEC_IGNOREPOS).
              */
             if (   strpos != strbeg
-                && (prog->intflags & (PREGf_ANCH_BOL|PREGf_ANCH_SBOL)))
+                && (prog->intflags & PREGf_ANCH_SBOL))
             {
                DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log,
                                 "  Not at start...\n"));
@@ -896,7 +896,7 @@ Perl_re_intuit_start(pTHX_
 
 
         /* If the regex is absolutely anchored to either the start of the
-         * string (BOL,SBOL) or to pos() (ANCH_GPOS), then
+         * string (SBOL) or to pos() (ANCH_GPOS), then
          * check_offset_max represents an upper bound on the string where
          * the substr could start. For the ANCH_GPOS case, we assume that
          * the caller of intuit will have already set strpos to
@@ -2637,7 +2637,6 @@ Perl_regexec_flags(pTHX_ REGEXP * const rx, char *stringarg, char *strend,
            magic belonging to this SV.
            Not newSVsv, either, as it does not COW.
         */
-        assert(!IS_PADGV(sv));
         reginfo->sv = newSV(0);
         SvSetSV_nosteal(reginfo->sv, sv);
         SAVEFREESV(reginfo->sv);
@@ -2715,7 +2714,7 @@ Perl_regexec_flags(pTHX_ REGEXP * const rx, char *stringarg, char *strend,
     }
 
     /* Simplest case:  anchored match need be tried only once. */
-    /*  [unless only anchor is BOL and multiline is set] */
+    /*  [unless only anchor is MBOL - implying multiline is set] */
     if (prog->intflags & (PREGf_ANCH & ~PREGf_ANCH_GPOS)) {
        if (s == startpos && regtry(reginfo, &s))
            goto got_it;
@@ -3075,7 +3074,8 @@ Perl_regexec_flags(pTHX_ REGEXP * const rx, char *stringarg, char *strend,
                  * and replaced it with this one. Yves */
                DEBUG_EXECUTE_r(
                    PerlIO_printf(Perl_debug_log,
-                       "String does not contain required substring, cannot match.\n"
+                       "%sString does not contain required substring, cannot match.%s\n",
+                        PL_colors[4], PL_colors[5]
                    ));
                goto phooey;
            }
@@ -4013,8 +4013,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)
         assert(nextchr < 256 && (nextchr >= 0 || nextchr == NEXTCHR_EOS));
 
        switch (state_num) {
-       case BOL:  /*  /^../   */
-       case SBOL: /*  /^../s  */
+       case SBOL: /*  /^../ and /\A../  */
            if (locinput == reginfo->strbeg)
                break;
            sayNO;
@@ -4052,9 +4051,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)
                sayNO;
            break;
 
-       case EOL: /* /..$/  */
-            /* FALLTHROUGH */
-       case SEOL: /* /..$/s  */
+       case SEOL: /* /..$/  */
            if (!NEXTCHR_IS_EOS && nextchr != '\n')
                sayNO;
            if (reginfo->strend - locinput > 1)
@@ -5192,9 +5189,6 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)
        case TAIL: /* placeholder while compiling (A|B|C) */
            break;
 
-       case BACK: /* ??? doesn't appear to be used ??? */
-           break;
-
 #undef  ST
 #define ST st->u.eval
        {
@@ -5451,7 +5445,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)
@@ -7630,7 +7624,7 @@ Perl_regclass_swash(pTHX_ const regexp *prog, const regnode* node, bool doinit,
         *altsvp = NULL;
     }
 
-    return newSVsv(_get_regclass_nonbitmap_data(prog, node, doinit, listsvp, NULL));
+    return newSVsv(_get_regclass_nonbitmap_data(prog, node, doinit, listsvp, NULL, NULL));
 }
 
 #endif /* !defined(PERL_IN_XSUB_RE) || defined(PLUGGABLE_RE_EXTENSION) */
@@ -7678,19 +7672,22 @@ S_reginclass(pTHX_ regexp * const prog, const regnode * const n, const U8* const
     if (c < NUM_ANYOF_CODE_POINTS) {
        if (ANYOF_BITMAP_TEST(n, c))
            match = TRUE;
-       else if (flags & ANYOF_NON_UTF8_NON_ASCII_ALL
-               && ! utf8_target
-               && ! isASCII(c))
+       else if ((flags & ANYOF_MATCHES_ALL_NON_UTF8_NON_ASCII)
+                 && ! utf8_target
+                 && ! isASCII(c))
        {
            match = TRUE;
        }
        else if (flags & ANYOF_LOCALE_FLAGS) {
-           if (flags & ANYOF_LOC_FOLD) {
-                if (ANYOF_BITMAP_TEST(n, PL_fold_locale[c])) {
-                    match = TRUE;
-                }
+           if ((flags & ANYOF_LOC_FOLD)
+                && c < 256
+               && ANYOF_BITMAP_TEST(n, PL_fold_locale[c]))
+            {
+                match = TRUE;
             }
-           if (! match && ANYOF_POSIXL_TEST_ANY_SET(n)) {
+            else if (ANYOF_POSIXL_TEST_ANY_SET(n)
+                     && c < 256
+            ) {
 
                 /* The data structure is arranged so bits 0, 2, 4, ... are set
                  * if the class includes the Posix character class given by
@@ -7743,18 +7740,20 @@ S_reginclass(pTHX_ regexp * const prog, const regnode * const n, const U8* const
     /* If the bitmap didn't (or couldn't) match, and something outside the
      * bitmap could match, try that. */
     if (!match) {
-       if (c >= 256 && (flags & ANYOF_ABOVE_LATIN1_ALL)) {
-           match = TRUE;       /* Everything above 255 matches */
+       if (c >= NUM_ANYOF_CODE_POINTS
+            && (flags & ANYOF_MATCHES_ALL_ABOVE_BITMAP))
+        {
+           match = TRUE;       /* Everything above the bitmap matches */
        }
-       else if ((flags & ANYOF_NONBITMAP_NON_UTF8)
-                 || (utf8_target && (flags & ANYOF_UTF8))
+       else if ((flags & ANYOF_HAS_NONBITMAP_NON_UTF8_MATCHES)
+                 || (utf8_target && (flags & ANYOF_HAS_UTF8_NONBITMAP_MATCHES))
                   || ((flags & ANYOF_LOC_FOLD)
                        && IN_UTF8_CTYPE_LOCALE
-                       && ARG(n) != ANYOF_NONBITMAP_EMPTY))
+                       && ARG(n) != ANYOF_ONLY_HAS_BITMAP))
         {
             SV* only_utf8_locale = NULL;
            SV * const sw = _get_regclass_nonbitmap_data(prog, n, TRUE, 0,
-                                                            &only_utf8_locale);
+                                                       &only_utf8_locale, NULL);
            if (sw) {
                 U8 utf8_buffer[2];
                U8 * utf8_p;