ruby-changes:18854
From: naruse <ko1@a...>
Date: Tue, 15 Feb 2011 16:08:32 +0900 (JST)
Subject: [ruby-changes:18854] Ruby:r30879 (trunk): * hash.c (inspect_i): copy the encoding of the first key as
naruse 2011-02-15 16:08:20 +0900 (Tue, 15 Feb 2011) New Revision: 30879 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=30879 Log: * hash.c (inspect_i): copy the encoding of the first key as an initial encoding. Modified files: trunk/ChangeLog trunk/hash.c Index: ChangeLog =================================================================== --- ChangeLog (revision 30878) +++ ChangeLog (revision 30879) @@ -1,3 +1,8 @@ +Tue Feb 15 15:40:53 2011 NARUSE, Yui <naruse@r...> + + * hash.c (inspect_i): copy the encoding of the first key as + an initial encoding. + Mon Feb 14 15:00:16 2011 NARUSE, Yui <naruse@r...> * array.c (inspect_ary): don't taint the inspected result of a Index: hash.c =================================================================== --- hash.c (revision 30878) +++ hash.c (revision 30879) @@ -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 @@ 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, "=>"); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/