summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-15 14:03:21 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-15 14:03:21 +0000
commit41bf214fd7273b2156e96dd600d57a578481daf1 (patch)
treeca92b5c2e59f8f706e9f482b84f482dbb2a64193
parent42389bd7361dc0e16687ef473c7a0d4a45c31dce (diff)
* 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
-rw-r--r--ChangeLog7
-rw-r--r--string.c10
-rw-r--r--test/ruby/test_m17n.rb4
3 files changed, 16 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index fb67511..a0c4f46 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/string.c b/string.c
index 7fd09d0..67f1e33 100644
--- a/string.c
+++ b/string.c
@@ -4530,12 +4530,12 @@ 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 (del && !NIL_P(rb_hash_lookup(del, v))) {
+ if (!nodel || NIL_P(rb_hash_lookup(nodel, v))) {
+ return Qtrue;
+ }
}
- if (nodel && NIL_P(rb_hash_lookup(nodel, v)))
- return Qfalse;
- return Qtrue;
+ return Qfalse;
}
}
diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb
index 3fd32ae..e5f9f85 100644
--- a/test/ruby/test_m17n.rb
+++ b/test/ruby/test_m17n.rb
@@ -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?