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");
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");
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");
#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
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);
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) {
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() : \
{
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 /* @- */
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;
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:
}
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) {
}
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) {
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;
/*
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;
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;
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];
}
}
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;
}
}
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);
}
}
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;
}
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);
#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)));
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))
}
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. */
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
}
#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 */
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));
}
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;
if (!rx->prelen && PL_curpm) {
pm = PL_curpm;
- rx = pm->op_pmregexp;
+ rx = PM_GETRE(pm);
}
if (rx->minlen > len) goto failure;
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;
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;
}
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)) {