diff options
author | David Mitchell <davem@iabyn.com> | 2012-09-13 11:38:26 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2012-09-14 08:49:35 +0100 |
commit | c07e9d7bfdcf863c1376d16cbfc8060c6a54c433 (patch) | |
tree | ddeeac5509b2945c4c23a28e72f84fb11ecaefc8 /regexec.c | |
parent | 37f53970823babaf529f5aedc61fc2696b876b2f (diff) | |
download | perl-c07e9d7bfdcf863c1376d16cbfc8060c6a54c433.tar.gz |
regmatch(): remove reginput from CURLYM
reginput, locinput and st->locinput were being used in a little
ballet to determine the length of the first match.
This is now simply locinput - st->locinput, or its unicode equivalent;
so the code can be simplified.
Elsewhere in the block: where reginput was being used, locinput and/or
nextchr already contain the same info, so use them instead.
This is part of a campaign to eliminate the reginput variable.
Diffstat (limited to 'regexec.c')
-rw-r--r-- | regexec.c | 21 |
1 files changed, 8 insertions, 13 deletions
@@ -5235,21 +5235,18 @@ NULL assert(0); /* NOTREACHED */ case CURLYM_A: /* we've just matched an A */ - locinput = st->locinput; - nextchr = UCHARAT(locinput); - ST.count++; /* after first match, determine A's length: u.curlym.alen */ if (ST.count == 1) { if (PL_reg_match_utf8) { - char *s = locinput; - while (s < reginput) { + char *s = st->locinput; + while (s < locinput) { ST.alen++; s += UTF8SKIP(s); } } else { - ST.alen = reginput - locinput; + ST.alen = locinput - st->locinput; } if (ST.alen == 0) ST.count = ST.minmod ? ARG1(ST.me) : ARG2(ST.me); @@ -5261,8 +5258,6 @@ NULL (IV) ST.count, (IV)ST.alen) ); - locinput = reginput; - if (cur_eval && cur_eval->u.eval.close_paren && cur_eval->u.eval.close_paren == (U32)ST.me->flags) goto fake_end; @@ -5283,7 +5278,6 @@ NULL sayNO; curlym_do_B: /* execute the B in /A{m,n}B/ */ - reginput = locinput; if (ST.c1 == CHRTEST_UNINIT) { /* calculate c1 and c2 for possible match of 1st char * following curly */ @@ -5325,8 +5319,8 @@ NULL "", (IV)ST.count) ); if (ST.c1 != CHRTEST_VOID - && UCHARAT(reginput) != ST.c1 - && UCHARAT(reginput) != ST.c2) + && nextchr != ST.c1 + && nextchr != ST.c2) { /* simulate B failing */ DEBUG_OPTIMISE_r( @@ -5344,8 +5338,8 @@ NULL I32 paren = ST.me->flags; if (ST.count) { rex->offs[paren].start - = HOPc(reginput, -ST.alen) - PL_bostr; - rex->offs[paren].end = reginput - PL_bostr; + = HOPc(locinput, -ST.alen) - PL_bostr; + rex->offs[paren].end = locinput - PL_bostr; if ((U32)paren > rex->lastparen) rex->lastparen = paren; rex->lastcloseparen = paren; @@ -5379,6 +5373,7 @@ NULL sayNO; ST.count--; locinput = HOPc(locinput, -ST.alen); + nextchr = UCHARAT(locinput); goto curlym_do_B; /* try to match B */ #undef ST |