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

ruby-changes:30119

From: naruse <ko1@a...>
Date: Fri, 26 Jul 2013 01:34:08 +0900 (JST)
Subject: [ruby-changes:30119] naruse:r42171 (trunk): * file.c (rb_file_expand_path_internal): fix r42160; skip '~'.

naruse	2013-07-26 01:33:57 +0900 (Fri, 26 Jul 2013)

  New Revision: 42171

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

  Log:
    * file.c (rb_file_expand_path_internal): fix r42160; skip '~'.

  Modified files:
    trunk/ChangeLog
    trunk/file.c
    trunk/test/ruby/test_file_exhaustive.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 42170)
+++ ChangeLog	(revision 42171)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Jul 26 01:21:41 2013  NARUSE, Yui  <naruse@r...>
+
+	* file.c (rb_file_expand_path_internal): fix r42160; skip '~'.
+
 Thu Jul 25 17:53:18 2013  NARUSE, Yui  <naruse@r...>
 
 	* lib/net/http.rb (Net::HTTP#connect): disable Nagle's algorithm on
Index: test/ruby/test_file_exhaustive.rb
===================================================================
--- test/ruby/test_file_exhaustive.rb	(revision 42170)
+++ test/ruby/test_file_exhaustive.rb	(revision 42171)
@@ -669,6 +669,11 @@ class TestFileExhaustive < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file_exhaustive.rb#L669
     assert_raise(ArgumentError, bug) { File.expand_path("~anything") }
   end if DRIVE
 
+  def test_expand_path_for_existent_username
+    user = ENV['USER']
+    assert_equal(ENV['HOME'], File.expand_path("~#{user}"))
+  end unless DRIVE
+
   def test_expand_path_error_for_nonexistent_username
     user = "\u{3086 3046 3066 3044}:\u{307F 3084 304A 3046}"
     assert_raise_with_message(ArgumentError, /#{user}/) {File.expand_path("~#{user}")}
Index: file.c
===================================================================
--- file.c	(revision 42170)
+++ file.c	(revision 42171)
@@ -2990,6 +2990,7 @@ rb_file_expand_path_internal(VALUE fname https://github.com/ruby/ruby/blob/trunk/file.c#L2990
 	}
 	else {
 	    s = nextdirsep(b = s, fend, enc);
+	    b++; /* b[0] is '~' */
 	    userlen = s - b;
 	    BUFCHECK(bdiff + userlen >= buflen);
 	    memcpy(p, b, userlen);

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

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