ruby-changes:18024
From: yugui <ko1@a...>
Date: Thu, 2 Dec 2010 17:08:14 +0900 (JST)
Subject: [ruby-changes:18024] Ruby:r30040 (ruby_1_9_2): merges r29453 from trunk into ruby_1_9_2.
yugui 2010-12-02 17:06:58 +0900 (Thu, 02 Dec 2010) New Revision: 30040 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=30040 Log: merges r29453 from trunk into ruby_1_9_2. -- * string.c (rb_str_concat): use unsigned int for GB18030. Modified files: branches/ruby_1_9_2/ChangeLog branches/ruby_1_9_2/string.c branches/ruby_1_9_2/test/ruby/test_m17n_comb.rb branches/ruby_1_9_2/version.h Index: ruby_1_9_2/ChangeLog =================================================================== --- ruby_1_9_2/ChangeLog (revision 30039) +++ ruby_1_9_2/ChangeLog (revision 30040) @@ -1,3 +1,7 @@ +Tue Oct 12 18:25:04 2010 NARUSE, Yui <naruse@r...> + + * string.c (rb_str_concat): use unsigned int for GB18030. + Tue Oct 12 15:52:35 2010 NAKAMURA Usaku <usa@r...> * win32/win32.c (rb_w32_strerror): unmap some range of errno for Index: ruby_1_9_2/string.c =================================================================== --- ruby_1_9_2/string.c (revision 30039) +++ ruby_1_9_2/string.c (revision 30040) @@ -1992,37 +1992,28 @@ VALUE rb_str_concat(VALUE str1, VALUE str2) { - SIGNED_VALUE lc; + unsigned int lc; if (FIXNUM_P(str2)) { - lc = FIX2LONG(str2); - if (lc < 0) - rb_raise(rb_eRangeError, "negative argument"); + lc = FIX2UINT(str2); } else if (TYPE(str2) == T_BIGNUM) { - if (!RBIGNUM_SIGN(str2)) - rb_raise(rb_eRangeError, "negative argument"); - lc = rb_big2ulong(str2); + lc = NUM2UINT(str2); } else { return rb_str_append(str1, str2); } -#if SIZEOF_INT < SIZEOF_VALUE - if ((VALUE)lc > UINT_MAX) { - rb_raise(rb_eRangeError, "%"PRIuVALUE" out of char range", lc); - } -#endif { rb_encoding *enc = STR_ENC_GET(str1); long pos = RSTRING_LEN(str1); int cr = ENC_CODERANGE(str1); - int c, len; + int len; - if ((len = rb_enc_codelen(c = (int)lc, enc)) <= 0) { - rb_raise(rb_eRangeError, "%u invalid char", c); + if ((len = rb_enc_codelen(lc, enc)) <= 0) { + rb_raise(rb_eRangeError, "%u invalid char", lc); } rb_str_resize(str1, pos+len); - rb_enc_mbcput(c, RSTRING_PTR(str1)+pos, enc); + rb_enc_mbcput(lc, RSTRING_PTR(str1)+pos, enc); ENC_CODERANGE_SET(str1, cr); return str1; } Index: ruby_1_9_2/version.h =================================================================== --- ruby_1_9_2/version.h (revision 30039) +++ ruby_1_9_2/version.h (revision 30040) @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.2" -#define RUBY_PATCHLEVEL 70 +#define RUBY_PATCHLEVEL 71 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 Index: ruby_1_9_2/test/ruby/test_m17n_comb.rb =================================================================== --- ruby_1_9_2/test/ruby/test_m17n_comb.rb (revision 30039) +++ ruby_1_9_2/test/ruby/test_m17n_comb.rb (revision 30040) @@ -346,6 +346,9 @@ assert_raise(Encoding::CompatibilityError) { s << s2 } end } + + assert_equal("A\x84\x31\xA4\x39".force_encoding("GB18030"), + "A".force_encoding("GB18030") << 0x8431A439) end def test_str_aref -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/