Not quite so relicy as thought in #11651 (op/concat #4 and #5
Jarkko Hietaniemi [Sun, 12 Aug 2001 22:46:12 +0000 (22:46 +0000)]
stopped working).

p4raw-id: //depot/perl@11653

op.h
pp_ctl.c
regcomp.c

diff --git a/op.h b/op.h
index af8280b..e92b1d8 100644 (file)
--- a/op.h
+++ b/op.h
@@ -263,6 +263,10 @@ struct pmop {
 
 #define PMdf_USED      0x01            /* pm has been used once already */
 #define PMdf_TAINTED   0x02            /* pm compiled from tainted pattern */
+#define PMdf_UTF8      0x04            /* pm compiled from utf8 data */
+#define PMdf_DYN_UTF8  0x08
+
+#define PMdf_CMP_UTF8  (PMdf_UTF8|PMdf_DYN_UTF8)
 
 #define PMf_RETAINT    0x0001          /* taint $1 etc. if target tainted */
 #define PMf_ONCE       0x0002          /* use pattern only once per reset */
index 8a187b0..1605e21 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -121,7 +121,16 @@ PP(pp_regcomp)
                PL_reginterp_cnt = I32_MAX; /* Mark as safe.  */
 
            pm->op_pmflags = pm->op_pmpermflags;        /* reset case sensitivity */
+           if (DO_UTF8(tmpstr))
+               pm->op_pmdynflags |= PMdf_DYN_UTF8;
+           else {
+               pm->op_pmdynflags &= ~PMdf_DYN_UTF8;
+               if (pm->op_pmdynflags & PMdf_UTF8)
+                   t = (char*)bytes_to_utf8((U8*)t, &len);
+           }
            PM_SETRE(pm, CALLREGCOMP(aTHX_ t, t + len, pm));
+           if (!DO_UTF8(tmpstr) && (pm->op_pmdynflags & PMdf_UTF8))
+               Safefree(t);
            PL_reginterp_cnt = 0;       /* XXXX Be extra paranoid - needed
                                           inside tie/overload accessors.  */
        }
index 2b9fbbb..2e37633 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -1666,7 +1666,11 @@ Perl_pregcomp(pTHX_ char *exp, char *xend, PMOP *pm)
     if (exp == NULL)
        FAIL("NULL regexp argument");
 
-    RExC_utf8 = 0;
+    /* XXXX This looks very suspicious... */
+    if (pm->op_pmdynflags & PMdf_CMP_UTF8)
+        RExC_utf8 = 1;
+    else
+        RExC_utf8 = 0;
 
     RExC_precomp = exp;
     DEBUG_r(if (!PL_colorset) reginitcolors());