STATIC I32
S_do_trans_count(pTHX_ SV *sv)
{
- U8 *s;
- U8 *send;
+ const U8 *s;
+ const U8 *send;
I32 matches = 0;
STRLEN len;
const I32 complement = PL_op->op_private & OPpTRANS_COMPLEMENT;
if (!tbl)
Perl_croak(aTHX_ "panic: do_trans_count line %d",__LINE__);
- s = (U8*)SvPV(sv, len);
+ s = (const U8*)SvPV_const(sv, len);
send = s + len;
if (!SvUTF8(sv))
if (num_args > 2) {
if (num_args > 3) {
repl_sv = POPs;
- repl = SvPV(repl_sv, repl_len);
+ repl = SvPV_const(repl_sv, repl_len);
repl_is_utf8 = DO_UTF8(repl_sv) && SvCUR(repl_sv);
}
len = POPi;
/* One needs to be upgraded. */
SV *bytes = little_utf8 ? big : little;
STRLEN len;
- char *p = SvPV(bytes, len);
+ const char *p = SvPV_const(bytes, len);
temp = newSVpvn(p, len);
#ifdef HAS_CRYPT
dSP; dTARGET;
dPOPTOPssrl;
- STRLEN n_a;
STRLEN len;
const char *tmps = SvPV_const(left, len);
# endif /* HAS_CRYPT_R */
# endif /* USE_ITHREADS */
# ifdef FCRYPT
- sv_setpv(TARG, fcrypt(tmps, SvPV(right, n_a)));
+ sv_setpv(TARG, fcrypt(tmps, SvPV_nolen_const(right)));
# else
- sv_setpv(TARG, PerlProc_crypt(tmps, SvPV(right, n_a)));
+ sv_setpv(TARG, PerlProc_crypt(tmps, SvPV_nolen_const(right)));
# endif
SETs(TARG);
RETURN;
{
dSP;
SV *sv = TOPs;
- register U8 *s;
+ const U8 *s;
STRLEN slen;
SvGETMAGIC(sv);
if (DO_UTF8(sv) &&
- (s = (U8*)SvPV_nomg(sv, slen)) && slen &&
+ (s = (const U8*)SvPV_nomg_const(sv, slen)) && slen &&
UTF8_IS_START(*s)) {
U8 tmpbuf[UTF8_MAXBYTES_CASE+1];
STRLEN ulen;
}
}
else {
+ U8 *s1;
if (!SvPADTMP(sv) || SvREADONLY(sv)) {
dTARGET;
SvUTF8_off(TARG); /* decontaminate */
sv = TARG;
SETs(sv);
}
- s = (U8*)SvPV_force_nomg(sv, slen);
- if (*s) {
+ s1 = (U8*)SvPV_force_nomg(sv, slen);
+ if (*s1) {
if (IN_LOCALE_RUNTIME) {
TAINT;
SvTAINTED_on(sv);
- *s = toUPPER_LC(*s);
+ *s1 = toUPPER_LC(*s1);
}
else
- *s = toUPPER(*s);
+ *s1 = toUPPER(*s1);
}
}
SvSETMAGIC(sv);
{
dSP;
SV *sv = TOPs;
- register U8 *s;
+ const U8 *s;
STRLEN slen;
SvGETMAGIC(sv);
if (DO_UTF8(sv) &&
- (s = (U8*)SvPV_nomg(sv, slen)) && slen &&
+ (s = (const U8*)SvPV_nomg_const(sv, slen)) && slen &&
UTF8_IS_START(*s)) {
STRLEN ulen;
U8 tmpbuf[UTF8_MAXBYTES_CASE+1];
}
}
else {
+ U8 *s1;
if (!SvPADTMP(sv) || SvREADONLY(sv)) {
dTARGET;
SvUTF8_off(TARG); /* decontaminate */
sv = TARG;
SETs(sv);
}
- s = (U8*)SvPV_force_nomg(sv, slen);
- if (*s) {
+ s1 = (U8*)SvPV_force_nomg(sv, slen);
+ if (*s1) {
if (IN_LOCALE_RUNTIME) {
TAINT;
SvTAINTED_on(sv);
- *s = toLOWER_LC(*s);
+ *s1 = toLOWER_LC(*s1);
}
else
- *s = toLOWER(*s);
+ *s1 = toLOWER(*s1);
}
}
SvSETMAGIC(sv);
len = rx->minlen;
if (len == 1 && !(rx->reganch & ROPT_UTF8) && !tail) {
- STRLEN n_a;
- char c = *SvPV(csv, n_a);
+ char c = *SvPV_nolen_const(csv);
while (--limit) {
/*SUPPRESS 530*/
for (m = s; m < strend && *m != c; m++) ;
/* string increment */
register SV* cur = cx->blk_loop.iterlval;
STRLEN maxlen = 0;
- const char *max = SvOK((SV*)av) ? SvPV((SV*)av, maxlen) : "";
+ const char *max = SvOK((SV*)av) ? SvPV_const((SV*)av, maxlen) : "";
if (!SvNIOK(cur) && SvCUR(cur) <= maxlen) {
if (SvREFCNT(*itersvp) == 1 && !SvMAGICAL(*itersvp)) {
/* safe to reuse old SV */
/* Fall through! */
case 'p':
while (len-- > 0) {
- char *aptr;
+ const char *aptr;
fromstr = NEXTFROM;
SvGETMAGIC(fromstr);
"Attempt to pack pointer to temporary value");
}
if (SvPOK(fromstr) || SvNIOK(fromstr))
- aptr = SvPV_flags(fromstr, n_a, 0);
+ aptr = SvPV_nomg_const(fromstr, n_a);
else
aptr = SvPV_force_flags(fromstr, n_a, 0);
}
"Field too wide in 'u' format in pack");
len = 63;
}
- aptr = SvPV(fromstr, fromlen);
+ aptr = SvPV_const(fromstr, fromlen);
from_utf8 = DO_UTF8(fromstr);
if (from_utf8) {
aend = aptr + fromlen;
else {
cv = sv_2cv(*++MARK, &stash, &gv, 0);
if (cv && SvPOK(cv)) {
- STRLEN n_a;
- char *proto = SvPV((SV*)cv, n_a);
+ char *proto = SvPV_nolen((SV*)cv);
if (proto && strEQ(proto, "$$")) {
hasargs = TRUE;
}
}
else {
if (!SvPOK(*p1)) {
- STRLEN n_a;
if (SvAMAGIC(*p1))
overloading = 1;
else
- (void)sv_2pv(*p1, &n_a);
+ (void)sv_2pv_flags(*p1, 0,
+ SV_GMAGIC|SV_CONST_RETURN);
}
}
}
GV *gv;
IO *io;
SV *bufsv;
- char *buffer;
+ const char *buffer;
Size_t length;
SSize_t retval;
STRLEN blen;
bufsv = sv_2mortal(newSVsv(bufsv));
buffer = sv_2pvutf8(bufsv, &blen);
} else
- buffer = SvPV(bufsv, blen);
+ buffer = SvPV_const(bufsv, blen);
}
else {
if (DO_UTF8(bufsv)) {
bufsv = sv_2mortal(newSVsv(bufsv));
sv_utf8_downgrade(bufsv, FALSE);
}
- buffer = SvPV(bufsv, blen);
+ buffer = SvPV_const(bufsv, blen);
}
if (PL_op->op_type == OP_SYSWRITE) {
if (length > blen - offset)
length = blen - offset;
if (DO_UTF8(bufsv)) {
- buffer = (char*)utf8_hop((U8 *)buffer, offset);
+ buffer = (const char*)utf8_hop((const U8 *)buffer, offset);
length = utf8_hop((U8 *)buffer, length) - (U8 *)buffer;
}
else {
}
else {
SV *sv = POPs;
- char *name;
- STRLEN n_a;
+ const char *name;
if (SvTYPE(sv) == SVt_PVGV) {
tmpgv = (GV*)sv; /* *main::FRED for example */
goto do_ftruncate_io;
}
- name = SvPV(sv, n_a);
+ name = SvPV_nolen_const(sv);
TAINT_PROPER("truncate");
#ifdef HAS_TRUNCATE
if (truncate(name, len) < 0)
#ifdef HAS_SYMLINK
dSP; dTARGET;
STRLEN n_a;
- char *tmps2 = POPpx;
- char *tmps = SvPV(TOPs, n_a);
+ const char *tmps2 = POPpconstx;
+ const char *tmps = SvPV_nolen_const(TOPs);
TAINT_PROPER("symlink");
SETi( symlink(tmps, tmps2) >= 0 );
RETURN;
}
else {
STRLEN len;
- char *t = SvPV(ret, len);
+ const char *t = SvPV_const(ret, len);
PMOP pm;
char * const oprecomp = PL_regprecomp;
const I32 osize = PL_regsize;
Zero(&pm, 1, PMOP);
if (DO_UTF8(ret)) pm.op_pmdynflags |= PMdf_DYN_UTF8;
- re = CALLREGCOMP(aTHX_ t, t + len, &pm);
+ re = CALLREGCOMP(aTHX_ (char*)t, (char*)t + len, &pm);
if (!(SvFLAGS(ret)
& (SVs_TEMP | SVs_PADTMP | SVf_READONLY
| SVs_GMG)))
len = SvCUR(sv);
}
else if (SvPOKp(sv))
- sbegin = SvPV(sv, len);
+ sbegin = SvPV_const(sv, len);
else
return SvFLAGS(sv) & (SVf_NOK|SVp_NOK|SVf_IOK|SVp_IOK);
return grok_number(sbegin, len, NULL);
void
Perl_sv_pos_b2u(pTHX_ register SV* sv, I32* offsetp)
{
- U8* s;
+ const U8* s;
STRLEN len;
if (!sv)
return;
- s = (U8*)SvPV(sv, len);
+ s = (const U8*)SvPV_const(sv, len);
if ((I32)len < *offsetp)
Perl_croak(aTHX_ "panic: sv_pos_b2u: bad byte offset");
else {
- U8* send = s + *offsetp;
+ const U8* send = s + *offsetp;
MAGIC* mg = NULL;
STRLEN *cache = NULL;
STRLEN backw = cache[1] - *offsetp;
if (!(forw < 2 * backw)) {
- U8 *p = s + cache[1];
+ const U8 *p = s + cache[1];
STRLEN ubackw = 0;
cache[1] -= backw;
if ((gv = gv_fetchpv(pkgname, FALSE, SVt_PVCV))) {
SV *sv;
if (GvCV(gv) && (sv = cv_const_sv(GvCV(gv)))) {
- pkgname = SvPV_nolen(sv);
+ pkgname = SvPV_nolen_const(sv);
}
}