mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* string.c (tr_find): String#delete returned wrong result when multiple
utf-8 arguments are passed. * test/ruby/test_m17n.rb (test_delete): add a test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16426 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
42389bd736
commit
41bf214fd7
3 changed files with 16 additions and 5 deletions
|
@ -1,3 +1,10 @@
|
|||
Thu May 15 23:01:06 2008 Yusuke Endoh <mame@tsg.ne.jp>
|
||||
|
||||
* string.c (tr_find): String#delete returned wrong result when multiple
|
||||
utf-8 arguments are passed.
|
||||
|
||||
* test/ruby/test_m17n.rb (test_delete): add a test for above.
|
||||
|
||||
Thu May 15 22:37:56 2008 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* parse.y (ripper_warningS): now used.
|
||||
|
|
10
string.c
10
string.c
|
@ -4530,13 +4530,13 @@ tr_find(int c, char table[256], VALUE del, VALUE nodel)
|
|||
else {
|
||||
VALUE v = INT2NUM(c);
|
||||
|
||||
if (!del || NIL_P(rb_hash_lookup(del, v))) {
|
||||
return Qfalse;
|
||||
}
|
||||
if (nodel && NIL_P(rb_hash_lookup(nodel, v)))
|
||||
return Qfalse;
|
||||
if (del && !NIL_P(rb_hash_lookup(del, v))) {
|
||||
if (!nodel || NIL_P(rb_hash_lookup(nodel, v))) {
|
||||
return Qtrue;
|
||||
}
|
||||
}
|
||||
return Qfalse;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -894,6 +894,10 @@ class TestM17N < Test::Unit::TestCase
|
|||
assert_equal(1, e("\xa1\xa2").delete("z").length)
|
||||
s = e("\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4")
|
||||
assert_raise(ArgumentError){s.delete(a("\xa3\xb2"))}
|
||||
|
||||
a = "\u3042\u3044\u3046\u3042\u3044\u3046"
|
||||
a.delete!("\u3042\u3044", "^\u3044")
|
||||
assert_equal("\u3044\u3046\u3044\u3046", a)
|
||||
end
|
||||
|
||||
def test_include?
|
||||
|
|
Loading…
Reference in a new issue