From: Nicholas Clark Date: Tue, 7 Jun 2005 19:45:13 +0000 (+0000) Subject: More consting of SvPV X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=245d4a47e185d4e38ca6440eb62ae19d5e411fd1;p=p5sagit%2Fp5-mst-13.2.git More consting of SvPV p4raw-id: //depot/perl@24742 --- diff --git a/embed.fnc b/embed.fnc index 05ea88a..ee43d90 100644 --- a/embed.fnc +++ b/embed.fnc @@ -1263,10 +1263,12 @@ sR |I32 |expect_number |NN char** pattern s |SV* |gv_share |SV *sv|CLONE_PARAMS *param # endif s |bool |utf8_mg_pos |NN SV *sv|NN MAGIC **mgp|NN STRLEN **cachep \ - |I32 i|NN I32 *offsetp|I32 uoff|NN U8 **sp \ - |NN U8 *start|NN U8 *send -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 + |I32 i|NN I32 *offsetp|I32 uoff \ + |NN const U8 **sp|NN const U8 *start \ + |NN const U8 *send +s |bool |utf8_mg_pos_init |NN SV *sv|NN MAGIC **mgp \ + |NN STRLEN **cachep|I32 i|I32 offsetp \ + |NN const U8 *s|NN const U8 *start #if defined(PERL_COPY_ON_WRITE) sM |void |sv_release_COW |SV *sv|const char *pvx|STRLEN cur|STRLEN len \ |U32 hash|SV *after diff --git a/pp_ctl.c b/pp_ctl.c index befebb6..406ad23 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -388,7 +388,7 @@ PP(pp_formline) register SV *tmpForm = *++MARK; register U32 *fpc; register char *t; - register char *f; + const char *f; register char *s; register char *send; register I32 arg; @@ -428,11 +428,9 @@ PP(pp_formline) targ_is_utf8 = TRUE; t = SvGROW(PL_formtarget, len + fudge + 1); /* XXX SvCUR bad */ t += len; - f = SvPV(tmpForm, len); + f = SvPV_const(tmpForm, len); /* need to jump to the next word */ - s = f + len + WORD_ALIGN - SvCUR(tmpForm) % WORD_ALIGN; - - fpc = (U32*)s; + fpc = (U32*)(f + len + WORD_ALIGN - SvCUR(tmpForm) % WORD_ALIGN); for (;;) { DEBUG_f( { @@ -511,7 +509,7 @@ PP(pp_formline) break; case FF_CHECKNL: - item = s = SvPV(sv, len); + s = item = SvPV(sv, len); itemsize = len; if (DO_UTF8(sv)) { itemsize = sv_len_utf8(sv); @@ -553,7 +551,7 @@ PP(pp_formline) break; case FF_CHECKCHOP: - item = s = SvPV(sv, len); + s = item = SvPV(sv, len); itemsize = len; if (DO_UTF8(sv)) { itemsize = sv_len_utf8(sv); @@ -732,7 +730,7 @@ PP(pp_formline) case FF_LINEGLOB: oneline = FALSE; ff_line: - item = s = SvPV(sv, len); + s = item = SvPV(sv, len); itemsize = len; if ((item_is_utf8 = DO_UTF8(sv))) itemsize = sv_len_utf8(sv); diff --git a/proto.h b/proto.h index 9f5ced8..c981d7f 100644 --- a/proto.h +++ b/proto.h @@ -2382,7 +2382,7 @@ STATIC I32 S_expect_number(pTHX_ char** pattern) # if defined(USE_ITHREADS) STATIC SV* S_gv_share(pTHX_ SV *sv, CLONE_PARAMS *param); # endif -STATIC bool S_utf8_mg_pos(pTHX_ SV *sv, MAGIC **mgp, STRLEN **cachep, I32 i, I32 *offsetp, I32 uoff, U8 **sp, U8 *start, U8 *send) +STATIC bool S_utf8_mg_pos(pTHX_ SV *sv, MAGIC **mgp, STRLEN **cachep, I32 i, I32 *offsetp, I32 uoff, const U8 **sp, const U8 *start, const U8 *send) __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_2) __attribute__nonnull__(pTHX_3) @@ -2391,7 +2391,7 @@ STATIC bool S_utf8_mg_pos(pTHX_ SV *sv, MAGIC **mgp, STRLEN **cachep, I32 i, I32 __attribute__nonnull__(pTHX_8) __attribute__nonnull__(pTHX_9); -STATIC bool S_utf8_mg_pos_init(pTHX_ SV *sv, MAGIC **mgp, STRLEN **cachep, I32 i, I32 offsetp, U8 *s, U8 *start) +STATIC bool S_utf8_mg_pos_init(pTHX_ SV *sv, MAGIC **mgp, STRLEN **cachep, I32 i, I32 offsetp, const U8 *s, const U8 *start) __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_2) __attribute__nonnull__(pTHX_3) diff --git a/sv.c b/sv.c index e9fe2c9..49de923 100644 --- a/sv.c +++ b/sv.c @@ -6226,7 +6226,8 @@ Perl_sv_len_utf8(pTHX_ register SV *sv) * */ STATIC bool -S_utf8_mg_pos_init(pTHX_ SV *sv, MAGIC **mgp, STRLEN **cachep, I32 i, I32 offsetp, U8 *s, U8 *start) +S_utf8_mg_pos_init(pTHX_ SV *sv, MAGIC **mgp, STRLEN **cachep, I32 i, + I32 offsetp, const U8 *s, const U8 *start) { bool found = FALSE; @@ -6259,7 +6260,7 @@ S_utf8_mg_pos_init(pTHX_ SV *sv, MAGIC **mgp, STRLEN **cachep, I32 i, I32 offset * */ STATIC bool -S_utf8_mg_pos(pTHX_ SV *sv, MAGIC **mgp, STRLEN **cachep, I32 i, I32 *offsetp, I32 uoff, U8 **sp, U8 *start, U8 *send) +S_utf8_mg_pos(pTHX_ SV *sv, MAGIC **mgp, STRLEN **cachep, I32 i, I32 *offsetp, I32 uoff, const U8 **sp, const U8 *start, const U8 *send) { bool found = FALSE; @@ -6391,21 +6392,21 @@ type coercion. void Perl_sv_pos_u2b(pTHX_ register SV *sv, I32* offsetp, I32* lenp) { - U8 *start; + const U8 *start; STRLEN len; if (!sv) return; - start = (U8*)SvPV(sv, len); + start = (U8*)SvPV_const(sv, len); if (len) { STRLEN boffset = 0; STRLEN *cache = 0; - U8 *s = start; - I32 uoffset = *offsetp; - U8 *send = s + len; - MAGIC *mg = 0; - bool found = FALSE; + const U8 *s = start; + I32 uoffset = *offsetp; + const U8 *send = s + len; + MAGIC *mg = 0; + bool found = FALSE; if (utf8_mg_pos(sv, &mg, &cache, 0, offsetp, *offsetp, &s, start, send)) found = TRUE; @@ -9309,7 +9310,7 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV const char *eptr = Nullch; STRLEN elen = 0; SV *vecsv = Nullsv; - U8 *vecstr = Null(U8*); + const U8 *vecstr = Null(U8*); STRLEN veclen = 0; char c = 0; int i; @@ -9429,18 +9430,18 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV else vecsv = (evix ? evix <= svmax : svix < svmax) ? svargs[evix ? evix-1 : svix++] : &PL_sv_undef; - dotstr = SvPVx(vecsv, dotstrlen); + dotstr = SvPV_const(vecsv, dotstrlen); if (DO_UTF8(vecsv)) is_utf8 = TRUE; } if (args) { vecsv = va_arg(*args, SV*); - vecstr = (U8*)SvPVx(vecsv,veclen); + vecstr = (U8*)SvPV_const(vecsv,veclen); vec_utf8 = DO_UTF8(vecsv); } else if (efix ? efix <= svmax : svix < svmax) { vecsv = svargs[efix ? efix-1 : svix++]; - vecstr = (U8*)SvPVx(vecsv,veclen); + vecstr = (U8*)SvPV_const(vecsv,veclen); vec_utf8 = DO_UTF8(vecsv); /* if this is a version object, we need to return the * stringified representation (which the SvPVX_const has @@ -9449,7 +9450,7 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV if ( *q == 'd' && sv_derived_from(vecsv,"version") ) { q++; /* skip past the rest of the %vd format */ - eptr = (char *) vecstr; + eptr = (const char *) vecstr; elen = strlen(eptr); vectorize=FALSE; goto string;