From d629684bb91e7ea64508cd24629a44d41ff328dd Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 24 May 2009 23:06:57 +0000 Subject: [PATCH] * string.c (rb_str_rpartition): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 +++- string.c | 1 + test/ruby/test_string.rb | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 22e0426e18..b5ce069c17 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,10 @@ -Mon May 25 07:50:05 2009 Nobuyoshi Nakada +Mon May 25 08:06:52 2009 Nobuyoshi Nakada * string.c (rb_str_partition): should use the converted result. a patch from Marc-Andre Lafortune at [ruby-core:23540]. + * string.c (rb_str_rpartition): ditto. + Mon May 25 06:25:38 2009 Yukihiro Matsumoto * test/ruby/test_hash.rb (TestHash::test_equal2): recursive hashes diff --git a/string.c b/string.c index 246599d050..c75bb1003c 100644 --- a/string.c +++ b/string.c @@ -6924,6 +6924,7 @@ rb_str_rpartition(VALUE str, VALUE sep) rb_raise(rb_eTypeError, "type mismatch: %s given", rb_obj_classname(sep)); } + sep = tmp; pos = rb_str_sublen(str, pos); pos = rb_str_rindex(str, sep, pos); } diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index 4a784b18f1..1d65c84c1c 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -1712,6 +1712,8 @@ class TestString < Test::Unit::TestCase assert_equal(%w(hel l o), "hello".rpartition(/l/)) assert_equal(%w(hel l o), "hello".rpartition("l")) assert_raise(TypeError) { "hello".rpartition(1) } + def (hyphen = Object.new).to_str; "-"; end + assert_equal(%w(foo - bar), "foo-bar".rpartition(hyphen), '[ruby-core:23540]') end def test_setter