ruby-changes:23755
From: nobu <ko1@a...>
Date: Sat, 26 May 2012 16:26:46 +0900 (JST)
Subject: [ruby-changes:23755] nobu:r35806 (trunk): file.c: fix for UNC
nobu 2012-05-26 16:26:36 +0900 (Sat, 26 May 2012) New Revision: 35806 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=35806 Log: file.c: fix for UNC * file.c (realpath_rec): UNC prefix does not end with path separator, so new separator is needed after it. Modified files: trunk/ChangeLog trunk/file.c trunk/test/ruby/test_file.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 35805) +++ ChangeLog (revision 35806) @@ -1,3 +1,8 @@ +Sat May 26 16:26:30 2012 Nobuyoshi Nakada <nobu@r...> + + * file.c (realpath_rec): UNC prefix does not end with path separator, + so new separator is needed after it. + Sat May 26 15:29:22 2012 Koichi Sasada <ko1@a...> * test/ruby/test_backtrace.rb (test_caller_lev): Index: test/ruby/test_file.rb =================================================================== --- test/ruby/test_file.rb (revision 35805) +++ test/ruby/test_file.rb (revision 35806) @@ -231,6 +231,14 @@ assert_equal(realdir, File.realdirpath(".", tst)) assert_equal(File.join(realdir, "foo"), File.realdirpath("foo", tst)) } + begin + result = File.realdirpath("bar", "//:/foo") + rescue SystemCallError + else + if result.start_with?("//") + assert_equal("//:/foo/bar", result) + end + end end def test_utime_with_minus_time_segv Index: file.c =================================================================== --- file.c (revision 35805) +++ file.c (revision 35806) @@ -3350,6 +3350,13 @@ VALUE testpath = rb_str_dup(*resolvedp); if (*prefixlenp < RSTRING_LEN(testpath)) rb_str_cat2(testpath, "/"); +#if defined(DOSISH_UNC) || defined(DOSISH_DRIVE_LETTER) + if (*prefixlenp > 1 && *prefixlenp == RSTRING_LEN(testpath)) { + const char *prefix = RSTRING_PTR(testpath); + const char *last = rb_enc_left_char_head(prefix, prefix + *prefixlenp - 1, prefix + *prefixlenp, enc); + if (!isdirsep(*last)) rb_str_cat2(testpath, "/"); + } +#endif rb_str_cat(testpath, testname, testnamelen); checkval = rb_hash_aref(loopcheck, testpath); if (!NIL_P(checkval)) { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/