With Damian's approval synchronize damian's modules'
[p5sagit/p5-mst-13.2.git] / regcomp.c
index 05a48d9..19ad253 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -1599,7 +1599,7 @@ Perl_pregcomp(pTHX_ char *exp, char *xend, PMOP *pm)
     else
         RExC_utf8 = 0;
 
-    RExC_precomp = savepvn(exp, xend - exp);
+    RExC_precomp = exp;
     DEBUG_r(if (!PL_colorset) reginitcolors());
     DEBUG_r(PerlIO_printf(Perl_debug_log, "%sCompiling REx%s `%s%*s%s'\n",
                      PL_colors[4],PL_colors[5],PL_colors[0],
@@ -1625,7 +1625,6 @@ Perl_pregcomp(pTHX_ char *exp, char *xend, PMOP *pm)
     REGC((U8)REG_MAGIC, (char*)RExC_emit);
 #endif
     if (reg(pRExC_state, 0, &flags) == NULL) {
-       Safefree(RExC_precomp);
        RExC_precomp = Nullch;
        return(NULL);
     }
@@ -1652,7 +1651,7 @@ Perl_pregcomp(pTHX_ char *exp, char *xend, PMOP *pm)
 #endif
     r->refcnt = 1;
     r->prelen = xend - exp;
-    r->precomp = RExC_precomp;
+    r->precomp = savepvn(RExC_precomp, r->prelen);
     r->subbeg = NULL;
     r->reganch = pm->op_pmflags & PMf_COMPILETIME;
     r->nparens = RExC_npar - 1;        /* set early to validate backrefs */
@@ -2902,7 +2901,7 @@ tryagain:
                default:
                  normal_default:
                    if (UTF8_IS_START(*p) && UTF) {
-                       ender = utf8n_to_uvuni((U8*)p, RExC_end - p,
+                       ender = utf8n_to_uvchr((U8*)p, RExC_end - p,
                                               &numlen, 0);
                        p += numlen;
                    }
@@ -2914,7 +2913,7 @@ tryagain:
                    p = regwhite(p, RExC_end);
                if (UTF && FOLD) {
                    if (LOC)
-                       ender = toLOWER_LC_uvchr(UNI_TO_NATIVE(ender));
+                       ender = toLOWER_LC_uvchr(ender);
                    else
                        ender = toLOWER_uni(ender);
                }
@@ -2923,7 +2922,7 @@ tryagain:
                        p = oldp;
                    /* ender is a Unicode value so it can be > 0xff --
                     * in other words, do not use UTF8_IS_CONTINUED(). */
-                   else if (ender >= 0x80 && UTF) {
+                   else if (NATIVE_TO_ASCII(ender) >= 0x80 && UTF) {
                        reguni(pRExC_state, ender, s, &numlen);
                        s += numlen;
                        len += numlen;
@@ -2936,7 +2935,7 @@ tryagain:
                }
                /* ender is a Unicode value so it can be > 0xff --
                 * in other words, do not use UTF8_IS_CONTINUED(). */
-               if (ender >= 0x80 && UTF) {
+               if (NATIVE_TO_ASCII(ender) >= 0x80 && UTF) {
                    reguni(pRExC_state, ender, s, &numlen);
                    s += numlen;
                    len += numlen - 1;
@@ -3201,7 +3200,7 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state)
        if (!range)
            rangebegin = RExC_parse;
        if (UTF) {
-           value = utf8n_to_uvuni((U8*)RExC_parse,
+           value = utf8n_to_uvchr((U8*)RExC_parse,
                               RExC_end - RExC_parse,
                               &numlen, 0);
            RExC_parse += numlen;
@@ -3212,7 +3211,7 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state)
            namedclass = regpposixcc(pRExC_state, value);
        else if (value == '\\') {
            if (UTF) {
-               value = utf8n_to_uvuni((U8*)RExC_parse,
+               value = utf8n_to_uvchr((U8*)RExC_parse,
                                   RExC_end - RExC_parse,
                                   &numlen, 0);
                RExC_parse += numlen;
@@ -3320,8 +3319,7 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state)
                    else {
                        ANYOF_FLAGS(ret) |= ANYOF_UNICODE;
                        Perl_sv_catpvf(aTHX_ listsv,
-                                      /* 0x002D is Unicode for '-' */
-                                      "%04"UVxf"\n002D\n", (UV)lastvalue);
+                                      "%04"UVxf"\n%04"UVxf"\n", (UV)lastvalue, (UV) '-');
                    }
                }
 
@@ -3883,7 +3881,7 @@ S_reganode(pTHX_ RExC_state_t *pRExC_state, U8 op, U32 arg)
 STATIC void
 S_reguni(pTHX_ RExC_state_t *pRExC_state, UV uv, char* s, STRLEN* lenp)
 {
-    *lenp = SIZE_ONLY ? UNISKIP(uv) : (uvuni_to_utf8((U8*)s, uv) - (U8*)s);
+    *lenp = SIZE_ONLY ? UNISKIP(uv) : (uvchr_to_utf8((U8*)s, uv) - (U8*)s);
 }
 
 /*