object.c: preserve encodings
* object.c (inspect_i): preserve encodings in inspected result string. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48574 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f2fc80cebe
commit
d0ac6d5879
10
object.c
10
object.c
@ -489,8 +489,6 @@ inspect_i(st_data_t k, st_data_t v, st_data_t a)
|
|||||||
ID id = (ID)k;
|
ID id = (ID)k;
|
||||||
VALUE value = (VALUE)v;
|
VALUE value = (VALUE)v;
|
||||||
VALUE str = (VALUE)a;
|
VALUE str = (VALUE)a;
|
||||||
VALUE str2;
|
|
||||||
const char *ivname;
|
|
||||||
|
|
||||||
/* need not to show internal data */
|
/* need not to show internal data */
|
||||||
if (CLASS_OF(value) == 0) return ST_CONTINUE;
|
if (CLASS_OF(value) == 0) return ST_CONTINUE;
|
||||||
@ -502,12 +500,8 @@ inspect_i(st_data_t k, st_data_t v, st_data_t a)
|
|||||||
else {
|
else {
|
||||||
rb_str_cat2(str, ", ");
|
rb_str_cat2(str, ", ");
|
||||||
}
|
}
|
||||||
ivname = rb_id2name(id);
|
rb_str_catf(str, "%"PRIsVALUE"=%+"PRIsVALUE,
|
||||||
rb_str_cat2(str, ivname);
|
rb_id2str(id), value);
|
||||||
rb_str_cat2(str, "=");
|
|
||||||
str2 = rb_inspect(value);
|
|
||||||
rb_str_append(str, str2);
|
|
||||||
OBJ_INFECT(str, str2);
|
|
||||||
|
|
||||||
return ST_CONTINUE;
|
return ST_CONTINUE;
|
||||||
}
|
}
|
||||||
|
@ -758,10 +758,12 @@ class TestObject < Test::Unit::TestCase
|
|||||||
def initialize
|
def initialize
|
||||||
@\u{3044} = 42
|
@\u{3044} = 42
|
||||||
end
|
end
|
||||||
new.inspect
|
new
|
||||||
end
|
end
|
||||||
EOS
|
EOS
|
||||||
assert_match(/\bInspect\u{3042}:.* @\u{3044}=42\b/, x)
|
assert_match(/\bInspect\u{3042}:.* @\u{3044}=42\b/, x.inspect)
|
||||||
|
x.instance_variable_set("@\u{3046}".encode(Encoding::EUC_JP), 6)
|
||||||
|
assert_match(/@\u{3046}=6\b/, x.inspect)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_singleton_class
|
def test_singleton_class
|
||||||
|
Loading…
x
Reference in New Issue
Block a user