summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pp.c5
-rw-r--r--sv.c17
2 files changed, 16 insertions, 6 deletions
diff --git a/pp.c b/pp.c
index c65ed1c8c9..aeaca4c607 100644
--- a/pp.c
+++ b/pp.c
@@ -604,11 +604,8 @@ PP(pp_study)
if(unop->op_first && unop->op_first->op_type == OP_PUSHRE) {
PMOP *pm = (PMOP *)unop->op_first;
SV *rv = sv_newmortal();
- REGEXP *re = pm->op_pmregexp;
-
sv = newSVrv(rv, "Regexp");
- sv_setpvn(sv,re->precomp,re->prelen);
- sv_magic(sv,(SV*)ReREFCNT_inc(re),'r',0,0);
+ sv_magic(sv,(SV*)ReREFCNT_inc(pm->op_pmregexp),'r',0,0);
RETURNX(PUSHs(rv));
}
diff --git a/sv.c b/sv.c
index f098efa5bb..8c7d9c2a3b 100644
--- a/sv.c
+++ b/sv.c
@@ -1696,7 +1696,21 @@ sv_2pv(register SV *sv, STRLEN *lp)
if (!sv)
s = "NULLREF";
else {
+ MAGIC *mg;
+
switch (SvTYPE(sv)) {
+ case SVt_PVMG:
+ if ( ((SvFLAGS(sv) &
+ (SVs_OBJECT|SVf_OK|SVs_GMG|SVs_SMG|SVs_RMG))
+ == (SVs_OBJECT|SVs_RMG))
+ && strEQ(s=HvNAME(SvSTASH(sv)), "Regexp")
+ && (mg = mg_find(sv, 'r'))) {
+ regexp *re = (regexp *)mg->mg_obj;
+
+ *lp = re->prelen;
+ return re->precomp;
+ }
+ /* Fall through */
case SVt_NULL:
case SVt_IV:
case SVt_NV:
@@ -1704,8 +1718,7 @@ sv_2pv(register SV *sv, STRLEN *lp)
case SVt_PV:
case SVt_PVIV:
case SVt_PVNV:
- case SVt_PVBM:
- case SVt_PVMG: s = "SCALAR"; break;
+ case SVt_PVBM: s = "SCALAR"; break;
case SVt_PVLV: s = "LVALUE"; break;
case SVt_PVAV: s = "ARRAY"; break;
case SVt_PVHV: s = "HASH"; break;