diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-04-03 05:25:00 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-04-03 05:25:00 +0000 |
commit | c94187bce08dc83ae0c3d30835a73eb6dfe4689e (patch) | |
tree | b5911b3405aec1bee504fe6ccfa044e9195d90f8 | |
parent | 153f513f4906aebb5e4b718b25011ddeb5769810 (diff) |
* eval.c (rb_f_missing): use "inspect" for T_OBJECT as well.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | array.c | 3 | ||||
-rw-r--r-- | eval.c | 8 | ||||
-rw-r--r-- | ext/tk/lib/tk.rb | 2 | ||||
-rw-r--r-- | hash.c | 1 | ||||
-rw-r--r-- | io.c | 13 | ||||
-rw-r--r-- | numeric.c | 2 |
7 files changed, 26 insertions, 9 deletions
@@ -3,8 +3,14 @@ Wed Apr 02 15:11:23 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net> * README.EXT, README.EXT.ja (3.3): clarified -1 as free for Data_Wrap_Struct(). [ruby-dev:19881] +Mon Mar 31 11:11:36 2003 Yukihiro Matsumoto <matz@ruby-lang.org> + + * eval.c (rb_f_missing): use "inspect" for T_OBJECT as well. + Mon Mar 31 10:50:48 2003 Yukihiro Matsumoto <matz@ruby-lang.org> + * eval.c (rb_f_missing): + * hash.c (env_reject_bang): untaint key string. * hash.c (env_delete_m): execute block only if deleting key does @@ -1915,6 +1915,8 @@ Init_Array() rb_define_alloc_func(rb_cArray, ary_alloc); rb_define_singleton_method(rb_cArray, "[]", rb_ary_s_create, -1); rb_define_method(rb_cArray, "initialize", rb_ary_initialize, -1); + rb_define_method(rb_cArray, "copy_object", rb_ary_replace, 1); + rb_define_method(rb_cArray, "to_s", rb_ary_to_s, 0); rb_define_method(rb_cArray, "inspect", rb_ary_inspect, 0); rb_define_method(rb_cArray, "to_a", rb_ary_to_a, 0); @@ -1948,7 +1950,6 @@ Init_Array() rb_define_method(rb_cArray, "rindex", rb_ary_rindex, 1); rb_define_method(rb_cArray, "indexes", rb_ary_indexes, -1); rb_define_method(rb_cArray, "indices", rb_ary_indexes, -1); - rb_define_method(rb_cArray, "copy_object", rb_ary_replace, 1); rb_define_method(rb_cArray, "join", rb_ary_join_m, -1); rb_define_method(rb_cArray, "reverse", rb_ary_reverse_m, 0); rb_define_method(rb_cArray, "reverse!", rb_ary_reverse_bang, 0); @@ -4509,11 +4509,11 @@ rb_f_missing(argc, argv, obj) case T_FALSE: desc = "false"; break; - case T_OBJECT: - d = rb_any_to_s(obj); - break; default: - d = rb_inspect(obj); + if (rb_respond_to(obj, rb_intern("inspect"))) + d = rb_inspect(obj); + else + d = rb_any_to_s(obj); break; } if (d) { diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb index 2e4d9d039e..0ffb0ee434 100644 --- a/ext/tk/lib/tk.rb +++ b/ext/tk/lib/tk.rb @@ -1270,7 +1270,7 @@ class TkVariable def ==(other) case other when TkVariable - self.equal(self) + self.equal(other) when String self.to_s == other when Integer @@ -1715,7 +1715,6 @@ Init_Hash() rb_define_alloc_func(rb_cHash, hash_alloc); rb_define_singleton_method(rb_cHash, "[]", rb_hash_s_create, -1); rb_define_method(rb_cHash,"initialize", rb_hash_initialize, -1); - rb_define_method(rb_cHash,"copy_object", rb_hash_replace, 1); rb_define_method(rb_cHash,"rehash", rb_hash_rehash, 0); @@ -2886,6 +2886,17 @@ rb_io_s_new(argc, argv, klass) return rb_class_new_instance(argc, argv, klass); } +static VALUE +rb_io_s_for_fd(argc, argv, klass) + int argc; + VALUE *argv; + VALUE klass; +{ + VALUE io = rb_obj_alloc(klass); + rb_io_initialize(argc, argv, io); + return io; +} + static int binmode = 0; static VALUE @@ -3944,7 +3955,7 @@ Init_IO() rb_define_singleton_method(rb_cIO, "new", rb_io_s_new, -1); rb_define_singleton_method(rb_cIO, "open", rb_io_s_open, -1); rb_define_singleton_method(rb_cIO, "sysopen", rb_io_s_sysopen, -1); - rb_define_singleton_method(rb_cIO, "for_fd", rb_class_new_instance, -1); + rb_define_singleton_method(rb_cIO, "for_fd", rb_io_s_for_fd, -1); rb_define_singleton_method(rb_cIO, "popen", rb_io_s_popen, -1); rb_define_singleton_method(rb_cIO, "foreach", rb_io_s_foreach, -1); rb_define_singleton_method(rb_cIO, "readlines", rb_io_s_readlines, -1); @@ -1721,8 +1721,8 @@ Init_Numeric() rb_cNumeric = rb_define_class("Numeric", rb_cObject); rb_include_module(rb_cNumeric, rb_mComparable); - rb_define_method(rb_cNumeric, "coerce", num_coerce, 1); rb_define_method(rb_cNumeric, "copy_object", num_copy_object, 1); + rb_define_method(rb_cNumeric, "coerce", num_coerce, 1); rb_define_method(rb_cNumeric, "+@", num_uplus, 0); rb_define_method(rb_cNumeric, "-@", num_uminus, 0); |