summaryrefslogtreecommitdiff
path: root/encoding.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-02-15 07:08:15 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-02-15 07:08:15 +0000
commita8f5a06a68f24ac48363083114c14e9c95ea61ff (patch)
tree0b7844f6215c52d43b361616b47026c2c731ccd9 /encoding.c
parent443b1517cfbee8cf3a0c44f040939edf4f94b9a0 (diff)
* encoding.c (rb_enc_compatible): change the rule for empty strings:
remove the special treatment of the US-ASCII encoded empty string. Now Encoding.compatible? usually respect the encoding of the receiver. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30877 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'encoding.c')
-rw-r--r--encoding.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/encoding.c b/encoding.c
index 2a9881bb08..272f3ff75d 100644
--- a/encoding.c
+++ b/encoding.c
@@ -754,10 +754,10 @@ rb_enc_compatible(VALUE str1, VALUE str2)
enc1 = rb_enc_from_index(idx1);
enc2 = rb_enc_from_index(idx2);
- if (TYPE(str2) == T_STRING && RSTRING_LEN(str2) == 0)
- return (idx1 == ENCINDEX_US_ASCII && rb_enc_asciicompat(enc2)) ? enc2 : enc1;
- if (TYPE(str1) == T_STRING && RSTRING_LEN(str1) == 0)
- return (idx2 == ENCINDEX_US_ASCII && rb_enc_asciicompat(enc1)) ? enc1 : enc2;
+ if (BUILTIN_TYPE(str2) == T_STRING && RSTRING_LEN(str2) == 0)
+ return enc1;
+ if (BUILTIN_TYPE(str1) == T_STRING && RSTRING_LEN(str1) == 0)
+ return (rb_enc_asciicompat(enc1) && rb_enc_str_asciionly_p(str2)) ? enc1 : enc2;
if (!rb_enc_asciicompat(enc1) || !rb_enc_asciicompat(enc2)) {
return 0;
}