Now the test should be really testing what it's supposed to.
[p5sagit/p5-mst-13.2.git] / regexec.c
index 6d18de4..961611b 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -67,7 +67,8 @@
  *
  ****    Alterations to Henry's code are...
  ****
- ****    Copyright (c) 1991-2003, Larry Wall
+ ****    Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+ ****    2000, 2001, 2002, 2003, by Larry Wall and others
  ****
  ****    You may distribute under the terms of either the GNU General Public
  ****    License or the Artistic License, as specified in the README file.
@@ -171,7 +172,7 @@ S_regcppush(pTHX_ I32 parenfloor)
        Perl_croak(aTHX_ "panic: paren_elems_to_push < 0");
 
 #define REGCP_OTHER_ELEMS 6
-    SSCHECK(paren_elems_to_push + REGCP_OTHER_ELEMS);
+    SSGROW(paren_elems_to_push + REGCP_OTHER_ELEMS);
     for (p = PL_regsize; p > parenfloor; p--) {
 /* REGCP_PARENS_ELEMS are pushed per pairs of parentheses. */
        SSPUSHINT(PL_regendp[p]);
@@ -544,7 +545,7 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
            goto fail_finish;
        /* we may be pointing at the wrong string */
        if (s && RX_MATCH_COPIED(prog))
-           s = prog->subbeg + (s - SvPVX(sv));
+           s = strbeg + (s - SvPVX(sv));
        if (data)
            *data->scream_olds = s;
     }
@@ -852,10 +853,6 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
        char *startpos = strbeg;
 
        t = s;
-       if (prog->reganch & ROPT_UTF8) {        
-           PL_regdata = prog->data;
-           PL_bostr = startpos;
-       }
        cache_re(prog);
        s = find_byclass(prog, prog->regstclass, s, endpos, startpos, 1);
        if (!s) {
@@ -1866,7 +1863,7 @@ Perl_regexec_flags(pTHX_ register regexp *prog, char *stringarg, register char *
                                  PL_multiline ? FBMrf_MULTILINE : 0))) ) {
            /* we may be pointing at the wrong string */
            if ((flags & REXEC_SCREAM) && RX_MATCH_COPIED(prog))
-               s = prog->subbeg + (s - SvPVX(sv));
+               s = strbeg + (s - SvPVX(sv));
            DEBUG_r( did_match = 1 );
            if (HOPc(s, -back_max) > last1) {
                last1 = HOPc(s, -back_min);
@@ -1955,7 +1952,7 @@ Perl_regexec_flags(pTHX_ register regexp *prog, char *stringarg, register char *
                    last = scream_olds; /* Only one occurrence. */
                /* we may be pointing at the wrong string */
                else if (RX_MATCH_COPIED(prog))
-                   s = prog->subbeg + (s - SvPVX(sv));
+                   s = strbeg + (s - SvPVX(sv));
            }
            else {
                STRLEN len;
@@ -2838,6 +2835,7 @@ S_regmatch(pTHX_ regnode *prog)
            COP *ocurcop = PL_curcop;
            PAD *old_comppad;
            SV *ret;
+           struct regexp *oreg = PL_reg_re;
        
            n = ARG(scan);
            PL_op = (OP_4tree*)PL_regdata->data[n];
@@ -2970,8 +2968,10 @@ S_regmatch(pTHX_ regnode *prog)
                sw = SvTRUE(ret);
                logical = 0;
            }
-           else
+           else {
                sv_setsv(save_scalar(PL_replgv), ret);
+               cache_re(oreg);
+           }
            break;
        }
        case OPEN:
@@ -3351,6 +3351,7 @@ S_regmatch(pTHX_ regnode *prog)
        {
            I32 l = 0;
            CHECKPOINT lastcp;
+           I32 lparen = *PL_reglastparen;
        
            /* We suppose that the next guy does not need
               backtracking: in particular, it is of constant length,
@@ -3435,6 +3436,8 @@ S_regmatch(pTHX_ regnode *prog)
                        }
                        if (regmatch(next))
                            sayYES;
+                       /* t/op/regexp.t test 885 fails if this is performed */
+                       /* *PL_reglastparen = lparen; */
                        REGCP_UNWIND(lastcp);
                    }
                    /* Couldn't or didn't -- move forward. */
@@ -3522,6 +3525,7 @@ S_regmatch(pTHX_ regnode *prog)
                        }
                        if (regmatch(next))
                            sayYES;
+                       *PL_reglastparen = lparen;
                        REGCP_UNWIND(lastcp);
                    }
                    /* Couldn't or didn't -- back up. */
@@ -3634,6 +3638,7 @@ S_regmatch(pTHX_ regnode *prog)
            PL_reginput = locinput;
            if (minmod) {
                CHECKPOINT lastcp;
+               I32 lparen = *PL_reglastparen;
                minmod = 0;
                if (ln && regrepeat(scan, ln) < ln)
                    sayNO;
@@ -3740,6 +3745,7 @@ S_regmatch(pTHX_ regnode *prog)
                        if (c == (UV)c1 || c == (UV)c2)
                        {
                            TRYPAREN(paren, ln, PL_reginput);
+                           *PL_reglastparen = lparen;
                            REGCP_UNWIND(lastcp);
                        }
                    }
@@ -3747,6 +3753,7 @@ S_regmatch(pTHX_ regnode *prog)
                    else if (c1 == -1000)
                    {
                        TRYPAREN(paren, ln, PL_reginput);
+                       *PL_reglastparen = lparen;
                        REGCP_UNWIND(lastcp);
                    }
                    /* Couldn't or didn't -- move forward. */
@@ -3761,6 +3768,7 @@ S_regmatch(pTHX_ regnode *prog)
            }
            else {
                CHECKPOINT lastcp;
+               I32 lparen = *PL_reglastparen;
                n = regrepeat(scan, n);
                locinput = PL_reginput;
                if (ln < n && PL_regkind[(U8)OP(next)] == EOL &&
@@ -3791,6 +3799,7 @@ S_regmatch(pTHX_ regnode *prog)
                        if (c1 == -1000 || c == (UV)c1 || c == (UV)c2)
                            {
                                TRYPAREN(paren, n, PL_reginput);
+                               *PL_reglastparen = lparen;
                                REGCP_UNWIND(lastcp);
                            }
                        /* Couldn't or didn't -- back up. */
@@ -3814,6 +3823,7 @@ S_regmatch(pTHX_ regnode *prog)
                        if (c1 == -1000 || c == (UV)c1 || c == (UV)c2)
                            {
                                TRYPAREN(paren, n, PL_reginput);
+                               *PL_reglastparen = lparen;
                                REGCP_UNWIND(lastcp);
                            }
                        /* Couldn't or didn't -- back up. */