* 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:
parent
3a20287053
commit
42bf899458
@ -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
|
||||
|
9
string.c
9
string.c
@ -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. */
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user