ruby-changes:2726
From: ko1@a...
Date: 13 Dec 2007 22:44:59 +0900
Subject: [ruby-changes:2726] matz - Ruby:r14217 (trunk): * encoding.c (rb_enc_compatible): encoding should never fall back
matz 2007-12-13 22:44:02 +0900 (Thu, 13 Dec 2007) New Revision: 14217 Modified files: trunk/ChangeLog trunk/encoding.c trunk/re.c trunk/test/ruby/test_m17n.rb Log: * encoding.c (rb_enc_compatible): encoding should never fall back to ASCII-8BIT unless both encodings are ASCII-8BIT. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=14217&r2=14216 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/re.c?r1=14217&r2=14216 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/encoding.c?r1=14217&r2=14216 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_m17n.rb?r1=14217&r2=14216 Index: encoding.c =================================================================== --- encoding.c (revision 14216) +++ encoding.c (revision 14217) @@ -397,7 +397,10 @@ if (cr1 == ENC_CODERANGE_7BIT) return rb_enc_from_index(idx2); if (cr2 == ENC_CODERANGE_7BIT) return rb_enc_from_index(idx1); } - if (cr1 == ENC_CODERANGE_7BIT) return rb_enc_from_index(0); + if (cr2 == ENC_CODERANGE_7BIT) { + if (idx1 == 0) return rb_enc_from_index(idx2); + if (idx2 == 0) return rb_enc_from_index(idx1); + } } if (cr1 == ENC_CODERANGE_7BIT && rb_enc_asciicompat(enc = rb_enc_from_index(idx2))) Index: re.c =================================================================== --- re.c (revision 14216) +++ re.c (revision 14217) @@ -144,6 +144,7 @@ #define ARG_KCODE_EUC 1 #define ARG_KCODE_SJIS 2 #define ARG_KCODE_UTF8 3 +#define ARG_KCODE_MASK 3 static int char_to_option(int c) @@ -1968,7 +1969,7 @@ if (unescaped == Qnil) return -1; - if (fixed_enc && (options & ARG_ENCODING_FIXED) && fixed_enc != enc) { + if (fixed_enc && fixed_enc != enc) { strcpy(err, "character encodings differ"); return -1; } Index: ChangeLog =================================================================== --- ChangeLog (revision 14216) +++ ChangeLog (revision 14217) @@ -1,3 +1,8 @@ +Thu Dec 13 22:16:46 2007 Yukihiro Matsumoto <matz@r...> + + * encoding.c (rb_enc_compatible): encoding should never fall back + to ASCII-8BIT unless both encodings are ASCII-8BIT. + Thu Dec 13 20:31:28 2007 Tanaka Akira <akr@f...> * string.c (rb_str_shared_replace): make str noembed after free. Index: test/ruby/test_m17n.rb =================================================================== --- test/ruby/test_m17n.rb (revision 14216) +++ test/ruby/test_m17n.rb (revision 14217) @@ -447,13 +447,13 @@ end def test_regexp_unicode - assert_nothing_raised { eval '/\u{0}/' } - assert_nothing_raised { eval '/\u{D7FF}/' } - assert_raise(SyntaxError) { eval '/\u{D800}/' } - assert_raise(SyntaxError) { eval '/\u{DFFF}/' } - assert_nothing_raised { eval '/\u{E000}/' } - assert_nothing_raised { eval '/\u{10FFFF}/' } - assert_raise(SyntaxError) { eval '/\u{110000}/' } + assert_nothing_raised { eval '/\u{0}/u' } + assert_nothing_raised { eval '/\u{D7FF}/u' } + assert_raise(SyntaxError) { eval '/\u{D800}/u' } + assert_raise(SyntaxError) { eval '/\u{DFFF}/u' } + assert_nothing_raised { eval '/\u{E000}/u' } + assert_nothing_raised { eval '/\u{10FFFF}/u' } + assert_raise(SyntaxError) { eval '/\u{110000}/u' } end def test_regexp_mixed_unicode -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml