const I32 grows = PL_op->op_private & OPpTRANS_GROWS;
STRLEN len;
- const short *tbl = (short*)cPVOP->op_pv;
+ const short * const tbl = (short*)cPVOP->op_pv;
if (!tbl)
Perl_croak(aTHX_ "panic: do_trans_simple line %d",__LINE__);
const I32 ch = tbl[*s];
if (ch >= 0) {
matches++;
- *s++ = (U8)ch;
+ *s = (U8)ch;
}
- else
- s++;
+ s++;
}
SvSETMAGIC(sv);
return matches;
/* Allow for expansion: $_="a".chr(400); tr/a/\xFE/, FE needs encoding */
if (grows)
- New(0, d, len*2+1, U8);
+ Newx(d, len*2+1, U8);
else
d = s;
dstart = d;
}
else { /* isutf8 */
if (grows)
- New(0, d, len*2+1, U8);
+ Newx(d, len*2+1, U8);
else
d = s;
dstart = d;
const I32 grows = PL_op->op_private & OPpTRANS_GROWS;
STRLEN len;
- SV* rv = (SV*)cSVOP->op_sv;
- HV* hv = (HV*)SvRV(rv);
- SV** svp = hv_fetch(hv, "NONE", 4, FALSE);
+ SV* const rv = (SV*)cSVOP->op_sv;
+ HV* const hv = (HV*)SvRV(rv);
+ SV* const * svp = hv_fetch(hv, "NONE", 4, FALSE);
const UV none = svp ? SvUV(*svp) : 0x7fffffff;
const UV extra = none + 1;
UV final = 0;
s = (U8*)SvPV(sv, len);
isutf8 = SvUTF8(sv);
if (!isutf8) {
- const U8 *t = s, *e = s + len;
+ const U8 *t = s;
+ const U8 * const e = s + len;
while (t < e) {
const U8 ch = *t++;
if ((hibit = !NATIVE_IS_INVARIANT(ch)))
if (grows) {
/* d needs to be bigger than s, in case e.g. upgrading is required */
- New(0, d, len * 3 + UTF8_MAXBYTES, U8);
+ Newx(d, len * 3 + UTF8_MAXBYTES, U8);
dend = d + len * 3;
dstart = d;
}
I32 matches = 0;
STRLEN len;
- SV* rv = (SV*)cSVOP->op_sv;
- HV* hv = (HV*)SvRV(rv);
- SV** svp = hv_fetch(hv, "NONE", 4, FALSE);
+ SV* const rv = (SV*)cSVOP->op_sv;
+ HV* const hv = (HV*)SvRV(rv);
+ SV* const * const svp = hv_fetch(hv, "NONE", 4, FALSE);
const UV none = svp ? SvUV(*svp) : 0x7fffffff;
const UV extra = none + 1;
U8 hibit = 0;
s = (const U8*)SvPV_const(sv, len);
if (!SvUTF8(sv)) {
const U8 *t = s;
- const U8 *e = s + len;
+ const U8 * const e = s + len;
while (t < e) {
const U8 ch = *t++;
if ((hibit = !NATIVE_IS_INVARIANT(ch)))
send = s + len;
while (s < send) {
- UV uv;
- if ((uv = swash_fetch(rv, s, TRUE)) < none || uv == extra)
+ const UV uv = swash_fetch(rv, s, TRUE);
+ if (uv < none || uv == extra)
matches++;
s += UTF8SKIP(s);
}
const I32 squash = PL_op->op_private & OPpTRANS_SQUASH;
const I32 del = PL_op->op_private & OPpTRANS_DELETE;
const I32 grows = PL_op->op_private & OPpTRANS_GROWS;
- SV* rv = (SV*)cSVOP->op_sv;
- HV* hv = (HV*)SvRV(rv);
- SV** svp = hv_fetch(hv, "NONE", 4, FALSE);
+ SV * const rv = (SV*)cSVOP->op_sv;
+ HV * const hv = (HV*)SvRV(rv);
+ SV * const *svp = hv_fetch(hv, "NONE", 4, FALSE);
const UV none = svp ? SvUV(*svp) : 0x7fffffff;
const UV extra = none + 1;
UV final = 0;
U8 *s = (U8*)SvPV(sv, len);
const I32 isutf8 = SvUTF8(sv);
if (!isutf8) {
- const U8 *t = s, *e = s + len;
+ const U8 *t = s;
+ const U8 * const e = s + len;
while (t < e) {
const U8 ch = *t++;
if ((hibit = !NATIVE_IS_INVARIANT(ch)))
if (grows) {
/* d needs to be bigger than s, in case e.g. upgrading is required */
- New(0, d, len * 3 + UTF8_MAXBYTES, U8);
+ Newx(d, len * 3 + UTF8_MAXBYTES, U8);
dend = d + len * 3;
dstart = d;
}
void
Perl_do_join(pTHX_ register SV *sv, SV *del, register SV **mark, register SV **sp)
{
- SV **oldmark = mark;
+ SV ** const oldmark = mark;
register I32 items = sp - mark;
register STRLEN len;
STRLEN delimlen;
Perl_do_sprintf(pTHX_ SV *sv, I32 len, SV **sarg)
{
STRLEN patlen;
- const char *pat = SvPV_const(*sarg, patlen);
+ const char * const pat = SvPV_const(*sarg, patlen);
bool do_taint = FALSE;
SvUTF8_off(sv);
void
Perl_do_vecset(pTHX_ SV *sv)
{
- SV *targ = LvTARG(sv);
register I32 offset;
register I32 size;
register unsigned char *s;
I32 mask;
STRLEN targlen;
STRLEN len;
+ SV * const targ = LvTARG(sv);
if (!targ)
return;
if (SvTYPE(sv) == SVt_PVAV) {
register I32 i;
- AV* av = (AV*)sv;
+ AV* const av = (AV*)sv;
const I32 max = AvFILL(av);
for (i = 0; i <= max; i++) {
return;
}
else if (SvTYPE(sv) == SVt_PVHV) {
- HV* hv = (HV*)sv;
+ HV* const hv = (HV*)sv;
HE* entry;
(void)hv_iterinit(hv);
while ((entry = hv_iternext(hv)))
s = SvPV_force(sv, len);
if (DO_UTF8(sv)) {
if (s && len) {
- char *send = s + len;
+ char * const send = s + len;
char *start = s;
s = send - 1;
while (s > start && UTF8_IS_CONTINUATION(*s))
s--;
- if (utf8_to_uvchr((U8*)s, 0)) {
+ if (is_utf8_string((U8*)s, send - s)) {
sv_setpvn(astr, s, send - s);
*s = '\0';
SvCUR_set(sv, s - start);
count = 0;
if (SvTYPE(sv) == SVt_PVAV) {
register I32 i;
- AV* av = (AV*)sv;
+ AV* const av = (AV*)sv;
const I32 max = AvFILL(av);
for (i = 0; i <= max; i++) {
return count;
}
else if (SvTYPE(sv) == SVt_PVHV) {
- HV* hv = (HV*)sv;
+ HV* const hv = (HV*)sv;
HE* entry;
(void)hv_iterinit(hv);
while ((entry = hv_iternext(hv)))
lensave = len;
if ((left_utf || right_utf) && (sv == left || sv == right)) {
needlen = optype == OP_BIT_AND ? len : leftlen + rightlen;
- Newz(801, dc, needlen + 1, char);
+ Newxz(dc, needlen + 1, char);
}
else if (SvOK(sv) || SvTYPE(sv) > SVt_PVMG) {
- STRLEN n_a;
- dc = SvPV_force_nomg(sv, n_a);
+ dc = SvPV_force_nomg_nolen(sv);
if (SvCUR(sv) < (STRLEN)len) {
dc = SvGROW(sv, (STRLEN)(len + 1));
(void)memzero(dc + SvCUR(sv), len - SvCUR(sv) + 1);
else {
needlen = ((optype == OP_BIT_AND)
? len : (leftlen > rightlen ? leftlen : rightlen));
- Newz(801, dc, needlen + 1, char);
+ Newxz(dc, needlen + 1, char);
(void)sv_usepvn(sv, dc, needlen);
dc = SvPVX(sv); /* sv_usepvn() calls Renew() */
}
(void)SvPOK_only(sv);
if (left_utf || right_utf) {
UV duc, luc, ruc;
- char *dcsave = dc;
+ char * const dcsave = dc;
STRLEN lulen = leftlen;
STRLEN rulen = rightlen;
STRLEN ulen;
Perl_do_kv(pTHX)
{
dSP;
- HV *hv = (HV*)POPs;
+ HV * const hv = (HV*)POPs;
HV *keys;
register HE *entry;
const I32 gimme = GIMME_V;
while ((entry = hv_iternext(keys))) {
SPAGAIN;
if (dokeys) {
- SV* sv = hv_iterkeysv(entry);
+ SV* const sv = hv_iterkeysv(entry);
XPUSHs(sv); /* won't clobber stack_sp */
}
if (dovalues) {