summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avar@cpan.org>2008-01-09 21:05:15 +0000
committerNicholas Clark <nick@ccl4.org>2008-01-10 00:32:20 +0000
commit67d2d14de02de63c7c9137828ed7884f27d67b65 (patch)
tree1531ff19d3766c7fd0f6754091ae414321d84dd2 /sv.c
parent1db36481d13cc744ff50a6e79d19885d5071f098 (diff)
downloadperl-67d2d14de02de63c7c9137828ed7884f27d67b65.tar.gz
Move the reg_stringify logic to Perl_sv_2pv_flags
Message-ID: <86zlveaewk.fsf@cpan.org> with two corrections. Plus remove reg_stringify from embed.fnc and regen. p4raw-id: //depot/perl@32934
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/sv.c b/sv.c
index 5dfbba17a1..b26379f74f 100644
--- a/sv.c
+++ b/sv.c
@@ -2726,21 +2726,25 @@ Perl_sv_2pv_flags(pTHX_ register SV *sv, STRLEN *lp, I32 flags)
len = 7;
retval = buffer = savepvn("NULLREF", len);
} else if (SvTYPE(referent) == SVt_REGEXP) {
- char *str = NULL;
- I32 haseval = 0;
- U32 flags = 0;
- struct magic temp;
- /* FIXME - get rid of this cast away of const, or work out
- how to do it better. */
- temp.mg_obj = (SV *)referent;
- assert(temp.mg_obj);
- (str) = CALLREG_AS_STR(&temp,lp,&flags,&haseval);
- if (flags & 1)
- SvUTF8_on(sv);
- else
- SvUTF8_off(sv);
- PL_reginterp_cnt += haseval;
- return str;
+ const REGEXP * const re = (REGEXP *)referent;
+ I32 seen_evals = 0;
+
+ assert(re);
+
+ /* If the regex is UTF-8 we want the containing scalar to
+ have an UTF-8 flag too */
+ if (RX_UTF8(re))
+ SvUTF8_on(sv);
+ else
+ SvUTF8_off(sv);
+
+ if ((seen_evals = RX_SEEN_EVALS(re)))
+ PL_reginterp_cnt += seen_evals;
+
+ if (lp)
+ *lp = RX_WRAPLEN(re);
+
+ return RX_WRAPPED(re);
} else {
const char *const typestr = sv_reftype(referent, 0);
const STRLEN typelen = strlen(typestr);