From: Nicholas Clark Date: Wed, 8 Jun 2005 16:02:54 +0000 (+0000) Subject: Add and use MgPV_nolen_const X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=01b8bcb77a033a072e6afd95c46cef74d30628c1;p=p5sagit%2Fp5-mst-13.2.git Add and use MgPV_nolen_const p4raw-id: //depot/perl@24761 --- diff --git a/mg.c b/mg.c index c0b2762..bcf6291 100644 --- a/mg.c +++ b/mg.c @@ -1027,9 +1027,8 @@ Perl_magic_setenv(pTHX_ SV *sv, MAGIC *mg) int Perl_magic_clearenv(pTHX_ SV *sv, MAGIC *mg) { - STRLEN n_a; (void)sv; - my_setenv(MgPV(mg,n_a),Nullch); + my_setenv(MgPV_nolen_const(mg),Nullch); return 0; } @@ -1107,9 +1106,8 @@ int Perl_magic_getsig(pTHX_ SV *sv, MAGIC *mg) { I32 i; - STRLEN n_a; /* Are we fetching a signal entry? */ - i = whichsig(MgPV(mg,n_a)); + i = whichsig(MgPV_nolen_const(mg)); if (i > 0) { if(PL_psig_ptr[i]) sv_setsv(sv,PL_psig_ptr[i]); @@ -1140,8 +1138,7 @@ Perl_magic_clearsig(pTHX_ SV *sv, MAGIC *mg) * refactoring might be in order. */ dVAR; - STRLEN n_a; - register const char *s = MgPV(mg,n_a); + register const char *s = MgPV_nolen_const(mg); (void)sv; if (*s == '_') { SV** svp = 0; @@ -1633,12 +1630,11 @@ Perl_magic_setdbline(pTHX_ SV *sv, MAGIC *mg) I32 i; GV* gv; SV** svp; - STRLEN n_a; gv = PL_DBline; i = SvTRUE(sv); svp = av_fetch(GvAV(gv), - atoi(MgPV(mg,n_a)), FALSE); + atoi(MgPV_nolen_const(mg)), FALSE); if (svp && SvIOKp(*svp) && (o = INT2PTR(OP*,SvIVX(*svp)))) { /* set or clear breakpoint in the relevant control op */ if (i) diff --git a/mg.h b/mg.h index f07c248..8f5644b 100644 --- a/mg.h +++ b/mg.h @@ -48,8 +48,11 @@ struct magic { #define MgPV(mg,lp) ((((int)(lp = (mg)->mg_len)) == HEf_SVKEY) ? \ SvPV((SV*)((mg)->mg_ptr),lp) : \ (mg)->mg_ptr) -#define MgPV_const(mg,lp) ((((int)(lp = (mg)->mg_len)) == HEf_SVKEY) ? \ - SvPV_const((SV*)((mg)->mg_ptr),lp) : \ +#define MgPV_const(mg,lp) ((((int)(lp = (mg)->mg_len)) == HEf_SVKEY) ? \ + SvPV_const((SV*)((mg)->mg_ptr),lp) : \ + (const char*)(mg)->mg_ptr) +#define MgPV_nolen_const(mg) (((((int)(mg)->mg_len)) == HEf_SVKEY) ? \ + SvPV_nolen_const((SV*)((mg)->mg_ptr)) : \ (const char*)(mg)->mg_ptr) #define SvTIED_mg(sv,how) \