1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* string.c (rb_str_succ): use ONIGENC_MBCLEN_CHARFOUND_P correctly.

* string.c (rb_str_dump): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2013-07-04 06:52:33 +00:00
parent c294ed5824
commit 05bc47773a
2 changed files with 14 additions and 4 deletions

View file

@ -1,3 +1,9 @@
Thu Jul 4 15:51:56 2013 NARUSE, Yui <naruse@ruby-lang.org>
* 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@ruby-lang.org> Thu Jul 4 10:04:11 2013 NARUSE, Yui <naruse@ruby-lang.org>
* regcomp.c (): Merge Onigmo 5.13.5 23b523076d6f1161. * regcomp.c (): Merge Onigmo 5.13.5 23b523076d6f1161.

View file

@ -2976,7 +2976,9 @@ rb_str_succ(VALUE orig)
break; 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); neighbor = enc_succ_alnum_char(s, l, enc, carry);
switch (neighbor) { switch (neighbor) {
case NEIGHBOR_NOT_CHAR: case NEIGHBOR_NOT_CHAR:
@ -2995,7 +2997,9 @@ rb_str_succ(VALUE orig)
s = e; s = e;
while ((s = rb_enc_prev_char(sbeg, s, e, enc)) != 0) { while ((s = rb_enc_prev_char(sbeg, s, e, enc)) != 0) {
enum neighbor_char neighbor; 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); neighbor = enc_succ_char(s, l, enc);
if (neighbor == NEIGHBOR_FOUND) if (neighbor == NEIGHBOR_FOUND)
return str; return str;
@ -4618,9 +4622,9 @@ rb_str_dump(VALUE str)
len++; len++;
} }
else { else {
if (u8) { /* \u{NN} */ if (u8 && c > 0x7F) { /* \u{NN} */
int n = rb_enc_precise_mbclen(p-1, pend, enc); 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); unsigned int cc = rb_enc_mbc_to_codepoint(p-1, pend, enc);
while (cc >>= 4) len++; while (cc >>= 4) len++;
len += 5; len += 5;