summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-11 19:03:26 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-11 19:03:26 +0000
commit2b79366f5243fad65ad13005e12e78c88d3a95ba (patch)
tree513a1c0788e84f999c1039f56216ce6c48bd4e14 /string.c
parentc19f9a508f50ee6c813b2b4f7908c95b6fd9e3c3 (diff)
* string.c (rb_str_inspect): fix: extra back slash is added when
the string is dummy encoding and includes \x22 or \x5C. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/string.c b/string.c
index ade48c65bd..e202291f08 100644
--- a/string.c
+++ b/string.c
@@ -4251,12 +4251,13 @@ rb_str_inspect(VALUE str)
n = MBCLEN_CHARFOUND_LEN(n);
c = rb_enc_mbc_to_codepoint(p, pend, enc);
p += n;
- if (c == '"'|| c == '\\' ||
+ if ((asciicompat || unicode_p) &&
+ (c == '"'|| c == '\\' ||
(c == '#' &&
p < pend &&
MBCLEN_CHARFOUND_P(rb_enc_precise_mbclen(p,pend,enc)) &&
(cc = rb_enc_codepoint(p,pend,enc),
- (cc == '$' || cc == '@' || cc == '{')))) {
+ (cc == '$' || cc == '@' || cc == '{'))))) {
if (p - n > prev) str_buf_cat(result, prev, p - n - prev);
str_buf_cat2(result, "\\");
if (asciicompat || enc == resenc) {