From 764c6a285e26ba7261cb9c39d4263d2be081e481 Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 4 Sep 2000 08:24:09 +0000 Subject: matz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@927 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 29 ++++++++++++++++++++++++++-- README.jp | 2 +- hash.c | 4 +++- io.c | 2 +- parse.y | 58 +++++++++++++++++++++++++++++++++++++++---------------- ruby.1 | 6 +++--- win32/config.h.in | 1 + 7 files changed, 77 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5480cfaced..09d8619903 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,14 +1,39 @@ +Mon Sep 4 12:58:31 2000 Yukihiro Matsumoto + + * stable version 1.6.0 released. + Mon Sep 4 13:40:40 2000 WATANABE Hirofumi * configure.in: renamed libruby.a to libruby.{cygwin,mingw32}.a on cygwin and mingw32. -Fri Sep 1 10:36:45 2000 Yukihiro Matsumoto +Sun Sep 3 23:44:04 2000 Noriaki Harada - * stable version 1.6.0 released. + * io.c (NO_SAFE_RENAME): for BeOS too. + +Sun Sep 3 11:31:53 2000 Takaaki Tateishi + + * parse.y (rescue): no assignment was done if rescue body as + empty. + +Sat Sep 2 10:52:21 2000 Yukihiro Matsumoto + + * parse.y (call_args,aref_args): block_call can be the last + argument. + + * parse.y (COND_PUSH,COND_POP): maintain condition stack to allow + kDO2 in parentheses in while/until/for conditions. + + * parse.y (yylex): generate kDO2 for EXPR_ARG outside of + while/until/for condition. Fri Sep 1 10:36:29 2000 Yukihiro Matsumoto + * parse.y (aref_args,opt_call_args): add block_call to allow a + method without parentheses and with block as a last argument. + + * hash.c (rb_hash_sort): should not retrun nil. + * re.c (match_aref): should use rb_reg_nth_match(). * eval.c (POP_SCOPE): recycled scopes too much diff --git a/README.jp b/README.jp index e4c8a42eaf..fccedb2f99 100644 --- a/README.jp +++ b/README.jp @@ -191,7 +191,7 @@ Public License) * 著者 -コメント,バグレポートその他は matz@zetabis.com まで. +コメント,バグレポートその他は matz@zetabits.com まで. ------------------------------------------------------- created at: Thu Aug 3 11:57:36 JST 1995 Local variables: diff --git a/hash.c b/hash.c index 0d65dc9d43..3ff58cc41c 100644 --- a/hash.c +++ b/hash.c @@ -613,7 +613,9 @@ static VALUE rb_hash_sort(hash) VALUE hash; { - return rb_ary_sort_bang(rb_hash_to_a(hash)); + VALUE entries = rb_hash_to_a(hash); + rb_ary_sort_bang(entries); + return entries; } static int diff --git a/io.c b/io.c index 7c2a89c7be..e61314a1fb 100644 --- a/io.c +++ b/io.c @@ -19,7 +19,7 @@ #include #include -#if defined(MSDOS) || defined(__BOW__) || defined(__CYGWIN__) || defined(NT) || defined(__human68k__) || defined(__EMX__) +#if defined(MSDOS) || defined(__BOW__) || defined(__CYGWIN__) || defined(NT) || defined(__human68k__) || defined(__EMX__) || defined(__BEOS__) # define NO_SAFE_RENAME #endif diff --git a/parse.y b/parse.y index 5580500f91..2912dbd365 100644 --- a/parse.y +++ b/parse.y @@ -58,6 +58,17 @@ static enum lex_state { } lex_state; static int cond_nest = 0; +static unsigned long cond_stack = 0; +#define COND_PUSH do {\ + cond_nest++;\ + cond_stack = (cond_stack<<1)|1;\ +} while(0) +#define COND_POP do {\ + cond_nest--;\ + cond_stack >>= 1;\ +} while (0) +#define IN_COND (cond_nest > 0 && (cond_stack&1)) + static int class_nest = 0; static int in_single = 0; static int compile_for_eval = 0; @@ -214,8 +225,6 @@ static void top_local_setup(); * precedence table */ -/*%nonassoc kDO -%nonassoc kDO2*/ %left kIF_MOD kUNLESS_MOD kWHILE_MOD kUNTIL_MOD kRESCUE_MOD %left kOR kAND %right kNOT @@ -859,15 +868,19 @@ aref_args : none { $$ = NEW_LIST($1); } + | args ',' command_call opt_nl + { + $$ = list_append($1, $3); + } | block_call opt_nl { $$ = NEW_LIST($1); } - | args opt_nl + | args ',' block_call opt_nl { - $$ = $1; + $$ = list_append($1, $3); } - | args ',' opt_nl + | args trailer { $$ = $1; } @@ -876,11 +889,7 @@ aref_args : none value_expr($4); $$ = arg_concat($1, $4); } - | assocs - { - $$ = NEW_LIST(NEW_HASH($1)); - } - | assocs ',' + | assocs trailer { $$ = NEW_LIST(NEW_HASH($1)); } @@ -896,6 +905,10 @@ opt_call_args : none { $$ = NEW_LIST($1); } + | args ',' block_call + { + $$ = list_append($1, $3); + } call_args : command_call { @@ -1152,7 +1165,7 @@ primary : literal $$ = NEW_UNLESS(cond($2), $4, $5); fixpos($$, $2); } - | kWHILE {cond_nest++;} expr do { cond_nest--; } + | kWHILE {COND_PUSH;} expr do {COND_POP;} compstmt kEND { @@ -1160,7 +1173,7 @@ primary : literal $$ = NEW_WHILE(cond($3), $6, 1); fixpos($$, $3); } - | kUNTIL {cond_nest++;} expr do { cond_nest--; } + | kUNTIL {COND_PUSH;} expr do {COND_POP;} compstmt kEND { @@ -1176,7 +1189,7 @@ primary : literal $$ = NEW_CASE($2, $3); fixpos($$, $2); } - | kFOR block_var kIN {cond_nest++;} expr do {cond_nest--;} + | kFOR block_var kIN {COND_PUSH;} expr do {COND_POP;} compstmt kEND { @@ -1442,8 +1455,7 @@ method_call : operation '(' opt_call_args close_paren close_paren : ')' { - if (cond_nest == 0) - lex_state = EXPR_PAREN; + if (!IN_COND) lex_state = EXPR_PAREN; } stmt_rhs : block_call @@ -1484,7 +1496,7 @@ rescue : kRESCUE exc_list exc_var then compstmt rescue { - if ($3 && $5) { + if ($3) { $3 = node_assign($3, NEW_GVAR(rb_intern("$!"))); $5 = block_append($3, $5); } @@ -1908,6 +1920,7 @@ yycompile(f, line) rb_gc(); ruby_in_compile = 0; cond_nest = 0; + cond_stack = 0; class_nest = 0; in_single = 0; cur_mid = 0; @@ -3198,7 +3211,13 @@ yylex() case ']': case '}': + lex_state = EXPR_END; + return c; + case ')': + if (cond_nest > 0) { + cond_stack >>= 1; + } lex_state = EXPR_END; return c; @@ -3264,6 +3283,9 @@ yylex() return '~'; case '(': + if (cond_nest > 0) { + cond_stack = (cond_stack<<1)|0; + } if (lex_state == EXPR_BEG || lex_state == EXPR_MID) { c = tLPAREN; } @@ -3513,7 +3535,9 @@ yylex() if (state == EXPR_FNAME) { yylval.id = rb_intern(kw->name); } - if (state == EXPR_PAREN && kw->id[0] == kDO) { + if (kw->id[0] == kDO && + (state == EXPR_PAREN || + (!IN_COND && state == EXPR_ARG))) { return kDO2; } return kw->id[state != EXPR_BEG]; diff --git a/ruby.1 b/ruby.1 index d81833b7f7..27ce207df8 100644 --- a/ruby.1 +++ b/ruby.1 @@ -1,6 +1,6 @@ -.\"Ruby is copyrighted by Yukihiro Matsumoto . +.\"Ruby is copyrighted by Yukihiro Matsumoto . .na -.TH RUBY 1 "ruby 1.5" "5/Nov/99" "Ruby Programmers Reference Guide" +.TH RUBY 1 "ruby 1.6" "2000-09-04" "Ruby Programmers Reference Guide" .SH NAME ruby - Interpreted object-oriented scripting language .SH SYNOPSIS @@ -288,4 +288,4 @@ state messages during compiling scripts. You don't have to specify this switch, unless you are going to debug the Ruby interpreter. .PP .SH AUTHOR - Ruby is designed and implemented by Yukihiro Matsumoto . + Ruby is designed and implemented by Yukihiro Matsumoto . diff --git a/win32/config.h.in b/win32/config.h.in index b56238e869..9a1c24cd15 100644 --- a/win32/config.h.in +++ b/win32/config.h.in @@ -38,6 +38,7 @@ #define RSHIFT(x,y) ((x)>>y) #define FILE_COUNT _cnt +#define DEFAULT_KCODE KCODE_NONE #define DLEXT ".so" #define DLEXT2 ".dll" #define RUBY_LIB "/lib/ruby/1.6" -- cgit v1.2.3