summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-07 04:34:34 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-07 04:34:34 +0000
commite895bc3cdb71eb950951f6a7b7ce70bcb2ae9022 (patch)
tree3c57971c07372421166c18c035036508e0a35bc5
parent9041ac4289cc88751d4d7d492f0402c13fac3057 (diff)
* enum.c (rb_enum_join): non-nil separator must be convertible to
String. [ruby-core:24172] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--enum.c1
-rw-r--r--test/ruby/test_enum.rb9
3 files changed, 15 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index f6728bb5a2..6b4396f744 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Jul 7 13:34:30 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * enum.c (rb_enum_join): non-nil separator must be convertible to
+ String. [ruby-core:24172]
+
Tue Jul 7 12:47:28 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
* enum.c (rb_enum_join): should propagate taint to the return
diff --git a/enum.c b/enum.c
index bb480ba9ea..cab612bbb3 100644
--- a/enum.c
+++ b/enum.c
@@ -1828,6 +1828,7 @@ rb_enum_join(VALUE obj, VALUE sep)
args[0] = 0;
args[1] = sep;
+ if (!NIL_P(sep)) StringValue(args[1]);
rb_block_call(obj, id_each, 0, 0, join_i, (VALUE)args);
if (!args[0]) args[0] = rb_str_new(0, 0);
OBJ_INFECT(args[0], obj);
diff --git a/test/ruby/test_enum.rb b/test/ruby/test_enum.rb
index 6f27c5b826..e0e77b4869 100644
--- a/test/ruby/test_enum.rb
+++ b/test/ruby/test_enum.rb
@@ -285,8 +285,15 @@ class TestEnumerable < Test::Unit::TestCase
end
def test_join
+ ofs = $,
assert_equal("abc", ("a".."c").join(""))
assert_equal("a-b-c", ("a".."c").join("-"))
+ $, = "-"
+ assert_equal("a-b-c", ("a".."c").join())
+ $, = nil
+ assert_equal("abc", ("a".."c").join())
+ assert_equal("123", (1..3).join())
+ assert_raise(TypeError, '[ruby-core:24172]') {("a".."c").join(1)}
class << (e = Object.new.extend(Enumerable))
def to_s
"e"
@@ -296,5 +303,7 @@ class TestEnumerable < Test::Unit::TestCase
end
end
assert_equal("e", e.join(""))
+ ensure
+ $, = ofs
end
end