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

ruby-changes:28346

From: nagachika <ko1@a...>
Date: Sun, 21 Apr 2013 00:15:03 +0900 (JST)
Subject: [ruby-changes:28346] nagachika:r40398 (ruby_2_0_0): merge revision(s) 40135,40148,40173: [Backport #8165]

nagachika	2013-04-21 00:14:51 +0900 (Sun, 21 Apr 2013)

  New Revision: 40398

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

  Log:
    merge revision(s) 40135,40148,40173: [Backport #8165]
    
    * load.c (features_index_add): use rb_str_subseq() to specify C string
      position properly to fix require non ascii path.
      [ruby-core:53733] [Bug #8165]
    
    * test/ruby/test_require.rb (TestRequire#test_require_nonascii_path):
      a test for the above.
    
    * test/ruby/test_require.rb (TestRequire#test_require_nonascii_path):
      fix load path for encoding to run the test as stand-alone.
    
    * test/ruby/test_require.rb (TestRequire#test_require_nonascii_path):
      RUBY_PLATFORM should escape as Regexp,
      because RUBY_PLATFORM may contain '.'.

  Modified directories:
    branches/ruby_2_0_0/
  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/load.c
    branches/ruby_2_0_0/test/ruby/test_require.rb
    branches/ruby_2_0_0/version.h

Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 40397)
+++ ruby_2_0_0/ChangeLog	(revision 40398)
@@ -1,3 +1,23 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Sun Apr 21 00:14:36 2013  Kazuhiro NISHIYAMA  <zn@m...>
+
+	* test/ruby/test_require.rb (TestRequire#test_require_nonascii_path):
+	  RUBY_PLATFORM should escape as Regexp,
+	  because RUBY_PLATFORM may contain '.'.
+
+Sun Apr 21 00:14:36 2013  Hiroshi Shirosaki  <h.shirosaki@g...>
+
+	* test/ruby/test_require.rb (TestRequire#test_require_nonascii_path):
+	  fix load path for encoding to run the test as stand-alone.
+
+Sun Apr 21 00:14:36 2013  Hiroshi Shirosaki  <h.shirosaki@g...>
+
+	* load.c (features_index_add): use rb_str_subseq() to specify C string
+	  position properly to fix require non ascii path.
+	  [ruby-core:53733] [Bug #8165]
+
+	* test/ruby/test_require.rb (TestRequire#test_require_nonascii_path):
+	  a test for the above.
+
 Sun Apr 21 00:13:24 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* load.c (rb_feature_p), vm_core.h (rb_vm_struct): turn
Index: ruby_2_0_0/load.c
===================================================================
--- ruby_2_0_0/load.c	(revision 40397)
+++ ruby_2_0_0/load.c	(revision 40398)
@@ -247,16 +247,16 @@ features_index_add(VALUE feature, VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/load.c#L247
 	if (p < feature_str)
 	    break;
 	/* Now *p == '/'.  We reach this point for every '/' in `feature`. */
-	short_feature = rb_str_substr(feature, p + 1 - feature_str, feature_end - p - 1);
+	short_feature = rb_str_subseq(feature, p + 1 - feature_str, feature_end - p - 1);
 	features_index_add_single(short_feature, offset);
 	if (ext) {
-	    short_feature = rb_str_substr(feature, p + 1 - feature_str, ext - p - 1);
+	    short_feature = rb_str_subseq(feature, p + 1 - feature_str, ext - p - 1);
 	    features_index_add_single(short_feature, offset);
 	}
     }
     features_index_add_single(feature, offset);
     if (ext) {
-	short_feature = rb_str_substr(feature, 0, ext - feature_str);
+	short_feature = rb_str_subseq(feature, 0, ext - feature_str);
 	features_index_add_single(short_feature, offset);
     }
 }
Index: ruby_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 40397)
+++ ruby_2_0_0/version.h	(revision 40398)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1
 #define RUBY_VERSION "2.0.0"
 #define RUBY_RELEASE_DATE "2013-04-21"
-#define RUBY_PATCHLEVEL 157
+#define RUBY_PATCHLEVEL 158
 
 #define RUBY_RELEASE_YEAR 2013
 #define RUBY_RELEASE_MONTH 4
Index: ruby_2_0_0/test/ruby/test_require.rb
===================================================================
--- ruby_2_0_0/test/ruby/test_require.rb	(revision 40397)
+++ ruby_2_0_0/test/ruby/test_require.rb	(revision 40398)
@@ -58,6 +58,29 @@ class TestRequire < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_require.rb#L58
     end
   end
 
+  def test_require_nonascii_path
+    bug8165 = '[ruby-core:53733] [Bug #8165]'
+    Dir.mktmpdir {|tmp|
+      encoding = /mswin|mingw/ =~ RUBY_PLATFORM ? 'filesystem' : 'UTF-8'
+      dir = "\u3042" * 5
+      begin
+        require_path = File.join(tmp, dir, 'foo.rb').encode(encoding)
+      rescue
+        skip "cannot convert path encoding to #{encoding}"
+      end
+      Dir.mkdir(File.dirname(require_path))
+      open(require_path, "wb") {}
+      assert_in_out_err([], <<-INPUT, %w(:ok), [], bug8165)
+        # coding: #{encoding}
+        # leave paths for require encoding objects
+        enc_path = Regexp.new(Regexp.escape(RUBY_PLATFORM))
+        $:.replace([IO::NULL] + $:.reject {|path| enc_path !~ path})
+        p :ok if require '#{require_path}'
+        p :ng if require '#{require_path}'
+      INPUT
+    }
+  end
+
   def test_require_path_home_1
     env_rubypath, env_home = ENV["RUBYPATH"], ENV["HOME"]
     pathname_too_long = /pathname too long \(ignored\).*\(LoadError\)/m

Property changes on: ruby_2_0_0
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r40135,40148,40173


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

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