diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-05-20 13:32:16 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-05-20 13:32:16 +0000 |
commit | 2053b5f4538e157581b8fbf96a30624a2594158c (patch) | |
tree | 8d5b386a9583996920f3182ba45dc302e67b0181 /string.c | |
parent | 44faaf110f45bf5b2591409959f5af30f537007a (diff) | |
download | ruby-2053b5f4538e157581b8fbf96a30624a2594158c.tar.gz |
* enc/shift_jis.c (code_to_mbclen): return
ONIGERR_INVALID_CODE_POINT_VALUE if the code is invalid.
* enc/shift_jis.c (tr_next): increment character until the code
is a valid character. [ruby-dev:45652] [Bug #6450]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 19 |
1 files changed, 14 insertions, 5 deletions
@@ -4967,6 +4967,7 @@ trnext(struct tr *t, rb_encoding *enc) for (;;) { if (!t->gen) { +nextpart: if (t->p == t->pend) return -1; if (rb_enc_ascget(t->p, t->pend, &n, enc) == '\\' && t->p + n < t->pend) { t->p += n; @@ -4995,12 +4996,20 @@ trnext(struct tr *t, rb_encoding *enc) } return t->now; } - else if (++t->now < t->max) { - return t->now; - } else { - t->gen = 0; - return t->max; + while (ONIGENC_CODE_TO_MBCLEN(enc, ++t->now) <= 0) { + if (t->now == t->max) { + t->gen = 0; + goto nextpart; + } + } + if (t->now < t->max) { + return t->now; + } + else { + t->gen = 0; + return t->max; + } } } } |