[#42338] [Ruby 1.9-Bug#3907][Open] WIN32OLE_TYPELIB Can't load while envvar in the pathname . — Akio Tajima <redmine@...>
Bug #3907: WIN32OLE_TYPELIB Can't load while envvar in the pathname .
[#42345] [Ruby 1.9-Feature#3917][Open] [proposal] called_from() which is much faster than caller() — makoto kuwata <redmine@...>
Feature #3917: [proposal] called_from() which is much faster than caller()
ささだです。
桑田です。日本語が文字化けしてたようで申し訳ないです。
桑田さん
[#42369] [BUG: trunk] Lazy sweep and ObjectSpace.each_object — SASADA Koichi <ko1@...>
ささだです。
まつもと ゆきひろです
ささだです。
nariです。
ささだです。
[#42375] [Ruby 1.9-Feature#3946][Open] Array#packのqQ指定子に機種依存サイズフラグ!を追加 — Yui NARUSE <redmine@...>
Feature #3946: Array#packのqQ指定子に機種依存サイズフラグ!を追加
2010年10月14日15:36 Yui NARUSE <redmine@ruby-lang.org>:
(2010/10/14 21:07), Tanaka Akira wrote:
2010年10月14日21:29 NARUSE, Yui <naruse@airemix.jp>:
2010年10月18日13:26 Tanaka Akira <akr@fsij.org>:
2010年10月18日14:04 NARUSE, Yui <naruse@airemix.jp>:
チケット #3946 が更新されました。 (by Usaku NAKAMURA)
2010年11月25日10:57 Usaku NAKAMURA <redmine@ruby-lang.org>:
こんにちは、なかむら(う)です。
2012年2月9日16:47 U.Nakamura <usa@garbagecollect.jp>:
[#42376] [Ruby 1.9-Feature#3947][Open] Array#packのにエンディアン指定修飾子</>を追加 — Yui NARUSE <redmine@...>
Feature #3947: Array#packのにエンディアン指定修飾子</>を追加
チケット #3947 が更新されました。 (by Yui NARUSE)
2010年10月14日21:36 Yui NARUSE <redmine@ruby-lang.org>:
2010年10月15日8:01 Tanaka Akira <akr@fsij.org>:
[#42403] [Ruby 1.9-Bug#3956][Open] format() の %a 指定子で幅指定が正しく機能しない — tadayoshi funaba <redmine@...>
Bug #3956: format() の %a 指定子で幅指定が正しく機能しない
2010年10月17日23:21 tadayoshi funaba <redmine@ruby-lang.org>:
> 2010年10月17日23:21 tadayoshi funaba <redmine@ruby-lang.org>:
> > 2010年10月17日23:21 tadayoshi funaba <redmine@ruby-lang.org>:
[#42420] [Ruby 1.9-Feature#3961][Open] printfと精度指定と負の値と — Yui NARUSE <redmine@...>
Feature #3961: printfと精度指定と負の値と
[#42464] [Ruby 1.9-Bug#3990][Assigned] tests of rexml/rss reports many errors and failures without iconv — Usaku NAKAMURA <redmine@...>
Bug #3990: tests of rexml/rss reports many errors and failures without iconv
チケット #3990 が更新されました。 (by Kouhei Sutou)
成瀬です。
須藤です。
(2010/11/02 21:50), Kouhei Sutou wrote:
須藤です。
成瀬です。
須藤です。
成瀬です。
須藤です。
(2010/11/06 12:10), Kouhei Sutou wrote:
須藤です。
成瀬です。
須藤です。
成瀬です。
須藤です。
成瀬です。
須藤です。
成瀬です。
須藤です。
成瀬です。
須藤です。
成瀬です。
須藤です。
成瀬です。
須藤です。
成瀬です。
須藤です。
> iconv.soがない環境でtest-allを実行すると、rexmlとrssのテストで
[#42469] Re: [ruby-cvs:36800] Ruby:r29603 (trunk): * object.c (Init_Object), constant.h, variable.c — Yukihiro Matsumoto <matz@...>
まつもと ゆきひろです
遠藤です。
[#42477] [Ruby 1.9-Feature#3995][Open] Hash#update with Enumerable — Nobuyoshi Nakada <redmine@...>
Feature #3995: Hash#update with Enumerable
[#42480] memory profiler for test-all — SASADA Koichi <ko1@...>
ささだです。
ささだです。
[ruby-dev:42477] [Ruby 1.9-Feature#3995][Open] Hash#update with Enumerable
Feature #3995: Hash#update with Enumerable http://redmine.ruby-lang.org/issues/show/3995 起票者: Nobuyoshi Nakada ステータス: Open, 優先度: Normal [ruby-dev:42476]でMLからの登録に失敗したので再登録します 今のところHash#updateはHashしか受け付けませんが、Enumerableまで 受け付けるように拡張するのはどうでしょうか。 ---------------------------------------- http://redmine.ruby-lang.org
Attachments (1)
diff --git i/hash.c w/hash.c
index 873219a..8d0c72a 100644
--- i/hash.c
+++ w/hash.c
@@ -1748,6 +1748,45 @@ rb_hash_update_block_i(VALUE key, VALUE value, VALUE hash)
return ST_CONTINUE;
}
+static VALUE
+rb_enum_update_i(VALUE obj, VALUE hash, int argc, VALUE *argv)
+{
+ if (argc == 1 && RB_TYPE_P(obj, T_ARRAY)) {
+ argc = RARRAY_LEN(obj);
+ argv = RARRAY_PTR(obj);
+ }
+ if (argc == 2) {
+ st_insert(RHASH(hash)->ntbl, argv[0], argv[1]);
+ }
+ return Qnil;
+}
+
+static VALUE
+rb_enum_update_block_i(VALUE obj, VALUE hash, int argc, VALUE *argv)
+{
+ VALUE key, value = Qundef, oldval;
+ if (argc == 1 && RB_TYPE_P(obj, T_ARRAY)) {
+ argc = RARRAY_LEN(obj);
+ argv = RARRAY_PTR(obj);
+ }
+ switch (argc) {
+ case 2:
+ value = argv[1];
+ case 1:
+ key = argv[0];
+ oldval = rb_hash_lookup2(hash, key, Qundef);
+ if (oldval != Qundef) {
+ value = rb_yield_values(argc + 1, key, oldval, value);
+ }
+ else if (value == Qundef) {
+ value = rb_yield(key);
+ }
+ st_insert(RHASH(hash)->ntbl, key, value);
+ break;
+ }
+ return Qnil;
+}
+
/*
* call-seq:
* hsh.merge!(other_hash) -> hsh
@@ -1769,13 +1808,36 @@ rb_hash_update_block_i(VALUE key, VALUE value, VALUE hash)
* h2 = { "b" => 254, "c" => 300 }
* h1.merge!(h2) { |key, v1, v2| v1 }
* #=> {"a"=>100, "b"=>200, "c"=>300}
+ *
+ * If <i>other_hash</i> is not a Hash but an Enumerable, its #each
+ * method should yield [key, newval] pairs or mere key. In the latter
+ * case, thegiven block is always called regardless oldval, but without
+ * newval.
+ *
+ * h1 = { "a" => 100, "b" => 200 }
+ * e1 = [["b", 254], ["c", 300]]
+ * h1.merge!(e1) { |key, *v| v }
+ * #=> {"a"=>100, "b"=>[200,254], "c"=>300}
+ *
+ * h1 = { "a" => 100, "b" => 200 }
+ * e1 = [["b"], ["c"]]
+ * h1.merge!(e1) { |key, v1, v2| v1 }
+ * #=> {"a"=>100, "b"=>[200], "c"=>[]}
*/
static VALUE
rb_hash_update(VALUE hash1, VALUE hash2)
{
+ VALUE tmp;
rb_hash_modify(hash1);
- hash2 = to_hash(hash2);
+ tmp = rb_check_hash_type(hash2);
+ if (NIL_P(tmp)) {
+ VALUE (*bfunc)(ANYARGS) = rb_block_given_p() ?
+ rb_enum_update_block_i : rb_enum_update_i;
+ rb_each_call(hash2, 0, 0, bfunc, hash1);
+ return hash1;
+ }
+ hash2 = tmp;
if (rb_block_given_p()) {
rb_hash_foreach(hash2, rb_hash_update_block_i, hash1);
}
diff --git i/include/ruby/ruby.h w/include/ruby/ruby.h
index 4a3e0ff..aa7808b 100644
--- i/include/ruby/ruby.h
+++ w/include/ruby/ruby.h
@@ -1164,6 +1164,7 @@ PRINTF_ARGS(void rb_compile_warn(const char *, int, const char*, ...), 3, 4);
typedef VALUE rb_block_call_func(VALUE, VALUE, int, VALUE*);
VALUE rb_each(VALUE);
+VALUE rb_each_call(VALUE,int,VALUE*,VALUE(*)(ANYARGS),VALUE);
VALUE rb_yield(VALUE);
VALUE rb_yield_values(int n, ...);
VALUE rb_yield_values2(int n, const VALUE *argv);
diff --git i/vm_eval.c w/vm_eval.c
index 05fd3fa..6f93897 100644
--- i/vm_eval.c
+++ w/vm_eval.c
@@ -947,6 +947,12 @@ rb_each(VALUE obj)
return rb_call(obj, idEach, 0, 0, CALL_FCALL);
}
+VALUE
+rb_each_call(VALUE obj, int argc, VALUE *argv, VALUE (*bl_proc)(ANYARGS), VALUE arg)
+{
+ return rb_block_call(obj, idEach, argc, argv, bl_proc, arg);
+}
+
static VALUE
eval_string_with_cref(VALUE self, VALUE src, VALUE scope, NODE *cref, const char *volatile file, volatile int line)
{