summaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-25 10:01:06 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-25 10:01:06 +0000
commit50ba92f23642557fd50550302dd565696ab30e6e (patch)
tree589f0a9cbfe3a8e54529d270a4e937c403f996bc /string.c
parentefeda2a553b0405a0239b3dd0b616a4f2dffd955 (diff)
downloadruby-50ba92f23642557fd50550302dd565696ab30e6e.tar.gz
ruby-50ba92f23642557fd50550302dd565696ab30e6e.tar.xz
ruby-50ba92f23642557fd50550302dd565696ab30e6e.zip
* 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: http://svn.ruby-lang.org/repos/ruby/trunk@14692 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/string.c b/string.c
index aaf14468a..9dc6a1310 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;