summaryrefslogtreecommitdiff
path: root/pp_ctl.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2007-12-28 09:59:06 +0000
committerNicholas Clark <nick@ccl4.org>2007-12-28 09:59:06 +0000
commit5c35adbb8fc4c988807097c4d379e2485ada5865 (patch)
tree68cb0d31f61fbabefe05d3673ae29eefe3550118 /pp_ctl.c
parent662f1f9e0a1bbee45e1e02386151364c8517604e (diff)
downloadperl-5c35adbb8fc4c988807097c4d379e2485ada5865.tar.gz
First class regexps.
p4raw-id: //depot/perl@32751
Diffstat (limited to 'pp_ctl.c')
-rw-r--r--pp_ctl.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/pp_ctl.c b/pp_ctl.c
index 64157f3e94..2ce3a978cf 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -77,8 +77,7 @@ PP(pp_regcomp)
dSP;
register PMOP *pm = (PMOP*)cLOGOP->op_other;
SV *tmpstr;
- MAGIC *mg = NULL;
- regexp * re;
+ regexp *re = NULL;
/* prevent recompiling under /o and ithreads. */
#if defined(USE_ITHREADS)
@@ -117,11 +116,11 @@ PP(pp_regcomp)
if (SvROK(tmpstr)) {
SV * const sv = SvRV(tmpstr);
- if(SvMAGICAL(sv))
- mg = mg_find(sv, PERL_MAGIC_qr);
+ if (SvTYPE(sv) == SVt_REGEXP)
+ re = ((struct xregexp *)SvANY(sv))->xrx_regexp;
}
- if (mg) {
- regexp * const re = reg_temp_copy((regexp *)mg->mg_obj);
+ if (re) {
+ re = reg_temp_copy(re);
ReREFCNT_dec(PM_GETRE(pm));
PM_SETRE(pm, re);
}
@@ -3890,7 +3889,6 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other)
SV *e = TOPs; /* e is for 'expression' */
SV *d = TOPm1s; /* d is for 'default', as in PL_defgv */
SV *This, *Other; /* 'This' (and Other to match) to play with C++ */
- MAGIC *mg;
regexp *this_regex, *other_regex;
# define NOT_EMPTY_PROTO(cv) (!SvPOK(cv) || SvCUR(cv) == 0)
@@ -3906,24 +3904,22 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other)
&& NOT_EMPTY_PROTO(This) && (Other = d)))
# define SM_REGEX ( \
- (SvROK(d) && SvMAGICAL(This = SvRV(d)) \
- && (mg = mg_find(This, PERL_MAGIC_qr)) \
- && (this_regex = (regexp *)mg->mg_obj) \
+ (SvROK(d) && (SvTYPE(This = SvRV(d)) == SVt_REGEXP) \
+ && (this_regex = ((struct xregexp *)SvANY(This))->xrx_regexp) \
&& (Other = e)) \
|| \
- (SvROK(e) && SvMAGICAL(This = SvRV(e)) \
- && (mg = mg_find(This, PERL_MAGIC_qr)) \
- && (this_regex = (regexp *)mg->mg_obj) \
+ (SvROK(e) && (SvTYPE(This = SvRV(e)) == SVt_REGEXP) \
+ && (this_regex = ((struct xregexp *)SvANY(This))->xrx_regexp) \
&& (Other = d)) )
# define SM_OTHER_REF(type) \
(SvROK(Other) && SvTYPE(SvRV(Other)) == SVt_##type)
-# define SM_OTHER_REGEX (SvROK(Other) && SvMAGICAL(SvRV(Other)) \
- && (mg = mg_find(SvRV(Other), PERL_MAGIC_qr)) \
- && (other_regex = (regexp *)mg->mg_obj))
-
+# define SM_OTHER_REGEX (SvROK(Other) \
+ && (SvTYPE(SvRV(Other)) == SVt_REGEXP) \
+ && (other_regex = ((struct xregexp *)SvANY(SvRV(Other)))->xrx_regexp))
+
# define SM_SEEN_THIS(sv) hv_exists_ent(seen_this, \
sv_2mortal(newSViv(PTR2IV(sv))), 0)