int mode = O_BINARY;
if (discp) {
STRLEN len;
- const char *s = SvPV(discp,len);
+ const char *s = SvPV_const(discp,len);
while (*s) {
if (*s == ':') {
switch (s[1]) {
{
dSP;
SV *sv;
- STRLEN n_a;
if (PL_op->op_flags & OPf_REF) {
EXTEND(SP,1);
if (cGVOP_gv == PL_defgv) {
return (PL_laststatval = -1);
}
/* XXX Do really need to be calling SvPV() all these times? */
- sv_setpv(PL_statname,SvPV(sv, n_a));
- PL_laststatval = PerlLIO_lstat(SvPV(sv, n_a),&PL_statcache);
- if (PL_laststatval < 0 && ckWARN(WARN_NEWLINE) && strchr(SvPV(sv, n_a), '\n'))
+ sv_setpv(PL_statname,SvPV_nolen_const(sv));
+ PL_laststatval = PerlLIO_lstat(SvPV_nolen_const(sv),&PL_statcache);
+ if (PL_laststatval < 0 && ckWARN(WARN_NEWLINE) && strchr(SvPV_nolen_const(sv), '\n'))
Perl_warner(aTHX_ packWARN(WARN_NEWLINE), PL_warn_nl, "lstat");
return PL_laststatval;
}
#else
register char **a;
const char *tmps = Nullch;
- STRLEN n_a;
if (sp > mark) {
New(401,PL_Argv, sp - mark + 1, char*);
a = PL_Argv;
while (++mark <= sp) {
if (*mark)
- *a++ = SvPVx(*mark, n_a);
+ *a++ = (char*)SvPV_nolen_const(*mark);
else
*a++ = "";
}
*a = Nullch;
if (really)
- tmps = SvPV(really, n_a);
+ tmps = SvPV_nolen_const(really);
if ((!really && *PL_Argv[0] != '/') ||
(really && *tmps != '/')) /* will execvp use PATH? */
TAINT_ENV(); /* testing IFS here is overkill, probably */
const char *what;
const char *s;
SV **oldmark = mark;
- STRLEN n_a;
#define APPLY_TAINT_PROPER() \
STMT_START { \
APPLY_TAINT_PROPER();
tot = sp - mark;
while (++mark <= sp) {
- const char *name = SvPVx(*mark, n_a);
+ const char *name = SvPV_nolen_const(*mark);
APPLY_TAINT_PROPER();
if (PerlLIO_chmod(name, val))
tot--;
APPLY_TAINT_PROPER();
tot = sp - mark;
while (++mark <= sp) {
- const char *name = SvPVx(*mark, n_a);
+ const char *name = SvPV_nolen_const(*mark);
APPLY_TAINT_PROPER();
if (PerlLIO_chown(name, val, val2))
tot--;
APPLY_TAINT_PROPER();
if (mark == sp)
break;
- s = SvPVx_const(*++mark, n_a);
+ s = SvPVx_nolen_const(*++mark);
if (isALPHA(*s)) {
if (*s == 'S' && s[1] == 'I' && s[2] == 'G')
s += 3;
APPLY_TAINT_PROPER();
tot = sp - mark;
while (++mark <= sp) {
- s = SvPVx_const(*mark, n_a);
+ s = SvPV_nolen_const(*mark);
APPLY_TAINT_PROPER();
if (PL_euid || PL_unsafe) {
if (UNLINK(s))
APPLY_TAINT_PROPER();
tot = sp - mark;
while (++mark <= sp) {
- STRLEN n_a;
- const char *name = SvPVx(*mark, n_a);
+ const char *name = SvPV_nolen_const(*mark);
APPLY_TAINT_PROPER();
if (PerlLIO_utime(name, utbufp))
tot--;
register char *dc;
STRLEN leftlen;
STRLEN rightlen;
- register char *lc;
- register char *rc;
+ register const char *lc;
+ register const char *rc;
register I32 len;
I32 lensave;
- char *lsave;
- char *rsave;
+ const char *lsave;
+ const char *rsave;
const bool left_utf = DO_UTF8(left);
const bool right_utf = DO_UTF8(right);
I32 needlen = 0;
if (sv != left || (optype != OP_BIT_AND && !SvOK(sv) && !SvGMAGICAL(sv)))
sv_setpvn(sv, "", 0); /* avoid undef warning on |= and ^= */
- lsave = lc = SvPV_nomg(left, leftlen);
- rsave = rc = SvPV_nomg(right, rightlen);
+ lsave = lc = SvPV_nomg_const(left, leftlen);
+ rsave = rc = SvPV_nomg_const(right, rightlen);
len = leftlen < rightlen ? leftlen : rightlen;
lensave = len;
if ((left_utf || right_utf) && (sv == left || sv == right)) {
return Nullgv;
if (stash) {
if (SvTYPE(stash) < SVt_PVHV) {
- packname = SvPV((SV*)stash, packname_len);
+ packname = SvPV_const((SV*)stash, packname_len);
stash = Nullhv;
}
else {
Perl_is_gv_magical_sv(pTHX_ SV *name, U32 flags)
{
STRLEN len;
- const char *temp = SvPV(name, len);
+ const char *temp = SvPV_const(name, len);
return is_gv_magical(temp, len, flags);
}
{
dVAR;
register char *s;
- char *ptr;
+ const char *ptr;
STRLEN len, klen;
s = SvPV(sv,len);
- ptr = MgPV(mg,klen);
+ ptr = MgPV_const(mg,klen);
my_setenv(ptr, s);
#ifdef DYNAMIC_ENV_FETCH
if (*args == &PL_sv_undef)
return PerlIO_tmpfile();
else {
- const char *name = SvPV_nolen(*args);
+ const char *name = SvPV_nolen_const(*args);
if (*mode == IoTYPE_NUMERIC) {
fd = PerlLIO_open3(name, imode, perm);
if (fd >= 0)
if (items < 2)
Perl_croak(aTHX_ "Usage class->find(name[,load])");
else {
- const char *name = SvPV_nolen(ST(1));
+ const char *name = SvPV_nolen_const(ST(1));
ST(0) = (strEQ(name, "crlf")
|| strEQ(name, "raw")) ? &PL_sv_yes : &PL_sv_undef;
XSRETURN(1);
Perl_warn(aTHX_ "attrib %" SVf, sv);
for (i = 2; i < items; i++) {
STRLEN len;
- const char *name = SvPV(ST(i), len);
+ const char *name = SvPV_const(ST(i), len);
SV *layer = PerlIO_find_layer(aTHX_ name, len, 1);
if (layer) {
av_push(av, SvREFCNT_inc(layer));
*/
dXSARGS;
if (items)
- PerlIO_debug("warning:%s\n",SvPV_nolen(ST(0)));
+ PerlIO_debug("warning:%s\n",SvPV_nolen_const(ST(0)));
XSRETURN(0);
}
Perl_croak(aTHX_ "Usage class->find(name[,load])");
else {
STRLEN len;
- const char *name = SvPV(ST(1), len);
+ const char *name = SvPV_const(ST(1), len);
const bool load = (items > 2) ? SvTRUE(ST(2)) : 0;
PerlIO_funcs *layer = PerlIO_find_layer(aTHX_ name, len, load);
ST(0) =
perm = 0666;
}
if (imode != -1) {
- const char *path = SvPV_nolen(*args);
+ const char *path = SvPV_nolen_const(*args);
fd = PerlLIO_open3(path, imode, perm);
}
}
{
char tmode[8];
if (PerlIOValid(f)) {
- const char *path = SvPV_nolen(*args);
+ const char *path = SvPV_nolen_const(*args);
PerlIOStdio *s = PerlIOSelf(f, PerlIOStdio);
FILE *stdio;
PerlIOUnix_refcnt_dec(fileno(s->stdio));
}
else {
if (narg > 0) {
- const char *path = SvPV_nolen(*args);
+ const char *path = SvPV_nolen_const(*args);
if (*mode == IoTYPE_NUMERIC) {
mode++;
fd = PerlLIO_open3(path, imode, perm);
SV *tmpRef;
const char *elem;
dSP;
- STRLEN n_a;
sv = POPs;
- elem = SvPV(sv, n_a);
+ elem = SvPV_nolen_const(sv);
gv = (GV*)POPs;
tmpRef = Nullsv;
sv = Nullsv;
{
dSP;
register PMOP *pm = (PMOP*)cLOGOP->op_other;
- register char *t;
SV *tmpstr;
- STRLEN len;
MAGIC *mg = Null(MAGIC*);
/* prevent recompiling under /o and ithreads. */
PM_SETRE(pm, ReREFCNT_inc(re));
}
else {
- t = SvPV(tmpstr, len);
+ STRLEN len;
+ const char *t = SvPV_const(tmpstr, len);
/* Check against the last compiled regexp. */
if (!PM_GETRE(pm) || !PM_GETRE(pm)->precomp ||
if (pm->op_pmdynflags & PMdf_UTF8)
t = (char*)bytes_to_utf8((U8*)t, &len);
}
- PM_SETRE(pm, CALLREGCOMP(aTHX_ t, t + len, pm));
+ PM_SETRE(pm, CALLREGCOMP(aTHX_ (char *)t, (char *)t + len, pm));
if (!DO_UTF8(tmpstr) && (pm->op_pmdynflags & PMdf_UTF8))
Safefree(t);
PL_reginterp_cnt = 0; /* XXXX Be extra paranoid - needed
if (MAXARG < 1)
tmps = "";
else
- tmps = POPpx;
+ tmps = POPpconstx;
sv_reset(tmps, CopSTASH(PL_curcop));
PUSHs(&PL_sv_yes);
RETURN;
else {
if (!preeminent) {
STRLEN keylen;
- const char * const key = SvPV(keysv, keylen);
+ const char * const key = SvPV_const(keysv, keylen);
SAVEDELETE(hv, savepvn(key,keylen), keylen);
} else
save_helem(hv, keysv, svp);
const char *aptr;
fromstr = NEXTFROM;
- aptr = SvPV(fromstr, fromlen);
+ aptr = SvPV_const(fromstr, fromlen);
if (DO_UTF8(fromstr)) {
const char *end, *s;
if (fp) {
const char *type = NULL;
if (PL_curcop->cop_io) {
- type = SvPV_nolen(PL_curcop->cop_io);
+ type = SvPV_nolen_const(PL_curcop->cop_io);
}
if (type && *type)
PerlIO_apply_layers(aTHX_ fp,mode,type);
else {
tmpsv = TOPs;
}
- tmps = SvPV(tmpsv, len);
+ tmps = SvPV_const(tmpsv, len);
if ((!tmps || !len) && PL_errgv) {
SV *error = ERRSV;
SvUPGRADE(error, SVt_PV);
if (SvPOK(error) && SvCUR(error))
sv_catpv(error, "\t...caught");
tmpsv = error;
- tmps = SvPV(tmpsv, len);
+ tmps = SvPV_const(tmpsv, len);
}
if (!tmps || !len)
tmpsv = sv_2mortal(newSVpvn("Warning: something's wrong", 26));
if (SvPOK(error) && SvCUR(error))
sv_catpv(error, "\t...propagated");
tmpsv = error;
- tmps = SvPV(tmpsv, len);
+ tmps = SvPV_const(tmpsv, len);
}
}
if (!tmps || !len)
PUTBACK;
if (PerlIO_binmode(aTHX_ fp,IoTYPE(io),mode_from_discipline(discp),
- (discp) ? SvPV_nolen(discp) : Nullch)) {
+ (discp) ? SvPV_nolen_const(discp) : Nullch)) {
if (IoOFP(io) && IoOFP(io) != IoIFP(io)) {
if (!PerlIO_binmode(aTHX_ IoOFP(io),IoTYPE(io),
mode_from_discipline(discp),
- (discp) ? SvPV_nolen(discp) : Nullch)) {
+ (discp) ? SvPV_nolen_const(discp) : Nullch)) {
SPAGAIN;
RETPUSHUNDEF;
}
if (!cv) {
if (fgv) {
SV * const tmpsv = sv_newmortal();
- char *name;
+ const char *name;
gv_efullname4(tmpsv, fgv, Nullch, FALSE);
- name = SvPV_nolen(tmpsv);
+ name = SvPV_nolen_const(tmpsv);
if (name && *name)
DIE(aTHX_ "Undefined format \"%s\" called", name);
}
SV * const sv = sv_newmortal();
const char *name;
gv_efullname4(sv, fgv, Nullch, FALSE);
- name = SvPV_nolen(sv);
+ name = SvPV_nolen_const(sv);
if (name && *name)
DIE(aTHX_ "Undefined top format \"%s\" called",name);
}
dSP;
GV *gv;
SV *sv;
- char *tmps;
+ const char *tmps;
STRLEN len;
const int perm = (MAXARG > 3) ? POPi : 0666;
const int mode = POPi;
/* Need TIEHANDLE method ? */
- tmps = SvPV(sv, len);
- if (do_open(gv, tmps, len, TRUE, mode, perm, Nullfp)) {
+ tmps = SvPV_const(sv, len);
+ /* FIXME? do_open should do const */
+ if (do_open(gv, (char*)tmps, len, TRUE, mode, perm, Nullfp)) {
IoLINES(GvIOp(gv)) = 0;
PUSHs(&PL_sv_yes);
}
dSP; dTARGET;
int anum;
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("rename");
#ifdef HAS_RENAME
anum = PerlLIO_rename(tmps, tmps2);
#ifdef HAS_LINK
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("link");
SETi( PerlLIO_link(tmps, tmps2) >= 0 );
RETURN;
/* each *s can expand to 4 chars + "...\0",
i.e. need room for 8 chars */
- char *s, *end;
- for (s = SvPVX(sv), end = s + SvCUR(sv); s < end && d < limit; s++) {
+ const char *s, *end;
+ for (s = SvPVX_const(sv), end = s + SvCUR(sv); s < end && d < limit;
+ s++) {
int ch = *s & 0xFF;
if (ch & 128 && !isPRINT_LC(ch)) {
*d++ = 'M';
else
{
STRLEN len, ulen;
- const U8 *s = (U8*)SvPV(sv, len);
+ const U8 *s = (U8*)SvPV_const(sv, len);
MAGIC *mg = SvMAGICAL(sv) ? mg_find(sv, PERL_MAGIC_utf8) : 0;
if (mg && mg->mg_len != -1 && (mg->mg_len > 0 || len == 0)) {
NV retval = 0.0;
NV nshift = 1.0;
STRLEN len;
- const char *start = SvPVx(sv,len);
+ const char *start = SvPVx_const(sv,len);
const char *end = start + len;
const bool utf = SvUTF8(sv) ? TRUE : FALSE;
while (start < end) {
|| (SvGMAGICAL(sv) && SvPOKp(sv) && SvCUR(sv))))
XSRETURN_UNDEF;
- name = (const char *)SvPV(ST(1),n_a);
+ name = SvPV_const(ST(1),n_a);
ST(0) = boolSV(sv_derived_from(sv, name));
XSRETURN(1);
|| (SvGMAGICAL(sv) && SvPOKp(sv) && SvCUR(sv))))
XSRETURN_UNDEF;
- name = (const char *)SvPV(ST(1),n_a);
+ name = SvPV_const(ST(1),n_a);
rv = &PL_sv_undef;
if (SvROK(sv)) {
SV * sv = ST(0);
{
STRLEN len;
- const char *s = SvPV(sv,len);
+ const char *s = SvPV_const(sv,len);
if (!SvUTF8(sv) || is_utf8_string((const U8*)s,len))
XSRETURN_YES;
else
SV **varp = svp;
SV **valp = svp + 1;
STRLEN klen;
- const char *key = SvPV(*varp, klen);
+ const char *key = SvPV_const(*varp, klen);
switch (*key) {
case 'i':
Perl_savesvpv(pTHX_ SV *sv)
{
STRLEN len;
- const char *pv = SvPV(sv, len);
+ const char *pv = SvPV_const(sv, len);
register char *newaddr;
++len;