Change 34770 by [EMAIL PROTECTED] on 2008/11/07 22:33:39

        Revert SvPVX() to allow lvalue usage, but also add a
        MUTABLE_SV() check. Use SvPVX_const() instead of SvPVX()
        where only a const SV* is available. Also fix two falsely
        consted pointers in Perl_sv_2pv_flags().

Affected files ...

... //depot/perl/op.c#1020 edit
... //depot/perl/regexec.c#578 edit
... //depot/perl/regexp.h#140 edit
... //depot/perl/sv.c#1574 edit
... //depot/perl/sv.h#355 edit

Differences ...

==== //depot/perl/op.c#1020 (text) ====
Index: perl/op.c
--- perl/op.c#1019~34705~       2008-11-03 08:25:42.000000000 -0800
+++ perl/op.c   2008-11-07 14:33:39.000000000 -0800
@@ -7919,7 +7919,7 @@
     if (kid && kid->op_type == OP_MATCH) {
        if (ckWARN(WARN_SYNTAX)) {
             const REGEXP *re = PM_GETRE(kPMOP);
-           const char *pmstr = re ? RX_PRECOMP(re) : "STRING";
+           const char *pmstr = re ? RX_PRECOMP_const(re) : "STRING";
            const STRLEN len = re ? RX_PRELEN(re) : 6;
            Perl_warner(aTHX_ packWARN(WARN_SYNTAX),
                        "/%.*s/ should probably be written as \"%.*s\"",

==== //depot/perl/regexec.c#578 (text) ====
Index: perl/regexec.c
--- perl/regexec.c#577~34755~   2008-11-06 10:48:28.000000000 -0800
+++ perl/regexec.c      2008-11-07 14:33:39.000000000 -0800
@@ -2590,7 +2590,7 @@
             reginitcolors();    
     {
         RE_PV_QUOTED_DECL(s0, utf8_pat, PERL_DEBUG_PAD_ZERO(0), 
-            RX_PRECOMP(prog), RX_PRELEN(prog), 60);   
+            RX_PRECOMP_const(prog), RX_PRELEN(prog), 60);   
         
         RE_PV_QUOTED_DECL(s1, do_utf8, PERL_DEBUG_PAD_ZERO(1), 
             start, end - start, 60); 

==== //depot/perl/regexp.h#140 (text) ====
Index: perl/regexp.h
--- perl/regexp.h#139~34672~    2008-10-30 15:08:41.000000000 -0700
+++ perl/regexp.h       2008-11-07 14:33:39.000000000 -0800
@@ -371,11 +371,13 @@
 
 /* For source compatibility. We used to store these explicitly.  */
 #define RX_PRECOMP(prog)       (RX_WRAPPED(prog) + ((struct regexp 
*)SvANY(prog))->pre_prefix)
+#define RX_PRECOMP_const(prog) (RX_WRAPPED_const(prog) + ((struct regexp 
*)SvANY(prog))->pre_prefix)
 /* FIXME? Are we hardcoding too much here and constraining plugin extension
    writers? Specifically, the value 1 assumes that the wrapped version always
    has exactly one character at the end, a ')'. Will that always be true?  */
 #define RX_PRELEN(prog)                (RX_WRAPLEN(prog) - ((struct regexp 
*)SvANY(prog))->pre_prefix - 1)
 #define RX_WRAPPED(prog)       SvPVX(prog)
+#define RX_WRAPPED_const(prog) SvPVX_const(prog)
 #define RX_WRAPLEN(prog)       SvCUR(prog)
 #define RX_CHECK_SUBSTR(prog)  (((struct regexp *)SvANY(prog))->check_substr)
 #define RX_REFCNT(prog)                SvREFCNT(prog)

==== //depot/perl/sv.c#1574 (text) ====
Index: perl/sv.c
--- perl/sv.c#1573~34698~       2008-11-02 13:12:59.000000000 -0800
+++ perl/sv.c   2008-11-07 14:33:39.000000000 -0800
@@ -2840,13 +2840,13 @@
                STRLEN len;
                char *retval;
                char *buffer;
-               const SV *const referent = SvRV(sv);
+               SV *const referent = SvRV(sv);
 
                if (!referent) {
                    len = 7;
                    retval = buffer = savepvn("NULLREF", len);
                } else if (SvTYPE(referent) == SVt_REGEXP) {
-                   const REGEXP * const re = (REGEXP *)referent;
+                   REGEXP * const re = (REGEXP *)MUTABLE_PTR(referent);
                    I32 seen_evals = 0;
 
                    assert(re);
@@ -10567,7 +10567,7 @@
            }
            else {
                /* Some other special case - random pointer */
-               SvPV_set(dstr, SvPVX(sstr));            
+               SvPV_set(dstr, (char *) SvPVX_const(sstr));             
            }
        }
     }

==== //depot/perl/sv.h#355 (text) ====
Index: perl/sv.h
--- perl/sv.h#354~34613~        2008-10-27 15:39:45.000000000 -0700
+++ perl/sv.h   2008-11-07 14:33:39.000000000 -0800
@@ -1072,7 +1072,7 @@
 #  if defined (DEBUGGING) && defined(__GNUC__) && 
!defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN)
 /* These get expanded inside other macros that already use a variable _sv  */
 #    define SvPVX(sv)                                                  \
-       (*({ const SV *const _svpvx = (const SV *)(sv);                 \
+       (*({ SV *const _svpvx = MUTABLE_SV(sv);                         \
            assert(SvTYPE(_svpvx) >= SVt_PV);                           \
            assert(SvTYPE(_svpvx) != SVt_PVAV);                         \
            assert(SvTYPE(_svpvx) != SVt_PVHV);                         \
End of Patch.

Reply via email to