From 353650e6b486482a256250611d73b668f3fa8dbc Mon Sep 17 00:00:00 2001 From: matz Date: Fri, 1 Jun 2001 06:47:32 +0000 Subject: * parse.y (yylex): fixed 'print CGI::bar() {}, "\n"' syntax breakage, adding new lex_state status. sigh. [new] * file.c (rb_file_s_unlink): should not allow if $SAFE >= 2. * range.c (Init_Range): define "to_ary". git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 13 +++++++++++++ ext/tk/lib/tk.rb | 6 +++--- file.c | 1 + parse.y | 21 ++++++++++++--------- range.c | 1 + 5 files changed, 30 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index dddc8f2d5c..afb09101eb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,22 @@ +Fri Jun 1 15:01:40 2001 Yukihiro Matsumoto + + * parse.y (yylex): fixed 'print CGI::bar() {}, "\n"' syntax + breakage, adding new lex_state status. sigh. [new] + Fri Jun 1 11:21:04 2001 WATANABE Hirofumi * configure.in: use waitpid on mingw32. * ext/dbm/extconf.rb: include , not . +Thu May 31 18:34:57 2001 K.Kosako + + * file.c (rb_file_s_unlink): should not allow if $SAFE >= 2. + +Thu May 31 17:23:25 2001 Yukihiro Matsumoto + + * range.c (Init_Range): define "to_ary". + Thu May 31 13:30:25 2001 WATANABE Hirofumi * mkconfig.rb, ext/configsub.rb: VERSION -> RUBY_VERSION. diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb index 217c76f565..f10e8e23d8 100644 --- a/ext/tk/lib/tk.rb +++ b/ext/tk/lib/tk.rb @@ -1188,15 +1188,15 @@ class TkVariable end def to_i - Integer(number(value)) + number(value).to_i end def to_f - Float(number(value)) + number(value).to_f end def to_s - String(string(value)) + string(value).to_s end def inspect diff --git a/file.c b/file.c index 14c6d9271b..1cff4778ca 100644 --- a/file.c +++ b/file.c @@ -1246,6 +1246,7 @@ rb_file_s_unlink(klass, args) { int n; + rb_secure(2); n = apply2files(unlink_internal, args, 0); return INT2FIX(n); } diff --git a/parse.y b/parse.y index 1f79918d59..9696defde8 100644 --- a/parse.y +++ b/parse.y @@ -52,6 +52,7 @@ static enum lex_state { EXPR_END, /* newline significant, +/- is a operator. */ EXPR_ARG, /* newline significant, +/- is a operator. */ EXPR_CMDARG, /* newline significant, +/- is a operator. */ + EXPR_ENDARG, /* newline significant, +/- is a operator. */ EXPR_MID, /* newline significant, +/- is a operator. */ EXPR_FNAME, /* ignore newline, no reserved words. */ EXPR_DOT, /* right after `.' or `::', no reserved words. */ @@ -1089,13 +1090,13 @@ command_args : { } open_args : call_args - | tLPAREN_ARG ')' + | tLPAREN_ARG {lex_state = EXPR_ENDARG;} ')' { rb_warning("%s (...) interpreted as method call", rb_id2name(last_id)); $$ = 0; } - | tLPAREN_ARG call_args2 ')' + | tLPAREN_ARG call_args2 {lex_state = EXPR_ENDARG;} ')' { rb_warning("%s (...) interpreted as method call", rb_id2name(last_id)); @@ -1185,7 +1186,7 @@ primary : literal } fixpos($$, $2); } - | tLPAREN_ARG expr ')' + | tLPAREN_ARG expr {lex_state = EXPR_ENDARG;} ')' { rb_warning("%s (...) interpreted as command call", rb_id2name(last_id)); $$ = $2; @@ -3008,7 +3009,9 @@ yylex() case '<': c = nextc(); if (c == '<' && - lex_state != EXPR_END && lex_state != EXPR_CLASS && + lex_state != EXPR_END && + lex_state != EXPR_ENDARG + && lex_state != EXPR_CLASS && (!IS_ARG() || space_seen)) { int c2 = nextc(); int indent = 0; @@ -3067,7 +3070,7 @@ yylex() return parse_qstring(c,0); case '?': - if (lex_state == EXPR_END) { + if (lex_state == EXPR_END || lex_state == EXPR_ENDARG) { lex_state = EXPR_BEG; return '?'; } @@ -3390,7 +3393,7 @@ yylex() return tCOLON2; } pushback(c); - if (lex_state == EXPR_END || ISSPACE(c)) { + if (lex_state == EXPR_END || lex_state == EXPR_ENDARG || ISSPACE(c)) { lex_state = EXPR_BEG; return ':'; } @@ -3484,10 +3487,10 @@ yylex() case '{': if (!IS_ARG()) { - if (lex_state != EXPR_END) - c = tLBRACE; - if (space_seen && CMDARG_P()) + if (space_seen && lex_state == EXPR_ENDARG) c = tLBRACE_ARG; + if (lex_state != EXPR_END && lex_state != EXPR_ENDARG) + c = tLBRACE; } COND_PUSH(0); CMDARG_PUSH(0); diff --git a/range.c b/range.c index f6760ec9fa..128733d34e 100644 --- a/range.c +++ b/range.c @@ -424,6 +424,7 @@ Init_Range() rb_define_method(rb_cRange, "end", range_last, 0); rb_define_method(rb_cRange, "to_s", range_to_s, 0); rb_define_method(rb_cRange, "inspect", range_inspect, 0); + rb_define_alias(rb_cRange, "to_ary", "to_a"); rb_define_method(rb_cRange, "exclude_end?", range_exclude_end_p, 0); -- cgit v1.2.3