diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-02-15 07:08:20 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-02-15 07:08:20 +0000 |
commit | 7798b9667efc5396b8dd7409901c950f046c917d (patch) | |
tree | b25566ade5b47147738742d1a181ce384c2b71f2 /hash.c | |
parent | 366e1c3884e97b0d833b8805a6afcd9071ea1e8b (diff) | |
download | ruby-7798b9667efc5396b8dd7409901c950f046c917d.tar.gz |
* hash.c (inspect_i): copy the encoding of the first key as
an initial encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30879 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r-- | hash.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -14,6 +14,7 @@ #include "ruby/ruby.h" #include "ruby/st.h" #include "ruby/util.h" +#include "ruby/encoding.h" #include <errno.h> #ifdef __APPLE__ @@ -1367,10 +1368,13 @@ inspect_i(VALUE key, VALUE value, VALUE str) VALUE str2; if (key == Qundef) return ST_CONTINUE; + str2 = rb_inspect(key); if (RSTRING_LEN(str) > 1) { rb_str_cat2(str, ", "); } - str2 = rb_inspect(key); + else { + rb_enc_copy(str, str2); + } rb_str_buf_append(str, str2); OBJ_INFECT(str, str2); rb_str_buf_cat2(str, "=>"); |