From ae8ed19dad0b2bbe93f2027682bfe222d6160ca6 Mon Sep 17 00:00:00 2001 From: naruse Date: Thu, 21 Feb 2008 19:54:48 +0000 Subject: * string.c (rb_str_times): empty string's coderange is CODERANGE_7BIT. * string.c (rb_str_substr): ditto. * encoding.c (rb_enc_compatible): empty string is compatible with not only nonasciicompatible strings. [ruby-dev:33895] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@15566 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 b64688e0f..002c0c04f 100644 --- a/encoding.c +++ b/encoding.c @@ -670,11 +670,11 @@ 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 enc1; + if (TYPE(str1) == T_STRING && RSTRING_LEN(str1) == 0) + return enc2; if (!rb_enc_asciicompat(enc1) || !rb_enc_asciicompat(enc2)) { - if (TYPE(str2) == T_STRING && RSTRING_LEN(str2) == 0) - return enc1; - if (TYPE(str1) == T_STRING && RSTRING_LEN(str1) == 0) - return enc2; return 0; } -- cgit