summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 fb6751137e..a0c4f4634f 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 7fd09d0b3a..67f1e33b17 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 3fd32ae92a..e5f9f8585f 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?