summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorAndy Lester <andy@petdance.com>2005-06-22 04:41:00 -0500
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-06-23 08:39:44 +0000
commit1b6737cc10a847650f574c35f419cbd680a5a5ef (patch)
treeb96d16d5faf3db00f9c9488a814c8a8d6a217387 /pp.c
parent89e33a0587050e7ef2e88ba45c87444d8506f821 (diff)
downloadperl-1b6737cc10a847650f574c35f419cbd680a5a5ef.tar.gz
Const Boy II: The Localizing
Message-ID: <20050622144059.GA19598@petdance.com> p4raw-id: //depot/perl@24945
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c449
1 files changed, 206 insertions, 243 deletions
diff --git a/pp.c b/pp.c
index 11ca9ced47..e2649d30ca 100644
--- a/pp.c
+++ b/pp.c
@@ -83,7 +83,7 @@ PP(pp_padav)
if (SvMAGICAL(TARG)) {
U32 i;
for (i=0; i < (U32)maxarg; i++) {
- SV **svp = av_fetch((AV*)TARG, i, FALSE);
+ SV ** const svp = av_fetch((AV*)TARG, i, FALSE);
SP[i+1] = (svp) ? *svp : &PL_sv_undef;
}
}
@@ -93,7 +93,7 @@ PP(pp_padav)
SP += maxarg;
}
else if (gimme == G_SCALAR) {
- SV* sv = sv_newmortal();
+ SV* const sv = sv_newmortal();
const I32 maxarg = AvFILL((AV*)TARG) + 1;
sv_setiv(sv, maxarg);
PUSHs(sv);
@@ -121,7 +121,7 @@ PP(pp_padhv)
RETURNOP(do_kv());
}
else if (gimme == G_SCALAR) {
- SV* sv = Perl_hv_scalar(aTHX_ (HV*)TARG);
+ SV* const sv = Perl_hv_scalar(aTHX_ (HV*)TARG);
SETs(sv);
}
RETURN;
@@ -144,7 +144,7 @@ PP(pp_rv2gv)
sv = SvRV(sv);
if (SvTYPE(sv) == SVt_PVIO) {
- GV *gv = (GV*) sv_newmortal();
+ GV * const gv = (GV*) sv_newmortal();
gv_init(gv, 0, "", 0, 0);
GvIOp(gv) = (IO *)sv;
(void)SvREFCNT_inc(sv);
@@ -201,7 +201,7 @@ PP(pp_rv2gv)
if ((PL_op->op_flags & OPf_SPECIAL) &&
!(PL_op->op_flags & OPf_MOD))
{
- SV * temp = (SV*)gv_fetchsv(sv, FALSE, SVt_PVGV);
+ SV * const temp = (SV*)gv_fetchsv(sv, FALSE, SVt_PVGV);
if (!temp
&& (!is_gv_magical_sv(sv,0)
|| !(sv = (SV*)gv_fetchsv(sv, TRUE, SVt_PVGV)))) {
@@ -294,8 +294,8 @@ PP(pp_rv2sv)
PP(pp_av2arylen)
{
dSP;
- AV *av = (AV*)TOPs;
- SV **sv = Perl_av_arylen_p(aTHX_ (AV*)av);
+ AV * const av = (AV*)TOPs;
+ SV ** const sv = Perl_av_arylen_p(aTHX_ (AV*)av);
if (!*sv) {
*sv = NEWSV(0,0);
sv_upgrade(*sv, SVt_PVMG);
@@ -325,10 +325,8 @@ PP(pp_pos)
RETURN;
}
else {
- MAGIC* mg;
-
if (SvTYPE(sv) >= SVt_PVMG && SvMAGIC(sv)) {
- mg = mg_find(sv, PERL_MAGIC_regex_global);
+ const MAGIC * const mg = mg_find(sv, PERL_MAGIC_regex_global);
if (mg && mg->mg_len >= 0) {
I32 i = mg->mg_len;
if (DO_UTF8(sv))
@@ -504,10 +502,8 @@ S_refto(pTHX_ SV *sv)
PP(pp_ref)
{
dSP; dTARGET;
- SV *sv;
const char *pv;
-
- sv = POPs;
+ SV * const sv = POPs;
if (sv && SvGMAGICAL(sv))
mg_get(sv);
@@ -515,8 +511,7 @@ PP(pp_ref)
if (!sv || !SvROK(sv))
RETPUSHNO;
- sv = SvRV(sv);
- pv = sv_reftype(sv,TRUE);
+ pv = sv_reftype(SvRV(sv),TRUE);
PUSHp(pv, strlen(pv));
RETURN;
}
@@ -529,7 +524,7 @@ PP(pp_bless)
if (MAXARG == 1)
stash = CopSTASH(PL_curcop);
else {
- SV *ssv = POPs;
+ SV * const ssv = POPs;
STRLEN len;
const char *ptr;
@@ -548,63 +543,60 @@ PP(pp_bless)
PP(pp_gelem)
{
- GV *gv;
- SV *sv;
- SV *tmpRef;
- const char *elem;
dSP;
- sv = POPs;
- elem = SvPV_nolen_const(sv);
- gv = (GV*)POPs;
- tmpRef = Nullsv;
+ SV *sv = POPs;
+ const char * const elem = SvPV_nolen_const(sv);
+ GV * const gv = (GV*)POPs;
+ SV * tmpRef = Nullsv;
+
sv = Nullsv;
if (elem) {
/* elem will always be NUL terminated. */
- const char *elem2 = elem + 1;
+ const char * const second_letter = elem + 1;
switch (*elem) {
case 'A':
- if (strEQ(elem2, "RRAY"))
+ if (strEQ(second_letter, "RRAY"))
tmpRef = (SV*)GvAV(gv);
break;
case 'C':
- if (strEQ(elem2, "ODE"))
+ if (strEQ(second_letter, "ODE"))
tmpRef = (SV*)GvCVu(gv);
break;
case 'F':
- if (strEQ(elem2, "ILEHANDLE")) {
+ if (strEQ(second_letter, "ILEHANDLE")) {
/* finally deprecated in 5.8.0 */
deprecate("*glob{FILEHANDLE}");
tmpRef = (SV*)GvIOp(gv);
}
else
- if (strEQ(elem2, "ORMAT"))
+ if (strEQ(second_letter, "ORMAT"))
tmpRef = (SV*)GvFORM(gv);
break;
case 'G':
- if (strEQ(elem2, "LOB"))
+ if (strEQ(second_letter, "LOB"))
tmpRef = (SV*)gv;
break;
case 'H':
- if (strEQ(elem2, "ASH"))
+ if (strEQ(second_letter, "ASH"))
tmpRef = (SV*)GvHV(gv);
break;
case 'I':
- if (*elem2 == 'O' && !elem[2])
+ if (*second_letter == 'O' && !elem[2])
tmpRef = (SV*)GvIOp(gv);
break;
case 'N':
- if (strEQ(elem2, "AME"))
+ if (strEQ(second_letter, "AME"))
sv = newSVpvn(GvNAME(gv), GvNAMELEN(gv));
break;
case 'P':
- if (strEQ(elem2, "ACKAGE")) {
+ if (strEQ(second_letter, "ACKAGE")) {
const HEK *hek = HvNAME_HEK(GvSTASH(gv));
sv = hek ? newSVhek(hek) : newSVpvn("__ANON__", 8);
}
break;
case 'S':
- if (strEQ(elem2, "CALAR"))
+ if (strEQ(second_letter, "CALAR"))
tmpRef = GvSV(gv);
break;
}
@@ -670,7 +662,7 @@ PP(pp_study)
sfirst -= 256;
while (--pos >= 0) {
- ch = s[pos];
+ register const I32 ch = s[pos];
if (sfirst[ch] >= 0)
snext[pos] = sfirst[ch] - pos;
else
@@ -743,9 +735,8 @@ PP(pp_chomp)
PP(pp_defined)
{
dSP;
- register SV* sv;
+ register SV* const sv = POPs;
- sv = POPs;
if (!sv || !SvANY(sv))
RETPUSHNO;
switch (SvTYPE(sv)) {
@@ -917,7 +908,7 @@ PP(pp_pow)
if (baseuok) {
baseuv = SvUVX(TOPm1s);
} else {
- IV iv = SvIVX(TOPm1s);
+ const IV iv = SvIVX(TOPm1s);
if (iv >= 0) {
baseuv = iv;
baseuok = TRUE; /* effectively it's a UV now */
@@ -959,7 +950,7 @@ PP(pp_pow)
for (; power; base *= base, n++) {
/* Do I look like I trust gcc with long longs here?
Do I hell. */
- UV bit = (UV)1 << (UV)n;
+ const UV bit = (UV)1 << (UV)n;
if (power & bit) {
result *= base;
/* Only bother to clear the bit if it is set. */
@@ -991,7 +982,7 @@ PP(pp_pow)
register UV base = baseuv;
register int n = 0;
for (; power; base *= base, n++) {
- register UV bit = (UV)1 << (UV)n;
+ register const UV bit = (UV)1 << (UV)n;
if (power & bit) {
result *= base;
power -= bit;
@@ -1054,7 +1045,7 @@ PP(pp_multiply)
if (auvok) {
alow = SvUVX(TOPm1s);
} else {
- IV aiv = SvIVX(TOPm1s);
+ const IV aiv = SvIVX(TOPm1s);
if (aiv >= 0) {
alow = aiv;
auvok = TRUE; /* effectively it's a UV now */
@@ -1065,7 +1056,7 @@ PP(pp_multiply)
if (buvok) {
blow = SvUVX(TOPs);
} else {
- IV biv = SvIVX(TOPs);
+ const IV biv = SvIVX(TOPs);
if (biv >= 0) {
blow = biv;
buvok = TRUE; /* effectively it's a UV now */
@@ -1186,7 +1177,7 @@ PP(pp_divide)
right = SvUVX(TOPs);
}
else {
- IV biv = SvIVX(TOPs);
+ const IV biv = SvIVX(TOPs);
if (biv >= 0) {
right = biv;
right_non_neg = TRUE; /* effectively it's a UV now */
@@ -1207,7 +1198,7 @@ PP(pp_divide)
left = SvUVX(TOPm1s);
}
else {
- IV aiv = SvIVX(TOPm1s);
+ const IV aiv = SvIVX(TOPm1s);
if (aiv >= 0) {
left = aiv;
left_non_neg = TRUE; /* effectively it's a UV now */
@@ -1233,7 +1224,7 @@ PP(pp_divide)
#endif
) {
/* Integer division can't overflow, but it can be imprecise. */
- UV result = left / right;
+ const UV result = left / right;
if (result * right == left) {
SP--; /* result is valid */
if (left_non_neg == right_non_neg) {
@@ -1282,7 +1273,7 @@ PP(pp_modulo)
if (!right_neg) {
right = SvUVX(POPs);
} else {
- IV biv = SvIVX(POPs);
+ const IV biv = SvIVX(POPs);
if (biv >= 0) {
right = biv;
right_neg = FALSE; /* effectively it's a UV now */
@@ -1401,7 +1392,7 @@ PP(pp_repeat)
mg_get(sv);
if (SvIOKp(sv)) {
if (SvUOK(sv)) {
- UV uv = SvUV(sv);
+ const UV uv = SvUV(sv);
if (uv > IV_MAX)
count = IV_MAX; /* The best we can do? */
else
@@ -1415,7 +1406,7 @@ PP(pp_repeat)
}
}
else if (SvNOKp(sv)) {
- NV nv = SvNV(sv);
+ const NV nv = SvNV(sv);
if (nv < 0.0)
count = 0;
else
@@ -1546,7 +1537,7 @@ PP(pp_subtract)
if ((auvok = SvUOK(TOPm1s)))
auv = SvUVX(TOPm1s);
else {
- register IV aiv = SvIVX(TOPm1s);
+ register const IV aiv = SvIVX(TOPm1s);
if (aiv >= 0) {
auv = aiv;
auvok = 1; /* Now acting as a sign flag. */
@@ -1566,7 +1557,7 @@ PP(pp_subtract)
if (buvok)
buv = SvUVX(TOPs);
else {
- register IV biv = SvIVX(TOPs);
+ register const IV biv = SvIVX(TOPs);
if (biv >= 0) {
buv = biv;
buvok = 1;
@@ -1640,7 +1631,7 @@ PP(pp_left_shift)
{
dSP; dATARGET; tryAMAGICbin(lshift,opASSIGN);
{
- IV shift = POPi;
+ const IV shift = POPi;
if (PL_op->op_private & HINT_INTEGER) {
IV i = TOPi;
SETi(i << shift);
@@ -1657,7 +1648,7 @@ PP(pp_right_shift)
{
dSP; dATARGET; tryAMAGICbin(rshift,opASSIGN);
{
- IV shift = POPi;
+ const IV shift = POPi;
if (PL_op->op_private & HINT_INTEGER) {
IV i = TOPi;
SETi(i >> shift);
@@ -1682,16 +1673,16 @@ PP(pp_lt)
bool buvok = SvUOK(TOPs);
if (!auvok && !buvok) { /* ## IV < IV ## */
- IV aiv = SvIVX(TOPm1s);
- IV biv = SvIVX(TOPs);
+ const IV aiv = SvIVX(TOPm1s);
+ const IV biv = SvIVX(TOPs);
SP--;
SETs(boolSV(aiv < biv));
RETURN;
}
if (auvok && buvok) { /* ## UV < UV ## */
- UV auv = SvUVX(TOPm1s);
- UV buv = SvUVX(TOPs);
+ const UV auv = SvUVX(TOPm1s);
+ const UV buv = SvUVX(TOPs);
SP--;
SETs(boolSV(auv < buv));
@@ -1699,9 +1690,7 @@ PP(pp_lt)
}
if (auvok) { /* ## UV < IV ## */
UV auv;
- IV biv;
-
- biv = SvIVX(TOPs);
+ const IV biv = SvIVX(TOPs);
SP--;
if (biv < 0) {
/* As (a) is a UV, it's >=0, so it cannot be < */
@@ -1713,10 +1702,9 @@ PP(pp_lt)
RETURN;
}
{ /* ## IV < UV ## */
- IV aiv;
+ const IV aiv = SvIVX(TOPm1s);
UV buv;
- aiv = SvIVX(TOPm1s);
if (aiv < 0) {
/* As (b) is a UV, it's >=0, so it must be < */
SP--;
@@ -1760,16 +1748,16 @@ PP(pp_gt)
bool buvok = SvUOK(TOPs);
if (!auvok && !buvok) { /* ## IV > IV ## */
- IV aiv = SvIVX(TOPm1s);
- IV biv = SvIVX(TOPs);
-
+ const IV aiv = SvIVX(TOPm1s);
+ const IV biv = SvIVX(TOPs);
+
SP--;
SETs(boolSV(aiv > biv));
RETURN;
}
if (auvok && buvok) { /* ## UV > UV ## */
- UV auv = SvUVX(TOPm1s);
- UV buv = SvUVX(TOPs);
+ const UV auv = SvUVX(TOPm1s);
+ const UV buv = SvUVX(TOPs);
SP--;
SETs(boolSV(auv > buv));
@@ -1777,9 +1765,8 @@ PP(pp_gt)
}
if (auvok) { /* ## UV > IV ## */
UV auv;
- IV biv;
-
- biv = SvIVX(TOPs);
+ const IV biv = SvIVX(TOPs);
+
SP--;
if (biv < 0) {
/* As (a) is a UV, it's >=0, so it must be > */
@@ -1791,10 +1778,9 @@ PP(pp_gt)
RETURN;
}
{ /* ## IV > UV ## */
- IV aiv;
+ const IV aiv = SvIVX(TOPm1s);
UV buv;
- aiv = SvIVX(TOPm1s);
if (aiv < 0) {
/* As (b) is a UV, it's >=0, so it cannot be > */
SP--;
@@ -1838,8 +1824,8 @@ PP(pp_le)
bool buvok = SvUOK(TOPs);
if (!auvok && !buvok) { /* ## IV <= IV ## */
- IV aiv = SvIVX(TOPm1s);
- IV biv = SvIVX(TOPs);
+ const IV aiv = SvIVX(TOPm1s);
+ const IV biv = SvIVX(TOPs);
SP--;
SETs(boolSV(aiv <= biv));
@@ -1855,9 +1841,8 @@ PP(pp_le)
}
if (auvok) { /* ## UV <= IV ## */
UV auv;
- IV biv;
-
- biv = SvIVX(TOPs);
+ const IV biv = SvIVX(TOPs);
+
SP--;
if (biv < 0) {
/* As (a) is a UV, it's >=0, so a cannot be <= */
@@ -1869,10 +1854,9 @@ PP(pp_le)
RETURN;
}
{ /* ## IV <= UV ## */
- IV aiv;
+ const IV aiv = SvIVX(TOPm1s);
UV buv;
-
- aiv = SvIVX(TOPm1s);
+
if (aiv < 0) {
/* As (b) is a UV, it's >=0, so a must be <= */
SP--;
@@ -1916,26 +1900,25 @@ PP(pp_ge)
bool buvok = SvUOK(TOPs);
if (!auvok && !buvok) { /* ## IV >= IV ## */
- IV aiv = SvIVX(TOPm1s);
- IV biv = SvIVX(TOPs);
-
+ const IV aiv = SvIVX(TOPm1s);
+ const IV biv = SvIVX(TOPs);
+
SP--;
SETs(boolSV(aiv >= biv));
RETURN;
}
if (auvok && buvok) { /* ## UV >= UV ## */
- UV auv = SvUVX(TOPm1s);
- UV buv = SvUVX(TOPs);
-
+ const UV auv = SvUVX(TOPm1s);
+ const UV buv = SvUVX(TOPs);
+
SP--;
SETs(boolSV(auv >= buv));
RETURN;
}
if (auvok) { /* ## UV >= IV ## */
UV auv;
- IV biv;
-
- biv = SvIVX(TOPs);
+ const IV biv = SvIVX(TOPs);
+
SP--;
if (biv < 0) {
/* As (a) is a UV, it's >=0, so it must be >= */
@@ -1947,10 +1930,9 @@ PP(pp_ge)
RETURN;
}
{ /* ## IV >= UV ## */
- IV aiv;
+ const IV aiv = SvIVX(TOPm1s);
UV buv;
-
- aiv = SvIVX(TOPm1s);
+
if (aiv < 0) {
/* As (b) is a UV, it's >=0, so a cannot be >= */
SP--;
@@ -2007,9 +1989,9 @@ PP(pp_ne)
differ from normal zero. As I understand it. (Need to
check - is negative zero implementation defined behaviour
anyway?). NWC */
- UV buv = SvUVX(POPs);
- UV auv = SvUVX(TOPs);
-
+ const UV buv = SvUVX(POPs);
+ const UV auv = SvUVX(TOPs);
+
SETs(boolSV(auv != buv));
RETURN;
}
@@ -2068,12 +2050,12 @@ PP(pp_ncmp)
if (SvIOK(TOPs)) {
SvIV_please(TOPm1s);
if (SvIOK(TOPm1s)) {
- bool leftuvok = SvUOK(TOPm1s);
- bool rightuvok = SvUOK(TOPs);
+ const bool leftuvok = SvUOK(TOPm1s);
+ const bool rightuvok = SvUOK(TOPs);
I32 value;
if (!leftuvok && !rightuvok) { /* ## IV <=> IV ## */
- IV leftiv = SvIVX(TOPm1s);
- IV rightiv = SvIVX(TOPs);
+ const IV leftiv = SvIVX(TOPm1s);
+ const IV rightiv = SvIVX(TOPs);
if (leftiv > rightiv)
value = 1;
@@ -2082,8 +2064,8 @@ PP(pp_ncmp)
else
value = 0;
} else if (leftuvok && rightuvok) { /* ## UV <=> UV ## */
- UV leftuv = SvUVX(TOPm1s);
- UV rightuv = SvUVX(TOPs);
+ const UV leftuv = SvUVX(TOPm1s);
+ const UV rightuv = SvUVX(TOPs);
if (leftuv > rightuv)
value = 1;
@@ -2092,15 +2074,12 @@ PP(pp_ncmp)
else
value = 0;
} else if (leftuvok) { /* ## UV <=> IV ## */
- UV leftuv;
- IV rightiv;
-
- rightiv = SvIVX(TOPs);
+ const IV rightiv = SvIVX(TOPs);
if (rightiv < 0) {
/* As (a) is a UV, it's >=0, so it cannot be < */
value = 1;
} else {
- leftuv = SvUVX(TOPm1s);
+ const UV leftuv = SvUVX(TOPm1s);
if (leftuv > (UV)rightiv) {
value = 1;
} else if (leftuv < (UV)rightiv) {
@@ -2110,15 +2089,12 @@ PP(pp_ncmp)
}
}
} else { /* ## IV <=> UV ## */
- IV leftiv;
- UV rightuv;
-
- leftiv = SvIVX(TOPm1s);
+ const IV leftiv = SvIVX(TOPm1s);
if (leftiv < 0) {
/* As (b) is a UV, it's >=0, so it must be < */
value = -1;
} else {
- rightuv = SvUVX(TOPs);
+ const UV rightuv = SvUVX(TOPs);
if ((UV)leftiv > rightuv) {
value = 1;
} else if ((UV)leftiv < rightuv) {
@@ -2166,7 +2142,7 @@ PP(pp_slt)
dSP; tryAMAGICbinSET(slt,0);
{
dPOPTOPssrl;
- int cmp = (IN_LOCALE_RUNTIME
+ const int cmp = (IN_LOCALE_RUNTIME
? sv_cmp_locale(left, right)
: sv_cmp(left, right));
SETs(boolSV(cmp < 0));
@@ -2179,7 +2155,7 @@ PP(pp_sgt)
dSP; tryAMAGICbinSET(sgt,0);
{
dPOPTOPssrl;
- int cmp = (IN_LOCALE_RUNTIME
+ const int cmp = (IN_LOCALE_RUNTIME
? sv_cmp_locale(left, right)
: sv_cmp(left, right));
SETs(boolSV(cmp > 0));
@@ -2192,7 +2168,7 @@ PP(pp_sle)
dSP; tryAMAGICbinSET(sle,0);
{
dPOPTOPssrl;
- int cmp = (IN_LOCALE_RUNTIME
+ const int cmp = (IN_LOCALE_RUNTIME
? sv_cmp_locale(left, right)
: sv_cmp(left, right));
SETs(boolSV(cmp <= 0));
@@ -2205,7 +2181,7 @@ PP(pp_sge)
dSP; tryAMAGICbinSET(sge,0);
{
dPOPTOPssrl;
- int cmp = (IN_LOCALE_RUNTIME
+ const int cmp = (IN_LOCALE_RUNTIME
? sv_cmp_locale(left, right)
: sv_cmp(left, right));
SETs(boolSV(cmp >= 0));
@@ -2238,7 +2214,7 @@ PP(pp_scmp)
dSP; dTARGET; tryAMAGICbin(scmp,0);
{
dPOPTOPssrl;
- int cmp = (IN_LOCALE_RUNTIME
+ const int cmp = (IN_LOCALE_RUNTIME
? sv_cmp_locale(left, right)
: sv_cmp(left, right));
SETi( cmp );
@@ -2255,11 +2231,11 @@ PP(pp_bit_and)
if (SvGMAGICAL(right)) mg_get(right);
if (SvNIOKp(left) || SvNIOKp(right)) {
if (PL_op->op_private & HINT_INTEGER) {
- IV i = SvIV_nomg(left) & SvIV_nomg(right);
+ const IV i = SvIV_nomg(left) & SvIV_nomg(right);
SETi(i);
}
else {
- UV u = SvUV_nomg(left) & SvUV_nomg(right);
+ const UV u = SvUV_nomg(left) & SvUV_nomg(right);
SETu(u);
}
}
@@ -2280,11 +2256,11 @@ PP(pp_bit_xor)
if (SvGMAGICAL(right)) mg_get(right);
if (SvNIOKp(left) || SvNIOKp(right)) {
if (PL_op->op_private & HINT_INTEGER) {
- IV i = (USE_LEFT(left) ? SvIV_nomg(left) : 0) ^ SvIV_nomg(right);
+ const IV i = (USE_LEFT(left) ? SvIV_nomg(left) : 0) ^ SvIV_nomg(right);
SETi(i);
}
else {
- UV u = (USE_LEFT(left) ? SvUV_nomg(left) : 0) ^ SvUV_nomg(right);
+ const UV u = (USE_LEFT(left) ? SvUV_nomg(left) : 0) ^ SvUV_nomg(right);
SETu(u);
}
}
@@ -2305,11 +2281,11 @@ PP(pp_bit_or)
if (SvGMAGICAL(right)) mg_get(right);
if (SvNIOKp(left) || SvNIOKp(right)) {
if (PL_op->op_private & HINT_INTEGER) {
- IV i = (USE_LEFT(left) ? SvIV_nomg(left) : 0) | SvIV_nomg(right);
+ const IV i = (USE_LEFT(left) ? SvIV_nomg(left) : 0) | SvIV_nomg(right);
SETi(i);
}
else {
- UV u = (USE_LEFT(left) ? SvUV_nomg(left) : 0) | SvUV_nomg(right);
+ const UV u = (USE_LEFT(left) ? SvUV_nomg(left) : 0) | SvUV_nomg(right);
SETu(u);
}
}
@@ -2326,7 +2302,7 @@ PP(pp_negate)
dSP; dTARGET; tryAMAGICun(neg);
{
dTOPss;
- int flags = SvFLAGS(sv);
+ const int flags = SvFLAGS(sv);
if (SvGMAGICAL(sv))
mg_get(sv);
if ((flags & SVf_IOK) || ((flags & (SVp_IOK | SVp_NOK)) == SVp_IOK)) {
@@ -2408,11 +2384,11 @@ PP(pp_complement)
mg_get(sv);
if (SvNIOKp(sv)) {
if (PL_op->op_private & HINT_INTEGER) {
- IV i = ~SvIV_nomg(sv);
+ const IV i = ~SvIV_nomg(sv);
SETi(i);
}
else {
- UV u = ~SvUV_nomg(sv);
+ const UV u = ~SvUV_nomg(sv);
SETu(u);
}
}
@@ -2436,7 +2412,7 @@ PP(pp_complement)
send = tmps + len;
while (tmps < send) {
- UV c = utf8n_to_uvchr(tmps, send-tmps, &l, UTF8_ALLOW_ANYUV);
+ const UV c = utf8n_to_uvchr(tmps, send-tmps, &l, UTF8_ALLOW_ANYUV);
tmps += UTF8SKIP(tmps);
targlen += UNISKIP(~c);
nchar++;
@@ -2450,7 +2426,7 @@ PP(pp_complement)
if (nwide) {
Newz(0, result, targlen + 1, U8);
while (tmps < send) {
- UV c = utf8n_to_uvchr(tmps, send-tmps, &l, UTF8_ALLOW_ANYUV);
+ const UV c = utf8n_to_uvchr(tmps, send-tmps, &l, UTF8_ALLOW_ANYUV);
tmps += UTF8SKIP(tmps);
result = uvchr_to_utf8_flags(result, ~c, UNICODE_ALLOW_ANY);
}
@@ -2462,7 +2438,7 @@ PP(pp_complement)
else {
Newz(0, result, nchar + 1, U8);
while (tmps < send) {
- U8 c = (U8)utf8n_to_uvchr(tmps, 0, &l, UTF8_ALLOW_ANY);
+ const U8 c = (U8)utf8n_to_uvchr(tmps, 0, &l, UTF8_ALLOW_ANY);
tmps += UTF8SKIP(tmps);
*result++ = ~c;
}
@@ -2713,10 +2689,8 @@ PP(pp_sin)
{
dSP; dTARGET; tryAMAGICun(sin);
{
- NV value;
- value = POPn;
- value = Perl_sin(value);
- XPUSHn(value);
+ const NV value = POPn;
+ XPUSHn(Perl_sin(value));
RETURN;
}
}
@@ -2725,10 +2699,8 @@ PP(pp_cos)
{
dSP; dTARGET; tryAMAGICun(cos);
{
- NV value;
- value = POPn;
- value = Perl_cos(value);
- XPUSHn(value);
+ const NV value = POPn;
+ XPUSHn(Perl_cos(value));
RETURN;
}
}
@@ -2797,14 +2769,12 @@ PP(pp_log)
{
dSP; dTARGET; tryAMAGICun(log);
{
- NV value;
- value = POPn;
+ const NV value = POPn;
if (value <= 0.0) {
SET_NUMERIC_STANDARD();
DIE(aTHX_ "Can't take log of %"NVgf, value);
}
- value = Perl_log(value);
- XPUSHn(value);
+ XPUSHn(Perl_log(value));
RETURN;
}
}
@@ -2813,14 +2783,12 @@ PP(pp_sqrt)
{
dSP; dTARGET; tryAMAGICun(sqrt);
{
- NV value;
- value = POPn;
+ const NV value = POPn;
if (value < 0.0) {
SET_NUMERIC_STANDARD();
DIE(aTHX_ "Can't take sqrt of %"NVgf, value);
}
- value = Perl_sqrt(value);
- XPUSHn(value);
+ XPUSHn(Perl_sqrt(value));
RETURN;
}
}
@@ -2829,8 +2797,7 @@ PP(pp_int)
{
dSP; dTARGET; tryAMAGICun(int);
{
- NV value;
- IV iv = TOPi; /* attempt to convert to IV if possible. */
+ const IV iv = TOPi; /* attempt to convert to IV if possible. */
/* XXX it's arguable that compiler casting to IV might be subtly
different from modf (for numbers inside (IV_MIN,UV_MAX)) in which
else preferring IV has introduced a subtle behaviour change bug. OTOH
@@ -2840,12 +2807,12 @@ PP(pp_int)
SETu(0);
else if (SvIOK(TOPs)) {
if (SvIsUV(TOPs)) {
- UV uv = TOPu;
+ const UV uv = TOPu;
SETu(uv);
} else
SETi(iv);
} else {
- value = TOPn;
+ const NV value = TOPn;
if (value >= 0.0) {
if (value < (NV)UV_MAX + 0.5) {
SETu(U_V(value));
@@ -2870,7 +2837,7 @@ PP(pp_abs)
dSP; dTARGET; tryAMAGICun(abs);
{
/* This will cache the NV value if string isn't actually integer */
- IV iv = TOPi;
+ const IV iv = TOPi;
if (!SvOK(TOPs))
SETu(0);
@@ -2892,10 +2859,11 @@ PP(pp_abs)
}
}
} else{
- NV value = TOPn;
+ const NV value = TOPn;
if (value < 0.0)
- value = -value;
- SETn(value);
+ SETn(value);
+ else
+ SETn(-value);
}
}
RETURN;
@@ -2910,13 +2878,13 @@ PP(pp_hex)
STRLEN len;
NV result_nv;
UV result_uv;
- SV* sv = POPs;
+ SV* const sv = POPs;
tmps = (SvPV_const(sv, len));
if (DO_UTF8(sv)) {
/* If Unicode, try to downgrade
* If not possible, croak. */
- SV* tsv = sv_2mortal(newSVsv(sv));
+ SV* const tsv = sv_2mortal(newSVsv(sv));
SvUTF8_on(tsv);
sv_utf8_downgrade(tsv, FALSE);
@@ -2940,13 +2908,13 @@ PP(pp_oct)
STRLEN len;
NV result_nv;
UV result_uv;
- SV* sv = POPs;
+ SV* const sv = POPs;
tmps = (SvPV_const(sv, len));
if (DO_UTF8(sv)) {
/* If Unicode, try to downgrade
* If not possible, croak. */
- SV* tsv = sv_2mortal(newSVsv(sv));
+ SV* const tsv = sv_2mortal(newSVsv(sv));
SvUTF8_on(tsv);
sv_utf8_downgrade(tsv, FALSE);
@@ -3002,7 +2970,7 @@ PP(pp_substr)
SV *repl_sv = NULL;
const char *repl = 0;
STRLEN repl_len;
- int num_args = PL_op->op_private & 7;
+ const int num_args = PL_op->op_private & 7;
bool repl_need_utf8_upgrade = FALSE;
bool repl_is_utf8 = FALSE;
@@ -3079,8 +3047,8 @@ PP(pp_substr)
RETPUSHUNDEF;
}
else {
- I32 upos = pos;
- I32 urem = rem;
+ const I32 upos = pos;
+ const I32 urem = rem;
if (utf8_curlen)
sv_pos_u2b(sv, &pos, &rem);
tmps += pos;
@@ -3157,10 +3125,10 @@ PP(pp_substr)
PP(pp_vec)
{
dSP; dTARGET;
- register IV size = POPi;
- register IV offset = POPi;
- register SV *src = POPs;
- I32 lvalue = PL_op->op_flags & OPf_MOD || LVRET;
+ register const IV size = POPi;
+ register const IV offset = POPi;
+ register SV * const src = POPs;
+ const I32 lvalue = PL_op->op_flags & OPf_MOD || LVRET;
SvTAINTED_off(TARG); /* decontaminate */
if (lvalue) { /* it's an lvalue! */
@@ -3196,7 +3164,7 @@ PP(pp_index)
const char *tmps;
const char *tmps2;
STRLEN biglen;
- I32 arybase = PL_curcop->cop_arybase;
+ const I32 arybase = PL_curcop->cop_arybase;
int big_utf8;
int little_utf8;
@@ -3210,9 +3178,9 @@ PP(pp_index)
little_utf8 = DO_UTF8(little);
if (big_utf8 ^ little_utf8) {
/* One needs to be upgraded. */
- SV *bytes = little_utf8 ? big : little;
+ SV * const bytes = little_utf8 ? big : little;
STRLEN len;
- const char *p = SvPV_const(bytes, len);
+ const char * const p = SvPV_const(bytes, len);
temp = newSVpvn(p, len);
@@ -3260,7 +3228,7 @@ PP(pp_rindex)
I32 retval;
const char *tmps;
const char *tmps2;
- I32 arybase = PL_curcop->cop_arybase;
+ const I32 arybase = PL_curcop->cop_arybase;
int big_utf8;
int little_utf8;
@@ -3272,7 +3240,7 @@ PP(pp_rindex)
little_utf8 = DO_UTF8(little);
if (big_utf8 ^ little_utf8) {
/* One needs to be upgraded. */
- SV *bytes = little_utf8 ? big : little;
+ SV * const bytes = little_utf8 ? big : little;
STRLEN len;
const char *p = SvPV_const(bytes, len);
@@ -3418,7 +3386,7 @@ PP(pp_crypt)
/* If Unicode, try to downgrade.
* If not possible, croak.
* Yes, we made this up. */
- SV* tsv = sv_2mortal(newSVsv(left));
+ SV* const tsv = sv_2mortal(newSVsv(left));
SvUTF8_on(tsv);
sv_utf8_downgrade(tsv, FALSE);
@@ -3689,8 +3657,8 @@ PP(pp_lc)
d = (U8*)SvPVX(TARG);
send = s + len;
while (s < send) {
- STRLEN u = UTF8SKIP(s);
- UV uv = toLOWER_utf8(s, tmpbuf, &ulen);
+ const STRLEN u = UTF8SKIP(s);
+ const UV uv = toLOWER_utf8(s, tmpbuf, &ulen);
#define GREEK_CAPITAL_LETTER_SIGMA 0x03A3 /* Unicode U+03A3 */
if (uv == GREEK_CAPITAL_LETTER_SIGMA) {
@@ -3745,7 +3713,7 @@ PP(pp_lc)
s = (U8*)SvPV_force_nomg(sv, len);
if (len) {
- register U8 *send = s + len;
+ register const U8 * const send = s + len;
if (IN_LOCALE_RUNTIME) {
TAINT;
@@ -3766,13 +3734,13 @@ PP(pp_lc)
PP(pp_quotemeta)
{
dSP; dTARGET;
- SV *sv = TOPs;
+ SV * const sv = TOPs;
STRLEN len;
const register char *s = SvPV_const(sv,len);
- register char *d;
SvUTF8_off(TARG); /* decontaminate */
if (len) {
+ register char *d;
SvUPGRADE(TARG, SVt_PV);
SvGROW(TARG, (len * 2) + 1);
d = SvPVX(TARG);
@@ -3819,17 +3787,16 @@ PP(pp_quotemeta)
PP(pp_aslice)
{
dSP; dMARK; dORIGMARK;
- register SV** svp;
- register AV* av = (AV*)POPs;
- register I32 lval = (PL_op->op_flags & OPf_MOD || LVRET);
- I32 arybase = PL_curcop->cop_arybase;
- I32 elem;
+ register AV* const av = (AV*)POPs;
+ register const I32 lval = (PL_op->op_flags & OPf_MOD || LVRET);
if (SvTYPE(av) == SVt_PVAV) {
+ const I32 arybase = PL_curcop->cop_arybase;
if (lval && PL_op->op_private & OPpLVAL_INTRO) {
+ register SV **svp;
I32 max = -1;
for (svp = MARK + 1; svp <= SP; svp++) {
- elem = SvIVx(*svp);
+ const I32 elem = SvIVx(*svp);
if (elem > max)
max = elem;
}
@@ -3837,7 +3804,8 @@ PP(pp_aslice)
av_extend(av, max);
}
while (++MARK <= SP) {
- elem = SvIVx(*MARK);
+ register SV **svp;
+ I32 elem = SvIVx(*MARK);
if (elem > 0)
elem -= arybase;
@@ -3864,7 +3832,7 @@ PP(pp_aslice)
PP(pp_each)
{
dSP;
- HV *hash = (HV*)POPs;
+ HV * const hash = (HV*)POPs;
HE *entry;
const I32 gimme = GIMME_V;
@@ -3875,7 +3843,7 @@ PP(pp_each)
EXTEND(SP, 2);
if (entry) {
- SV* sv = hv_iterkeysv(entry);
+ SV* const sv = hv_iterkeysv(entry);
PUSHs(sv); /* won't clobber stack_sp */
if (gimme == G_ARRAY) {
SV *val;
@@ -3907,24 +3875,21 @@ PP(pp_delete)
dSP;
const I32 gimme = GIMME_V;
const I32 discard = (gimme == G_VOID) ? G_DISCARD : 0;
- SV *sv;
- HV *hv;
if (PL_op->op_private & OPpSLICE) {
dMARK; dORIGMARK;
- U32 hvtype;
- hv = (HV*)POPs;
- hvtype = SvTYPE(hv);
+ HV * const hv = (HV*)POPs;
+ const U32 hvtype = SvTYPE(hv);
if (hvtype == SVt_PVHV) { /* hash element */
while (++MARK <= SP) {
- sv = hv_delete_ent(hv, *MARK, discard, 0);
+ SV * const sv = hv_delete_ent(hv, *MARK, discard, 0);
*MARK = sv ? sv : &PL_sv_undef;
}
}
else if (hvtype == SVt_PVAV) { /* array element */
if (PL_op->op_flags & OPf_SPECIAL) {
while (++MARK <= SP) {
- sv = av_delete((AV*)hv, SvIV(*MARK), discard);
+ SV * const sv = av_delete((AV*)hv, SvIV(*MARK), discard);
*MARK = sv ? sv : &PL_sv_undef;
}
}
@@ -3944,7 +3909,8 @@ PP(pp_delete)
}
else {
SV *keysv = POPs;
- hv = (HV*)POPs;
+ HV * const hv = (HV*)POPs;
+ SV *sv;
if (SvTYPE(hv) == SVt_PVHV)
sv = hv_delete_ent(hv, keysv, discard, 0);
else if (SvTYPE(hv) == SVt_PVAV) {
@@ -3971,9 +3937,8 @@ PP(pp_exists)
if (PL_op->op_private & OPpEXISTS_SUB) {
GV *gv;
- CV *cv;
SV *sv = POPs;
- cv = sv_2cv(sv, &hv, &gv, FALSE);
+ CV * const cv = sv_2cv(sv, &hv, &gv, FALSE);
if (cv)
RETPUSHYES;
if (gv && isGV(gv) && GvCV(gv) && !GvCVGEN(gv))
@@ -4001,9 +3966,9 @@ PP(pp_exists)
PP(pp_hslice)
{
dSP; dMARK; dORIGMARK;
- register HV *hv = (HV*)POPs;
- register I32 lval = (PL_op->op_flags & OPf_MOD || LVRET);
- bool localizing = PL_op->op_private & OPpLVAL_INTRO ? TRUE : FALSE;
+ register HV * const hv = (HV*)POPs;
+ register const I32 lval = (PL_op->op_flags & OPf_MOD || LVRET);
+ const bool localizing = PL_op->op_private & OPpLVAL_INTRO;
bool other_magic = FALSE;
if (localizing) {
@@ -4021,7 +3986,7 @@ PP(pp_hslice)
}
while (++MARK <= SP) {
- SV *keysv = *MARK;
+ SV * const keysv = *MARK;
SV **svp;
HE *he;
bool preeminent = FALSE;
@@ -4076,20 +4041,18 @@ PP(pp_list)
PP(pp_lslice)
{
dSP;
- SV **lastrelem = PL_stack_sp;
- SV **lastlelem = PL_stack_base + POPMARK;
- SV **firstlelem = PL_stack_base + POPMARK + 1;
- register SV **firstrelem = lastlelem + 1;
- I32 arybase = PL_curcop->cop_arybase;
- I32 lval = PL_op->op_flags & OPf_MOD;
- I32 is_something_there = lval;
-
- register I32 max = lastrelem - lastlelem;
+ SV ** const lastrelem = PL_stack_sp;
+ SV ** const lastlelem = PL_stack_base + POPMARK;
+ SV ** const firstlelem = PL_stack_base + POPMARK + 1;
+ register SV ** const firstrelem = lastlelem + 1;
+ const I32 arybase = PL_curcop->cop_arybase;
+ I32 is_something_there = PL_op->op_flags & OPf_MOD;
+
+ register const I32 max = lastrelem - lastlelem;
register SV **lelem;
- register I32 ix;
if (GIMME != G_ARRAY) {
- ix = SvIVx(*lastlelem);
+ I32 ix = SvIVx(*lastlelem);
if (ix < 0)
ix += max;
else
@@ -4108,7 +4071,7 @@ PP(pp_lslice)
}
for (lelem = firstlelem; lelem <= lastlelem; lelem++) {
- ix = SvIVx(*lelem);
+ I32 ix = SvIVx(*lelem);
if (ix < 0)
ix += max;
else
@@ -4131,8 +4094,8 @@ PP(pp_lslice)
PP(pp_anonlist)
{
dSP; dMARK; dORIGMARK;
- I32 items = SP - MARK;
- SV *av = sv_2mortal((SV*)av_make(items, MARK+1));
+ const I32 items = SP - MARK;
+ SV * const av = sv_2mortal((SV*)av_make(items, MARK+1));
SP = ORIGMARK; /* av_make() might realloc stack_sp */
XPUSHs(av);
RETURN;
@@ -4141,11 +4104,11 @@ PP(pp_anonlist)
PP(pp_anonhash)
{
dSP; dMARK; dORIGMARK;
- HV* hv = (HV*)sv_2mortal((SV*)newHV());
+ HV* const hv = (HV*)sv_2mortal((SV*)newHV());
while (MARK < SP) {
- SV* key = *++MARK;
- SV *val = NEWSV(46, 0);
+ SV * const key = *++MARK;
+ SV * const val = NEWSV(46, 0);
if (MARK < SP)
sv_setsv(val, *++MARK);
else if (ckWARN(WARN_MISC))
@@ -4170,9 +4133,9 @@ PP(pp_splice)
I32 after;
I32 diff;
SV **tmparyval = 0;
- MAGIC *mg;
+ const MAGIC * const mg = SvTIED_mg((SV*)ary, PERL_MAGIC_tied);
- if ((mg = SvTIED_mg((SV*)ary, PERL_MAGIC_tied))) {
+ if (mg) {
*MARK-- = SvTIED_obj((SV*)ary, mg);
PUSHMARK(MARK);
PUTBACK;
@@ -4230,7 +4193,7 @@ PP(pp_splice)
/* make new elements SVs now: avoid problems if they're from the array */
for (dst = MARK, i = newlen; i; i--) {
- SV *h = *dst;
+ SV * const h = *dst;
*dst++ = newSVsv(h);
}
@@ -4368,10 +4331,9 @@ PP(pp_push)
{
dVAR; dSP; dMARK; dORIGMARK; dTARGET;
register AV *ary = (AV*)*++MARK;
- register SV *sv = &PL_sv_undef;
- MAGIC *mg;
+ const MAGIC * const mg = SvTIED_mg((SV*)ary, PERL_MAGIC_tied);
- if ((mg = SvTIED_mg((SV*)ary, PERL_MAGIC_tied))) {
+ if (mg) {
*MARK-- = SvTIED_obj((SV*)ary, mg);
PUSHMARK(MARK);
PUTBACK;
@@ -4383,7 +4345,7 @@ PP(pp_push)
else {
/* Why no pre-extend of ary here ? */
for (++MARK; MARK <= SP; MARK++) {
- sv = NEWSV(51, 0);
+ SV * const sv = NEWSV(51, 0);
if (*MARK)
sv_setsv(sv, *MARK);
av_push(ary, sv);
@@ -4397,8 +4359,8 @@ PP(pp_push)
PP(pp_pop)
{
dSP;
- AV *av = (AV*)POPs;
- SV *sv = av_pop(av);
+ AV * const av = (AV*)POPs;
+ SV * const sv = av_pop(av);
if (AvREAL(av))
(void)sv_2mortal(sv);
PUSHs(sv);
@@ -4408,8 +4370,8 @@ PP(pp_pop)
PP(pp_shift)
{
dSP;
- AV *av = (AV*)POPs;
- SV *sv = av_shift(av);
+ AV * const av = (AV*)POPs;
+ SV * const sv = av_shift(av);
EXTEND(SP, 1);
if (!sv)
RETPUSHUNDEF;
@@ -4423,11 +4385,9 @@ PP(pp_unshift)
{
dVAR; dSP; dMARK; dORIGMARK; dTARGET;
register AV *ary = (AV*)*++MARK;
- register SV *sv;
- register I32 i = 0;
- MAGIC *mg;
+ const MAGIC * const mg = SvTIED_mg((SV*)ary, PERL_MAGIC_tied);
- if ((mg = SvTIED_mg((SV*)ary, PERL_MAGIC_tied))) {
+ if (mg) {
*MARK-- = SvTIED_obj((SV*)ary, mg);
PUSHMARK(MARK);
PUTBACK;
@@ -4437,9 +4397,10 @@ PP(pp_unshift)
SPAGAIN;
}
else {
+ register I32 i = 0;
av_unshift(ary, SP - MARK);
while (MARK < SP) {
- sv = newSVsv(*++MARK);
+ SV * const sv = newSVsv(*++MARK);
(void)av_store(ary, i++, sv);
}
}
@@ -4451,13 +4412,12 @@ PP(pp_unshift)
PP(pp_reverse)
{
dSP; dMARK;
- register SV *tmp;
- SV **oldsp = SP;
+ SV ** const oldsp = SP;
if (GIMME == G_ARRAY) {
MARK++;
while (MARK < SP) {
- tmp = *MARK;
+ register SV * const tmp = *MARK;
*MARK++ = *SP;
*SP-- = tmp;
}
@@ -4526,10 +4486,10 @@ PP(pp_split)
dVAR; dSP; dTARG;
AV *ary;
register IV limit = POPi; /* note, negative is forever */
- SV *sv = POPs;
+ SV * const sv = POPs;
STRLEN len;
register const char *s = SvPV_const(sv, len);
- bool do_utf8 = DO_UTF8(sv);
+ const bool do_utf8 = DO_UTF8(sv);
const char *strend = s + len;
register PMOP *pm;
register REGEXP *rx;
@@ -4538,9 +4498,8 @@ PP(pp_split)
I32 iters = 0;
const STRLEN slen = do_utf8 ? utf8_length((U8*)s, (U8*)strend) : (strend - s);
I32 maxiters = slen + 10;
- I32 i;
const char *orig;
- I32 origlimit = limit;
+ const I32 origlimit = limit;
I32 realarray = 0;
I32 base;
const I32 gimme = GIMME_V;
@@ -4586,6 +4545,7 @@ PP(pp_split)
}
else {
if (!AvREAL(ary)) {
+ I32 i;
AvREAL_on(ary);
AvREIFY_off(ary);
for (i = AvFILLp(ary); i >= 0; i--)
@@ -4658,12 +4618,12 @@ PP(pp_split)
(rx->reganch & RE_USE_INTUIT) && !rx->nparens
&& (rx->reganch & ROPT_CHECK_ALL)
&& !(rx->reganch & ROPT_ANCH)) {
- int tail = (rx->reganch & RE_INTUIT_TAIL);
- SV *csv = CALLREG_INTUIT_STRING(aTHX_ rx);
+ const int tail = (rx->reganch & RE_INTUIT_TAIL);
+ SV * const csv = CALLREG_INTUIT_STRING(aTHX_ rx);
len = rx->minlen;
if (len == 1 && !(rx->reganch & ROPT_UTF8) && !tail) {
- char c = *SvPV_nolen_const(csv);
+ const char c = *SvPV_nolen_const(csv);
while (--limit) {
for (m = s; m < strend && *m != c; m++)
;
@@ -4707,11 +4667,12 @@ PP(pp_split)
maxiters += slen * rx->nparens;
while (s < strend && --limit)
{
+ I32 rex_return;
PUTBACK;
- i = CALLREGEXEC(aTHX_ rx, (char*)s, (char*)strend, (char*)orig, 1 ,
+ rex_return = CALLREGEXEC(aTHX_ rx, (char*)s, (char*)strend, (char*)orig, 1 ,
sv, NULL, 0);
SPAGAIN;
- if (i == 0)
+ if (rex_return == 0)
break;
TAINT_IF(RX_MATCH_TAINTED(rx));
if (RX_MATCH_COPIED(rx) && rx->subbeg != orig) {
@@ -4729,6 +4690,7 @@ PP(pp_split)
(void)SvUTF8_on(dstr);
XPUSHs(dstr);
if (rx->nparens) {
+ I32 i;
for (i = 1; i <= (I32)rx->nparens; i++) {
s = rx->startp[i] + orig;
m = rx->endp[i] + orig;
@@ -4758,7 +4720,7 @@ PP(pp_split)
/* keep field after final delim? */
if (s < strend || (iters && origlimit)) {
- STRLEN l = strend - s;
+ const STRLEN l = strend - s;
dstr = newSVpvn(s, l);
if (make_mortal)
sv_2mortal(dstr);
@@ -4800,6 +4762,7 @@ PP(pp_split)
LEAVE;
SPAGAIN;
if (gimme == G_ARRAY) {
+ I32 i;
/* EXTEND should not be needed - we just popped them */
EXTEND(SP, iters);
for (i=0; i < iters; i++) {