diff options
author | Nicholas Clark <nick@ccl4.org> | 2008-01-02 13:47:42 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2008-01-02 13:47:42 +0000 |
commit | 288b8c02c5ee89a2978a1b9e56ed255c53beb793 (patch) | |
tree | 6ae37841e6bccf1a6b817df3291f10c4e3b1783d /pp_hot.c | |
parent | 84679df57ca0626f7fb35fc3038e2e142b97f8a4 (diff) | |
download | perl-288b8c02c5ee89a2978a1b9e56ed255c53beb793.tar.gz |
Make struct regexp the body of SVt_REGEXP SVs, REGEXPs become SVs,
and regexp reference counting is via the regular SV reference counting.
This was not as easy at it looks.
p4raw-id: //depot/perl@32804
Diffstat (limited to 'pp_hot.c')
-rw-r--r-- | pp_hot.c | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -1194,11 +1194,21 @@ PP(pp_qr) REGEXP * rx = PM_GETRE(pm); SV * const pkg = CALLREG_PACKAGE(rx); SV * const rv = sv_newmortal(); - SV * const sv = newSVrv(rv, pkg ? SvPV_nolen(pkg) : NULL); + + SvUPGRADE(rv, SVt_IV); + /* This RV is about to own a reference to the regexp. (In addition to the + reference already owned by the PMOP. */ + ReREFCNT_inc(rx); + SvRV_set(rv, rx); + SvROK_on(rv); + + if (pkg) { + HV* const stash = gv_stashpv(SvPV_nolen(pkg), GV_ADD); + (void)sv_bless(rv, stash); + } + if (RX_EXTFLAGS(rx) & RXf_TAINTED) SvTAINTED_on(rv); - sv_upgrade(sv, SVt_REGEXP); - ((struct xregexp *)SvANY(sv))->xrx_regexp = ReREFCNT_inc(rx); XPUSHs(rv); RETURN; } |