summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authoreban <eban@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-12-30 18:19:08 +0000
committereban <eban@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-12-30 18:19:08 +0000
commitc2e3d3971be8cc5b2a5b7ab624e516cc0d1ce496 (patch)
tree78291bdeab4ffbe0341a95cf718cc5d330e112da /parse.y
parent67a7c345248496622e42bb742937128f160e0d6f (diff)
* parse.y (yylex): do not accept " __END__\n". ([ruby-dev:19245])
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3247 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y24
1 files changed, 13 insertions, 11 deletions
diff --git a/parse.y b/parse.y
index f98d6583e7..40ca42de47 100644
--- a/parse.y
+++ b/parse.y
@@ -3102,14 +3102,14 @@ whole_match_p(eos, len, indent)
int len, indent;
{
char *p = lex_pbeg;
+ int n;
if (indent) {
while (*p && ISSPACE(*p)) p++;
}
- if (strncmp(eos, p, len) == 0) {
- if (p[len] == '\n' || p[len] == '\r') return Qtrue;
- if (p + len == lex_pend) return Qtrue;
- }
+ n= lex_pend - (p + len);
+ if (n < 0 || n > 0 && p[len] != '\n' && p[len] != '\r') return Qfalse;
+ if (strncmp(eos, p, len) == 0) return Qtrue;
return Qfalse;
}
@@ -4206,6 +4206,15 @@ yylex()
}
break;
+ case '_':
+ if (lex_p - 1 == lex_pbeg && whole_match_p("__END__", 7, 0)) {
+ ruby__end__seen = 1;
+ lex_lastline = 0;
+ return -1;
+ }
+ newtok();
+ break;
+
default:
if (!is_identchar(c) || ISDIGIT(c)) {
rb_compile_error("Invalid char `\\%03o' in expression", c);
@@ -4321,13 +4330,6 @@ yylex()
}
}
tokfix();
- if (strncmp(tok(), "__END__", 7) == 0 &&
- (lex_p - lex_pbeg == 7 || lex_p - lex_pbeg == 8) &&
- (lex_pend == lex_p || *lex_p == '\n' || *lex_p == '\r')) {
- ruby__end__seen = 1;
- lex_lastline = 0;
- return -1;
- }
last_id = yylval.id = rb_intern(tok());
if ((dyna_in_block() && rb_dvar_defined(last_id)) || local_id(last_id)) {
lex_state = EXPR_END;