diff options
author | Malcolm Beattie <mbeattie@sable.ox.ac.uk> | 1997-10-08 10:19:27 +0000 |
---|---|---|
committer | Malcolm Beattie <mbeattie@sable.ox.ac.uk> | 1997-10-08 10:19:27 +0000 |
commit | 93af7a870f71dbbb13443b4087703de0221add17 (patch) | |
tree | e767c53d4d4f1783640e5410f94655e45b58b3d0 /regexec.c | |
parent | c116a00cf797ec2e6795338ee18b88d975e760c5 (diff) | |
parent | 2269e8ecc334a5a77bdb915666547431c0171402 (diff) | |
download | perl-93af7a870f71dbbb13443b4087703de0221add17.tar.gz |
Merge maint-5.004 branch (5.004_03) with mainline.
MANIFEST is out of sync.
p4raw-id: //depot/perl@114
Diffstat (limited to 'regexec.c')
-rw-r--r-- | regexec.c | 35 |
1 files changed, 32 insertions, 3 deletions
@@ -136,6 +136,35 @@ regcppop() return input; } +/* After a successful match in WHILEM, we want to restore paren matches + * that have been overwritten by a failed match attempt in the process + * of reaching this success. We do this by restoring regstartp[i] + * wherever regendp[i] has not changed; if OPEN is changed to modify + * regendp[], the '== endp' test below should be changed to match. + * This corrects the error of: + * 0 > length [ "foobar" =~ / ( (foo) | (bar) )* /x ]->[1] + */ +static void +regcppartblow() +{ + dTHR; + I32 i = SSPOPINT; + U32 paren; + char *startp; + char *endp; + assert(i == SAVEt_REGCONTEXT); + i = SSPOPINT; + /* input, lastparen, size */ + SSPOPPTR; SSPOPINT; SSPOPINT; + for (i -= 3; i > 0; i -= 3) { + paren = (U32)SSPOPINT; + startp = (char *) SSPOPPTR; + endp = (char *) SSPOPPTR; + if (paren <= *reglastparen && regendp[paren] == endp) + regstartp[paren] = startp; + } +} + #define regcpblow(cp) leave_scope(cp) /* @@ -947,7 +976,7 @@ char *prog; ln = regcc->cur; cp = regcppush(cc->parenfloor); if (regmatch(cc->next)) { - regcpblow(cp); + regcppartblow(cp); sayYES; /* All done. */ } regcppop(); @@ -963,7 +992,7 @@ char *prog; cc->lastloc = locinput; cp = regcppush(cc->parenfloor); if (regmatch(cc->scan)) { - regcpblow(cp); + regcppartblow(cp); sayYES; } regcppop(); @@ -978,7 +1007,7 @@ char *prog; cc->cur = n; cc->lastloc = locinput; if (regmatch(cc->scan)) { - regcpblow(cp); + regcppartblow(cp); sayYES; } regcppop(); /* Restore some previous $<digit>s? */ |