/* 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.
#define LEX_FORMLINE 1
#define LEX_KNOWNEXT 0
-#ifdef I_FCNTL
-#include <fcntl.h>
-#endif
-#ifdef I_SYS_FILE
-#include <sys/file.h>
-#endif
-
/* XXX If this causes problems, set i_unistd=undef in the hint file. */
#ifdef I_UNISTD
# include <unistd.h> /* Needed for execv() */
dTHR;
char *t;
char *n;
+ char *e;
char ch;
- int sawline = 0;
CopLINE_inc(PL_curcop);
if (*s++ != '#')
return;
while (*s == ' ' || *s == '\t') s++;
- if (strnEQ(s, "line ", 5)) {
- s += 5;
- sawline = 1;
- }
+ if (strnEQ(s, "line", 4))
+ s += 4;
+ else
+ return;
+ if (*s == ' ' || *s == '\t')
+ s++;
+ else
+ return;
+ while (*s == ' ' || *s == '\t') s++;
if (!isDIGIT(*s))
return;
n = s;
s++;
while (*s == ' ' || *s == '\t')
s++;
- if (*s == '"' && (t = strchr(s+1, '"')))
+ if (*s == '"' && (t = strchr(s+1, '"'))) {
s++;
+ e = t + 1;
+ }
else {
- if (!sawline)
- return; /* false alarm */
for (t = s; !isSPACE(*t); t++) ;
+ e = t;
}
+ while (*e == ' ' || *e == '\t' || *e == '\r' || *e == '\f')
+ e++;
+ if (*e != '\n' && *e != '\0')
+ return; /* false alarm */
+
ch = *t;
*t = '\0';
if (t - s > 0)
if (*d == 'v')
d++;
for (; isDIGIT(*d) || *d == '_' || *d == '.'; d++);
- if ((*d == ';' || isSPACE(*d)) && *(skipspace(d)) != ',') {
+ if (*d == ';' || isSPACE(*d) || *d == '}' || !*d) {
s = scan_num(s);
/* real VERSION number -- GBARR */
version = yylval.opval;
++s;
if (*s == '{') {
char* e = strchr(s, '}');
+ UV uv;
if (!e) {
yyerror("Missing right brace on \\x{}");
e = s;
}
/* note: utf always shorter than hex */
- d = (char*)uv_to_utf8((U8*)d,
- (UV)scan_hex(s + 1, e - s - 1, &len));
+ uv = (UV)scan_hex(s + 1, e - s - 1, &len);
+ if (uv > 127) {
+ d = (char*)uv_to_utf8((U8*)d, uv);
+ has_utf = TRUE;
+ }
+ else
+ *d++ = (char)uv;
s = e + 1;
- has_utf = TRUE;
}
else {
+ /* XXX collapse this branch into the one above */
UV uv = (UV)scan_hex(s, 2, &len);
if (utf && PL_lex_inwhat == OP_TRANS &&
utf != (OPpTRANS_FROM_UTF|OPpTRANS_TO_UTF))
for (d = s; d < PL_bufend && (isSPACE(*d) || *d == '('); d++) ;
if (*d != '0' && isDIGIT(*d))
Perl_warner(aTHX_ WARN_OCTAL,
- "chmod: mode argument is missing initial 0");
+ "chmod() mode argument is missing initial 0");
}
LOP(OP_CHMOD,XTERM);
pos++;
if (*pos == '.' && isDIGIT(pos[1])) {
UV rev;
- U8 tmpbuf[10];
+ U8 tmpbuf[UTF8_MAXLEN];
U8 *tmpend;
NV nshift = 1.0;
+ bool utf8 = FALSE;
s++; /* get past 'v' */
sv = NEWSV(92,5);
while (isDIGIT(*pos))
pos++;
- tmpend = uv_to_utf8(tmpbuf, rev);
- *tmpend = '\0';
+ if (rev > 127) {
+ tmpend = uv_to_utf8(tmpbuf, rev);
+ utf8 = TRUE;
+ }
+ else {
+ tmpbuf[0] = (U8)rev;
+ tmpend = &tmpbuf[1];
+ }
sv_catpvn(sv, (const char*)tmpbuf, tmpend - tmpbuf);
if (rev > 0)
SvNVX(sv) += (NV)rev/nshift;
rev = atoi(s);
s = pos;
tmpend = uv_to_utf8(tmpbuf, rev);
- *tmpend = '\0';
+ utf8 = utf8 || rev > 127;
sv_catpvn(sv, (const char*)tmpbuf, tmpend - tmpbuf);
if (rev > 0)
SvNVX(sv) += (NV)rev/nshift;
SvPOK_on(sv);
SvNOK_on(sv);
SvREADONLY_on(sv);
- SvUTF8_on(sv);
+ if (utf8) {
+ SvUTF8_on(sv);
+ sv_utf8_downgrade(sv, TRUE);
+ }
}
}
break;
}
else if (yychar > 255)
where = "next token ???";
+#ifdef USE_PURE_BISON
+/* GNU Bison sets the value -2 */
+ else if (yychar == -2) {
+#else
else if ((yychar & 127) == 127) {
+#endif
if (PL_lex_state == LEX_NORMAL ||
(PL_lex_state == LEX_KNOWNEXT && PL_lex_defer == LEX_NORMAL))
where = "at end of line";