From 7194267b3bdf68ad75bd6bee8e7c6377f7b0ea2f Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 10 Apr 2000 05:48:43 +0000 Subject: 2000-04-10 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@661 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- object.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'object.c') diff --git a/object.c b/object.c index 1f11e96b7f..b2806da171 100644 --- a/object.c +++ b/object.c @@ -159,16 +159,16 @@ inspect_i(id, value, str) if (!rb_is_instance_id(id)) return ST_CONTINUE; if (RSTRING(str)->ptr[0] == '-') { RSTRING(str)->ptr[0] = '#'; - rb_str_cat(str, ": ", 2); + rb_str_cat2(str, ": "); } else { - rb_str_cat(str, ", ", 2); + rb_str_cat2(str, ", "); } ivname = rb_id2name(id); - rb_str_cat(str, ivname, strlen(ivname)); - rb_str_cat(str, "=", 1); + rb_str_cat2(str, ivname); + rb_str_cat2(str, "="); str2 = rb_inspect(value); - rb_str_cat(str, RSTRING(str2)->ptr, RSTRING(str2)->len); + rb_str_append(str, str2); OBJ_INFECT(str, str2); return ST_CONTINUE; @@ -179,7 +179,7 @@ inspect_obj(obj, str) VALUE obj, str; { st_foreach(ROBJECT(obj)->iv_tbl, inspect_i, str); - rb_str_cat(str, ">", 1); + rb_str_cat2(str, ">"); OBJ_INFECT(str, obj); return str; @@ -202,7 +202,7 @@ rb_obj_inspect(obj) return rb_str_new2(buf); } str = rb_str_new2("-<"); - rb_str_cat(str, b, strlen(b)); + rb_str_cat2(str, b); return rb_protect_inspect(inspect_obj, obj, str); } return rb_funcall(obj, rb_intern("to_s"), 0, 0); @@ -494,7 +494,7 @@ sym_to_i(sym) } static VALUE -sym_to_s(sym) +sym_inspect(sym) VALUE sym; { char *name, *buf; @@ -507,7 +507,7 @@ sym_to_s(sym) } static VALUE -sym_id2name(sym) +sym_to_s(sym) VALUE sym; { return rb_str_new2(rb_id2name(SYM2ID(sym))); @@ -1117,8 +1117,9 @@ Init_Object() rb_undef_method(CLASS_OF(rb_cSymbol), "new"); rb_define_method(rb_cSymbol, "type", sym_type, 0); rb_define_method(rb_cSymbol, "to_i", sym_to_i, 0); + rb_define_method(rb_cSymbol, "inspect", sym_inspect, 0); rb_define_method(rb_cSymbol, "to_s", sym_to_s, 0); - rb_define_method(rb_cSymbol, "id2name", sym_id2name, 0); + rb_define_method(rb_cSymbol, "id2name", sym_to_s, 0); rb_define_method(rb_cModule, "===", rb_mod_eqq, 1); rb_define_method(rb_cModule, "<=>", rb_mod_cmp, 1); -- cgit v1.2.3