From 0ee5a49dd4ffbbb285c25fa6cba88370ce96ed3e Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 25 Dec 2007 10:01:06 +0000 Subject: * 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 --- string.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'string.c') diff --git a/string.c b/string.c index aaf14468af..9dc6a13109 100644 --- a/string.c +++ b/string.c @@ -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; -- cgit v1.2.3