Change 24740 by [EMAIL PROTECTED] on 2005/06/07 18:38:39
More SvPV consting.
Affected files ...
... //depot/perl/doio.c#263 edit
... //depot/perl/doop.c#154 edit
... //depot/perl/gv.c#246 edit
... //depot/perl/mg.c#337 edit
... //depot/perl/perlio.c#274 edit
... //depot/perl/pp.c#462 edit
... //depot/perl/pp_ctl.c#445 edit
... //depot/perl/pp_hot.c#395 edit
... //depot/perl/pp_pack.c#95 edit
... //depot/perl/pp_sys.c#409 edit
... //depot/perl/sv.c#876 edit
... //depot/perl/toke.c#568 edit
... //depot/perl/universal.c#110 edit
... //depot/perl/util.c#463 edit
Differences ...
==== //depot/perl/doio.c#263 (text) ====
Index: perl/doio.c
--- perl/doio.c#262~24726~ Tue Jun 7 05:11:48 2005
+++ perl/doio.c Tue Jun 7 11:38:39 2005
@@ -1176,7 +1176,7 @@
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]) {
@@ -1423,7 +1423,6 @@
{
dSP;
SV *sv;
- STRLEN n_a;
if (PL_op->op_flags & OPf_REF) {
EXTEND(SP,1);
if (cGVOP_gv == PL_defgv) {
@@ -1451,9 +1450,9 @@
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;
}
@@ -1476,20 +1475,19 @@
#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 */
@@ -1674,7 +1672,6 @@
const char *what;
const char *s;
SV **oldmark = mark;
- STRLEN n_a;
#define APPLY_TAINT_PROPER() \
STMT_START { \
@@ -1700,7 +1697,7 @@
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--;
@@ -1718,7 +1715,7 @@
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--;
@@ -1738,7 +1735,7 @@
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;
@@ -1808,7 +1805,7 @@
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))
@@ -1862,8 +1859,7 @@
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--;
==== //depot/perl/doop.c#154 (text) ====
Index: perl/doop.c
--- perl/doop.c#153~24726~ Tue Jun 7 05:11:48 2005
+++ perl/doop.c Tue Jun 7 11:38:39 2005
@@ -1149,12 +1149,12 @@
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;
@@ -1166,8 +1166,8 @@
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)) {
==== //depot/perl/gv.c#246 (text) ====
Index: perl/gv.c
--- perl/gv.c#245~24726~ Tue Jun 7 05:11:48 2005
+++ perl/gv.c Tue Jun 7 11:38:39 2005
@@ -498,7 +498,7 @@
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 {
@@ -1865,7 +1865,7 @@
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);
}
==== //depot/perl/mg.c#337 (text) ====
Index: perl/mg.c
--- perl/mg.c#336~24737~ Tue Jun 7 11:07:41 2005
+++ perl/mg.c Tue Jun 7 11:38:39 2005
@@ -953,11 +953,11 @@
{
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
==== //depot/perl/perlio.c#274 (text) ====
Index: perl/perlio.c
--- perl/perlio.c#273~24689~ Fri Jun 3 01:31:26 2005
+++ perl/perlio.c Tue Jun 7 11:38:39 2005
@@ -308,7 +308,7 @@
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)
@@ -334,7 +334,7 @@
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);
@@ -844,7 +844,7 @@
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));
@@ -875,7 +875,7 @@
*/
dXSARGS;
if (items)
- PerlIO_debug("warning:%s\n",SvPV_nolen(ST(0)));
+ PerlIO_debug("warning:%s\n",SvPV_nolen_const(ST(0)));
XSRETURN(0);
}
@@ -886,7 +886,7 @@
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) =
@@ -2443,7 +2443,7 @@
perm = 0666;
}
if (imode != -1) {
- const char *path = SvPV_nolen(*args);
+ const char *path = SvPV_nolen_const(*args);
fd = PerlLIO_open3(path, imode, perm);
}
}
@@ -2732,7 +2732,7 @@
{
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));
@@ -2746,7 +2746,7 @@
}
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);
==== //depot/perl/pp.c#462 (text) ====
Index: perl/pp.c
--- perl/pp.c#461~24727~ Tue Jun 7 06:01:42 2005
+++ perl/pp.c Tue Jun 7 11:38:39 2005
@@ -553,10 +553,9 @@
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;
==== //depot/perl/pp_ctl.c#445 (text) ====
Index: perl/pp_ctl.c
--- perl/pp_ctl.c#444~24735~ Tue Jun 7 10:03:16 2005
+++ perl/pp_ctl.c Tue Jun 7 11:38:39 2005
@@ -78,9 +78,7 @@
{
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. */
@@ -129,7 +127,8 @@
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 ||
@@ -151,7 +150,7 @@
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
@@ -1710,7 +1709,7 @@
if (MAXARG < 1)
tmps = "";
else
- tmps = POPpx;
+ tmps = POPpconstx;
sv_reset(tmps, CopSTASH(PL_curcop));
PUSHs(&PL_sv_yes);
RETURN;
==== //depot/perl/pp_hot.c#395 (text) ====
Index: perl/pp_hot.c
--- perl/pp_hot.c#394~24726~ Tue Jun 7 05:11:48 2005
+++ perl/pp_hot.c Tue Jun 7 11:38:39 2005
@@ -1719,7 +1719,7 @@
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);
==== //depot/perl/pp_pack.c#95 (text) ====
Index: perl/pp_pack.c
--- perl/pp_pack.c#94~24726~ Tue Jun 7 05:11:48 2005
+++ perl/pp_pack.c Tue Jun 7 11:38:39 2005
@@ -2750,7 +2750,7 @@
const char *aptr;
fromstr = NEXTFROM;
- aptr = SvPV(fromstr, fromlen);
+ aptr = SvPV_const(fromstr, fromlen);
if (DO_UTF8(fromstr)) {
const char *end, *s;
==== //depot/perl/pp_sys.c#409 (text) ====
Index: perl/pp_sys.c
--- perl/pp_sys.c#408~24726~ Tue Jun 7 05:11:48 2005
+++ perl/pp_sys.c Tue Jun 7 11:38:39 2005
@@ -335,7 +335,7 @@
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);
@@ -446,14 +446,14 @@
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));
@@ -513,7 +513,7 @@
if (SvPOK(error) && SvCUR(error))
sv_catpv(error, "\t...propagated");
tmpsv = error;
- tmps = SvPV(tmpsv, len);
+ tmps = SvPV_const(tmpsv, len);
}
}
if (!tmps || !len)
@@ -766,11 +766,11 @@
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;
}
@@ -1301,9 +1301,9 @@
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);
}
@@ -1392,7 +1392,7 @@
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);
}
@@ -1521,7 +1521,7 @@
dSP;
GV *gv;
SV *sv;
- char *tmps;
+ const char *tmps;
STRLEN len;
const int perm = (MAXARG > 3) ? POPi : 0666;
const int mode = POPi;
@@ -1531,8 +1531,9 @@
/* 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);
}
@@ -3647,9 +3648,8 @@
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);
@@ -3674,8 +3674,8 @@
#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;
==== //depot/perl/sv.c#876 (text) ====
Index: perl/sv.c
--- perl/sv.c#875~24735~ Tue Jun 7 10:03:16 2005
+++ perl/sv.c Tue Jun 7 11:38:39 2005
@@ -2248,8 +2248,9 @@
/* 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';
@@ -6191,7 +6192,7 @@
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)) {
==== //depot/perl/toke.c#568 (text) ====
Index: perl/toke.c
--- perl/toke.c#567~24735~ Tue Jun 7 10:03:16 2005
+++ perl/toke.c Tue Jun 7 11:38:39 2005
@@ -980,7 +980,7 @@
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) {
==== //depot/perl/universal.c#110 (text) ====
Index: perl/universal.c
--- perl/universal.c#109~24553~ Mon May 23 08:24:05 2005
+++ perl/universal.c Tue Jun 7 11:38:39 2005
@@ -268,7 +268,7 @@
|| (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);
@@ -295,7 +295,7 @@
|| (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)) {
@@ -642,7 +642,7 @@
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
@@ -810,7 +810,7 @@
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':
==== //depot/perl/util.c#463 (text) ====
Index: perl/util.c
--- perl/util.c#462~24735~ Tue Jun 7 10:03:16 2005
+++ perl/util.c Tue Jun 7 11:38:39 2005
@@ -839,7 +839,7 @@
Perl_savesvpv(pTHX_ SV *sv)
{
STRLEN len;
- const char *pv = SvPV(sv, len);
+ const char *pv = SvPV_const(sv, len);
register char *newaddr;
++len;
End of Patch.