From b83604b4e5062f93776f6a381f822df058667e23 Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Thu, 9 Jun 2005 10:36:53 +0000 Subject: [PATCH] More SvPV consting p4raw-id: //depot/perl@24778 --- mg.c | 27 +++++++++++++-------------- perlio.c | 8 ++++---- pp_pack.c | 4 ++-- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/mg.c b/mg.c index 257d53d..e49b26e 100644 --- a/mg.c +++ b/mg.c @@ -951,11 +951,11 @@ int Perl_magic_setenv(pTHX_ SV *sv, MAGIC *mg) { dVAR; - register char *s; + const char *s; const char *ptr; STRLEN len, klen; - s = SvPV(sv,len); + s = SvPV_const(sv,len); ptr = MgPV_const(mg,klen); my_setenv(ptr, s); @@ -965,7 +965,7 @@ Perl_magic_setenv(pTHX_ SV *sv, MAGIC *mg) if (!len) { SV **valp; if ((valp = hv_fetch(GvHVn(PL_envgv), ptr, klen, FALSE))) - s = SvPV(*valp, len); + s = SvPV_const(*valp, len); } #endif @@ -1001,7 +1001,7 @@ Perl_magic_setenv(pTHX_ SV *sv, MAGIC *mg) } #endif /* VMS */ if (s && klen == 4 && strEQ(ptr,"PATH")) { - char *strend = s + len; + const char *strend = s + len; while (s < strend) { char tmpbuf[256]; @@ -1040,13 +1040,12 @@ Perl_magic_set_all_env(pTHX_ SV *sv, MAGIC *mg) #else if (PL_localizing) { HE* entry; - STRLEN n_a; magic_clear_all_env(sv,mg); hv_iterinit((HV*)sv); while ((entry = hv_iternext((HV*)sv))) { I32 keylen; my_setenv(hv_iterkey(entry, &keylen), - SvPV(hv_iterval((HV*)sv, entry), n_a)); + SvPV_nolen_const(hv_iterval((HV*)sv, entry))); } } #endif @@ -1098,7 +1097,7 @@ Perl_magic_clear_all_env(pTHX_ SV *sv, MAGIC *mg) static void restore_sigmask(pTHX_ SV *save_sv) { - sigset_t *ossetp = (sigset_t *) SvPV_nolen( save_sv ); + const sigset_t *ossetp = (const sigset_t *) SvPV_nolen_const( save_sv ); (void)sigprocmask(SIG_SETMASK, ossetp, (sigset_t *)0); } #endif @@ -1766,7 +1765,7 @@ Perl_magic_getsubstr(pTHX_ SV *sv, MAGIC *mg) { STRLEN len; SV * const lsv = LvTARG(sv); - const char * const tmps = SvPV(lsv,len); + const char * const tmps = SvPV_const(lsv,len); I32 offs = LvTARGOFF(sv); I32 rem = LvTARGLEN(sv); (void)mg; @@ -1787,7 +1786,7 @@ int Perl_magic_setsubstr(pTHX_ SV *sv, MAGIC *mg) { STRLEN len; - char *tmps = SvPV(sv, len); + const char *tmps = SvPV_const(sv, len); SV * const lsv = LvTARG(sv); I32 lvoff = LvTARGOFF(sv); I32 lvlen = LvTARGLEN(sv); @@ -2066,7 +2065,7 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg) case '\004': /* ^D */ #ifdef DEBUGGING - s = SvPV_nolen(sv); + s = SvPV_nolen_const(sv); PL_debug = get_debug_opts(&s, 0) | DEBUG_TOP_FLAG; DEBUG_x(dump_all()); #else @@ -2168,7 +2167,7 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg) STRLEN len, i; int accumulate = 0 ; int any_fatals = 0 ; - const char * const ptr = (char*)SvPV(sv, len) ; + const char * const ptr = SvPV_const(sv, len) ; for (i = 0 ; i < len ; ++i) { accumulate |= ptr[i] ; any_fatals |= (ptr[i] & 0xAA) ; @@ -2385,7 +2384,7 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg) case ')': #ifdef HAS_SETGROUPS { - const char *p = SvPV(sv, len); + const char *p = SvPV_const(sv, len); Groups_t gary[NGROUPS]; while (isSPACE(*p)) @@ -2442,7 +2441,7 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg) * show a string from the process struct and provide * the setproctitle() routine to manipulate that. */ { - s = SvPV(sv, len); + s = SvPV_const(sv, len); # if __FreeBSD_version > 410001 /* The leading "-" removes the "perl: " prefix, * but not the "(perl) suffix from the ps(1) @@ -2464,7 +2463,7 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg) #if defined(__hpux) && defined(PSTAT_SETCMD) { union pstun un; - s = SvPV(sv, len); + s = SvPV_const(sv, len); un.pst_command = (char *)s; pstat(PSTAT_SETCMD, un, len, 0, 0); } diff --git a/perlio.c b/perlio.c index 55148e8..df4ddc0 100644 --- a/perlio.c +++ b/perlio.c @@ -484,7 +484,7 @@ PerlIO_debug(const char *fmt, ...) (IV) CopLINE(PL_curcop)); Perl_sv_vcatpvf(aTHX_ sv, fmt, &ap); - s = SvPV(sv, len); + s = SvPV_const(sv, len); PerlLIO_write(PL_perlio_debug_fd, s, len); SvREFCNT_dec(sv); #endif @@ -1388,7 +1388,7 @@ PerlIO_context_layers(pTHX_ const char *mode) SV *layers = PL_curcop->cop_io; if (layers) { STRLEN len; - type = SvPV(layers, len); + type = SvPV_const(layers, len); if (type && mode[0] != 'r') { /* * Skip to write part @@ -4832,7 +4832,7 @@ PerlIO_vprintf(PerlIO *f, const char *fmt, va_list ap) { dTHX; SV *sv = newSVpvn("", 0); - char *s; + const char *s; STRLEN len; SSize_t wrote; #ifdef NEED_VA_COPY @@ -4842,7 +4842,7 @@ PerlIO_vprintf(PerlIO *f, const char *fmt, va_list ap) #else sv_vcatpvf(sv, fmt, &ap); #endif - s = SvPV(sv, len); + s = SvPV_const(sv, len); wrote = PerlIO_write(f, s, len); SvREFCNT_dec(sv); return wrote; diff --git a/pp_pack.c b/pp_pack.c index 11a1ed6..16e724e 100644 --- a/pp_pack.c +++ b/pp_pack.c @@ -2832,14 +2832,14 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist ) } case 'B': case 'b': { - char *str, *end; + const char *str, *end; I32 l, field_len; U8 bits; bool utf8_source; U32 utf8_flags; fromstr = NEXTFROM; - str = SvPV(fromstr, fromlen); + str = SvPV_const(fromstr, fromlen); end = str + fromlen; if (DO_UTF8(fromstr)) { utf8_source = TRUE; -- 2.7.4