From: Richard Soderberg Date: Thu, 21 Jun 2001 07:01:22 +0000 (-0700) Subject: Step 2: Use the new PM_GETRE/SETRE macros everywhere. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=aaa362c4c9a4b61a85f6a240dc8826e53958f6da;p=p5sagit%2Fp5-mst-13.2.git Step 2: Use the new PM_GETRE/SETRE macros everywhere. Message-ID: p4raw-id: //depot/perl@10780 --- diff --git a/dump.c b/dump.c index 1dc5571..2a8fec6 100644 --- a/dump.c +++ b/dump.c @@ -319,9 +319,9 @@ Perl_do_pmop_dump(pTHX_ I32 level, PerlIO *file, PMOP *pm) ch = '?'; else ch = '/'; - if (pm->op_pmregexp) + if (PM_GETRE(pm)) Perl_dump_indent(aTHX_ level, file, "PMf_PRE %c%s%c%s\n", - ch, pm->op_pmregexp->precomp, ch, + ch, PM_GETRE(pm)->precomp, ch, (pm->op_private & OPpRUNTIME) ? " (RUNTIME)" : ""); else Perl_dump_indent(aTHX_ level, file, "PMf_PRE (RUNTIME)\n"); @@ -329,7 +329,7 @@ Perl_do_pmop_dump(pTHX_ I32 level, PerlIO *file, PMOP *pm) Perl_dump_indent(aTHX_ level, file, "PMf_REPL = "); op_dump(pm->op_pmreplroot); } - if (pm->op_pmflags || (pm->op_pmregexp && pm->op_pmregexp->check_substr)) { + if (pm->op_pmflags || (PM_GETRE(pm) && PM_GETRE(pm)->check_substr)) { SV *tmpsv = newSVpvn("", 0); if (pm->op_pmdynflags & PMdf_USED) sv_catpv(tmpsv, ",USED"); @@ -337,11 +337,11 @@ Perl_do_pmop_dump(pTHX_ I32 level, PerlIO *file, PMOP *pm) sv_catpv(tmpsv, ",TAINTED"); if (pm->op_pmflags & PMf_ONCE) sv_catpv(tmpsv, ",ONCE"); - if (pm->op_pmregexp && pm->op_pmregexp->check_substr - && !(pm->op_pmregexp->reganch & ROPT_NOSCAN)) + if (PM_GETRE(pm) && PM_GETRE(pm)->check_substr + && !(PM_GETRE(pm)->reganch & ROPT_NOSCAN)) sv_catpv(tmpsv, ",SCANFIRST"); - if (pm->op_pmregexp && pm->op_pmregexp->check_substr - && pm->op_pmregexp->reganch & ROPT_CHECK_ALL) + if (PM_GETRE(pm) && PM_GETRE(pm)->check_substr + && PM_GETRE(pm)->reganch & ROPT_CHECK_ALL) sv_catpv(tmpsv, ",ALL"); if (pm->op_pmflags & PMf_SKIPWHITE) sv_catpv(tmpsv, ",SKIPWHITE"); diff --git a/ext/B/B.xs b/ext/B/B.xs index ea4f620..df53d9a 100644 --- a/ext/B/B.xs +++ b/ext/B/B.xs @@ -667,7 +667,7 @@ LISTOP_children(o) #define PMOP_pmreplroot(o) o->op_pmreplroot #define PMOP_pmreplstart(o) o->op_pmreplstart #define PMOP_pmnext(o) o->op_pmnext -#define PMOP_pmregexp(o) o->op_pmregexp +#define PMOP_pmregexp(o) PM_GETRE(o) #define PMOP_pmflags(o) o->op_pmflags #define PMOP_pmpermflags(o) o->op_pmpermflags @@ -712,7 +712,7 @@ PMOP_precomp(o) REGEXP * rx = NO_INIT CODE: ST(0) = sv_newmortal(); - rx = o->op_pmregexp; + rx = PM_GETRE(o); if (rx) sv_setpvn(ST(0), rx->precomp, rx->prelen); diff --git a/ext/B/B/C.pm b/ext/B/B/C.pm index 4befe79..1f77a2c 100644 --- a/ext/B/B/C.pm +++ b/ext/B/B/C.pm @@ -362,7 +362,7 @@ sub B::PMOP::save { if (defined($re)) { my $resym = sprintf("re%d", $re_index++); $decl->add(sprintf("static char *$resym = %s;", cstring($re))); - $init->add(sprintf("$pm.op_pmregexp = pregcomp($resym, $resym + %u, &$pm);", + $init->add(sprintf("PM_SETRE($pm,pregcomp($resym, $resym + %u, &$pm));", length($re))); } if ($gvsym) { diff --git a/ext/ByteLoader/bytecode.h b/ext/ByteLoader/bytecode.h index 9ad3237..0188688 100644 --- a/ext/ByteLoader/bytecode.h +++ b/ext/ByteLoader/bytecode.h @@ -132,8 +132,8 @@ typedef IV IV64; hv_store((HV*)sv, bstate->bs_pv.xpv_pv, bstate->bs_pv.xpv_cur, arg, 0) #define BSET_pv_free(pv) Safefree(pv.xpv_pv) #define BSET_pregcomp(o, arg) \ - ((PMOP*)o)->op_pmregexp = arg ? \ - CALLREGCOMP(aTHX_ arg, arg + bstate->bs_pv.xpv_cur, ((PMOP*)o)) : 0 + (PM_SETRE(((PMOP*)o), arg ? \ + CALLREGCOMP(aTHX_ arg, arg + bstate->bs_pv.xpv_cur, ((PMOP*)o)) : 0)) #define BSET_newsv(sv, arg) \ STMT_START { \ sv = (arg == SVt_PVAV ? (SV*)newAV() : \ diff --git a/mg.c b/mg.c index 7230b01..0cf8228 100644 --- a/mg.c +++ b/mg.c @@ -341,7 +341,7 @@ Perl_magic_regdata_cnt(pTHX_ SV *sv, MAGIC *mg) { register REGEXP *rx; - if (PL_curpm && (rx = PL_curpm->op_pmregexp)) { + if (PL_curpm && (rx = PM_GETRE(PL_curpm))) { if (mg->mg_obj) /* @+ */ return rx->nparens; else /* @- */ @@ -360,7 +360,7 @@ Perl_magic_regdatum_get(pTHX_ SV *sv, MAGIC *mg) register REGEXP *rx; I32 t; - if (PL_curpm && (rx = PL_curpm->op_pmregexp)) { + if (PL_curpm && (rx = PM_GETRE(PL_curpm))) { paren = mg->mg_len; if (paren < 0) return 0; @@ -404,7 +404,7 @@ Perl_magic_len(pTHX_ SV *sv, MAGIC *mg) switch (*mg->mg_ptr) { case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '&': - if (PL_curpm && (rx = PL_curpm->op_pmregexp)) { + if (PL_curpm && (rx = PM_GETRE(PL_curpm))) { paren = atoi(mg->mg_ptr); /* $& is in [0] */ getparen: @@ -429,14 +429,14 @@ Perl_magic_len(pTHX_ SV *sv, MAGIC *mg) } return 0; case '+': - if (PL_curpm && (rx = PL_curpm->op_pmregexp)) { + if (PL_curpm && (rx = PM_GETRE(PL_curpm))) { paren = rx->lastparen; if (paren) goto getparen; } return 0; case '`': - if (PL_curpm && (rx = PL_curpm->op_pmregexp)) { + if (PL_curpm && (rx = PM_GETRE(PL_curpm))) { if (rx->startp[0] != -1) { i = rx->startp[0]; if (i > 0) { @@ -448,7 +448,7 @@ Perl_magic_len(pTHX_ SV *sv, MAGIC *mg) } return 0; case '\'': - if (PL_curpm && (rx = PL_curpm->op_pmregexp)) { + if (PL_curpm && (rx = PM_GETRE(PL_curpm))) { if (rx->endp[0] != -1) { i = rx->sublen - rx->endp[0]; if (i > 0) { @@ -614,7 +614,7 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg) break; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '&': - if (PL_curpm && (rx = PL_curpm->op_pmregexp)) { + if (PL_curpm && (rx = PM_GETRE(PL_curpm))) { I32 s1, t1; /* @@ -653,7 +653,7 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg) sv_setsv(sv,&PL_sv_undef); break; case '+': - if (PL_curpm && (rx = PL_curpm->op_pmregexp)) { + if (PL_curpm && (rx = PM_GETRE(PL_curpm))) { paren = rx->lastparen; if (paren) goto getparen; @@ -661,7 +661,7 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg) sv_setsv(sv,&PL_sv_undef); break; case '`': - if (PL_curpm && (rx = PL_curpm->op_pmregexp)) { + if (PL_curpm && (rx = PM_GETRE(PL_curpm))) { if ((s = rx->subbeg) && rx->startp[0] != -1) { i = rx->startp[0]; goto getrx; @@ -670,7 +670,7 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg) sv_setsv(sv,&PL_sv_undef); break; case '\'': - if (PL_curpm && (rx = PL_curpm->op_pmregexp)) { + if (PL_curpm && (rx = PM_GETRE(PL_curpm))) { if (rx->subbeg && rx->endp[0] != -1) { s = rx->subbeg + rx->endp[0]; i = rx->sublen - rx->endp[0]; diff --git a/op.c b/op.c index ee90f2d..2228289 100644 --- a/op.c +++ b/op.c @@ -850,8 +850,8 @@ clear_pmop: } } cPMOPo->op_pmreplroot = Nullop; - ReREFCNT_dec(cPMOPo->op_pmregexp); - cPMOPo->op_pmregexp = (REGEXP*)NULL; + ReREFCNT_dec(PM_GETRE(cPMOPo)); + PM_SETRE(cPMOPo, (REGEXP*)NULL); break; } @@ -2976,8 +2976,8 @@ Perl_pmruntime(pTHX_ OP *o, OP *expr, OP *repl) } if ((PL_hints & HINT_UTF8) || DO_UTF8(pat)) pm->op_pmdynflags |= PMdf_UTF8; - pm->op_pmregexp = CALLREGCOMP(aTHX_ p, p + plen, pm); - if (strEQ("\\s+", pm->op_pmregexp->precomp)) + PM_SETRE(pm, CALLREGCOMP(aTHX_ p, p + plen, pm)); + if (strEQ("\\s+", PM_GETRE(pm)->precomp)) pm->op_pmflags |= PMf_WHITE; op_free(expr); } @@ -3073,14 +3073,14 @@ Perl_pmruntime(pTHX_ OP *o, OP *expr, OP *repl) } if (curop == repl && !(repl_has_vars - && (!pm->op_pmregexp - || pm->op_pmregexp->reganch & ROPT_EVAL_SEEN))) { + && (!PM_GETRE(pm) + || PM_GETRE(pm)->reganch & ROPT_EVAL_SEEN))) { pm->op_pmflags |= PMf_CONST; /* const for long enough */ pm->op_pmpermflags |= PMf_CONST; /* const for long enough */ prepend_elem(o->op_type, scalar(repl), o); } else { - if (curop == repl && !pm->op_pmregexp) { /* Has variables. */ + if (curop == repl && !PM_GETRE(pm)) { /* Has variables. */ pm->op_pmflags |= PMf_MAYBE_CONST; pm->op_pmpermflags |= PMf_MAYBE_CONST; } @@ -6442,8 +6442,8 @@ Perl_ck_join(pTHX_ OP *o) OP *kid = cLISTOPo->op_first->op_sibling; if (kid && kid->op_type == OP_MATCH) { char *pmstr = "STRING"; - if (kPMOP->op_pmregexp) - pmstr = kPMOP->op_pmregexp->precomp; + if (PM_GETRE(kPMOP)) + pmstr = PM_GETRE(kPMOP)->precomp; Perl_warner(aTHX_ WARN_SYNTAX, "/%s/ should probably be written as \"%s\"", pmstr, pmstr); diff --git a/pp.c b/pp.c index 6d393bd..ea98b3c 100644 --- a/pp.c +++ b/pp.c @@ -4042,7 +4042,7 @@ PP(pp_split) #endif if (!pm || !s) DIE(aTHX_ "panic: pp_split"); - rx = pm->op_pmregexp; + rx = PM_GETRE(pm); TAINT_IF((pm->op_pmflags & PMf_LOCALE) && (pm->op_pmflags & (PMf_WHITE | PMf_SKIPWHITE))); diff --git a/pp_ctl.c b/pp_ctl.c index 81c235e..3bb8392 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -88,13 +88,6 @@ PP(pp_regcomp) MAGIC *mg = Null(MAGIC*); tmpstr = POPs; - - /* prevent recompiling under /o and ithreads. */ -#if defined(USE_ITHREADS) || defined(USE_THREADS) - if (pm->op_pmflags & PMf_KEEP && PM_GETRE(pm)) - RETURN; -#endif - if (SvROK(tmpstr)) { SV *sv = SvRV(tmpstr); if(SvMAGICAL(sv)) @@ -102,20 +95,20 @@ PP(pp_regcomp) } if (mg) { regexp *re = (regexp *)mg->mg_obj; - ReREFCNT_dec(pm->op_pmregexp); - pm->op_pmregexp = ReREFCNT_inc(re); + ReREFCNT_dec(PM_GETRE(pm)); + PM_SETRE(pm, ReREFCNT_inc(re)); } else { t = SvPV(tmpstr, len); /* Check against the last compiled regexp. */ - if (!pm->op_pmregexp || !pm->op_pmregexp->precomp || - pm->op_pmregexp->prelen != len || - memNE(pm->op_pmregexp->precomp, t, len)) + if (!PM_GETRE(pm) || !PM_GETRE(pm)->precomp || + PM_GETRE(pm)->prelen != len || + memNE(PM_GETRE(pm)->precomp, t, len)) { - if (pm->op_pmregexp) { - ReREFCNT_dec(pm->op_pmregexp); - pm->op_pmregexp = Null(REGEXP*); /* crucial if regcomp aborts */ + if (PM_GETRE(pm)) { + ReREFCNT_dec(PM_GETRE(pm)); + PM_SETRE(pm, Null(REGEXP*)); /* crucial if regcomp aborts */ } if (PL_op->op_flags & OPf_SPECIAL) PL_reginterp_cnt = I32_MAX; /* Mark as safe. */ @@ -128,7 +121,7 @@ PP(pp_regcomp) if (pm->op_pmdynflags & PMdf_UTF8) t = (char*)bytes_to_utf8((U8*)t, &len); } - pm->op_pmregexp = CALLREGCOMP(aTHX_ t, t + len, pm); + PM_SETRE(pm, CALLREGCOMP(aTHX_ t, t + len, pm)); if (!DO_UTF8(tmpstr) && (pm->op_pmdynflags & PMdf_UTF8)) Safefree(t); PL_reginterp_cnt = 0; /* XXXX Be extra paranoid - needed @@ -145,9 +138,9 @@ PP(pp_regcomp) } #endif - if (!pm->op_pmregexp->prelen && PL_curpm) + if (!PM_GETRE(pm)->prelen && PL_curpm) pm = PL_curpm; - else if (strEQ("\\s+", pm->op_pmregexp->precomp)) + else if (strEQ("\\s+", PM_GETRE(pm)->precomp)) pm->op_pmflags |= PMf_WHITE; /* XXX runtime compiled output needs to move to the pad */ diff --git a/pp_hot.c b/pp_hot.c index d5da0ae..e83626a 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -1190,7 +1190,7 @@ PP(pp_qr) register PMOP *pm = cPMOP; SV *rv = sv_newmortal(); SV *sv = newSVrv(rv, "Regexp"); - sv_magic(sv,(SV*)ReREFCNT_inc(pm->op_pmregexp), PERL_MAGIC_qr,0,0); + sv_magic(sv,(SV*)ReREFCNT_inc(PM_GETRE(pm)), PERL_MAGIC_qr,0,0); RETURNX(PUSHs(rv)); } @@ -1204,7 +1204,7 @@ PP(pp_match) I32 global; I32 r_flags = REXEC_CHECKED; char *truebase; /* Start of string */ - register REGEXP *rx = pm->op_pmregexp; + register REGEXP *rx = PM_GETRE(pm); bool rxtainted; I32 gimme = GIMME; STRLEN len; @@ -1238,7 +1238,7 @@ PP(pp_match) if (!rx->prelen && PL_curpm) { pm = PL_curpm; - rx = pm->op_pmregexp; + rx = PM_GETRE(pm); } if (rx->minlen > len) goto failure; @@ -1875,7 +1875,7 @@ PP(pp_subst) bool rxtainted; char *orig; I32 r_flags; - register REGEXP *rx = pm->op_pmregexp; + register REGEXP *rx = PM_GETRE(pm); STRLEN len; int force_on_match = 0; I32 oldsave = PL_savestack_ix; @@ -1921,7 +1921,7 @@ PP(pp_subst) if (!rx->prelen && PL_curpm) { pm = PL_curpm; - rx = pm->op_pmregexp; + rx = PM_GETRE(pm); } r_flags = (rx->nparens || SvTEMP(TARG) || PL_sawampersand) ? REXEC_COPY_STR : 0; diff --git a/regexec.c b/regexec.c index da4513b..1145b60 100644 --- a/regexec.c +++ b/regexec.c @@ -1850,7 +1850,7 @@ S_regtry(pTHX_ regexp *prog, char *startpos) } if (!PL_reg_curpm) Newz(22,PL_reg_curpm, 1, PMOP); - PL_reg_curpm->op_pmregexp = prog; + PM_SETRE(PL_reg_curpm, prog); PL_reg_oldcurpm = PL_curpm; PL_curpm = PL_reg_curpm; if (RX_MATCH_COPIED(prog)) {