From 977eea57a3e9a3513c60a9dae48092db4c1a6f2e Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 21 Dec 2007 11:09:19 +0000 Subject: [PATCH] * string.c (rb_str_succ): retry increasing until valid char is found. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ string.c | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 24f94528a1..6a404733ea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Fri Dec 21 20:09:18 2007 Nobuyoshi Nakada + + * string.c (rb_str_succ): retry increasing until valid char is found. + Fri Dec 21 20:00:02 2007 Nobuyoshi Nakada * encoding.c (rb_enc_replicate): now creates first class encoding. diff --git a/string.c b/string.c index 4079a8cf4f..f6cbc86f22 100644 --- a/string.c +++ b/string.c @@ -1872,9 +1872,9 @@ rb_str_succ(VALUE orig) c = '\001'; s = e; while ((s = rb_enc_prev_char(sbeg, s, enc)) != 0) { + int limit = 256; if (cc == 0) cc = rb_enc_codepoint(s, e, enc); - cc += 1; - l = rb_enc_mbcput(cc, carry, enc); + while ((l = rb_enc_mbcput(++cc, carry, enc)) < 0 && --limit); if (l > 0) { if (l == (o = e - s)) goto overlay; n = s - sbeg; @@ -4538,7 +4538,7 @@ rb_str_chomp_bang(int argc, VALUE *argv, VALUE str) if (p[len-1] == newline && (rslen <= 1 || memcmp(RSTRING_PTR(rs), pp, rslen) == 0)) { - if (ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc,p,pp) != (const UChar*)pp) + if (ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, (UChar *)p, (UChar *)pp) != (const UChar*)pp) return Qnil; rb_str_modify(str); STR_SET_LEN(str, RSTRING_LEN(str) - rslen);