ruby-changes:29716
From: naruse <ko1@a...>
Date: Thu, 4 Jul 2013 15:53:04 +0900 (JST)
Subject: [ruby-changes:29716] naruse:r41768 (trunk): * string.c (rb_str_succ): use ONIGENC_MBCLEN_CHARFOUND_P correctly.
naruse 2013-07-04 15:52:33 +0900 (Thu, 04 Jul 2013) New Revision: 41768 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41768 Log: * string.c (rb_str_succ): use ONIGENC_MBCLEN_CHARFOUND_P correctly. * string.c (rb_str_dump): ditto. Modified files: trunk/ChangeLog trunk/string.c Index: ChangeLog =================================================================== --- ChangeLog (revision 41767) +++ ChangeLog (revision 41768) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Jul 4 15:51:56 2013 NARUSE, Yui <naruse@r...> + + * string.c (rb_str_succ): use ONIGENC_MBCLEN_CHARFOUND_P correctly. + + * string.c (rb_str_dump): ditto. + Thu Jul 4 10:04:11 2013 NARUSE, Yui <naruse@r...> * regcomp.c (): Merge Onigmo 5.13.5 23b523076d6f1161. Index: string.c =================================================================== --- string.c (revision 41767) +++ string.c (revision 41768) @@ -2976,7 +2976,9 @@ rb_str_succ(VALUE orig) https://github.com/ruby/ruby/blob/trunk/string.c#L2976 break; } } - if ((l = rb_enc_precise_mbclen(s, e, enc)) <= 0) continue; + l = rb_enc_precise_mbclen(s, e, enc); + if (!ONIGENC_MBCLEN_CHARFOUND_P(l)) continue; + l = ONIGENC_MBCLEN_CHARFOUND_LEN(l); neighbor = enc_succ_alnum_char(s, l, enc, carry); switch (neighbor) { case NEIGHBOR_NOT_CHAR: @@ -2995,7 +2997,9 @@ rb_str_succ(VALUE orig) https://github.com/ruby/ruby/blob/trunk/string.c#L2997 s = e; while ((s = rb_enc_prev_char(sbeg, s, e, enc)) != 0) { enum neighbor_char neighbor; - if ((l = rb_enc_precise_mbclen(s, e, enc)) <= 0) continue; + l = rb_enc_precise_mbclen(s, e, enc); + if (!ONIGENC_MBCLEN_CHARFOUND_P(l)) continue; + l = ONIGENC_MBCLEN_CHARFOUND_LEN(l); neighbor = enc_succ_char(s, l, enc); if (neighbor == NEIGHBOR_FOUND) return str; @@ -4618,9 +4622,9 @@ rb_str_dump(VALUE str) https://github.com/ruby/ruby/blob/trunk/string.c#L4622 len++; } else { - if (u8) { /* \u{NN} */ + if (u8 && c > 0x7F) { /* \u{NN} */ int n = rb_enc_precise_mbclen(p-1, pend, enc); - if (MBCLEN_CHARFOUND_P(n-1)) { + if (MBCLEN_CHARFOUND_P(n)) { unsigned int cc = rb_enc_mbc_to_codepoint(p-1, pend, enc); while (cc >>= 4) len++; len += 5; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/