ruby-changes:17440
From: naruse <ko1@a...>
Date: Tue, 12 Oct 2010 14:14:29 +0900 (JST)
Subject: [ruby-changes:17440] Ruby:r29445 (trunk): * numeric.c (int_chr): a codepoint of Ruby M17N must be 32bit
naruse 2010-10-12 14:14:23 +0900 (Tue, 12 Oct 2010) New Revision: 29445 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=29445 Log: * numeric.c (int_chr): a codepoint of Ruby M17N must be 32bit unsigned int; GB18030 uses MSB. Also note that OnigCodePoint is defined as uisigned int. Modified files: trunk/ChangeLog trunk/numeric.c trunk/test/ruby/test_m17n.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 29444) +++ ChangeLog (revision 29445) @@ -1,3 +1,9 @@ +Tue Oct 12 14:04:41 2010 NARUSE, Yui <naruse@r...> + + * numeric.c (int_chr): a codepoint of Ruby M17N must be 32bit + unsigned int; GB18030 uses MSB. Also note that OnigCodePoint + is defined as uisigned int. + Tue Oct 12 12:20:54 2010 NAKAMURA Usaku <usa@r...> * vm_dump.c (dump_thread): foolish mistake. Index: numeric.c =================================================================== --- numeric.c (revision 29444) +++ numeric.c (revision 29445) @@ -2074,7 +2074,7 @@ { char c; int n; - SIGNED_VALUE i = NUM2LONG(num); + uint32_t i = NUM2UINT(num); rb_encoding *enc; VALUE str; @@ -2108,9 +2108,9 @@ #if SIZEOF_INT < SIZEOF_VALUE if (i > UINT_MAX) goto out_of_range; #endif - if (i < 0 || (n = rb_enc_codelen((int)i, enc)) <= 0) goto out_of_range; + if (i < 0 || (n = rb_enc_codelen(i, enc)) <= 0) goto out_of_range; str = rb_enc_str_new(0, n, enc); - rb_enc_mbcput((int)i, RSTRING_PTR(str), enc); + rb_enc_mbcput(i, RSTRING_PTR(str), enc); return str; } Index: test/ruby/test_m17n.rb =================================================================== --- test/ruby/test_m17n.rb (revision 29444) +++ test/ruby/test_m17n.rb (revision 29445) @@ -1139,6 +1139,7 @@ 0.upto(255) {|b| assert_equal([b].pack("C"), b.chr) } + assert_equal("\x84\x31\xA4\x39".force_encoding("GB18030"), 0x8431A439.chr("GB18030")) end def test_marshal -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/