1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* string.c (rb_str_succ): add missing case NEIGHBOR_WRAPPED.

r42078 caused buggy behavior like "\xFF".b -> "\x01\xFF".b

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42082 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2013-07-20 09:10:12 +00:00
parent 3a20287053
commit 42bf899458
3 changed files with 18 additions and 1 deletions

View file

@ -1,3 +1,8 @@
Sat Jul 20 17:46:03 2013 NARUSE, Yui <naruse@ruby-lang.org>
* string.c (rb_str_succ): add missing case NEIGHBOR_WRAPPED.
r42078 caused buggy behavior like "\xFF".b -> "\x01\xFF".b
Sat Jul 20 15:22:38 2013 Koichi Sasada <ko1@atdot.net>
* array.c (rb_ary_resize): use simple memcpy because there are no new

View file

@ -3117,9 +3117,16 @@ rb_str_succ(VALUE orig)
l = ONIGENC_MBCLEN_CHARFOUND_LEN(l);
MEMCPY(tmp, s, char, l);
neighbor = enc_succ_char(tmp, l, enc);
if (neighbor == NEIGHBOR_FOUND) {
switch (neighbor) {
case NEIGHBOR_FOUND:
MEMCPY(s, tmp, char, l);
return str;
break;
case NEIGHBOR_WRAPPED:
MEMCPY(s, tmp, char, l);
break;
case NEIGHBOR_NOT_CHAR:
break;
}
if (rb_enc_precise_mbclen(s, s+l, enc) != l) {
/* wrapped to \0...\0. search next valid char. */

View file

@ -1340,6 +1340,11 @@ class TestM17NComb < Test::Unit::TestCase
end
end
def test_str_succ2
assert_equal("\x01\x00".force_encoding("US-ASCII"), "\x7f".force_encoding("US-ASCII").succ)
assert_equal("\x01\x00".b, "\xff".b.succ)
end
def test_str_hash
combination(STRINGS, STRINGS) {|s1, s2|
if s1.eql?(s2)