diff options
author | Karl Williamson <khw@cpan.org> | 2020-10-18 10:46:14 -0600 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2020-12-19 20:45:42 -0700 |
commit | 22025c3030a7de7ac2690f126304d8d8b5d7656a (patch) | |
tree | 8124faec8436d1b04e6e507f53ae7da7c50d4310 /regexec.c | |
parent | a50454ce0f79538d3cedde9015ef68d4d6dfb89f (diff) | |
download | perl-22025c3030a7de7ac2690f126304d8d8b5d7656a.tar.gz |
regexec.c: Trim trailing blanks
Diffstat (limited to 'regexec.c')
-rw-r--r-- | regexec.c | 174 |
1 files changed, 87 insertions, 87 deletions
@@ -209,7 +209,7 @@ static const char non_utf8_target_but_utf8_required[] rn = (rn->flags == 0) ? NEXTOPER(NEXTOPER(rn)) : rn + ARG(rn); \ else rn += NEXT_OFF(rn); \ } \ -} STMT_END +} STMT_END #define SLAB_FIRST(s) (&(s)->states[0]) #define SLAB_LAST(s) (&(s)->states[PERL_REGMATCH_SLAB_SLOTS-1]) @@ -250,7 +250,7 @@ S_regcppush(pTHX_ const regexp *rex, I32 parenfloor, U32 maxopenparen _pDEPTH) (long)parenfloor); SSGROW(total_elems + REGCP_FRAME_ELEMS); - + DEBUG_BUFFERS_r( if ((int)maxopenparen > (int)parenfloor) Perl_re_exec_indentf( aTHX_ @@ -1007,7 +1007,7 @@ Perl_re_intuit_start(pTHX_ /* Substring at constant offset from beg-of-str... */ SSize_t slen = SvCUR(check); char *s = HOP3c(strpos, prog->check_offset_min, strend); - + DEBUG_EXECUTE_r(Perl_re_printf( aTHX_ " Looking for check substr at fixed offset %" IVdf "...\n", (IV)prog->check_offset_min)); @@ -1053,7 +1053,7 @@ Perl_re_intuit_start(pTHX_ #endif restart: - + /* This is the (re)entry point of the main loop in this function. * The goal of this loop is to: * 1) find the "check" substring in the region rx_origin..strend @@ -1094,7 +1094,7 @@ Perl_re_intuit_start(pTHX_ (IV)end_shift, (IV)prog->check_end_shift); }); - + end_point = HOPBACK3(strend, end_shift, rx_origin); if (!end_point) goto fail_finish; @@ -1526,9 +1526,9 @@ Perl_re_intuit_start(pTHX_ rx_max_float = HOP3c(check_at, -start_shift, strbeg); endpos = HOP3clim(rx_max_float, cl_l, strend); } - else + else endpos= strend; - + DEBUG_EXECUTE_r(Perl_re_printf( aTHX_ " looking for class: start_shift: %" IVdf " check_at: %" IVdf " rx_origin: %" IVdf " endpos: %" IVdf "\n", @@ -2155,7 +2155,7 @@ S_get_break_val_cp_checked(SV* const invlist, const UV cp_in) { /* annoyingly all the vars in this routine have different names from their counterparts in regmatch. /grrr */ STATIC char * -S_find_byclass(pTHX_ regexp * prog, const regnode *c, char *s, +S_find_byclass(pTHX_ regexp * prog, const regnode *c, char *s, const char *strend, regmatch_info *reginfo) { @@ -3671,13 +3671,13 @@ Perl_regexec_flags(pTHX_ REGEXP * const rx, char *stringarg, char *strend, } multiline = prog->extflags & RXf_PMf_MULTILINE; - + if (strend - s < (minlen+(prog->check_offset_min<0?prog->check_offset_min:0))) { DEBUG_EXECUTE_r(Perl_re_printf( aTHX_ "String too short [regexec_flags]...\n")); goto phooey; } - + /* Check validity of program. */ if (UCHARAT(progi->program) != REG_MAGIC) { Perl_croak(aTHX_ "corrupted regexp program"); @@ -3933,7 +3933,7 @@ Perl_regexec_flags(pTHX_ REGEXP * const rx, char *stringarg, char *strend, back_max = prog->float_max_offset; back_min = prog->float_min_offset; } - + if (back_min<0) { last = strend; } else { @@ -3992,7 +3992,7 @@ Perl_regexec_flags(pTHX_ REGEXP * const rx, char *stringarg, char *strend, ((must == prog->anchored_substr || must == prog->anchored_utf8) ? "anchored" : "floating"), quoted, RE_SV_TAIL(must)); - }); + }); goto phooey; } else if ( (c = progi->regstclass) ) { @@ -4160,7 +4160,7 @@ Perl_regexec_flags(pTHX_ REGEXP * const rx, char *stringarg, char *strend, LEAVE_SCOPE(oldsave); - if (RXp_PAREN_NAMES(prog)) + if (RXp_PAREN_NAMES(prog)) (void)hv_iterinit(RXp_PAREN_NAMES(prog)); /* make sure $`, $&, $', and $digit will work later */ @@ -4328,33 +4328,33 @@ S_debug_start_match(pTHX_ const REGEXP *prog, const bool utf8_target, PERL_ARGS_ASSERT_DEBUG_START_MATCH; - if (!PL_colorset) - reginitcolors(); + if (!PL_colorset) + reginitcolors(); { - RE_PV_QUOTED_DECL(s0, utf8_pat, PERL_DEBUG_PAD_ZERO(0), + RE_PV_QUOTED_DECL(s0, utf8_pat, PERL_DEBUG_PAD_ZERO(0), RX_PRECOMP_const(prog), RX_PRELEN(prog), PL_dump_re_max_len); - + RE_PV_QUOTED_DECL(s1, utf8_target, PERL_DEBUG_PAD_ZERO(1), start, end - start, PL_dump_re_max_len); - + Perl_re_printf( aTHX_ - "%s%s REx%s %s against %s\n", - PL_colors[4], blurb, PL_colors[5], s0, s1); - + "%s%s REx%s %s against %s\n", + PL_colors[4], blurb, PL_colors[5], s0, s1); + if (utf8_target||utf8_pat) Perl_re_printf( aTHX_ "UTF-8 %s%s%s...\n", utf8_pat ? "pattern" : "", utf8_pat && utf8_target ? " and " : "", utf8_target ? "string" : "" - ); + ); } } STATIC void -S_dump_exec_pos(pTHX_ const char *locinput, - const regnode *scan, - const char *loc_regeol, - const char *loc_bostr, +S_dump_exec_pos(pTHX_ const char *locinput, + const regnode *scan, + const char *loc_regeol, + const char *loc_bostr, const char *loc_reg_starttry, const bool utf8_target, const U32 depth @@ -4392,11 +4392,11 @@ S_dump_exec_pos(pTHX_ const char *locinput, RE_PV_COLOR_DECL(s0,len0,is_uni,PERL_DEBUG_PAD(0), (locinput - pref_len),pref0_len, PL_dump_re_max_len, 4, 5); - + RE_PV_COLOR_DECL(s1,len1,is_uni,PERL_DEBUG_PAD(1), (locinput - pref_len + pref0_len), pref_len - pref0_len, PL_dump_re_max_len, 2, 3); - + RE_PV_COLOR_DECL(s2,len2,is_uni,PERL_DEBUG_PAD(2), locinput, loc_regeol - locinput, 10, 0, 1); @@ -4417,7 +4417,7 @@ S_dump_exec_pos(pTHX_ const char *locinput, #endif /* reg_check_named_buff_matched() - * Checks to see if a named buffer has matched. The data array of + * Checks to see if a named buffer has matched. The data array of * buffer numbers corresponding to the buffer is expected to reside * in the regexp->data->data array in the slot stored in the ARG() of * node involved. Note that this routine doesn't actually care about the @@ -6017,7 +6017,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog) 3 * rex->nparens : MAX_RECURSE_EVAL_NOCHANGE_DEPTH; regmatch_state *yes_state = NULL; /* state to pop to on success of subpattern */ - /* mark_state piggy backs on the yes_state logic so that when we unwind + /* mark_state piggy backs on the yes_state logic so that when we unwind the stack on success we can update the mark_state as we go */ regmatch_state *mark_state = NULL; /* last mark state we have seen */ regmatch_state *cur_eval = NULL; /* most recent EVAL_AB state */ @@ -6028,7 +6028,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog) char *startpoint = locinput; SV *popmark = NULL; /* are we looking for a mark? */ SV *sv_commit = NULL; /* last mark name seen in failure */ - SV *sv_yes_mark = NULL; /* last mark name we have seen + SV *sv_yes_mark = NULL; /* last mark name we have seen during a successful match */ U32 lastopen = 0; /* last open we saw */ bool has_cutgroup = RXp_HAS_CUTGROUP(rex) ? 1 : 0; @@ -6189,7 +6189,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog) #define ST st->u.trie case TRIEC: /* (ab|cd) with known charclass */ /* In this case the charclass data is available inline so - we can fail fast without a lot of extra overhead. + we can fail fast without a lot of extra overhead. */ if ( ! NEXTCHR_IS_EOS && locinput < loceol @@ -6293,7 +6293,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog) } } - { + { U8 *uc = ( U8* )locinput; STRLEN len = 0; @@ -6538,7 +6538,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog) tmp ? pv_pretty(sv, SvPV_nolen_const(*tmp), SvCUR(*tmp), 0, PL_colors[0], PL_colors[1], (SvUTF8(*tmp) ? PERL_PV_ESCAPE_UNI : 0)|PERL_PV_ESCAPE_NONASCII - ) + ) : "not compiled under -Dr", PL_colors[5] ); }); @@ -7421,7 +7421,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog) } break; - + case REFFLN: /* /\g{name}/il */ { /* The capture buffer cases. The ones beginning with N for the named buffers just convert to the equivalent numbered and @@ -7584,7 +7584,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog) arg= (U32)ARG(scan); if (cur_eval && cur_eval->locinput == locinput) { if ( ++nochange_depth > max_nochange_depth ) - Perl_croak(aTHX_ + Perl_croak(aTHX_ "Pattern subroutine nesting without pos change" " exceeded limit in regex"); } else { @@ -7636,7 +7636,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog) Perl_croak(aTHX_ "EVAL without pos change exceeded limit in regex"); } else { nochange_depth = 0; - } + } { /* execute the code in the {...} */ @@ -7920,7 +7920,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog) DEBUG_EXECUTE_r( debug_start_match(re_sv, utf8_target, locinput, reginfo->strend, "EVAL/GOSUB: Matching embedded"); - ); + ); startpoint = rei->program + 1; EVAL_CLOSE_PAREN_CLEAR(st); /* ST.close_paren = 0; * close_paren only for GOSUB */ @@ -8032,7 +8032,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog) is_utf8_pat = reginfo->is_utf8_pat = cBOOL(RX_UTF8(rex_sv)); SET_reg_curpm(rex_sv); rex = ReANY(rex_sv); - rexi = RXi_GET(rex); + rexi = RXi_GET(rex); REGCP_UNWIND(ST.lastcp); regcppop(rex, &maxopenparen); @@ -8095,8 +8095,8 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog) if (ARG2L(scan)){ regnode *cursor; for (cursor=scan; - cursor && OP(cursor)!=END; - cursor=regnext(cursor)) + cursor && OP(cursor)!=END; + cursor=regnext(cursor)) { if ( OP(cursor)==CLOSE ){ n = ARG(cursor); @@ -8215,19 +8215,19 @@ I and O refer to inner and outer, C and W refer to CURLYX and WHILEM: cur_ curlyx backtrack stack ------ --------------- -NULL +NULL CO <CO prev=NULL> <WO> -CI <CO prev=NULL> <WO> <CI prev=CO> <WI> ai -CO <CO prev=NULL> <WO> <CI prev=CO> <WI> ai <WI prev=CI> bi +CI <CO prev=NULL> <WO> <CI prev=CO> <WI> ai +CO <CO prev=NULL> <WO> <CI prev=CO> <WI> ai <WI prev=CI> bi NULL <CO prev=NULL> <WO> <CI prev=CO> <WI> ai <WI prev=CI> bi <WO prev=CO> bo At this point the pattern succeeds, and we work back down the stack to clean up, restoring as we go: -CO <CO prev=NULL> <WO> <CI prev=CO> <WI> ai <WI prev=CI> bi -CI <CO prev=NULL> <WO> <CI prev=CO> <WI> ai +CO <CO prev=NULL> <WO> <CI prev=CO> <WI> ai <WI prev=CI> bi +CI <CO prev=NULL> <WO> <CI prev=CO> <WI> ai CO <CO prev=NULL> <WO> -NULL +NULL *******************************************************************/ @@ -8237,7 +8237,7 @@ NULL { /* No need to save/restore up to this paren */ I32 parenfloor = scan->flags; - + assert(next); /* keep Coverity happy */ if (OP(PREVOPER(next)) == NOTHING) /* LONGJMP */ next += ARG(next); @@ -8297,7 +8297,7 @@ NULL ST.save_lastloc = cur_curlyx->u.curlyx.lastloc; ST.cache_offset = 0; ST.cache_mask = 0; - + DEBUG_EXECUTE_r( Perl_re_exec_indentf( aTHX_ "WHILEM: matched %ld out of %d..%d\n", depth, (long)n, min, max) @@ -8557,7 +8557,7 @@ NULL no_final = 1; if (st->u.mark.mark_name) sv_commit = st->u.mark.mark_name; - sayNO; + sayNO; NOT_REACHED; /* NOTREACHED */ case BRANCH_next: @@ -8584,7 +8584,7 @@ NULL } continue; /* execute next BRANCH[J] op */ /* NOTREACHED */ - + case MINMOD: /* next op will be non-greedy, e.g. A*? */ minmod = 1; break; @@ -8654,7 +8654,7 @@ NULL if (EVAL_CLOSE_PAREN_IS_TRUE(cur_eval,(U32)ST.me->flags)) goto fake_end; - + { I32 max = (ST.minmod ? ARG1(ST.me) : ARG2(ST.me)); if ( max == REG_INFTY || ST.count < max ) @@ -8666,7 +8666,7 @@ NULL REGCP_UNWIND(ST.cp); - if (ST.minmod || ST.count < ARG1(ST.me) /* min*/ + if (ST.minmod || ST.count < ARG1(ST.me) /* min*/ || EVAL_CLOSE_PAREN_IS_TRUE(cur_eval,(U32)ST.me->flags)) sayNO; @@ -8744,13 +8744,13 @@ NULL if (EVAL_CLOSE_PAREN_IS_TRUE(cur_eval,(U32)ST.me->flags)) { - if (ST.count) + if (ST.count) goto fake_end; else sayNO; } } - + PUSH_STATE_GOTO(CURLYM_B, ST.B, locinput, loceol, /* match B */ script_run_begin); NOT_REACHED; /* NOTREACHED */ @@ -8845,7 +8845,7 @@ NULL else { regnode *text_node = next; - if (! HAS_TEXT(text_node)) + if (! HAS_TEXT(text_node)) FIND_NEXT_IMPT(text_node); if (! HAS_TEXT(text_node)) @@ -9148,7 +9148,7 @@ NULL (long)(locinput - startpos), (long)(reginfo->till - startpos), PL_colors[5])); - + sayNO_SILENT; /* Cannot match: too short. */ } sayYES; /* Success! */ @@ -9167,7 +9167,7 @@ NULL ST.start = locinput; ST.end = loceol; ST.count = 1; - goto do_ifmatch; + goto do_ifmatch; case UNLESSM: /* -ve lookaround: (?!A), or with 'flags', (?<!A) */ ST.wanted = 0; @@ -9222,7 +9222,7 @@ NULL ST.me = scan; ST.logical = logical; logical = 0; /* XXX: reset state of logical once it has been saved into ST */ - + /* execute body of (?...A) */ PUSH_YES_STATE_GOTO(IFMATCH_A, NEXTOPER(NEXTOPER(scan)), ST.start, ST.end, script_run_begin); @@ -9288,8 +9288,8 @@ NULL NOT_REACHED; /* NOTREACHED */ case COMMIT_next_fail: - no_final = 1; - /* FALLTHROUGH */ + no_final = 1; + /* FALLTHROUGH */ sayNO; NOT_REACHED; /* NOTREACHED */ @@ -9310,7 +9310,7 @@ NULL #define ST st->u.mark case MARKPOINT: /* (*MARK:foo) */ ST.prev_mark = mark_state; - ST.mark_name = sv_commit = sv_yes_mark + ST.mark_name = sv_commit = sv_yes_mark = MUTABLE_SV(rexi->data->data[ ARG( scan ) ]); mark_state = st; ST.mark_loc = locinput; @@ -9324,7 +9324,7 @@ NULL NOT_REACHED; /* NOTREACHED */ case MARKPOINT_next_fail: - if (popmark && sv_eq(ST.mark_name,popmark)) + if (popmark && sv_eq(ST.mark_name,popmark)) { if (ST.mark_loc > startpoint) reginfo->cutpoint = HOPBACKc(ST.mark_loc, 1); @@ -9338,7 +9338,7 @@ NULL }); } mark_state = ST.prev_mark; - sv_yes_mark = mark_state ? + sv_yes_mark = mark_state ? mark_state->u.mark.mark_name : NULL; sayNO; NOT_REACHED; /* NOTREACHED */ @@ -9351,15 +9351,15 @@ NULL PUSH_STATE_GOTO(SKIP_next,next, locinput, loceol, script_run_begin); } else { - /* (*SKIP:NAME) : if there is a (*MARK:NAME) fail where it was, - otherwise do nothing. Meaning we need to scan + /* (*SKIP:NAME) : if there is a (*MARK:NAME) fail where it was, + otherwise do nothing. Meaning we need to scan */ regmatch_state *cur = mark_state; SV *find = MUTABLE_SV(rexi->data->data[ ARG( scan ) ]); - + while (cur) { - if ( sv_eq( cur->u.mark.mark_name, - find ) ) + if ( sv_eq( cur->u.mark.mark_name, + find ) ) { ST.mark_name = find; PUSH_STATE_GOTO( SKIP_next, next, locinput, loceol, @@ -9367,26 +9367,26 @@ NULL } cur = cur->u.mark.prev_mark; } - } + } /* Didn't find our (*MARK:NAME) so ignore this (*SKIP:NAME) */ - break; + break; case SKIP_next_fail: if (ST.mark_name) { - /* (*CUT:NAME) - Set up to search for the name as we + /* (*CUT:NAME) - Set up to search for the name as we collapse the stack*/ - popmark = ST.mark_name; + popmark = ST.mark_name; } else { /* (*CUT) - No name, we cut here.*/ if (ST.mark_loc > startpoint) reginfo->cutpoint = HOPBACKc(ST.mark_loc, 1); /* but we set sv_commit to latest mark_name if there is one so they can test to see how things lead to this - cut */ - if (mark_state) - sv_commit=mark_state->u.mark.mark_name; - } - no_final = 1; + cut */ + if (mark_state) + sv_commit=mark_state->u.mark.mark_name; + } + no_final = 1; sayNO; NOT_REACHED; /* NOTREACHED */ #undef ST @@ -9417,8 +9417,8 @@ NULL else locinput++; break; - - } /* end switch */ + + } /* end switch */ /* switch break jumps here */ scan = next; /* prepare to execute the next op and ... */ @@ -9463,7 +9463,7 @@ NULL st->locinput = locinput; st->loceol = loceol; st->sr0 = script_run_begin; - newst = st+1; + newst = st+1; if (newst > SLAB_LAST(PL_regmatch_slab)) newst = S_push_slab(aTHX); PL_regmatch_state = newst; @@ -9501,7 +9501,7 @@ NULL } DEBUG_STATE_r({ if (no_final) { - DEBUG_STATE_pp("pop (no final)"); + DEBUG_STATE_pp("pop (no final)"); } else { DEBUG_STATE_pp("pop (yes)"); } @@ -9522,7 +9522,7 @@ NULL st = yes_state; yes_state = st->u.yes.prev_yes_state; PL_regmatch_state = st; - + if (no_final) { locinput= st->locinput; loceol= st->loceol; @@ -9567,7 +9567,7 @@ NULL } else { goto final_exit; } - } + } if (depth) { /* there's a previous state to backtrack to */ st--; @@ -9597,10 +9597,10 @@ NULL SV *sv_mrk = get_sv("REGMARK", 1); if (result) { sv_commit = &PL_sv_no; - if (!sv_yes_mark) + if (!sv_yes_mark) sv_yes_mark = &PL_sv_yes; } else { - if (!sv_commit) + if (!sv_commit) sv_commit = &PL_sv_yes; sv_yes_mark = &PL_sv_no; } @@ -10298,7 +10298,7 @@ S_regrepeat(pTHX_ regexp *prog, char **startposp, const regnode *p, /* - reginclass - determine if a character falls into a character class - + n is the ANYOF-type regnode p is the target string p_end points to one byte beyond the end of the target string |