summaryrefslogtreecommitdiff
path: root/marshal.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-10 05:51:17 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-10 05:51:17 +0000
commit143d1d840d18636379c141e425fe79cfe2f0e8bf (patch)
tree4feba4aa0fa3662c38b7db118bd86b7518969aa0 /marshal.c
parent234485dc7d0a6d2c228e76581deb56ef415b28bf (diff)
* marshal.c (r_object0): set encoding only if the encoding is not US-ASCII.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24015 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'marshal.c')
-rw-r--r--marshal.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/marshal.c b/marshal.c
index 3659e15fbf..e7c0c4b642 100644
--- a/marshal.c
+++ b/marshal.c
@@ -1398,7 +1398,8 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
r_ivar(v, arg);
*ivp = Qfalse;
}
- rb_enc_copy(str, v);
+ if (rb_enc_get_index(v) != rb_usascii_encindex())
+ rb_enc_copy(str, v);
if (rb_enc_get_index(str) != rb_utf8_encindex()) {
#define f_gsub_bang(x,y,z) rb_funcall(x, rb_intern("gsub!"), 2, y, z)
f_gsub_bang(str, rb_reg_new("\\\\u", 3, 0), rb_usascii_str_new_cstr("u"));