diff --git a/ChangeLog b/ChangeLog index b7db9f8b12..09298022f5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Fri Dec 21 00:26:39 2007 Yukihiro Matsumoto + + * string.c (tr_trans): wrong encoding check for tree strings. + + * test/ruby/test_m17n.rb (TestM17N::test_tr_s): "invalid mbstring + sequence" is not an error to be tested. + Thu Dec 20 19:29:07 2007 Shugo Maeda * lib/net/imap.rb (initialize): the second argument is an option diff --git a/string.c b/string.c index f1910af782..eecfc6347d 100644 --- a/string.c +++ b/string.c @@ -3453,7 +3453,7 @@ static VALUE tr_trans(VALUE str, VALUE src, VALUE repl, int sflag) { SIGNED_VALUE trans[256]; - rb_encoding *enc; + rb_encoding *enc, *e1, *e2; struct tr trsrc, trrepl; int cflag = 0; int c, last = 0, modify = 0, i; @@ -3471,9 +3471,13 @@ tr_trans(VALUE str, VALUE src, VALUE repl, int sflag) if (RSTRING_LEN(repl) == 0) { return rb_str_delete_bang(1, &src, str); } - enc = rb_enc_check(str, src); - if (rb_enc_check(str, repl) != enc) { - rb_raise(rb_eArgError, "character encodings differ"); + e1 = rb_enc_check(str, src); + e2 = rb_enc_check(str, repl); + if (e1 == e2) { + enc = e1; + } + else { + enc = rb_enc_check(src, repl); } trrepl.p = RSTRING_PTR(repl); trrepl.pend = trrepl.p + RSTRING_LEN(repl); diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb index 8b06a2e07b..1923d9294e 100644 --- a/test/ruby/test_m17n.rb +++ b/test/ruby/test_m17n.rb @@ -1643,7 +1643,7 @@ class TestM17N < Test::Unit::TestCase #puts "#{encdump s1}.tr_s(#{encdump s2}, #{encdump s3})" t = s1.tr_s(s2, s3) rescue ArgumentError - e = $! + e = $! unless /mbstring sequence/ =~ $!.message end if e encs = [] @@ -1651,7 +1651,7 @@ class TestM17N < Test::Unit::TestCase encs << s2.encoding if !is_ascii_only?(s2) encs << s3.encoding if !is_ascii_only?(s3) encs.uniq! - #p e, encs + #p e, encs, assert(1 < encs.length, "#{encdump s1}.tr_s(#{encdump s2}, #{encdump s3})") end } diff --git a/version.h b/version.h index ee0a9556fa..447c0416c4 100644 --- a/version.h +++ b/version.h @@ -1,7 +1,7 @@ #define RUBY_VERSION "1.9.0" -#define RUBY_RELEASE_DATE "2007-12-20" +#define RUBY_RELEASE_DATE "2007-12-21" #define RUBY_VERSION_CODE 190 -#define RUBY_RELEASE_CODE 20071220 +#define RUBY_RELEASE_CODE 20071221 #define RUBY_PATCHLEVEL 0 #define RUBY_VERSION_MAJOR 1 @@ -9,7 +9,7 @@ #define RUBY_VERSION_TEENY 0 #define RUBY_RELEASE_YEAR 2007 #define RUBY_RELEASE_MONTH 12 -#define RUBY_RELEASE_DAY 20 +#define RUBY_RELEASE_DAY 21 #ifdef RUBY_EXTERN RUBY_EXTERN const char ruby_version[];