public
Description: ruby lang (www.ruby-lang.org) svn mirror
Homepage: http://svn.ruby-lang.org/repos/ruby/
Clone URL: git://github.com/juretta/ruby.git
* 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: http://svn.ruby-lang.org/repos/ruby/trunk@16426 
b2dd03c8-39d4-4d8f-98ff-823fe69b080e
mame (author)
Thu May 15 07:03:21 -0700 2008
commit  73c51efe974f7c0b9490680824f1f948ac797388
tree    ca92b5c2e59f8f706e9f482b84f482dbb2a64193
parent  3e94ba46431b889c34088e10ac14d2d86d7df4db
...
 
 
 
 
 
 
 
1
2
3
...
1
2
3
4
5
6
7
8
9
10
0
@@ -1,3 +1,10 @@
0
+Thu May 15 23:01:06 2008 Yusuke Endoh <mame@tsg.ne.jp>
0
+
0
+ * string.c (tr_find): String#delete returned wrong result when multiple
0
+ utf-8 arguments are passed.
0
+
0
+ * test/ruby/test_m17n.rb (test_delete): add a test for above.
0
+
0
 Thu May 15 22:37:56 2008 NAKAMURA Usaku <usa@ruby-lang.org>
0
 
0
   * parse.y (ripper_warningS): now used.
...
4530
4531
4532
4533
4534
 
 
 
 
4535
4536
4537
4538
 
4539
4540
4541
...
4530
4531
4532
 
 
4533
4534
4535
4536
4537
 
 
 
4538
4539
4540
4541
0
@@ -4530,12 +4530,12 @@ tr_find(int c, char table[256], VALUE del, VALUE nodel)
0
     else {
0
   VALUE v = INT2NUM(c);
0
 
0
- if (!del || NIL_P(rb_hash_lookup(del, v))) {
0
- return Qfalse;
0
+ if (del && !NIL_P(rb_hash_lookup(del, v))) {
0
+ if (!nodel || NIL_P(rb_hash_lookup(nodel, v))) {
0
+ return Qtrue;
0
+ }
0
   }
0
- if (nodel && NIL_P(rb_hash_lookup(nodel, v)))
0
- return Qfalse;
0
- return Qtrue;
0
+ return Qfalse;
0
     }
0
 }
0
 
...
894
895
896
 
 
 
 
897
898
899
...
894
895
896
897
898
899
900
901
902
903
0
@@ -894,6 +894,10 @@ class TestM17N < Test::Unit::TestCase
0
     assert_equal(1, e("\xa1\xa2").delete("z").length)
0
     s = e("\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4")
0
     assert_raise(ArgumentError){s.delete(a("\xa3\xb2"))}
0
+
0
+ a = "\u3042\u3044\u3046\u3042\u3044\u3046"
0
+ a.delete!("\u3042\u3044", "^\u3044")
0
+ assert_equal("\u3044\u3046\u3044\u3046", a)
0
   end
0
 
0
   def test_include?

Comments

    No one has commented yet.