diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-25 10:01:06 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-25 10:01:06 +0000 |
commit | 0ee5a49dd4ffbbb285c25fa6cba88370ce96ed3e (patch) | |
tree | 589f0a9cbfe3a8e54529d270a4e937c403f996bc /string.c | |
parent | 3878b30881f46dab1458e70eaa6272dcff636518 (diff) | |
download | ruby-0ee5a49dd4ffbbb285c25fa6cba88370ce96ed3e.tar.gz |
* encoding.h (rb_enc_mbc_to_codepoint): wrapper for
ONIGENC_MBC_TO_CODE().
* string.c (rb_str_succ): deal with invalid sequence as binary.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14692 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -1876,7 +1876,8 @@ rb_str_succ(VALUE orig) s = e = sbeg + RSTRING_LEN(str); while ((s = rb_enc_prev_char(sbeg, s, enc)) != 0) { - cc = rb_enc_codepoint(s, e, enc); + if ((l = rb_enc_precise_mbclen(s, e, enc)) <= 0) continue; + cc = rb_enc_mbc_to_codepoint(s, e, enc); if (rb_enc_isalnum(cc, enc)) { if (rb_enc_isascii(cc, enc)) { if ((c = succ_char(s)) == 0) break; @@ -1892,7 +1893,8 @@ rb_str_succ(VALUE orig) s = e; while ((s = rb_enc_prev_char(sbeg, s, enc)) != 0) { int limit = 256; - cc = rb_enc_codepoint(s, e, enc); + if ((l = rb_enc_precise_mbclen(s, e, enc)) <= 0) continue; + cc = rb_enc_mbc_to_codepoint(s, e, enc); while ((l = rb_enc_mbcput(++cc, carry, enc)) < 0 && --limit); if (l > 0) { if (l == (o = e - s)) goto overlay; |