This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Wrap wrapped and wraplen from struct regexp in macros RW_WRAPPED() and
authorNicholas Clark <nick@ccl4.org>
Sat, 29 Dec 2007 00:17:41 +0000 (00:17 +0000)
committerNicholas Clark <nick@ccl4.org>
Sat, 29 Dec 2007 00:17:41 +0000 (00:17 +0000)
RX_WRAPLEN() to preserve source compatibility when they get moved
around.

p4raw-id: //depot/perl@32758

dump.c
ext/re/re.xs
regcomp.c
regexp.h

diff --git a/dump.c b/dump.c
index e62da78..126fe89 100644 (file)
--- a/dump.c
+++ b/dump.c
@@ -1285,7 +1285,8 @@ Perl_do_magic_dump(pTHX_ I32 level, PerlIO *file, const MAGIC *mg, I32 nest, I32
             if (mg->mg_type == PERL_MAGIC_qr) {
                const regexp * const re = (regexp *)mg->mg_obj;
                SV * const dsv = sv_newmortal();
-                const char * const s =  pv_pretty(dsv, re->wrapped, re->wraplen, 
+                const char * const s
+                   = pv_pretty(dsv, RX_WRAPPED(re), RX_WRAPLEN(re), 
                     60, NULL, NULL,
                     ( PERL_PV_PRETTY_QUOTE | PERL_PV_ESCAPE_RE | PERL_PV_PRETTY_ELLIPSES |
                     ((re->extflags & RXf_UTF8) ? PERL_PV_ESCAPE_UNI : 0))
index fa82127..94cb2f5 100644 (file)
@@ -126,7 +126,7 @@ PPCODE:
         } else {
             /* Scalar, so use the string that Perl would return */
             /* return the pattern in (?msix:..) format */
-            pattern = sv_2mortal(newSVpvn(re->wrapped,re->wraplen));
+            pattern = sv_2mortal(newSVpvn(RX_WRAPPED(re),RX_WRAPLEN(re)));
             if (re->extflags & RXf_UTF8) 
                 SvUTF8_on(pattern);
             XPUSHs(pattern);
index ff099f5..070b183 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -4289,12 +4289,12 @@ redo_first_pass:
        U16 reganch = (U16)((r->extflags & RXf_PMf_STD_PMMOD) >> 12);
        const char *fptr = STD_PAT_MODS;        /*"msix"*/
        char *p;
-        r->wraplen = plen + has_minus + has_p + has_runon
+        RX_WRAPLEN(r) = plen + has_minus + has_p + has_runon
             + (sizeof(STD_PAT_MODS) - 1)
             + (sizeof("(?:)") - 1);
 
-        Newx(r->wrapped, r->wraplen + 1, char );
-        p = r->wrapped;
+        Newx(RX_WRAPPED(r), RX_WRAPLEN(r) + 1, char );
+        p = RX_WRAPPED(r);
         *p++='('; *p++='?';
         if (has_p)
             *p++ = KEEPCOPY_PAT_MOD; /*'p'*/
@@ -4318,8 +4318,8 @@ redo_first_pass:
 
         *p++ = ':';
         Copy(RExC_precomp, p, plen, char);
-       assert ((r->wrapped - p) < 16);
-       r->pre_prefix = p - r->wrapped;
+       assert ((RX_WRAPPED(r) - p) < 16);
+       r->pre_prefix = p - RX_WRAPPED(r);
         p += plen;
         if (has_runon)
             *p++ = '\n';
@@ -9146,7 +9146,7 @@ Perl_pregfree(pTHX_ struct regexp *r)
         CALLREGFREE_PVT(r); /* free the private data */
         if (r->paren_names)
             SvREFCNT_dec(r->paren_names);
-        Safefree(r->wrapped);
+        Safefree(RX_WRAPPED(r));
     }        
     if (r->substrs) {
         if (r->anchored_substr)
@@ -9419,7 +9419,7 @@ Perl_re_dup(pTHX_ const regexp *r, CLONE_PARAMS *param)
        }
     }
 
-    ret->wrapped        = SAVEPVN(ret->wrapped, ret->wraplen+1);
+    RX_WRAPPED(ret)     = SAVEPVN(RX_WRAPPED(ret), RX_WRAPLEN(ret)+1);
     ret->paren_names    = hv_dup_inc(ret->paren_names, param);
 
     if (ret->pprivate)
@@ -9587,8 +9587,8 @@ Perl_reg_stringify(pTHX_ MAGIC *mg, STRLEN *lp, U32 *flags, I32 *haseval ) {
     if (flags)    
        *flags = ((re->extflags & RXf_UTF8) ? 1 : 0);
     if (lp)
-       *lp = re->wraplen;
-    return re->wrapped;
+       *lp = RX_WRAPLEN(re);
+    return RX_WRAPPED(re);
 }
 
 /*
index 37d92c5..623a4bb 100644 (file)
--- a/regexp.h
+++ b/regexp.h
@@ -358,6 +358,9 @@ and check for NULL.
    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)                        ((prog)->wraplen - (prog)->pre_prefix - 1)
+#define RX_WRAPPED(prog)               ((prog)->wrapped)
+#define RX_WRAPLEN(prog)               ((prog)->wraplen)
+
 
 #endif /* PLUGGABLE_RE_EXTENSION */