Re: Unicode/EBCDIC
[p5sagit/p5-mst-13.2.git] / toke.c
diff --git a/toke.c b/toke.c
index e312c4e..2bb9282 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -1245,7 +1245,7 @@ S_scan_const(pTHX_ char *start)
                    char *e = d++;
                    while (e-- > c)
                        *(e + 1) = *e;
-                   *c = 0xff;
+                   *c = (char)0xff;
                    /* mark the range as done, and continue */
                    dorange = FALSE;
                    didrange = TRUE;
@@ -1518,7 +1518,7 @@ S_scan_const(pTHX_ char *start)
 
            /* \N{latin small letter a} is a named character */
            case 'N':
-               s++;
+               ++s;
                if (*s == '{') {
                    char* e = strchr(s, '}');
                    SV *res;
@@ -1530,30 +1530,9 @@ S_scan_const(pTHX_ char *start)
                        e = s - 1;
                        goto cont_scan;
                    }
-                   if (s[1] == 'U' && s[2] == '+') { /* \N{U+HHHH} */
-                       STRLEN alen = e - s - 3;
-                       STRLEN blen;
-                       UV uv = (UV)scan_hex(s + 3, alen, &blen);
-
-                       if (blen == alen) {
-                           res = newSVpvn(s, (uv >> 8) + 1); /* filler */
-                           str = (char *)uv_to_utf8((U8*)SvPVX(res), uv);
-                           SvCUR_set(res, str - SvPVX(res));
-                           *str = '\0';
-                           if (uv > 0x7f)
-                               SvUTF8_on(res);
-                       }
-                       else {
-                           yyerror("Illegal hexadecimal code on \\N{U+...}");
-                           e = s - 1;
-                           goto cont_scan;
-                       }
-                   }
-                   else {
-                       res = newSVpvn(s + 1, e - s - 1);
-                       res = new_constant( Nullch, 0, "charnames",
-                                           res, Nullsv, "\\N{...}" );
-                   }
+                   res = newSVpvn(s + 1, e - s - 1);
+                   res = new_constant( Nullch, 0, "charnames",
+                                       res, Nullsv, "\\N{...}" );
                    if (has_utf8)
                        sv_utf8_upgrade(res);
                    str = SvPV(res,len);
@@ -7294,6 +7273,10 @@ vstring:
                                            "Integer overflow in decimal number");
                        }
                    }
+                   /* THIS IS EVIL */
+                   if (rev < 256) 
+                       rev = ASCII_TO_NATIVE(rev);
+
                    tmpend = uv_to_utf8(tmpbuf, rev);
                    if (rev > revmax)
                        revmax = rev;
@@ -7310,11 +7293,11 @@ vstring:
 
                SvPOK_on(sv);
                SvREADONLY_on(sv);
-               if (revmax > 127) {
-                   SvUTF8_on(sv);
+               /* if (revmax > 127) { */
+                   SvUTF8_on(sv); /*
                    if (revmax < 256)
                      sv_utf8_downgrade(sv, TRUE);
-               }
+               } */
            }
        }
        break;