Few more IDE/editor nits from p5p.
[p5sagit/p5-mst-13.2.git] / toke.c
diff --git a/toke.c b/toke.c
index 09a2e48..c6ef8e9 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -1383,7 +1383,8 @@ S_scan_const(pTHX_ char *start)
                    else {
                        STRLEN len = 1;         /* allow underscores */
                        uv = (UV)scan_hex(s + 1, e - s - 1, &len);
-                       to_be_utf8 = TRUE;
+                       if (PL_hints & HINT_UTF8)
+                           to_be_utf8 = TRUE;
                    }
                    s = e + 1;
                }
@@ -1400,6 +1401,12 @@ S_scan_const(pTHX_ char *start)
                 * There will always enough room in sv since such
                 * escapes will be longer than any UT-F8 sequence
                 * they can end up as. */
+
+               /* This spot is wrong for EBCDIC.  Characters like
+                * the lowercase letters and digits are >127 in EBCDIC,
+                * so here they would need to be mapped to the Unicode
+                * repertoire.   --jhi */
+               
                if (uv > 127) {
                    if (!has_utf8 && (to_be_utf8 || uv > 255)) {
                        /* Might need to recode whatever we have
@@ -1419,8 +1426,6 @@ S_scan_const(pTHX_ char *start)
                        if (hicount) {
                            char *old_pvx = SvPVX(sv);
                            char *src, *dst;
-                           U8 tmpbuf[UTF8_MAXLEN+1];
-                           U8 *tmpend;
                          
                            d = SvGROW(sv,
                                       SvCUR(sv) + hicount + 1) +
@@ -1432,10 +1437,8 @@ S_scan_const(pTHX_ char *start)
 
                            while (src < dst) {
                                if (UTF8_IS_CONTINUED(*src)) {
-                                   tmpend = uv_to_utf8(tmpbuf, (U8)*src--);
-                                   dst -= tmpend - tmpbuf;
-                                   Copy((char *)tmpbuf, dst+1,
-                                        tmpend - tmpbuf, char);
+                                   *dst-- = UTF8_EIGHT_BIT_LO(*src);
+                                   *dst-- = UTF8_EIGHT_BIT_HI(*src--);
                                }
                                else {
                                    *dst-- = *src--;
@@ -1444,7 +1447,7 @@ S_scan_const(pTHX_ char *start)
                         }
                     }
 
-                    if (to_be_utf8 || (has_utf8 && uv > 127) || uv > 255) {
+                    if (to_be_utf8 || has_utf8 || uv > 255) {
                        d = (char*)uv_to_utf8((U8*)d, uv);
                        has_utf8 = TRUE;
                     }
@@ -2105,6 +2108,7 @@ Perl_yylex(pTHX)
     STRLEN len;
     GV *gv = Nullgv;
     GV **gvp = 0;
+    bool bof = FALSE;
 
     /* check if there's an identifier for us to look at */
     if (PL_pending_ident) {
@@ -2525,7 +2529,7 @@ Perl_yylex(pTHX)
            goto retry;
        }
        do {
-           bool bof = PL_rsfp ? TRUE : FALSE;
+           bof = PL_rsfp ? TRUE : FALSE;
            if (bof) {
 #ifdef PERLIO_IS_STDIO
 #  ifdef __GNU_LIBRARY__