From 6913b2734a80fab9dffea70f573555d96b45e226 Mon Sep 17 00:00:00 2001 From: naruse Date: Tue, 12 Oct 2010 05:14:23 +0000 Subject: * 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 --- numeric.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'numeric.c') diff --git a/numeric.c b/numeric.c index 25c9e73e44..0f6d3dbb8c 100644 --- a/numeric.c +++ b/numeric.c @@ -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; } -- cgit v1.2.3