* 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
This commit is contained in:
naruse 2010-06-05 11:31:58 +00:00
Родитель 291809f473
Коммит 0d49737b4f
2 изменённых файлов: 9 добавлений и 1 удалений

Просмотреть файл

@ -1,3 +1,9 @@
Sat Jun 5 01:20:14 2010 NARUSE, Yui <naruse@ruby-lang.org>
* 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 <naruse@ruby-lang.org>
* string.c (rb_str_buf_cat_escaped_char): defined.

Просмотреть файл

@ -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);