diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-02-26 17:15:00 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-02-26 17:15:00 +0000 |
commit | aba4666e197331362f4a53b37bc21909144a3494 (patch) | |
tree | 9a59a2a739ca7ddbf1d798c7b5ebf66fd927944f | |
parent | 52e0246b61c3eb9871761692704e41687f8437c0 (diff) |
* eval.c (localjump_destination): lambda should not interfere
return from the yielded block.
* hash.c (delete_if_i): use st_delete_safe() (via
rb_hash_delete()) instead of returning ST_DELETE.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | enum.c | 2 | ||||
-rw-r--r-- | eval.c | 14 | ||||
-rw-r--r-- | hash.c | 11 | ||||
-rw-r--r-- | misc/ruby-mode.el | 8 |
5 files changed, 30 insertions, 15 deletions
@@ -1,3 +1,8 @@ +Fri Feb 27 02:10:49 2004 Yukihiro Matsumoto <matz@ruby-lang.org> + + * eval.c (localjump_destination): lambda should not interfere + return from the yielded block. + Fri Feb 27 00:53:49 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp> * lib/drb/drb.rb, test/drb/drbtest.rb: require drb/eq.rb by default @@ -7,6 +12,11 @@ Thu Feb 26 12:15:02 2004 Nobuyoshi Nakada <nobu@ruby-lang.org> * win32/win32.c (make_cmdvector): adjust successive double-quote handling. +Thu Feb 26 09:42:56 2004 Yukihiro Matsumoto <matz@ruby-lang.org> + + * hash.c (delete_if_i): use st_delete_safe() (via + rb_hash_delete()) instead of returning ST_DELETE. + Thu Feb 26 02:35:10 2004 Nobuyoshi Nakada <nobu@ruby-lang.org> * process.c (rb_f_exec): get rid of SEGV when exec failed for command @@ -661,7 +661,7 @@ min_ii(i, memo) * * a = %w(albatross dog horse) * a.min #=> "albatross" - * a.max {|a,b| a.length <=> b.length } #=> "dog" + * a.min {|a,b| a.length <=> b.length } #=> "dog" */ static VALUE @@ -912,6 +912,7 @@ static struct tag *prot_tag; #define PROT_ITER INT2FIX(1) /* 3 */ #define PROT_CALL INT2FIX(2) /* 5 */ #define PROT_PCALL INT2FIX(3) /* 7 */ +#define PROT_YIELD INT2FIX(4) /* 9 */ #define EXEC_TAG() (FLUSH_REGISTER_WINDOWS, setjmp(prot_tag->buf)) @@ -4514,10 +4515,15 @@ localjump_destination(state, retval) { struct tag *tt = prot_tag; VALUE tag = (state == TAG_BREAK) ? PROT_ITER : PROT_FUNC; + int uniq = 0; if (retval == Qundef) retval = Qnil; while (tt) { - if (tt->tag == PROT_PCALL || (tt->tag == PROT_THREAD && state == TAG_BREAK) || + if (tt->tag == PROT_YIELD) { + uniq = tt->frame->uniq; + } + if ((tt->tag == PROT_THREAD && state == TAG_BREAK) || + (tt->tag == PROT_PCALL && uniq == 0) || (tt->tag == PROT_CALL || tt->tag == tag) && tt->frame->uniq == ruby_frame->uniq) { tt->dst = (VALUE)ruby_frame->uniq; tt->retval = retval; @@ -4639,7 +4645,7 @@ rb_yield_0(val, self, klass, flags, avalue) ruby_current_node = node; PUSH_ITER(block->iter); - PUSH_TAG(PROT_NONE); + PUSH_TAG(PROT_YIELD); if ((state = EXEC_TAG()) == 0) { redo: if (nd_type(node) == NODE_CFUNC || nd_type(node) == NODE_IFUNC) { @@ -7988,7 +7994,7 @@ proc_invoke(proc, args, self, klass) proc_set_safe_level(proc); result = rb_yield_0(args, self, (self!=Qundef)?CLASS_OF(self):0, pcall, avalue); } - else if (pcall || orphan || TAG_DST()) { + else if (TAG_DST()) { result = prot_tag->retval; } POP_TAG(); @@ -8008,7 +8014,6 @@ proc_invoke(proc, args, self, klass) /* fall through */ case TAG_BREAK: case TAG_RETURN: - if (pcall) break; if (orphan) { /* orphan block */ char mesg[32]; snprintf(mesg, sizeof mesg, "%s from proc-closure", @@ -8016,6 +8021,7 @@ proc_invoke(proc, args, self, klass) localjump_error(mesg, result, state); } if (result != Qundef) { + if (pcall) break; localjump_destination(state, result); } default: @@ -679,12 +679,13 @@ rb_hash_shift(hash) } static enum st_retval -delete_if_i(key, value) - VALUE key, value; +delete_if_i(key, value, hash) + VALUE key, value, hash; { if (key == Qundef) return ST_CONTINUE; - if (RTEST(rb_yield_values(2, key, value))) - return ST_DELETE; + if (RTEST(rb_yield_values(2, key, value))) { + rb_hash_delete(hash, key); + } return ST_CONTINUE; } @@ -705,7 +706,7 @@ rb_hash_delete_if(hash) VALUE hash; { rb_hash_modify(hash); - rb_hash_foreach(hash, delete_if_i, 0); + rb_hash_foreach(hash, delete_if_i, hash); return hash; } diff --git a/misc/ruby-mode.el b/misc/ruby-mode.el index f1762e6b5d..a52b00893d 100644 --- a/misc/ruby-mode.el +++ b/misc/ruby-mode.el @@ -683,11 +683,9 @@ The variable ruby-indent-level controls the amount of indentation. (setq end nil)) (goto-char (or end pos)) (skip-chars-backward " \t") - (and - (setq state (ruby-parse-region parse-start (point))) - (nth 0 state) - (setq begin (cdr (nth 1 state))) - (goto-char pos))) + (setq state (ruby-parse-region parse-start (point))) + (setq begin (or (nth 0 state) (cdr (nth 1 state)))) + (goto-char pos)) (or (bobp) (forward-char -1)) (and (or (and (looking-at ruby-symbol-re) |