1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
eban 2002-12-30 18:19:08 +00:00
parent 67a7c34524
commit c2e3d3971b
3 changed files with 20 additions and 14 deletions

View file

@ -1,3 +1,7 @@
Tue Dec 31 01:30:29 2002 WATANABE Hirofumi <eban@ruby-lang.org>
* parse.y (yylex): do not accept " __END__\n". ([ruby-dev:19245])
Mon Dec 30 21:10:59 2002 WATANABE Hirofumi <eban@ruby-lang.org>
* parse.y (yylex): use strncmp instead of strcmp.

24
parse.y
View file

@ -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;

View file

@ -1,11 +1,11 @@
#define RUBY_VERSION "1.8.0"
#define RUBY_RELEASE_DATE "2002-12-30"
#define RUBY_RELEASE_DATE "2002-12-31"
#define RUBY_VERSION_CODE 180
#define RUBY_RELEASE_CODE 20021230
#define RUBY_RELEASE_CODE 20021231
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8
#define RUBY_VERSION_TEENY 0
#define RUBY_RELEASE_YEAR 2002
#define RUBY_RELEASE_MONTH 12
#define RUBY_RELEASE_DAY 30
#define RUBY_RELEASE_DAY 31