Change 34747 by [EMAIL PROTECTED] on 2008/11/06 11:32:25

        Reolve perlbug #59328: In re's, \N{U+...} doesn't match for ... > 256
        
          Subject: PATCH [perl #59328] In re's, \N{U+...} doesn't match for ... 
> 256
          From: karl williamson <[EMAIL PROTECTED]>
          Message-ID: <[EMAIL PROTECTED]>
          Date: Wed, 05 Nov 2008 18:42:16 -0700

Affected files ...

... //depot/perl/regcomp.c#671 edit
... //depot/perl/t/op/re_tests#136 edit

Differences ...

==== //depot/perl/regcomp.c#671 (text) ====
Index: perl/regcomp.c
--- perl/regcomp.c#670~34698~   2008-11-02 13:12:59.000000000 -0800
+++ perl/regcomp.c      2008-11-06 03:32:25.000000000 -0800
@@ -6617,20 +6617,30 @@
             | PERL_SCAN_DISALLOW_PREFIX
             | (SIZE_ONLY ? PERL_SCAN_SILENT_ILLDIGIT : 0);
         UV cp;
-       char string;
         len = (STRLEN)(endbrace - name - 2);
         cp = grok_hex(name + 2, &len, &fl, NULL);
         if ( len != (STRLEN)(endbrace - name - 2) ) {
             cp = 0xFFFD;
         }    
-        if (cp > 0xff)
-            RExC_utf8 = 1;
         if ( valuep ) {
+           if (cp > 0xff) RExC_utf8 = 1;
             *valuep = cp;
             return NULL;
         }
-       string = (char)cp;
-        sv_str= newSVpvn(&string, 1);
+
+       /* Need to convert to utf8 if either: won't fit into a byte, or the re
+        * is going to be in utf8 and the representation changes under utf8. */
+       if (cp > 0xff || (RExC_utf8 && ! UNI_IS_INVARIANT(cp))) {
+           U8 string[UTF8_MAXBYTES+1];
+           U8 *tmps;
+           RExC_utf8 = 1;
+           tmps = uvuni_to_utf8(string, cp);
+           sv_str = newSVpvn_utf8((char*)string, tmps - string, TRUE);
+       } else {    /* Otherwise, no need for utf8, can skip that step */
+           char string;
+           string = (char)cp;
+           sv_str= newSVpvn(&string, 1);
+       }
     } else {
         /* fetch the charnames handler for this scope */
         HV * const table = GvHV(PL_hintgv);
@@ -6809,7 +6819,7 @@
         Set_Node_Cur_Length(ret); /* MJD */
         RExC_parse--; 
         nextchar(pRExC_state);
-    } else {
+    } else {   /* zero length */
         ret = reg_node(pRExC_state,NOTHING);
     }
     if (!cached) {

==== //depot/perl/t/op/re_tests#136 (text) ====
Index: perl/t/op/re_tests
--- perl/t/op/re_tests#135~34746~       2008-11-06 02:44:13.000000000 -0800
+++ perl/t/op/re_tests  2008-11-06 03:32:25.000000000 -0800
@@ -1360,3 +1360,4 @@
 /(.*?)a(?!(a+)b\2c)/   baaabaac        y       $&-$1   baa-ba
 # [perl #60344] Regex lookbehind failure after an (if)then|else in perl 5.10
 /\A(?(?=db2)db2|\D+)(?<!processed)\.csv\z/xms  sql_processed.csv       n       
-       -
+/\N{U+0100}/   \x{100} y       $&      \x{100} # Bug #59328
\ No newline at end of file
End of Patch.

Reply via email to