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

ruby-changes:30389

From: nobu <ko1@a...>
Date: Fri, 9 Aug 2013 22:21:12 +0900 (JST)
Subject: [ruby-changes:30389] nobu:r42468 (trunk): ruby.c: use String path version parser functions

nobu	2013-08-09 22:20:58 +0900 (Fri, 09 Aug 2013)

  New Revision: 42468

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

  Log:
    ruby.c: use String path version parser functions
    
    * ruby.c (load_file_internal): use rb_parser_compile_string_path and
      rb_parser_compile_file_path, String path name versions.  [Bug #8753]

  Modified files:
    trunk/ChangeLog
    trunk/ruby.c
    trunk/test/ruby/test_require.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 42467)
+++ ChangeLog	(revision 42468)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Aug  9 22:20:51 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* ruby.c (load_file_internal): use rb_parser_compile_string_path and
+	  rb_parser_compile_file_path, String path name versions.  [Bug #8753]
+
 Fri Aug  9 07:16:00 2013  Charlie Somerville  <charliesome@r...>
 
 	* ext/io/console/console.c: delete redefinition of rb_cloexec_open.
Index: ruby.c
===================================================================
--- ruby.c	(revision 42467)
+++ ruby.c	(revision 42468)
@@ -1587,9 +1587,9 @@ load_file_internal(VALUE arg) https://github.com/ruby/ruby/blob/trunk/ruby.c#L1587
     extern VALUE rb_stdin;
     struct load_file_arg *argp = (struct load_file_arg *)arg;
     VALUE parser = argp->parser;
-    VALUE fname_v = rb_str_encode_ospath(argp->fname);
+    VALUE orig_fname = argp->fname;
+    VALUE fname_v = rb_str_encode_ospath(orig_fname);
     const char *fname = StringValueCStr(fname_v);
-    const char *orig_fname = StringValueCStr(argp->fname);
     int script = argp->script;
     struct cmdline_options *opt = argp->opt;
     VALUE f;
@@ -1723,10 +1723,10 @@ load_file_internal(VALUE arg) https://github.com/ruby/ruby/blob/trunk/ruby.c#L1723
     if (NIL_P(f)) {
 	f = rb_str_new(0, 0);
 	rb_enc_associate(f, enc);
-	return (VALUE)rb_parser_compile_string(parser, orig_fname, f, line_start);
+	return (VALUE)rb_parser_compile_string_path(parser, orig_fname, f, line_start);
     }
     rb_funcall(f, set_encoding, 2, rb_enc_from_encoding(enc), rb_str_new_cstr("-"));
-    tree = rb_parser_compile_file(parser, orig_fname, f, line_start);
+    tree = rb_parser_compile_file_path(parser, orig_fname, f, line_start);
     rb_funcall(f, set_encoding, 1, rb_parser_encoding(parser));
     if (script && tree && rb_parser_end_seen_p(parser)) {
 	/*
Index: test/ruby/test_require.rb
===================================================================
--- test/ruby/test_require.rb	(revision 42467)
+++ test/ruby/test_require.rb	(revision 42468)
@@ -68,6 +68,13 @@ class TestRequire < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_require.rb#L68
     assert_require_nonascii_path(encoding, bug8676)
   end
 
+  def test_require_nonascii_path_shift_jis
+    bug8676 = '[ruby-core:56136] [Bug #8676]'
+    encoding = Encoding::Shift_JIS
+    return if Encoding.find('filesystem') == encoding
+    assert_require_nonascii_path(encoding, bug8676)
+  end
+
   def assert_require_nonascii_path(encoding, bug)
     Dir.mktmpdir {|tmp|
       dir = "\u3042" * 5
@@ -77,7 +84,7 @@ class TestRequire < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_require.rb#L84
         skip "cannot convert path encoding to #{encoding}"
       end
       Dir.mkdir(File.dirname(require_path))
-      open(require_path, "wb") {}
+      open(require_path, "wb") {|f| f.puts '$:.push __FILE__'}
       begin
         load_path = $:.dup
         features = $".dup
@@ -87,6 +94,8 @@ class TestRequire < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_require.rb#L94
         $:.clear
         assert_nothing_raised(LoadError, bug) {
           assert(require(require_path), bug)
+          assert_equal(Encoding.find(encoding), $".last.encoding)
+          assert_equal(Encoding.find(encoding), $:.last.encoding, '[Bug #8753]')
           assert(!require(require_path), bug)
         }
       ensure

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

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