Change 24682 by rgs@bloom on 2005/06/03 07:43:52
Subject: [PATCH] SvPVX_const() - patch #4
From: Steve Peters <steve (AT) fisharerojo (DOT) org>
Date: Thu, 2 Jun 2005 13:41:35 -0500
Message-ID: <20050602184135.GA13682 (AT) mccoy (DOT) peters.homeunix.org>
Affected files
//depot/perl/embed.fnc#184 edit
//depot/perl/pod/perlapi.pod#219 edit
//depot/perl/proto.h#536 edit
//depot/perl/regcomp.c#371 edit
//depot/perl/regexec.c#346 edit
//depot/perl/sv.c#860 edit
Differences
//depot/perl/embed.fnc#184 (text)
Index: perl/embed.fnc
perl/embed.fnc#183~24625~Mon May 30 01:48:12 2005
perl/embed.fncFri Jun 3 00:43:52 2005
@@ -1266,7 +1266,7 @@
s|bool|utf8_mg_pos_init|NN SV *sv|NN MAGIC **mgp|NN STRLEN **cachep \
|I32 i|I32 offsetp|NN U8 *s|NN U8 *start
#if defined(PERL_CPYN_WRITE)
-sM|void|sv_release_CW|SV *sv|char *pvx|STRLEN cur|STRLEN len \
+sM|void|sv_release_CW|SV *sv|const char *pvx|STRLEN cur|STRLEN len \
|U32 hash|SV *after
#endif
#endif
//depot/perl/pod/perlapi.pod#219 (text+w)
Index: perl/pod/perlapi.pod
perl/pod/perlapi.pod#218~24592~Fri May 27 00:04:46 2005
perl/pod/perlapi.podFri Jun 3 00:43:52 2005
@@ -2997,12 +2997,12 @@
=item newSVpvn_share
-Creates a new SV with its SvPVX pointing to a shared string in the string
+Creates a new SV with its SvPVX_const pointing to a shared string in the string
table. If the string does not already exist in the table, it is created
first. Turns on READNLY and FAKE. The string's hash is stored in the UV
slot of the SV; if the C<hashparameter is non-zero, that value is used;
otherwise the hash is computed. The idea here is that as the string table
-is used for shared hash keys these strings will have SvPVX == HeKEY and
+is used for shared hash keys these strings will have SvPVX_const == HeKEY and
hash lookup will avoid string compare.
SV*newSVpvn_share(const char* s, I32 len, U32 hash)
@@ -4189,7 +4189,7 @@
SvPK(sv) must be true and the C<ptrmust be a pointer to somewhere inside
the string buffer. The C<ptrbecomes the first character of the adjusted
string. Uses the "K hack".
-Beware: after this function returns, C<ptrand SvPVX(sv) may no longer
+Beware: after this function returns, C<ptrand SvPVX_const(sv) may no longer
refer to the same chunk of data.
voidsv_chop(SV* sv, const char* ptr)
//depot/perl/proto.h#536 (text+w)
Index: perl/proto.h
perl/proto.h#535~24625~Mon May 30 01:48:12 2005
perl/proto.hFri Jun 3 00:43:52 2005
@@ -2375,7 +2375,7 @@
__attribute__nonnull__(pTHX_7);
#if defined(PERL_CPYN_WRITE)
-STATIC voidS_sv_release_CW(pTHX_ SV *sv, char *pvx, STRLEN cur, STRLEN len, U32 hash, SV *after);
+STATIC voidS_sv_release_CW(pTHX_ SV *sv, const char *pvx, STRLEN cur, STRLEN len, U32 hash, SV *after);
#endif
#endif
//depot/perl/regcomp.c#371 (text)
Index: perl/regcomp.c
perl/regcomp.c#370~24666~Thu Jun 2 00:39:30 2005
perl/regcomp.cFri Jun 3 00:43:52 2005
@@ -2388,7 +2388,7 @@
if (mincount 1) {
SvGRW(last_str, (mincount * l) + 1);
repeatcpy(SvPVX(last_str) + l,
- SvPVX(last_str), l, mincount - 1);
+ SvPVX_const(last_str), l, mincount - 1);
SvCUR_set(last_str, SvCUR(last_str) * mincount);
/* Add additional parts. */
SvCUR_set(data->last_found,
@@ -3140,7 +3140,7 @@
regprop(sv, (regnode*)data.start_class);
PerlI(Perl_debug_log,
"synthetic stclass \"%s\".\n",
- SvPVX(sv));});
+ SvPVX_const(sv));});
}
/* A temporary algorithm prefers floated substr to fixed one to dig more info. */
@@ -3195,7 +3195,7 @@
regprop(sv, (regnode*)data.start_class);
PerlI(Perl_debug_log,
"synthetic stclass \"%s\".\n",
- SvPVX(sv));});
+ SvPVX_const(sv));});
}
}
@@ -5694,7 +5694,7 @@
goto after_print;
regprop(sv, node);
PerlI(Perl_debug_log, "%4"IVdf":%*s%s", (IV)(node - start),
- (int)(2*l + 1), "", SvPVX(sv));
+ (int)(2*l + 1), "", SvPVX_const(sv));
if (next == NULL)/* Next ptr. */
PerlI(Perl_debug_log, "(0)");
else
@@ -5803,7 +5803,7 @@
"anchored \"%s%.*s%s\"%s at %"IVdf" ",
PL_colors[0],
(int)(SvCUR(r->anchored_substr) - (SvTAIL(r->anchored_substr)!=0)),
- SvPVX(r->anchored_substr),
+ SvPVX_const(r->anchored_substr),
PL_colors[1],
SvTAIL(r->anchored_substr) ? "$" : "",
(IV)r->anchored_offset);
@@ -5812,7 +5812,7 @@
"anchored utf8 \"%s%.*s%s\"%s at %"IVdf" ",
PL_colors[0],
(int)(SvCUR(r->anchored_utf8) - (SvTAIL(r->anchored_utf8)!=0)),
- SvPVX(r->anchored_utf8),
+ SvPVX_const(r->anchored_utf8),
PL_colors[1],
SvTAIL(r->anchored_utf8) ? "$" : "",
(IV)r->anchored_offset);
@@ -5821,7 +5821,7 @@
"floating \"%s%.*s%s\"%s at %"IVdf"%"UVuf" ",
PL_colors[0],
(int)(SvCUR(r->float_substr) - (SvTAIL(r->float_substr)!=0)),
- SvPVX(r->float_substr),
+ SvPVX_const(r->float_substr),
PL_colors[1],
SvTAIL(r->float_substr) ? "$" : "",
(IV)r->float_min_offset, (UV)r->float_max_offset);
@@ -5830,7 +5830,7 @@
"floating utf8 \"%s%.*s%s\"%s at %"IVdf"%"UVuf" ",
PL_colors[0],
(int)(SvCUR(r->float_utf8) - (SvTAIL(r->float_utf8)!=0)),
- SvPVX(r->float_utf8),
+ SvPVX_const(r->float_utf8),
PL_colors[1],
SvTAIL(r->float_utf8) ? "$" : "",
(IV)r->float_min_offset, (UV)r->float_max_offset);
@@ -5848,7 +5848,7 @@
if (r->regstclass) {
regprop(sv, r->regstclass);
-PerlI(Perl_debug_log, "stclass \"%s\" ", SvPVX(sv));
+PerlI(Perl_debug_log, "stclass \"%s\" ", SvPVX_const(sv));
}
if (r->reganch & RPT_ANCH) {
PerlI(Perl_debug_log, "anchored");
//depot/perl/regexec.c#346 (text)
Index: perl/regexec.c
perl/regexec.c#345~24666~Thu Jun 2 00:39:30 2005
perl/regexec.cFri Jun 3 00:43:52 2005
@@ -365,7 +365,7 @@
/* Assumptions: if ANCH_GPS, then strpos is anchored. XXXX Check GPS logic */
-/* If SCREAM, then SvPVX(sv) should be compatible with strpos and strend.
+/* If SCREAM, then SvPVX_const(sv) should be compatible with strpos and strend.
, only SvCUR(sv) is used to get strbeg. */
/* XXXX We assume that strpos is strbeg unless sv. */
@@ -480,7 +480,7 @@
if (!ml_anch) {
if ( !(prog->reganch & (RPT_ANCH_GPS /* Checked by the caller */
| RPT_IMPLICIT)) /* not a real BL */
- /* SvCUR is not set on references: SvRV and SvPVX overlap */
+ /* SvCUR is not set on references: SvRV and SvPVX_const overlap */
&& sv && !SvRK(sv)
&& (strpos != strbeg)) {
DEBUG_EXECUTE_r(PerlI(Perl_debug_log, "Not at start\n"));
@@ -502,17 +502,17 @@
}
/* Now should match s[0slen-2] */
slen--;
-if (slen && (*SvPVX(check) != *s
+if (slen && (*SvPVX_const(check) != *s
|| (slen 1
- && memNE(SvPVX(check), s, slen)))) {
+ && memNE(SvPVX_const(check), s, slen)))) {
report_neq:
DEBUG_EXECUTE_r(PerlI(Perl_debug_log, "String not equal\n"));
goto fail_finish;
}
}
- else if (*SvPVX(check) != *s
+ else if (*SvPVX_const(check) != *s
|| ((slen = SvCUR(check)) 1
- && memNE(SvPVX(check), s, slen)))
+ && memNE(SvPVX_const(check), s, slen)))
goto report_neq;
goto success_at_start;
}
@@ -562,7 +562,7 @@
goto fail_finish;
/* we may be pointing at the wrong string */
if (s && RX_MATCH_CPIED(prog))
- s = strbeg + (s - SvPVX(sv));
+ s = strbeg + (s - SvPVX_const(sv));
if (data)
*data->scream_olds = s;
}
@@ -583,7 +583,7 @@
(check == (do_utf8 ? prog->anchored_utf8 : prog->anchored_substr) ? "anchored" : "floating"),
PL_colors[0],
(int)(SvCUR(check) - (SvTAIL(check)!=0)),
- SvPVX(check),
+ SvPVX_const(check),
PL_colors[1], (SvTAIL(check) ? "$" : ""),
(s ? " at offset " : "\n") ) );
@@ -650,7 +650,7 @@
PL_colors[0],
(int)(SvCUR(must)
- (SvTAIL(must)!=0)),
- SvPVX(must),
+ SvPVX_const(must),
PL_colors[1], (SvTAIL(must) ? "$" : "")));
if (!s) {
if (last1 >= last2) {
@@ -708,7 +708,7 @@
(s ? "Found" : "Contradicts"),
PL_colors[0],
(int)(SvCUR(must) - (SvTAIL(must)!=0)),
- SvPVX(must),
+ SvPVX_const(must),
PL_colors[1], (SvTAIL(must) ? "$" : "")));
if (!s) {
if (last1 == last) {
@@ -1813,7 +1813,7 @@
#endif
if (!(do_utf8 ? prog->anchored_utf8 : prog->anchored_substr))
do_utf8 ? to_utf8_substr(prog) : to_byte_substr(prog);
-ch = SvPVX(do_utf8 ? prog->anchored_utf8 : prog->anchored_substr)[0];
+ch = SvPVX_const(do_utf8 ? prog->anchored_utf8 : prog->anchored_substr)[0];
if (do_utf8) {
while (s < strend) {
@@ -1896,7 +1896,7 @@
multiline ? FBMrf_MULTILINE : 0))) ) {
/* we may be pointing at the wrong string */
if ((flags & REXEC_SCREAM) && RX_MATCH_CPIED(prog))
-s = strbeg + (s - SvPVX(sv));
+s = strbeg + (s - SvPVX_const(sv));
DEBUG_EXECUTE_r( did_match = 1 );
if (HPc(s, -back_max) last1) {
last1 = HPc(s, -back_min);
@@ -1930,7 +1930,7 @@
? "anchored" : "floating"),
PL_colors[0],
(int)(SvCUR(must) - (SvTAIL(must)!=0)),
- SvPVX(must),
+ SvPVX_const(must),
PL_colors[1], (SvTAIL(must) ? "$" : ""))
);
goto phooey;
@@ -1951,7 +1951,7 @@
regprop(prop, c);
s0 = UTF ?
- pv_uni_display(dsv0, (U8*)SvPVX(prop), SvCUR(prop), 60,
+ pv_uni_display(dsv0, (U8*)SvPVX_const(prop), SvCUR(prop), 60,
UNI_DISPLAY_REGEX) :
SvPVX(prop);
len0 = UTF ? SvCUR(dsv0) : SvCUR(prop);
@@ -1985,7 +1985,7 @@
last = scream_olds; /* one occurrence. */
/* we may be pointing at the wrong string */
else if (RX_MATCH_CPIED(prog))
- s = strbeg + (s - SvPVX(sv));
+ s = strbeg + (s - SvPVX_const(sv));
}
else {
STRLEN len;
@@ -2486,7 +2486,7 @@
15 - l - pref_len + 1,
"",
(IV)(scan - PL_regprogram), PL_regindent*2, "",
- SvPVX(prop));
+ SvPVX_const(prop));
}
});
@@ -4594,7 +4594,7 @@
regprop(prop, p);
PerlI(Perl_debug_log,
"%*s %s can match %"IVdf" times out of %"IVdf"\n",
- REPRT_CDEFF+1, "", SvPVX(prop),(IV)c,(IV)max);
+ REPRT_CDEFF+1, "", SvPVX_const(prop),(IV)c,(IV)max);
});
});
//depot/perl/sv.c#860 (text)
Index: perl/sv.c
perl/sv.c#859~24676~Thu Jun 2 06:36:01 2005
perl/sv.cFri Jun 3 00:43:52 2005
@@ -773,7 +773,7 @@
*SvPVX(name) = '$';
sv = NEWSV(0,0);
Perl_sv_catpvf(aTHX_ name, "{%s}",
- pv_display(sv,SvPVX(keyname), SvCUR(keyname), 0, 32));
+ pv_display(sv,SvPVX_const(keyname), SvCUR(keyname), 0, 32));
SvREFCNT_dec(sv);
}
else if (subscript_type == FUV_SUBSCRIPT_ARRAY) {
@@ -1988,7 +1988,7 @@
assert(SvTYPE(sv) != SVt_PVHV);
assert(SvTYPE(sv) != SVt_PVAV);
if (SvIVX(sv)) {
-char *s = SvPVX(sv);
+const char *s = SvPVX_const(sv);
SvLEN_set(sv, SvLEN(sv) + SvIVX(sv));
SvPV_set(sv, SvPVX(sv) - SvIVX(sv));
SvIV_set(sv, 0);
@@ -2053,8 +2053,8 @@
}
else {
s = safemalloc(newlen);
- if (SvPVX(sv) && SvCUR(sv)) {
- Move(SvPVX(sv), s, (newlen < SvCUR(sv)) ? newlen : SvCUR(sv), char);
+ if (SvPVX_const(sv) && SvCUR(sv)) {
+ Move(SvPVX_const(sv), s, (newlen < SvCUR(sv)) ? newlen : SvCUR(sv), char);
}
}
SvPV_set(sv, s);
@@ -2318,7 +2318,7 @@
STRLEN len;
if (SvPK(sv)) {
-sbegin = SvPVX(sv);
+sbegin = SvPVX_const(sv);
len = SvCUR(sv);
}
else if (SvPKp(sv))
@@ -2415,7 +2415,7 @@
STATIC int
S_sv_2iuv_non_preserve(pTHX_ register SV *sv, I32 numtype)
{
- DEBUG_c(PerlI(Perl_debug_log,"sv_2iuv_non '%s', IV=0x%"UVxf" NV=%"NVgf" inttype=%"UVXf"\n", SvPVX(sv), SvIVX(sv), SvNVX(sv), (UV)numtype));
+ DEBUG_c(PerlI(Perl_debug_log,"sv_2iuv_non '%s', IV=0x%"UVxf" NV=%"NVgf" inttype=%"UVXf"\n", SvPVX_const(sv), SvIVX(sv), SvNVX(sv), (UV)numtype));
if (SvNVX(sv) < (NV)IV_MIN) {
(void)SvIKp_on(sv);
(void)SvNK_on(sv);
@@ -2672,7 +2672,7 @@
if ((numtype & (IS_NUMBER_IN_UV | IS_NUMBER_NT_INT))
!= IS_NUMBER_IN_UV) {
/* It wasn't an (integer that doesn't overflow the UV). */
- SvNV_set(sv, Atof(SvPVX(sv)));
+ SvNV_set(sv, Atof(SvPVX_const(sv)));
if (! numtype && ckWARN(WARN_NUMERIC))
not_a_number(sv);
@@ -2971,7 +2971,7 @@
if ((numtype & (IS_NUMBER_IN_UV | IS_NUMBER_NT_INT))
!= IS_NUMBER_IN_UV) {
/* It wasn't an integer, or it overflowed the UV. */
- SvNV_set(sv, Atof(SvPVX(sv)));
+ SvNV_set(sv, Atof(SvPVX_const(sv)));
if (! numtype && ckWARN(WARN_NUMERIC))
not_a_number(sv);
@@ -3082,7 +3082,7 @@
if (ckWARN(WARN_NUMERIC) && !SvIKp(sv) &&
!grok_number(SvPVX_const(sv), SvCUR(sv), NULL))
not_a_number(sv);
- return Atof(SvPVX(sv));
+ return Atof(SvPVX_const(sv));
}
if (SvIKp(sv)) {
if (SvIsUV(sv))
@@ -3158,7 +3158,7 @@
}
else if (SvPKp(sv) && SvLEN(sv)) {
UV value;
-const int numtype = grok_number(SvPVX(sv), SvCUR(sv), &value);
+const int numtype = grok_number(SvPVX_const(sv), SvCUR(sv), &value);
if (ckWARN(WARN_NUMERIC) && !SvIKp(sv) && !numtype)
not_a_number(sv);
#ifdef NV_PRESERVES_UV
@@ -3167,10 +3167,10 @@
/* It's definitely an integer */
SvNV_set(sv, (numtype & IS_NUMBER_NEG) ? -(NV)value : (NV)value);
} else
- SvNV_set(sv, Atof(SvPVX(sv)));
+ SvNV_set(sv, Atof(SvPVX_const(sv)));
SvNK_on(sv);
#else
-SvNV_set(sv, Atof(SvPVX(sv)));
+SvNV_set(sv, Atof(SvPVX_const(sv)));
/* set the public NV K flag if this NV preserves the value in
the PV at least as well as an IV/UV would.
Not sure how to do this 100% reliably. */
@@ -3275,7 +3275,7 @@
S_asIV(pTHX_ SV *sv)
{
UV value;
- int numtype = grok_number(SvPVX(sv), SvCUR(sv), &value);
+ int numtype = grok_number(SvPVX_const(sv), SvCUR(sv), &value);
if ((numtype & (IS_NUMBER_IN_UV | IS_NUMBER_NT_INT))
== IS_NUMBER_IN_UV) {
@@ -3292,7 +3292,7 @@
if (ckWARN(WARN_NUMERIC))
not_a_number(sv);
}
- return I_V(Atof(SvPVX(sv)));
+ return I_V(Atof(SvPVX_const(sv)));
}
/* asUV(): extract an unsigned integer from the string value of an SV
@@ -3314,7 +3314,7 @@
if (ckWARN(WARN_NUMERIC))
not_a_number(sv);
}
- return U_V(Atof(SvPVX(sv)));
+ return U_V(Atof(SvPVX_const(sv)));
}
/*
@@ -3636,11 +3636,11 @@
sv_upgrade(sv, SVt_PV);
return (char *)"";
}
- *lp = s - SvPVX(sv);
+ *lp = s - SvPVX_const(sv);
SvCUR_set(sv, *lp);
SvPK_on(sv);
DEBUG_c(PerlI(Perl_debug_log, "0x%"UVxf" 2pv(%s)\n",
- PTR2UV(sv),SvPVX(sv)));
+ PTR2UV(sv),SvPVX_const(sv)));
return SvPVX(sv);
tokensave:
@@ -3661,7 +3661,7 @@
if (tsv) {
sv_2mortal(tsv);
- t = SvPVX(tsv);
+ t = SvPVX_const(tsv);
len = SvCUR(tsv);
}
else {
@@ -4400,7 +4400,7 @@
SvTAINT(dstr);
return;
}
- if (SvPVX(dstr)) {
+ if (SvPVX_const(dstr)) {
SvPV_free(dstr);
SvLEN_set(dstr, 0);
SvCUR_set(dstr, 0);
@@ -4434,8 +4434,8 @@
/*
* Check to see if we can just swipe the string. If so, it's a
* possible small lose on short strings, but a big win on long ones.
- * It might even be a win on short strings if SvPVX(dstr)
- * has to be allocated and SvPVX(sstr) has to be freed.
+ * It might even be a win on short strings if SvPVX_const(dstr)
+ * has to be allocated and SvPVX_const(sstr) has to be freed.
*/
/* Whichever path we take through the next code, we want this true,
@@ -4466,7 +4466,7 @@
Have to copy the string. */
STRLEN len = SvCUR(sstr);
SvGRW(dstr, len + 1);/* inlined from sv_setpvn */
- Move(SvPVX(sstr),SvPVX(dstr),len,char);
+ Move(SvPVX_const(sstr),SvPVX(dstr),len,char);
SvCUR_set(dstr, len);
*SvEND(dstr) = '\0';
} else {
@@ -4498,13 +4498,13 @@
}
#endif
/* Initial code is common. */
- if (SvPVX(dstr)) {/* we know that dtype >= SVt_PV */
+ if (SvPVX_const(dstr)) {/* we know that dtype >= SVt_PV */
if (SK(dstr)) {
SvFLAGS(dstr) &= ~SVK;
- Safefree(SvPVX(dstr) - SvIVX(dstr));
+ Safefree(SvPVX_const(dstr) - SvIVX(dstr));
}
else if (SvLEN(dstr))
- Safefree(SvPVX(dstr));
+ Safefree(SvPVX_const(dstr));
}
#ifdef PERL_CPYN_WRITE
@@ -4525,7 +4525,7 @@
DEBUG_C(PerlI(Perl_debug_log,
"Copy on write: Sharing hash\n"));
SvPV_set(dstr,
- sharepvn(SvPVX(sstr),
+ sharepvn(SvPVX_const(sstr),
(sflags & SVf_UTF8...cur:cur), hash));
SvUV_set(dstr, hash);
}
@@ -4648,8 +4648,8 @@
if (dstr) {
if (SvTHINKFIRST(dstr))
sv_force_normal_flags(dstr, SV_CW_DRP_PV);
-else if (SvPVX(dstr))
- Safefree(SvPVX(dstr));
+else if (SvPVX_const(dstr))
+ Safefree(SvPVX_const(dstr));
}
else
new_SV(dstr);
@@ -4670,7 +4670,7 @@
DEBUG_C(PerlI(Perl_debug_log,
"Fast copy on write: Sharing hash\n"));
SvUV_set(dstr, hash);
- new_pv = sharepvn(SvPVX(sstr), (SvUTF8(sstr)...cur:cur), hash);
+ new_pv = sharepvn(SvPVX_const(sstr), (SvUTF8(sstr)...cur:cur), hash);
goto common_exit;
}
SV_CW_NEXT_SV_SET(dstr, SV_CW_NEXT_SV(sstr));
@@ -4820,7 +4820,7 @@
(void)SK_off(sv);
return;
}
- if (SvPVX(sv))
+ if (SvPVX_const(sv))
SvPV_free(sv);
allocate = PERL_STRLEN_RUNDUP(len + 1);
@@ -4855,7 +4855,7 @@
(which it can do by means other than releasing copy-on-write Svs)
or by changing the other copy-on-write SVs in the loop. */
STATIC void
-S_sv_release_CW(pTHX_ register SV *sv, char *pvx, STRLEN cur, STRLEN len,
+S_sv_release_CW(pTHX_ register SV *sv, const char *pvx, STRLEN cur, STRLEN len,
U32 hash, SV *after)
{
if (len) { /* this SV was SvIsCW_normal(sv) */
@@ -4877,7 +4877,7 @@
/* don't loop forever if the structure is bust, and we have
a pointer into a closed loop. */
assert (current != after);
- assert (SvPVX(current) == pvx);
+ assert (SvPVX_const(current) == pvx);
}
/* Make the SV before us point to the SV after us. */
SV_CW_NEXT_SV_SET(current, after);
@@ -4919,7 +4919,7 @@
if (SvREADNLY(sv)) {
/* At this point I believe I should acquire a global SV mutex. */
if (SvFAKE(sv)) {
- char *pvx = SvPVX(sv);
+ const char *pvx = SvPVX_const(sv);
STRLEN len = SvLEN(sv);
STRLEN cur = SvCUR(sv);
U32 hash = SvUVX(sv);
@@ -4956,7 +4956,7 @@
#else
if (SvREADNLY(sv)) {
if (SvFAKE(sv)) {
- char *pvx = SvPVX(sv);
+ char *pvx = SvPVX_const(sv);
const int is_utf8 = SvUTF8(sv);
STRLEN len = SvCUR(sv);
U32 hash = SvUVX(sv);
@@ -4965,7 +4965,7 @@
SvPV_set(sv, (char*)0);
SvLEN_set(sv, 0);
SvGRW(sv, len + 1);
- Move(pvx,SvPVX(sv),len,char);
+ Move(pvx,SvPVX_const(sv),len,char);
*SvEND(sv) = '\0';
unsharepvn(pvx, is_utf8 ? -(I32)len : len, hash);
}
@@ -5002,7 +5002,7 @@
SvPK(sv) must be true and the C<ptrmust be a pointer to somewhere inside
the string buffer. The C<ptrbecomes the first character of the adjusted
string. Uses the "K hack".
-Beware: after this function returns, C<ptrand SvPVX(sv) may no longer
+Beware: after this function returns, C<ptrand SvPVX_const(sv) may no longer
refer to the same chunk of data.
=cut
@@ -5014,17 +5014,17 @@
register STRLEN delta;
if (!ptr || !SvPKp(sv))
return;
- delta = ptr - SvPVX(sv);
+ delta = ptr - SvPVX_const(sv);
SV_CHECK_THINKFIRST(sv);
if (SvTYPE(sv) < SVt_PVIV)
sv_upgrade(sv,SVt_PVIV);
if (!SK(sv)) {
if (!SvLEN(sv)) { /* make copy of shared string */
- const char *pvx = SvPVX(sv);
+ const char *pvx = SvPVX_const(sv);
STRLEN len = SvCUR(sv);
SvGRW(sv, len + 1);
- Move(pvx,SvPVX(sv),len,char);
+ Move(pvx,SvPVX_const(sv),len,char);
*SvEND(sv) = '\0';
}
SvIV_set(sv, 0);
@@ -5078,7 +5078,7 @@
SvGRW(dsv, dlen + slen + 1);
if (sstr == dstr)
-sstr = SvPVX(dsv);
+sstr = SvPVX_const(dsv);
Move(sstr, SvPVX(dsv) + dlen, slen, char);
SvCUR_set(dsv, SvCUR(dsv) + slen);
*SvEND(dsv) = '\0';
@@ -5201,7 +5201,7 @@
len = strlen(ptr);
SvGRW(sv, tlen + len + 1);
if (ptr == junk)
-ptr = SvPVX(sv);
+ptr = SvPVX_const(sv);
Move(ptr,SvPVX(sv)+tlen,len+1,char);
SvCUR_set(sv, SvCUR(sv) + len);
(void)SvPK_only_UTF8(sv);/* validate pointer */
@@ -5665,7 +5665,7 @@
(void)SvPK_only_UTF8(bigstr);
if (offset + len curlen) {
SvGRW(bigstr, offset+len+1);
-Zero(SvPVX(bigstr)+curlen, offset+len-curlen, char);
+Zero(SvPVX_const(bigstr)+curlen, offset+len-curlen, char);
SvCUR_set(bigstr, offset+len);
}
@@ -5792,7 +5792,7 @@
while ((next = SV_CW_NEXT_SV(current)) != nsv) {
assert(next);
current = next;
- assert(SvPVX(current) == SvPVX(nsv));
+ assert(SvPVX_const(current) == SvPVX_const(nsv));
}
/* Make the SV before us point to the SV after us. */
if (DEBUG_C_TEST) {
@@ -5957,7 +5957,7 @@
SvREFCNT_dec(SvRV(sv));
}
#ifdef PERL_CPYN_WRITE
-else if (SvPVX(sv)) {
+else if (SvPVX_const(sv)) {
if (SvIsCW(sv)) {
/* I believe I need to grab the global SV mutex here and
then recheck the CW status. */
@@ -5965,19 +5965,19 @@
PerlI(Perl_debug_log, "Copy on write: clear\n");
sv_dump(sv);
}
- sv_release_CW(sv, SvPVX(sv), SvCUR(sv), SvLEN(sv),
+ sv_release_CW(sv, SvPVX_const(sv), SvCUR(sv), SvLEN(sv),
SvUVX(sv), SV_CW_NEXT_SV(sv));
/* And drop it here. */
SvFAKE_off(sv);
} else if (SvLEN(sv)) {
- Safefree(SvPVX(sv));
+ Safefree(SvPVX_const(sv));
}
}
#else
-else if (SvPVX(sv) && SvLEN(sv))
- Safefree(SvPVX(sv));
-else if (SvPVX(sv) && SvREADNLY(sv) && SvFAKE(sv)) {
- unsharepvn(SvPVX(sv),
+else if (SvPVX_const(sv) && SvLEN(sv))
+ Safefree(SvPVX_const(sv));
+else if (SvPVX_const(sv) && SvREADNLY(sv) && SvFAKE(sv)) {
+ unsharepvn(SvPVX_const(sv),
SvUTF8(sv) ? -(I32)SvCUR(sv) : SvCUR(sv),
SvUVX(sv));
SvFAKE_off(sv);
@@ -7046,7 +7046,7 @@
}
else
shortbuffered = 0;
- bp = (STDCHAR*)SvPVX(sv) + append; /* move these two too to registers */
+ bp = (STDCHAR*)SvPVX_const(sv) + append; /* move these two too to registers */
ptr = (STDCHAR*)PerlI(fp);
DEBUG_P(PerlI(Perl_debug_log,
"Screamer: entering, ptr=%"UVuf", cnt=%ld\n",PTR2UV(ptr),(long)cnt));
@@ -7075,10 +7075,10 @@
if (shortbuffered) {/* oh well, must extend */
cnt = shortbuffered;
shortbuffered = 0;
- bpx = bp - (STDCHAR*)SvPVX(sv); /* box up before relocation */
+ bpx = bp - (STDCHAR*)SvPVX_const(sv); /* box up before relocation */
SvCUR_set(sv, bpx);
SvGRW(sv, SvLEN(sv) + append + cnt + 2);
- bp = (STDCHAR*)SvPVX(sv) + bpx; /* unbox after relocation */
+ bp = (STDCHAR*)SvPVX_const(sv) + bpx; /* unbox after relocation */
continue;
}
@@ -7110,10 +7110,10 @@
if (i == EF)/* all done for ever? */
goto thats_really_all_folks;
-bpx = bp - (STDCHAR*)SvPVX(sv);/* box up before relocation */
+bpx = bp - (STDCHAR*)SvPVX_const(sv);/* box up before relocation */
SvCUR_set(sv, bpx);
SvGRW(sv, bpx + cnt + 2);
-bp = (STDCHAR*)SvPVX(sv) + bpx;/* unbox after relocation */
+bp = (STDCHAR*)SvPVX_const(sv) + bpx;/* unbox after relocation */
*bp++ = (STDCHAR)i;/* store character from PerlI */
@@ -7122,7 +7122,7 @@
}
thats_all_folks:
- if ((rslen 1 && (STRLEN)(bp - (STDCHAR*)SvPVX(sv)) < rslen) ||
+ if ((rslen 1 && (STRLEN)(bp - (STDCHAR*)SvPVX_const(sv)) < rslen) ||
memNE((char*)bp - rslen, rsptr, rslen))
goto screamer;/* go back to the fray */
thats_really_all_folks:
@@ -7136,10 +7136,10 @@
PTR2UV(PerlI(fp)), (long)PerlI(fp),
PTR2UV(PerlI (fp) ? PerlI(fp) : 0)));
*bp = '\0';
- SvCUR_set(sv, bp - (STDCHAR*)SvPVX(sv));/* set length */
+ SvCUR_set(sv, bp - (STDCHAR*)SvPVX_const(sv));/* set length */
DEBUG_P(PerlI(Perl_debug_log,
"Screamer: done, len=%ld, string=|%.*s|\n",
-(long)SvCUR(sv),(int)SvCUR(sv),SvPVX(sv)));
+(long)SvCUR(sv),(int)SvCUR(sv),SvPVX_const(sv)));
}
else
{
@@ -7181,7 +7181,7 @@
if (i != EF &&/* joy */
(!rslen ||
SvCUR(sv) < rslen ||
- memNE(SvPVX(sv) + SvCUR(sv) - rslen, rsptr, rslen)))
+ memNE(SvPVX_const(sv) + SvCUR(sv) - rslen, rsptr, rslen)))
{
append = -1;
/*
@@ -7287,7 +7287,7 @@
return;
}
- if (!(flags & SVp_PK) || !*SvPVX(sv)) {
+ if (!(flags & SVp_PK) || !*SvPVX_const(sv)) {
if ((flags & SVTYPEMASK) < SVt_PVIV)
sv_upgrade(sv, SVt_IV);
(void)SvIK_only(sv);
@@ -7326,18 +7326,18 @@
Fall through. */
#if defined(USE_LNG_DUBLE)
DEBUG_c(PerlI(Perl_debug_log,"sv_inc punt failed to convert '%s' to IK or NKp, UV=0x%"UVxf" NV=%"PERL_PRIgldbl"\n",
- SvPVX(sv), SvIVX(sv), SvNVX(sv)));
+ SvPVX_const(sv), SvIVX(sv), SvNVX(sv)));
#else
DEBUG_c(PerlI(Perl_debug_log,"sv_inc punt failed to convert '%s' to IK or NKp, UV=0x%"UVxf" NV=%"NVgf"\n",
- SvPVX(sv), SvIVX(sv), SvNVX(sv)));
+ SvPVX_const(sv), SvIVX(sv), SvNVX(sv)));
#endif
}
#endif /* PERL_PRESERVE_IVUV */
-sv_setnv(sv,Atof(SvPVX(sv)) + 1.0);
+sv_setnv(sv,Atof(SvPVX_const(sv)) + 1.0);
return;
}
d--;
- while (d >= SvPVX(sv)) {
+ while (d >= SvPVX_const(sv)) {
if (isDIGIT(*d)) {
if (d <= '9')
return;
@@ -7367,7 +7367,7 @@
/* oh,oh, the number grew */
SvGRW(sv, SvCUR(sv) + 2);
SvCUR_set(sv, SvCUR(sv) + 1);
- for (d = SvPVX(sv) + SvCUR(sv); d SvPVX(sv); d--)
+ for (d = SvPVX(sv) + SvCUR(sv); d SvPVX_const(sv); d--)
*d = d[-1];
if (isDIGIT(d[1]))
*d = '1';
@@ -7474,15 +7474,15 @@
Fall through. */
#if defined(USE_LNG_DUBLE)
DEBUG_c(PerlI(Perl_debug_log,"sv_dec punt failed to convert '%s' to IK or NKp, UV=0x%"UVxf" NV=%"PERL_PRIgldbl"\n",
- SvPVX(sv), SvIVX(sv), SvNVX(sv)));
+ SvPVX_const(sv), SvIVX(sv), SvNVX(sv)));
#else
DEBUG_c(PerlI(Perl_debug_log,"sv_dec punt failed to convert '%s' to IK or NKp, UV=0x%"UVxf" NV=%"NVgf"\n",
- SvPVX(sv), SvIVX(sv), SvNVX(sv)));
+ SvPVX_const(sv), SvIVX(sv), SvNVX(sv)));
#endif
}
}
#endif /* PERL_PRESERVE_IVUV */
- sv_setnv(sv,Atof(SvPVX(sv)) - 1.0);/* punt */
+ sv_setnv(sv,Atof(SvPVX_const(sv)) - 1.0);/* punt */
}
/*
@@ -7607,12 +7607,12 @@
/*
=for apidoc newSVpvn_share
-Creates a new SV with its SvPVX pointing to a shared string in the string
+Creates a new SV with its SvPVX_const pointing to a shared string in the string
table. If the string does not already exist in the table, it is created
first. Turns on READNLY and FAKE. The string's hash is stored in the UV
slot of the SV; if the C<hashparameter is non-zero, that value is used;
otherwise the hash is computed. The idea here is that as the string table
-is used for shared hash keys these strings will have SvPVX == HeKEY and
+is used for shared hash keys these strings will have SvPVX_const == HeKEY and
hash lookup will avoid string compare.
=cut
@@ -7883,7 +7883,7 @@
SK_off(sv);
if (SvTYPE(sv) >= SVt_PV) {
SvCUR_set(sv, 0);
- if (SvPVX(sv) != Nullch)
+ if (SvPVX_const(sv) != Nullch)
*SvPVX(sv) = '\0';
SvTAINT(sv);
}
@@ -8224,14 +8224,14 @@
}
else
s = sv_2pv_flags(sv, lp, flags);
-if (s != SvPVX(sv)) {/* Almost, but not quite, sv_setpvn() */
+if (s != SvPVX_const(sv)) {/* Almost, but not quite, sv_setpvn() */
const STRLEN len = *lp;
if (SvRK(sv))
sv_unref(sv);
(void)SvUPGRADE(sv, SVt_PV);/* Never FALSE */
SvGRW(sv, len + 1);
- Move(s,SvPVX(sv),len,char);
+ Move(s,SvPVX_const(sv),len,char);
SvCUR_set(sv, len);
*SvEND(sv) = '\0';
}
@@ -8239,7 +8239,7 @@
SvPK_on(sv);/* validate pointer */
SvTAINT(sv);
DEBUG_c(PerlI(Perl_debug_log, "0x%"UVxf" 2pv(%s)\n",
- PTR2UV(sv),SvPVX(sv)));
+ PTR2UV(sv),SvPVX_const(sv)));
}
}
return SvPVX(sv);
@@ -9369,7 +9369,7 @@
vecstr = (U8*)SvPVx(vecsv,veclen);
vec_utf8 = DUTF8(vecsv);
/* if this is a version object, we need to return the
- * stringified representation (which the SvPVX has
+ * stringified representation (which the SvPVX_const has
* already done for us), but not vectorize the args
*/
if ( *q == 'd' && sv_derived_from(vecsv,"version") )
@@ -10009,7 +10009,7 @@
Copy(eptr, p, elen, char);
p += elen;
*p = '\0';
- SvCUR_set(sv, p - SvPVX(sv));
+ SvCUR_set(sv, p - SvPVX_const(sv));
svix = osvix;
continue;/* not "break" */
}
@@ -10075,7 +10075,7 @@
if (has_utf8)
SvUTF8_on(sv);
*p = '\0';
-SvCUR_set(sv, p - SvPVX(sv));
+SvCUR_set(sv, p - SvPVX_const(sv));
if (vectorize) {
esignlen = 0;
goto vector;
@@ -10629,11 +10629,11 @@
: sv_dup_inc(SvRV(sstr), param));
}
- else if (SvPVX(sstr)) {
+ else if (SvPVX_const(sstr)) {
/* Has something there */
if (SvLEN(sstr)) {
/* Normal PV - clone whole allocated space */
- SvPV_set(dstr, SAVEPVN(SvPVX(sstr), SvLEN(sstr)-1));
+ SvPV_set(dstr, SAVEPVN(SvPVX_const(sstr), SvLEN(sstr)-1));
if (SvREADNLY(sstr) && SvFAKE(sstr)) {
/* Not that normal - actually sstr is copy on write.
But we are a true, independant SV, so: */
@@ -10650,12 +10650,12 @@
and they should not have these flags
turned off */
- SvPV_set(dstr, sharepvn(SvPVX(sstr), SvCUR(sstr),
+ SvPV_set(dstr, sharepvn(SvPVX_const(sstr), SvCUR(sstr),
SvUVX(sstr)));
SvUV_set(dstr, SvUVX(sstr));
} else {
- SvPV_set(dstr, SAVEPVN(SvPVX(sstr), SvCUR(sstr)));
+ SvPV_set(dstr, SAVEPVN(SvPVX_const(sstr), SvCUR(sstr)));
SvFAKE_off(dstr);
SvREADNLY_off(dstr);
}
@@ -10724,9 +10724,9 @@
SvREFCNT(dstr)= 0;/* must be before any other dups! */
#ifdef DEBUGGING
- if (SvANY(sstr) && PL_watch_pvx && SvPVX(sstr) == PL_watch_pvx)
+ if (SvANY(sstr) && PL_watch_pvx && SvPVX_const(sstr) == PL_watch_pvx)
PerlI(Perl_debug_log, "watch at %p hit, found string \"%s\"\n",
- PL_watch_pvx, SvPVX(sstr));
+ PL_watch_pvx, SvPVX_const(sstr));
#endif
/* don't clone objects whose class has asked us not to */
@@ -11994,13 +11994,13 @@
*/
if (SvANY(proto_perl->Ilinestr)) {
PL_linestr= sv_dup_inc(proto_perl->Ilinestr, param);
-i = proto_perl->Ibufptr - SvPVX(proto_perl->Ilinestr);
+i = proto_perl->Ibufptr - SvPVX_const(proto_perl->Ilinestr);
PL_bufptr= SvPVX(PL_linestr) + (i < 0 ? 0 : i);
-i = proto_perl->Ioldbufptr - SvPVX(proto_perl->Ilinestr);
+i = proto_perl->Ioldbufptr - SvPVX_const(proto_perl->Ilinestr);
PL_oldbufptr= SvPVX(PL_linestr) + (i < 0 ? 0 : i);
-i = proto_perl->Ioldoldbufptr - SvPVX(proto_perl->Ilinestr);
+i = proto_perl->Ioldoldbufptr - SvPVX_const(proto_perl->Ilinestr);
PL_oldoldbufptr= SvPVX(PL_linestr) + (i < 0 ? 0 : i);
-i = proto_perl->Ilinestart - SvPVX(proto_perl->Ilinestr);
+i = proto_perl->Ilinestart - SvPVX_const(proto_perl->Ilinestr);
PL_linestart= SvPVX(PL_linestr) + (i < 0 ? 0 : i);
}
else {
@@ -12026,9 +12026,9 @@
/* XXX See comment on SvANY(proto_perl->Ilinestr) above */
if (SvANY(proto_perl->Ilinestr)) {
-i = proto_perl->Ilast_uni - SvPVX(proto_perl->Ilinestr);
+i = proto_perl->Ilast_uni - SvPVX_const(proto_perl->Ilinestr);
PL_last_uni= SvPVX(PL_linestr) + (i < 0 ? 0 : i);
-i = proto_perl->Ilast_lop - SvPVX(proto_perl->Ilinestr);
+i = proto_perl->Ilast_lop - SvPVX_const(proto_perl->Ilinestr);
PL_last_lop= SvPVX(PL_linestr) + (i < 0 ? 0 : i);
PL_last_lop_op= proto_perl->Ilast_lop_op;
}
@@ -12411,9 +12411,9 @@
uni = PPs;
PUTBACK;
s = SvPV(uni, len);
-if (s != SvPVX(sv)) {
+if (s != SvPVX_const(sv)) {
SvGRW(sv, len + 1);
- Move(s, SvPVX(sv), len, char);
+ Move(s, SvPVX_const(sv), len, char);
SvCUR_set(sv, len);
SvPVX(sv)[len] = 0;
}
End of Patch.