Integrate mainline (for regexp stuff).
[p5sagit/p5-mst-13.2.git] / toke.c
diff --git a/toke.c b/toke.c
index f68eac8..0d4fc1d 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -179,7 +179,7 @@ int yyactlevel = -1;
 
 STATIC void
 S_tokereport(pTHX_ char *thing, char* s, I32 rv)
-{ 
+{
     SV *report;
     DEBUG_T({
         report = newSVpv(thing, 0);
@@ -838,7 +838,7 @@ Perl_str_to_version(pTHX_ SV *sv)
        STRLEN skip;
        UV n;
        if (utf)
-           n = utf8_to_uv((U8*)start, len, &skip, 0);
+           n = utf8n_to_uvchr((U8*)start, len, &skip, 0);
        else {
            n = *(U8*)start;
            skip = 1;
@@ -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;
@@ -1475,7 +1475,7 @@ S_scan_const(pTHX_ char *start)
                        if (hicount) {
                            char *old_pvx = SvPVX(sv);
                            char *src, *dst;
-                         
+                       
                            d = SvGROW(sv,
                                       SvLEN(sv) + hicount + 1) +
                                         (d - old_pvx);
@@ -1497,7 +1497,7 @@ S_scan_const(pTHX_ char *start)
                     }
 
                     if (has_utf8 || uv > 255) {
-                       d = (char*)uv_to_utf8((U8*)d, uv);
+                       d = (char*)uvchr_to_utf8((U8*)d, uv);
                        has_utf8 = TRUE;
                        if (PL_lex_inwhat == OP_TRANS &&
                            PL_sublex_info.sub_op) {
@@ -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)
-                               has_utf8 = TRUE;
-                       }
-                       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);
@@ -1643,14 +1622,14 @@ S_scan_const(pTHX_ char *start)
            STRLEN len = (STRLEN) -1;
            UV uv;
            if (this_utf8) {
-               uv = utf8_to_uv((U8*)s, send - s, &len, 0);
+               uv = utf8n_to_uvchr((U8*)s, send - s, &len, 0);
            }
            if (len == (STRLEN)-1) {
                /* Illegal UTF8 (a high-bit byte), make it valid. */
                char *old_pvx = SvPVX(sv);
                /* need space for one extra char (NOTE: SvCUR() not set here) */
                d = SvGROW(sv, SvLEN(sv) + 1) + (d - old_pvx);
-               d = (char*)uv_to_utf8((U8*)d, (U8)*s++);
+               d = (char*)uvchr_to_utf8((U8*)d, (U8)*s++);
            }
            else {
                while (len--)
@@ -7294,7 +7273,8 @@ vstring:
                                            "Integer overflow in decimal number");
                        }
                    }
-                   tmpend = uv_to_utf8(tmpbuf, rev);
+                   /* Append native character for the rev point */
+                   tmpend = uvchr_to_utf8(tmpbuf, rev);
                    if (rev > revmax)
                        revmax = rev;
                    sv_catpvn(sv, (const char*)tmpbuf, tmpend - tmpbuf);
@@ -7310,11 +7290,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;