summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2005-06-08 14:52:17 +0000
committerNicholas Clark <nick@ccl4.org>2005-06-08 14:52:17 +0000
commit13c5b33cae5690f108494286e4d841e38c57677d (patch)
treea2047db7c9a986ca8c1e7b8e3f78506a7fa4a848 /sv.c
parent0510663fa1f5ec2b546d095c2c040e4f25909e8a (diff)
downloadperl-13c5b33cae5690f108494286e4d841e38c57677d.tar.gz
Allow a null length pointer to sv_pvn_force_flags.
Add SvPV_force_nolen and use it to remove some C<n_a>s p4raw-id: //depot/perl@24759
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/sv.c b/sv.c
index 5062520ae9..b580af2038 100644
--- a/sv.c
+++ b/sv.c
@@ -8293,11 +8293,13 @@ Perl_sv_pvn_force_flags(pTHX_ SV *sv, STRLEN *lp, I32 flags)
sv_force_normal_flags(sv, 0);
if (SvPOK(sv)) {
- *lp = SvCUR(sv);
+ if (lp)
+ *lp = SvCUR(sv);
}
else {
char *s;
-
+ STRLEN len;
+
if (SvREADONLY(sv) && !(flags & SV_MUTABLE_RETURN)) {
if (PL_op)
Perl_croak(aTHX_ "Can't coerce readonly %s to string in %s",
@@ -8311,10 +8313,11 @@ Perl_sv_pvn_force_flags(pTHX_ SV *sv, STRLEN *lp, I32 flags)
OP_NAME(PL_op));
}
else
- s = sv_2pv_flags(sv, lp, flags);
+ s = sv_2pv_flags(sv, &len, flags);
+ if (lp)
+ *lp = len;
+
if (s != SvPVX_const(sv)) { /* Almost, but not quite, sv_setpvn() */
- const STRLEN len = *lp;
-
if (SvROK(sv))
sv_unref(sv);
SvUPGRADE(sv, SVt_PV); /* Never FALSE */