From b1bcb8265d7a06efeb876a9d70997ff50e90296d Mon Sep 17 00:00:00 2001 From: naruse Date: Thu, 1 Mar 2012 09:41:08 +0000 Subject: merge revision(s) r33525: [Backport #6104] * file.c (rb_file_join): honor input encodings than ASCII-8BIT. [ruby-core:40338] [Bug #5483] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ file.c | 5 ++++- test/ruby/test_path.rb | 9 +++++++++ version.h | 8 ++++---- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 49ad8fee91..4c30ee8113 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Mar 1 18:39:44 2012 Nobuyoshi Nakada + + * file.c (rb_file_join): honor input encodings than ASCII-8BIT. + [ruby-core:40338] [Bug #5483] + Tue Feb 28 11:56:52 2012 Nobuyoshi Nakada * configure.in (debugflags): check if -ggdb is accepted. diff --git a/file.c b/file.c index f6ec06bd4e..67b281aba1 100644 --- a/file.c +++ b/file.c @@ -3837,7 +3837,10 @@ rb_file_join(VALUE ary, VALUE sep) FilePathStringValue(tmp); } name = StringValueCStr(result); - if (i > 0 && !NIL_P(sep)) { + if (i == 0) { + rb_enc_copy(result, tmp); + } + else if (!NIL_P(sep)) { tail = chompdirsep(name); if (RSTRING_PTR(tmp) && isdirsep(RSTRING_PTR(tmp)[0])) { rb_str_set_len(result, tail - name); diff --git a/test/ruby/test_path.rb b/test/ruby/test_path.rb index 74d568ae49..2db7be0b76 100644 --- a/test/ruby/test_path.rb +++ b/test/ruby/test_path.rb @@ -247,4 +247,13 @@ class TestPath < Test::Unit::TestCase assert_raise(Encoding::CompatibilityError) {open(s.encode("utf-32be"))} assert_raise(Encoding::CompatibilityError) {open(s.encode("utf-32le"))} end + + def test_join + bug5483 = '[ruby-core:40338]' + path = %w[a b] + Encoding.list.each do |e| + next unless e.ascii_compatible? + assert_equal(e, File.join(*path.map {|s| s.force_encoding(e)}).encoding, bug5483) + end + end end diff --git a/version.h b/version.h index a98f0afa4d..8341716000 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "1.9.3" -#define RUBY_PATCHLEVEL 153 +#define RUBY_PATCHLEVEL 154 -#define RUBY_RELEASE_DATE "2012-02-28" +#define RUBY_RELEASE_DATE "2012-03-01" #define RUBY_RELEASE_YEAR 2012 -#define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 28 +#define RUBY_RELEASE_MONTH 3 +#define RUBY_RELEASE_DAY 1 #include "ruby/version.h" -- cgit v1.2.3