From a8f5a06a68f24ac48363083114c14e9c95ea61ff Mon Sep 17 00:00:00 2001 From: naruse Date: Tue, 15 Feb 2011 07:08:15 +0000 Subject: * 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 --- encoding.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'encoding.c') 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; } -- cgit v1.2.3