Commit 9a5e93bf authored by NAKAMURA Usaku's avatar NAKAMURA Usaku

``__END__'' must start at the beginning of the line.

parent daedb2b9
...@@ -3125,10 +3125,11 @@ enum string_type { ...@@ -3125,10 +3125,11 @@ enum string_type {
str_dsym = (STR_FUNC_SYMBOL|STR_FUNC_EXPAND) str_dsym = (STR_FUNC_SYMBOL|STR_FUNC_EXPAND)
}; };
static void static int
newtok(parser_state *p) newtok(parser_state *p)
{ {
p->bidx = 0; p->bidx = 0;
return p->column - 1;
} }
static void static void
...@@ -3420,6 +3421,7 @@ parser_yylex(parser_state *p) ...@@ -3420,6 +3421,7 @@ parser_yylex(parser_state *p)
int space_seen = 0; int space_seen = 0;
int cmd_state; int cmd_state;
enum mrb_lex_state_enum last_state; enum mrb_lex_state_enum last_state;
int token_column;
if (p->sterm) { if (p->sterm) {
return parse_string(p, p->sterm); return parse_string(p, p->sterm);
...@@ -3675,7 +3677,7 @@ parser_yylex(parser_state *p) ...@@ -3675,7 +3677,7 @@ parser_yylex(parser_state *p)
p->lstate = EXPR_VALUE; p->lstate = EXPR_VALUE;
return '?'; return '?';
} }
newtok(p); token_column = newtok(p);
// need support UTF-8 if configured // need support UTF-8 if configured
if ((isalnum(c) || c == '_')) { if ((isalnum(c) || c == '_')) {
int c2 = nextc(p); int c2 = nextc(p);
...@@ -3848,7 +3850,7 @@ parser_yylex(parser_state *p) ...@@ -3848,7 +3850,7 @@ parser_yylex(parser_state *p)
is_float = seen_point = seen_e = nondigit = 0; is_float = seen_point = seen_e = nondigit = 0;
p->lstate = EXPR_END; p->lstate = EXPR_END;
newtok(p); token_column = newtok(p);
if (c == '-' || c == '+') { if (c == '-' || c == '+') {
tokadd(p, c); tokadd(p, c);
c = nextc(p); c = nextc(p);
...@@ -4337,7 +4339,7 @@ parser_yylex(parser_state *p) ...@@ -4337,7 +4339,7 @@ parser_yylex(parser_state *p)
case '$': case '$':
p->lstate = EXPR_END; p->lstate = EXPR_END;
newtok(p); token_column = newtok(p);
c = nextc(p); c = nextc(p);
switch (c) { switch (c) {
case '_': /* $_: last read line string */ case '_': /* $_: last read line string */
...@@ -4415,7 +4417,7 @@ parser_yylex(parser_state *p) ...@@ -4415,7 +4417,7 @@ parser_yylex(parser_state *p)
case '@': case '@':
c = nextc(p); c = nextc(p);
newtok(p); token_column = newtok(p);
tokadd(p, '@'); tokadd(p, '@');
if (c == '@') { if (c == '@') {
tokadd(p, '@'); tokadd(p, '@');
...@@ -4437,7 +4439,7 @@ parser_yylex(parser_state *p) ...@@ -4437,7 +4439,7 @@ parser_yylex(parser_state *p)
break; break;
case '_': case '_':
newtok(p); token_column = newtok(p);
break; break;
default: default:
...@@ -4446,7 +4448,7 @@ parser_yylex(parser_state *p) ...@@ -4446,7 +4448,7 @@ parser_yylex(parser_state *p)
goto retry; goto retry;
} }
newtok(p); token_column = newtok(p);
break; break;
} }
...@@ -4455,8 +4457,8 @@ parser_yylex(parser_state *p) ...@@ -4455,8 +4457,8 @@ parser_yylex(parser_state *p)
c = nextc(p); c = nextc(p);
if (c < 0) break; if (c < 0) break;
} while (identchar(c)); } while (identchar(c));
if (p->column == 0 && p->bidx == 7 && (c < 0 || c == '\n') && if (token_column == 0 && toklen(p) == 7 && (c < 0 || c == '\n') &&
strncmp(tok(p), "__END__", p->bidx) == 0) strncmp(tok(p), "__END__", toklen(p)) == 0)
return -1; return -1;
switch (tok(p)[0]) { switch (tok(p)[0]) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment