ruby-changes:42136
From: nobu <ko1@a...>
Date: Mon, 21 Mar 2016 19:09:38 +0900 (JST)
Subject: [ruby-changes:42136] nobu:r54210 (trunk): string.c: skip invalid char gap
nobu 2016-03-21 19:09:33 +0900 (Mon, 21 Mar 2016) New Revision: 54210 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54210 Log: string.c: skip invalid char gap * string.c (enc_succ_alnum_char): try to skip an invalid character gap between GREEK CAPITAL RHO and SIGMA. [ruby-core:74478] [Bug #12204] Modified files: trunk/ChangeLog trunk/string.c trunk/test/ruby/test_m17n.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 54209) +++ ChangeLog (revision 54210) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Mon Mar 21 19:09:31 2016 Nobuyoshi Nakada <nobu@r...> + + * string.c (enc_succ_alnum_char): try to skip an invalid character + gap between GREEK CAPITAL RHO and SIGMA. + [ruby-core:74478] [Bug #12204] + Mon Mar 21 18:55:49 2016 Nobuyoshi Nakada <nobu@r...> * node.c (rb_gc_mark_node): NODE_MATCH2 can have nd_args, u3, Index: string.c =================================================================== --- string.c (revision 54209) +++ string.c (revision 54210) @@ -3552,6 +3552,10 @@ enc_succ_alnum_char(char *p, long len, r https://github.com/ruby/ruby/blob/trunk/string.c#L3552 int range; char save[ONIGENC_CODE_TO_MBC_MAXLEN]; + /* skip 03A2, invalid char between GREEK CAPITAL LETTERS */ + int try; + const int max_gaps = 1; + c = rb_enc_mbc_to_codepoint(p, p+len, enc); if (rb_enc_isctype(c, ONIGENC_CTYPE_DIGIT, enc)) ctype = ONIGENC_CTYPE_DIGIT; @@ -3561,11 +3565,13 @@ enc_succ_alnum_char(char *p, long len, r https://github.com/ruby/ruby/blob/trunk/string.c#L3565 return NEIGHBOR_NOT_CHAR; MEMCPY(save, p, char, len); - ret = enc_succ_char(p, len, enc); - if (ret == NEIGHBOR_FOUND) { - c = rb_enc_mbc_to_codepoint(p, p+len, enc); - if (rb_enc_isctype(c, ctype, enc)) - return NEIGHBOR_FOUND; + for (try = 0; try <= max_gaps; ++try) { + ret = enc_succ_char(p, len, enc); + if (ret == NEIGHBOR_FOUND) { + c = rb_enc_mbc_to_codepoint(p, p+len, enc); + if (rb_enc_isctype(c, ctype, enc)) + return NEIGHBOR_FOUND; + } } MEMCPY(p, save, char, len); range = 1; Index: test/ruby/test_m17n.rb =================================================================== --- test/ruby/test_m17n.rb (revision 54209) +++ test/ruby/test_m17n.rb (revision 54210) @@ -1678,4 +1678,9 @@ class TestM17N < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_m17n.rb#L1678 end assert_equal(e("[\"\xB4\xC1\xBB\xFA\"]"), s, bug11787) end + + def test_greek_capital_gap + bug12204 = '[ruby-core:74478] [Bug #12204] GREEK CAPITAL RHO and SIGMA' + assert_equal("\u03A3", "\u03A1".succ, bug12204) + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/