[前][次][番号順一覧][スレッド一覧]

ruby-changes:38464

From: nagachika <ko1@a...>
Date: Wed, 20 May 2015 02:23:38 +0900 (JST)
Subject: [ruby-changes:38464] nagachika:r50545 (ruby_2_2): merge revision(s) 49859, 49861, 49865: [Backport #10941] [Backport #10978] [Backport #11089]

nagachika	2015-05-20 02:23:27 +0900 (Wed, 20 May 2015)

  New Revision: 50545

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50545

  Log:
    merge revision(s) 49859,49861,49865: [Backport #10941] [Backport #10978] [Backport #11089]
    
    * dir.c (replace_real_basename): shouldn't create Ruby object before
      the object system is loaded.
      [ruby-core:68430] [Bug #10941]
    
    * dir.c (replace_real_basename): need to check the return value of
      GLOB_REALLOC().

  Modified directories:
    branches/ruby_2_2/
  Modified files:
    branches/ruby_2_2/ChangeLog
    branches/ruby_2_2/dir.c
    branches/ruby_2_2/test/ruby/test_rubyoptions.rb
    branches/ruby_2_2/version.h
Index: ruby_2_2/ChangeLog
===================================================================
--- ruby_2_2/ChangeLog	(revision 50544)
+++ ruby_2_2/ChangeLog	(revision 50545)
@@ -1,3 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1
+Wed May 20 02:16:05 2015  NAKAMURA Usaku  <usa@r...>
+
+	* dir.c (replace_real_basename): need to check the return value of
+	  GLOB_REALLOC().
+
+Wed May 20 02:16:05 2015  NAKAMURA Usaku  <usa@r...>
+
+	* dir.c (replace_real_basename): shouldn't create Ruby object before
+	  the object system is loaded.
+	  [ruby-core:68430] [Bug #10941]
+
 Wed May 20 01:58:12 2015  Tanaka Akira  <akr@f...>
 
 	* lib/resolv.rb (Resolv::DNS::Label::Str#==): Check class equality.
Index: ruby_2_2/dir.c
===================================================================
--- ruby_2_2/dir.c	(revision 50544)
+++ ruby_2_2/dir.c	(revision 50545)
@@ -1481,12 +1481,34 @@ replace_real_basename(char *path, long b https://github.com/ruby/ruby/blob/trunk/ruby_2_2/dir.c#L1481
     free(wplain);
     if (h == INVALID_HANDLE_VALUE) return path;
     FindClose(h);
-    tmp = rb_w32_conv_from_wchar(fd.cFileName, enc);
-    wlen = RSTRING_LEN(tmp);
-    path = GLOB_REALLOC(path, base + wlen + 1);
-    memcpy(path + base, RSTRING_PTR(tmp), wlen);
-    path[base + wlen] = 0;
-    rb_str_resize(tmp, 0);
+    if (tmp) {
+	char *buf;
+	tmp = rb_w32_conv_from_wchar(fd.cFileName, enc);
+	wlen = RSTRING_LEN(tmp);
+	buf = GLOB_REALLOC(path, base + wlen + 1);
+	if (buf) {
+	    path = buf;
+	    memcpy(path + base, RSTRING_PTR(tmp), wlen);
+	    path[base + wlen] = 0;
+	}
+	rb_str_resize(tmp, 0);
+    }
+    else {
+	char *utf8filename;
+	wlen = WideCharToMultiByte(CP_UTF8, 0, fd.cFileName, -1, NULL, 0, NULL, NULL);
+	utf8filename = GLOB_REALLOC(0, wlen);
+	if (utf8filename) {
+	    char *buf;
+	    WideCharToMultiByte(CP_UTF8, 0, fd.cFileName, -1, utf8filename, wlen, NULL, NULL);
+	    buf = GLOB_REALLOC(path, base + wlen + 1);
+	    if (buf) {
+		path = buf;
+		memcpy(path + base, utf8filename, wlen);
+		path[base + wlen] = 0;
+	    }
+	    GLOB_FREE(utf8filename);
+	}
+    }
     return path;
 }
 #elif USE_NAME_ON_FS == 1
Index: ruby_2_2/version.h
===================================================================
--- ruby_2_2/version.h	(revision 50544)
+++ ruby_2_2/version.h	(revision 50545)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1
 #define RUBY_VERSION "2.2.3"
 #define RUBY_RELEASE_DATE "2015-05-20"
-#define RUBY_PATCHLEVEL 104
+#define RUBY_PATCHLEVEL 105
 
 #define RUBY_RELEASE_YEAR 2015
 #define RUBY_RELEASE_MONTH 5
Index: ruby_2_2/test/ruby/test_rubyoptions.rb
===================================================================
--- ruby_2_2/test/ruby/test_rubyoptions.rb	(revision 50544)
+++ ruby_2_2/test/ruby/test_rubyoptions.rb	(revision 50545)
@@ -720,6 +720,14 @@ class TestRubyOptions < Test::Unit::Test https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_rubyoptions.rb#L720
                           bug10555, encoding: "locale")
       end
     end
+
+    def test_command_line_glob_with_dir
+      bug10941 = '[ruby-core:68430] [Bug #10941]'
+      with_tmpchdir do |dir|
+        Dir.mkdir('test')
+        assert_in_out_err(["-e", "", "test/*"], "", [], [], bug10941)
+      end
+    end
   end
 
   if /mswin|mingw/ =~ RUBY_PLATFORM

Property changes on: ruby_2_2
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r49859,49861,49865


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]