This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add and use MgPV_nolen_const
authorNicholas Clark <nick@ccl4.org>
Wed, 8 Jun 2005 16:02:54 +0000 (16:02 +0000)
committerNicholas Clark <nick@ccl4.org>
Wed, 8 Jun 2005 16:02:54 +0000 (16:02 +0000)
p4raw-id: //depot/perl@24761

mg.c
mg.h

diff --git a/mg.c b/mg.c
index c0b2762..bcf6291 100644 (file)
--- 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 (file)
--- 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) \