* string.c (rb_str_succ): limit carrying in an alphanumeric region if

exists.  [ruby-dev:35094]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17945 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2008-07-07 15:23:01 +00:00
Родитель 6aff4b8eaa
Коммит f10c88827e
3 изменённых файлов: 16 добавлений и 3 удалений

Просмотреть файл

@ -1,3 +1,8 @@
Tue Jul 8 00:22:58 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* string.c (rb_str_succ): limit carrying in an alphanumeric region if
exists. [ruby-dev:35094]
Mon Jul 7 20:39:28 2008 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole.c(Init_win32ole): add

Просмотреть файл

@ -2535,13 +2535,16 @@ rb_str_succ(VALUE orig)
enum neighbor_char neighbor;
if ((l = rb_enc_precise_mbclen(s, e, enc)) <= 0) continue;
neighbor = enc_succ_alnum_char(s, l, enc, carry);
if (neighbor == NEIGHBOR_NOT_CHAR)
continue;
if (neighbor == NEIGHBOR_FOUND)
if (neighbor == NEIGHBOR_NOT_CHAR) {
if (c == -1) continue;
s++;
}
else if (neighbor == NEIGHBOR_FOUND)
return str;
c = 1;
carry_pos = s - sbeg;
carry_len = l;
if (neighbor == NEIGHBOR_NOT_CHAR) break;
}
if (c == -1) { /* str contains no alnum */
s = e;

Просмотреть файл

@ -1222,6 +1222,7 @@ class TestString < Test::Unit::TestCase
assert_equal(S("124"), S("123").succ)
assert_equal(S("1000"), S("999").succ)
assert_equal(S("No.10"), S("No.9").succ)
assert_equal(S("2000aaa"), S("1999zzz").succ)
assert_equal(S("AAAAA000"), S("ZZZZ999").succ)
assert_equal(S("*+"), S("**").succ)
@ -1269,6 +1270,10 @@ class TestString < Test::Unit::TestCase
assert_equal(S("*+"), a.succ!)
assert_equal(S("*+"), a)
a = S("No.9")
assert_equal(S("No.10"), a.succ!)
assert_equal(S("No.10"), a)
assert_equal("aaaaaaaaaaaa", "zzzzzzzzzzz".succ!)
assert_equal("aaaaaaaaaaaaaaaaaaaaaaaa", "zzzzzzzzzzzzzzzzzzzzzzz".succ!)
end