mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29445 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
243831cd37
commit
6913b2734a
3 changed files with 10 additions and 3 deletions
|
@ -1,3 +1,9 @@
|
|||
Tue Oct 12 14:04:41 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* 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@ruby-lang.org>
|
||||
|
||||
* vm_dump.c (dump_thread): foolish mistake.
|
||||
|
|
|
@ -2074,7 +2074,7 @@ int_chr(int argc, VALUE *argv, VALUE num)
|
|||
{
|
||||
char c;
|
||||
int n;
|
||||
SIGNED_VALUE i = NUM2LONG(num);
|
||||
uint32_t i = NUM2UINT(num);
|
||||
rb_encoding *enc;
|
||||
VALUE str;
|
||||
|
||||
|
@ -2108,9 +2108,9 @@ int_chr(int argc, VALUE *argv, VALUE num)
|
|||
#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;
|
||||
}
|
||||
|
||||
|
|
|
@ -1139,6 +1139,7 @@ class TestM17N < Test::Unit::TestCase
|
|||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue