ruby-changes:42333
From: naruse <ko1@a...>
Date: Tue, 29 Mar 2016 23:48:45 +0900 (JST)
Subject: [ruby-changes:42333] naruse:r54407 (ruby_2_3): merge revision(s) 53877, 53881: [Backport #12081]
naruse 2016-03-29 23:48:39 +0900 (Tue, 29 Mar 2016) New Revision: 54407 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54407 Log: merge revision(s) 53877,53881: [Backport #12081] * dir.c (push_pattern, push_glob): deal with read paths as UTF-8 to stat later, on Windows as well as OS X. [ruby-core:73868] [Bug #12081] Modified directories: branches/ruby_2_3/ Modified files: branches/ruby_2_3/ChangeLog branches/ruby_2_3/dir.c branches/ruby_2_3/test/ruby/test_dir_m17n.rb branches/ruby_2_3/version.h Index: ruby_2_3/ChangeLog =================================================================== --- ruby_2_3/ChangeLog (revision 54406) +++ ruby_2_3/ChangeLog (revision 54407) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ChangeLog#L1 +Tue Mar 29 23:45:24 2016 Nobuyoshi Nakada <nobu@r...> + + * dir.c (push_pattern, push_glob): deal with read paths as UTF-8 + to stat later, on Windows as well as OS X. + [ruby-core:73868] [Bug #12081] + Tue Mar 29 23:36:49 2016 Nobuyoshi Nakada <nobu@r...> * ext/extmk.rb: add cygwin case, nothing excluded. Index: ruby_2_3/test/ruby/test_dir_m17n.rb =================================================================== --- ruby_2_3/test/ruby/test_dir_m17n.rb (revision 54406) +++ ruby_2_3/test/ruby/test_dir_m17n.rb (revision 54407) @@ -365,10 +365,24 @@ class TestDir_M17N < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/ruby/test_dir_m17n.rb#L365 def test_glob_encoding with_tmpdir do - %W"file_one.ext file_two.ext".each {|f| open(f, "w") {}} + list = %W"file_one.ext file_two.ext \u{6587 4ef6}1.txt \u{6587 4ef6}2.txt" + list.each {|f| open(f, "w") {}} a = "file_one*".force_encoding Encoding::IBM437 b = "file_two*".force_encoding Encoding::EUC_JP assert_equal([a, b].map(&:encoding), Dir[a, b].map(&:encoding)) + dir = "\u{76EE 5F551}" + Dir.mkdir(dir) + list << dir + bug12081 = '[ruby-core:73868] [Bug #12081]' + a = "*".force_encoding("us-ascii") + result = Dir[a].map {|n| + if n.encoding == Encoding::ASCII_8BIT + n.force_encoding(Encoding::UTF_8) + else + n.encode(Encoding::UTF_8) + end + } + assert_equal(list, result.sort!, bug12081) end end Index: ruby_2_3/version.h =================================================================== --- ruby_2_3/version.h (revision 54406) +++ ruby_2_3/version.h (revision 54407) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1 #define RUBY_VERSION "2.3.0" #define RUBY_RELEASE_DATE "2016-03-29" -#define RUBY_PATCHLEVEL 55 +#define RUBY_PATCHLEVEL 56 #define RUBY_RELEASE_YEAR 2016 #define RUBY_RELEASE_MONTH 3 Index: ruby_2_3/dir.c =================================================================== --- ruby_2_3/dir.c (revision 54406) +++ ruby_2_3/dir.c (revision 54407) @@ -2027,7 +2027,7 @@ rb_glob(const char *path, void (*func)(c https://github.com/ruby/ruby/blob/trunk/ruby_2_3/dir.c#L2027 static void push_pattern(const char *path, VALUE ary, void *enc) { -#ifdef __APPLE__ +#if defined _WIN32 || defined __APPLE__ VALUE name = rb_utf8_str_new_cstr(path); rb_encoding *eenc = rb_default_internal_encoding(); OBJ_TAINT(name); @@ -2148,7 +2148,7 @@ push_glob(VALUE ary, VALUE str, int flag https://github.com/ruby/ruby/blob/trunk/ruby_2_3/dir.c#L2148 struct push_glob_args args; rb_encoding *enc = rb_enc_get(str); -#ifdef __APPLE__ +#if defined _WIN32 || defined __APPLE__ str = rb_str_encode_ospath(str); #endif if (rb_enc_to_index(enc) == ENCINDEX_US_ASCII) @@ -2160,7 +2160,7 @@ push_glob(VALUE ary, VALUE str, int flag https://github.com/ruby/ruby/blob/trunk/ruby_2_3/dir.c#L2160 args.glob.value = ary; args.glob.enc = enc; args.flags = flags; -#ifdef __APPLE__ +#if defined _WIN32 || defined __APPLE__ enc = rb_utf8_encoding(); #endif Property changes on: ruby_2_3 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r53877,53881 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/