This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
pod fixes (from Abigail and M J T Guy)
[perl5.git] / toke.c
diff --git a/toke.c b/toke.c
index 22db523..3410ab5 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -1,6 +1,6 @@
 /*    toke.c
  *
- *    Copyright (c) 1991-1999, Larry Wall
+ *    Copyright (c) 1991-2000, Larry Wall
  *
  *    You may distribute under the terms of either the GNU General Public
  *    License or the Artistic License, as specified in the README file.
@@ -376,6 +376,15 @@ Perl_lex_start(pTHX_ SV *line)
     SAVEI32(PL_lex_state);
     SAVEVPTR(PL_lex_inpat);
     SAVEI32(PL_lex_inwhat);
+    if (PL_lex_state == LEX_KNOWNEXT) {
+       I32 toke = PL_nexttoke;
+       while (--toke >= 0) {
+           SAVEI32(PL_nexttype[toke]);
+           SAVEVPTR(PL_nextval[toke]);
+       }
+       SAVEI32(PL_nexttoke);
+       PL_nexttoke = 0;
+    }
     SAVECOPLINE(PL_curcop);
     SAVEPPTR(PL_bufptr);
     SAVEPPTR(PL_bufend);
@@ -1352,12 +1361,6 @@ S_scan_const(pTHX_ char *start)
                        yyerror("Missing right brace on \\x{}");
                        e = s;
                    }
-                   if (!utf) {
-                       dTHR;
-                       if (ckWARN(WARN_UTF8))
-                           Perl_warner(aTHX_ WARN_UTF8,
-                                  "Use of \\x{} without utf8 declaration");
-                   }
                    /* note: utf always shorter than hex */
                    d = (char*)uv_to_utf8((U8*)d,
                                          (UV)scan_hex(s + 1, e - s - 1, &len));
@@ -6887,6 +6890,7 @@ Perl_scan_num(pTHX_ char *start)
                U8 tmpbuf[10];
                U8 *tmpend;
                NV nshift = 1.0;
+               bool utf8 = FALSE;
                s++;                            /* get past 'v' */
 
                sv = NEWSV(92,5);
@@ -6901,7 +6905,14 @@ Perl_scan_num(pTHX_ char *start)
                    while (isDIGIT(*pos))
                        pos++;
 
-                   tmpend = uv_to_utf8(tmpbuf, rev);
+                   if (rev > 127) {
+                       tmpend = uv_to_utf8(tmpbuf, rev);
+                       utf8 = TRUE;
+                   }
+                   else {
+                       tmpbuf[0] = (U8)rev;
+                       tmpend = &tmpbuf[1];
+                   }
                    *tmpend = '\0';
                    sv_catpvn(sv, (const char*)tmpbuf, tmpend - tmpbuf);
                    if (rev > 0)
@@ -6914,6 +6925,7 @@ Perl_scan_num(pTHX_ char *start)
                rev = atoi(s);
                s = pos;
                tmpend = uv_to_utf8(tmpbuf, rev);
+               utf8 = utf8 || rev > 127;
                *tmpend = '\0';
                sv_catpvn(sv, (const char*)tmpbuf, tmpend - tmpbuf);
                if (rev > 0)
@@ -6922,7 +6934,8 @@ Perl_scan_num(pTHX_ char *start)
                SvPOK_on(sv);
                SvNOK_on(sv);
                SvREADONLY_on(sv);
-               SvUTF8_on(sv);
+               if (utf8)
+                   SvUTF8_on(sv);
            }
        }
        break;