From c07e9d7bfdcf863c1376d16cbfc8060c6a54c433 Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Thu, 13 Sep 2012 11:38:26 +0100 Subject: [PATCH] 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. --- regexec.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/regexec.c b/regexec.c index a1a2a6d..9c423ed 100644 --- a/regexec.c +++ b/regexec.c @@ -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 -- 1.8.3.1