From 0d49737b4f8fed8bd5224eda57382891c4492f46 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 5 Jun 2010 11:31:58 +0000 Subject: [PATCH] * string.c (sym_inspect): Escape when the symbol is not resulted encoding and not ascii_only. It had escaped ascii-incompatible string, but it is wrong. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28176 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ string.c | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 7e5a8fa24b..6876871bff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sat Jun 5 01:20:14 2010 NARUSE, Yui + + * string.c (sym_inspect): Escape when the symbol is not + resulted encoding and not ascii_only. It had escaped + ascii-incompatible string, but it is wrong. + Sat Jun 5 01:10:12 2010 NARUSE, Yui * string.c (rb_str_buf_cat_escaped_char): defined. diff --git a/string.c b/string.c index 476be6d124..a642d309fa 100644 --- a/string.c +++ b/string.c @@ -7078,12 +7078,14 @@ sym_inspect(VALUE sym) const char *ptr; long len; char *dest; + rb_encoding *resenc = rb_default_internal_encoding(); + if (resenc == NULL) resenc = rb_default_external_encoding(); sym = rb_id2str(id); enc = STR_ENC_GET(sym); ptr = RSTRING_PTR(sym); len = RSTRING_LEN(sym); - if (!rb_enc_asciicompat(enc) || len != (long)strlen(ptr) || + if ((resenc != enc && !rb_str_is_ascii_only_p(sym)) || len != (long)strlen(ptr) || !rb_enc_symname_p(ptr, enc) || !sym_printable(ptr, ptr + len, enc)) { str = rb_str_inspect(sym); len = RSTRING_LEN(str);