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

* 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
This commit is contained in:
matz 2004-02-26 17:15:00 +00:00
parent 52e0246b61
commit aba4666e19
5 changed files with 30 additions and 15 deletions

View file

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

2
enum.c
View file

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

14
eval.c
View file

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

11
hash.c
View file

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

View file

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