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

* 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
This commit is contained in:
matz 2001-06-01 06:47:32 +00:00
parent df2c6aef1e
commit 353650e6b4
5 changed files with 30 additions and 12 deletions

View file

@ -1,9 +1,22 @@
Fri Jun 1 15:01:40 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* 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 <eban@ruby-lang.org>
* configure.in: use waitpid on mingw32.
* ext/dbm/extconf.rb: include <ndbm.h>, not <gdbm.h>.
Thu May 31 18:34:57 2001 K.Kosako <kosako@sofnec.co.jp>
* file.c (rb_file_s_unlink): should not allow if $SAFE >= 2.
Thu May 31 17:23:25 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* range.c (Init_Range): define "to_ary".
Thu May 31 13:30:25 2001 WATANABE Hirofumi <eban@ruby-lang.org>
* mkconfig.rb, ext/configsub.rb: VERSION -> RUBY_VERSION.

View file

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

1
file.c
View file

@ -1246,6 +1246,7 @@ rb_file_s_unlink(klass, args)
{
int n;
rb_secure(2);
n = apply2files(unlink_internal, args, 0);
return INT2FIX(n);
}

21
parse.y
View file

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

View file

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