ruby-changes:4252
From: ko1@a...
Date: Tue, 11 Mar 2008 09:55:24 +0900 (JST)
Subject: [ruby-changes:4252] matz - Ruby:r15742 (trunk): * string.c (rb_str_comparable): empty strings in any encoding are
matz 2008-03-11 09:55:02 +0900 (Tue, 11 Mar 2008) New Revision: 15742 Modified files: trunk/ChangeLog trunk/string.c Log: * string.c (rb_str_comparable): empty strings in any encoding are compatible each other. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/string.c?r1=15742&r2=15741&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15742&r2=15741&diff_format=u Index: ChangeLog =================================================================== --- ChangeLog (revision 15741) +++ ChangeLog (revision 15742) @@ -1,3 +1,8 @@ +Tue Mar 11 09:52:49 2008 Yukihiro Matsumoto <matz@r...> + + * string.c (rb_str_comparable): empty strings in any encoding are + compatible each other. + Tue Mar 11 00:46:29 2008 Yukihiro Matsumoto <matz@r...> * ruby.c (usage): remove some unimportant lines to fit -h message Index: string.c =================================================================== --- string.c (revision 15741) +++ string.c (revision 15742) @@ -1847,20 +1847,23 @@ int rb_str_comparable(VALUE str1, VALUE str2) { - int idx1 = ENCODING_GET(str1); - int idx2 = ENCODING_GET(str2); + int idx1, idx2; int rc1, rc2; + if (RSTRING_LEN(str1) == 0) return Qtrue; + if (RSTRING_LEN(str2) == 0) return Qtrue; + idx1 = ENCODING_GET(str1); + idx2 = ENCODING_GET(str2); if (idx1 == idx2) return Qtrue; rc1 = rb_enc_str_coderange(str1); rc2 = rb_enc_str_coderange(str2); if (rc1 == ENC_CODERANGE_7BIT) { if (rc2 == ENC_CODERANGE_7BIT) return Qtrue; - if (rb_enc_asciicompat(rb_enc_from_index(idx1))) + if (rb_enc_asciicompat(rb_enc_from_index(idx2))) return Qtrue; } if (rc2 == ENC_CODERANGE_7BIT) { - if (rb_enc_asciicompat(rb_enc_from_index(idx2))) + if (rb_enc_asciicompat(rb_enc_from_index(idx1))) return Qtrue; } return Qfalse; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/