ruby-changes:9919
From: yugui <ko1@a...>
Date: Mon, 12 Jan 2009 22:32:58 +0900 (JST)
Subject: [ruby-changes:9919] Ruby:r21459 (ruby_1_9_1): merges r21424 from trunk into ruby_1_9_1.
yugui 2009-01-12 22:32:30 +0900 (Mon, 12 Jan 2009) New Revision: 21459 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=21459 Log: merges r21424 from trunk into ruby_1_9_1. * hash.c (rb_hash_s_create): set nil as the value if assoc length is not enough. [ruby-core:21249] Modified files: branches/ruby_1_9_1/ChangeLog branches/ruby_1_9_1/hash.c Index: ruby_1_9_1/ChangeLog =================================================================== --- ruby_1_9_1/ChangeLog (revision 21458) +++ ruby_1_9_1/ChangeLog (revision 21459) @@ -1,3 +1,8 @@ +Sun Jan 11 09:47:30 2009 Nobuyoshi Nakada <nobu@r...> + + * hash.c (rb_hash_s_create): set nil as the value if assoc length + is not enough. [ruby-core:21249] + Sat Jan 10 20:26:17 2009 Tanaka Akira <akr@f...> * version.h: make version string succinct: Index: ruby_1_9_1/hash.c =================================================================== --- ruby_1_9_1/hash.c (revision 21458) +++ ruby_1_9_1/hash.c (revision 21459) @@ -348,10 +348,16 @@ hash = hash_alloc(klass); for (i = 0; i < RARRAY_LEN(tmp); ++i) { VALUE v = rb_check_array_type(RARRAY_PTR(tmp)[i]); - + VALUE key, val = Qnil; + if (NIL_P(v)) continue; - if (RARRAY_LEN(v) < 1 || 2 < RARRAY_LEN(v)) continue; - rb_hash_aset(hash, RARRAY_PTR(v)[0], RARRAY_PTR(v)[1]); + switch (RARRAY_LEN(v)) { + case 2: + val = RARRAY_PTR(v)[1]; + case 1: + key = RARRAY_PTR(v)[0]; + rb_hash_aset(hash, key, val); + } } return hash; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/