diff --git a/ChangeLog b/ChangeLog index 91256c923f..71ad3b0c6b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,8 +3,14 @@ Wed Apr 02 15:11:23 2003 Nobuyoshi Nakada * 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 + + * eval.c (rb_f_missing): use "inspect" for T_OBJECT as well. + Mon Mar 31 10:50:48 2003 Yukihiro Matsumoto + * 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 diff --git a/array.c b/array.c index 759c4a3536..74bf094f51 100644 --- a/array.c +++ b/array.c @@ -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); diff --git a/eval.c b/eval.c index d361bd57d7..8706984537 100644 --- a/eval.c +++ b/eval.c @@ -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 diff --git a/hash.c b/hash.c index a2fa1fdcdf..d07530a834 100644 --- a/hash.c +++ b/hash.c @@ -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); diff --git a/io.c b/io.c index a148434fa0..e9a4ced2c0 100644 --- a/io.c +++ b/io.c @@ -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); diff --git a/numeric.c b/numeric.c index e3344497c5..fe4b0308f3 100644 --- a/numeric.c +++ b/numeric.c @@ -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);