summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDagfinn Ilmari Mannsåker <ilmari@ilmari.org>2017-10-19 10:48:49 +0100
committerDagfinn Ilmari Mannsåker <ilmari@ilmari.org>2019-05-28 13:43:53 +0100
commit2324bdb9a8664e4dd5b50ba32a17f9794126d2fd (patch)
tree80b85093ec20157ecba89ef7746558611eea37a6
parent0478e945a30d8c53408e52b0e5844af899471b96 (diff)
downloadperl-2324bdb9a8664e4dd5b50ba32a17f9794126d2fd.tar.gz
Remove remaining assignments to SvCUR and SvLEN in core
Also make the macros non-lvalues under PERL_CORE
-rw-r--r--doop.c4
-rw-r--r--ext/XS-APItest/APItest.pm2
-rw-r--r--ext/XS-APItest/APItest.xs2
-rw-r--r--gv.c4
-rw-r--r--pp.c2
-rw-r--r--sv.h15
-rw-r--r--t/porting/customized.dat2
-rw-r--r--toke.c2
-rw-r--r--vutil.c2
9 files changed, 25 insertions, 10 deletions
diff --git a/doop.c b/doop.c
index 54e35f10a6..772c158e1b 100644
--- a/doop.c
+++ b/doop.c
@@ -1200,13 +1200,13 @@ Perl_do_vop(pTHX_ I32 optype, SV *sv, SV *left, SV *right)
len = lensave;
if (rightlen > len) {
if (dc == rc)
- SvCUR(sv) = rightlen;
+ SvCUR_set(sv, rightlen);
else
sv_catpvn_nomg(sv, rsave + len, rightlen - len);
}
else if (leftlen > len) {
if (dc == lc)
- SvCUR(sv) = leftlen;
+ SvCUR_set(sv, leftlen);
else
sv_catpvn_nomg(sv, lsave + len, leftlen - len);
}
diff --git a/ext/XS-APItest/APItest.pm b/ext/XS-APItest/APItest.pm
index ba76d8f4da..a4573b9028 100644
--- a/ext/XS-APItest/APItest.pm
+++ b/ext/XS-APItest/APItest.pm
@@ -5,7 +5,7 @@ use strict;
use warnings;
use Carp;
-our $VERSION = '1.00';
+our $VERSION = '1.01';
require XSLoader;
diff --git a/ext/XS-APItest/APItest.xs b/ext/XS-APItest/APItest.xs
index e77ff44f33..904462e4b4 100644
--- a/ext/XS-APItest/APItest.xs
+++ b/ext/XS-APItest/APItest.xs
@@ -1339,7 +1339,7 @@ my_ck_rv2cv(pTHX_ OP *o)
{
SvGROW(ref, SvCUR(ref)+2);
*SvEND(ref) = '_';
- SvCUR(ref)++;
+ SvCUR(ref)++; /* Not _set, so we don't accidentally break non-PERL_CORE */
*SvEND(ref) = '\0';
}
return old_ck_rv2cv(aTHX_ o);
diff --git a/gv.c b/gv.c
index 3b8759e88a..46a32dcc20 100644
--- a/gv.c
+++ b/gv.c
@@ -1266,7 +1266,7 @@ Perl_gv_autoload_pvn(pTHX_ HV *stash, const char *name, STRLEN len, U32 flags)
if (SvUTF8(cv))
sv_utf8_upgrade_flags_grow(tmpsv, 0, CvPROTOLEN(cv) + 2);
ulen = SvCUR(tmpsv);
- SvCUR(tmpsv)++; /* include null in string */
+ SvCUR_set(tmpsv, SvCUR(tmpsv) + 1); /* include null in string */
sv_catpvn_flags(
tmpsv, proto, CvPROTOLEN(cv), SV_CATBYTES*!SvUTF8(cv)
);
@@ -1275,7 +1275,7 @@ Perl_gv_autoload_pvn(pTHX_ HV *stash, const char *name, STRLEN len, U32 flags)
SvTEMP_off(tmpsv);
SvREFCNT_dec_NN(tmpsv);
SvLEN_set(cv, SvCUR(cv) + 1);
- SvCUR(cv) = ulen;
+ SvCUR_set(cv, ulen);
}
else {
sv_setpvn((SV *)cv, name, len);
diff --git a/pp.c b/pp.c
index 62a548bc0a..26c682d6a9 100644
--- a/pp.c
+++ b/pp.c
@@ -2543,7 +2543,7 @@ S_scomplement(pTHX_ SV *targ, SV *sv)
if (len && ! utf8_to_bytes(tmps, &len)) {
Perl_croak(aTHX_ FATAL_ABOVE_FF_MSG, PL_op_desc[PL_op->op_type]);
}
- SvCUR(TARG) = len;
+ SvCUR_set(TARG, len);
SvUTF8_off(TARG);
}
diff --git a/sv.h b/sv.h
index 3a648e4971..637cd14dc0 100644
--- a/sv.h
+++ b/sv.h
@@ -1170,7 +1170,11 @@ object type. Exposed to perl code via Internals::SvREADONLY().
# define SvMAGIC(sv) (0 + *(assert_(SvTYPE(sv) >= SVt_PVMG) &((XPVMG*) SvANY(sv))->xmg_u.xmg_magic))
# define SvSTASH(sv) (0 + *(assert_(SvTYPE(sv) >= SVt_PVMG) &((XPVMG*) SvANY(sv))->xmg_stash))
#else
+# ifdef PERL_CORE
+# define SvLEN(sv) (0 + ((XPV*) SvANY(sv))->xpv_len)
+# else
# define SvLEN(sv) ((XPV*) SvANY(sv))->xpv_len
+# endif
# define SvEND(sv) ((sv)->sv_u.svu_pv + ((XPV*)SvANY(sv))->xpv_cur)
# if defined (DEBUGGING) && defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN)
@@ -1183,6 +1187,16 @@ object type. Exposed to perl code via Internals::SvREADONLY().
&& !(IoFLAGS(_svpvx) & IOf_FAKE_DIRP))); \
&((_svpvx)->sv_u.svu_pv); \
}))
+# ifdef PERL_CORE
+# define SvCUR(sv) \
+ ({ const SV *const _svcur = (const SV *)(sv); \
+ assert(PL_valid_types_PVX[SvTYPE(_svcur) & SVt_MASK]); \
+ assert(!isGV_with_GP(_svcur)); \
+ assert(!(SvTYPE(_svcur) == SVt_PVIO \
+ && !(IoFLAGS(_svcur) & IOf_FAKE_DIRP))); \
+ (((XPV*) MUTABLE_PTR(SvANY(_svcur)))->xpv_cur); \
+ })
+# else
# define SvCUR(sv) \
(*({ const SV *const _svcur = (const SV *)(sv); \
assert(PL_valid_types_PVX[SvTYPE(_svcur) & SVt_MASK]); \
@@ -1191,6 +1205,7 @@ object type. Exposed to perl code via Internals::SvREADONLY().
&& !(IoFLAGS(_svcur) & IOf_FAKE_DIRP))); \
&(((XPV*) MUTABLE_PTR(SvANY(_svcur)))->xpv_cur); \
}))
+# endif
# define SvIVX(sv) \
(*({ const SV *const _svivx = (const SV *)(sv); \
assert(PL_valid_types_IVX[SvTYPE(_svivx) & SVt_MASK]); \
diff --git a/t/porting/customized.dat b/t/porting/customized.dat
index dd41c3d453..f710639adc 100644
--- a/t/porting/customized.dat
+++ b/t/porting/customized.dat
@@ -26,4 +26,4 @@ autodie cpan/autodie/t/mkdir.t 9e70d2282a3cc7d76a78bf8144fccba20fb37dac
autodie cpan/autodie/t/recv.t 63bea2daa330e44b67714527ddf701c1bf3a6954
experimental cpan/experimental/t/basic.t cb9da8dd05b854375809872a05dd32637508d5da
version cpan/version/lib/version.pm 7ef9219d1d5f1d71f08a79f3b0577df138b21b12
-version vutil.c 105543ef1824fbc2429a7d5ebd19189c8081fede
+version vutil.c 317c25a807f9503282d58917a4a53b667232a6c5
diff --git a/toke.c b/toke.c
index 03c4f2ba26..b0fa2c35ba 100644
--- a/toke.c
+++ b/toke.c
@@ -1334,7 +1334,7 @@ Perl_lex_next_chunk(pTHX_ U32 flags)
PL_parser->last_lop = NULL;
last_uni_pos = last_lop_pos = 0;
*buf = 0;
- SvCUR(linestr) = 0;
+ SvCUR_set(linestr, 0);
} else {
old_bufend_pos = PL_parser->bufend - buf;
bufptr_pos = PL_parser->bufptr - buf;
diff --git a/vutil.c b/vutil.c
index 2367489153..4314fb9280 100644
--- a/vutil.c
+++ b/vutil.c
@@ -533,7 +533,7 @@ Perl_new_version(pTHX_ SV *ver)
under = ninstr(raw, raw+len, underscore, underscore + 1);
if (under) {
Move(under + 1, under, raw + len - under - 1, char);
- SvCUR(rv)--;
+ SvCUR_set(rv, SvCUR(rv) - 1);
*SvEND(rv) = '\0';
}
/* this is for consistency with the pure Perl class */