Skip to content

Commit

Permalink
file.c: fix for UNC
Browse files Browse the repository at this point in the history
* file.c (realpath_rec): UNC prefix does not end with path separator,
  so new separator is needed after it.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35806 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed May 26, 2012
1 parent 62bab7f commit 5212b7f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Sat May 26 16:26:30 2012 Nobuyoshi Nakada <[email protected]>

* 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 <[email protected]>

* test/ruby/test_backtrace.rb (test_caller_lev):
Expand Down
7 changes: 7 additions & 0 deletions file.c
Original file line number Diff line number Diff line change
Expand Up @@ -3350,6 +3350,13 @@ realpath_rec(long *prefixlenp, VALUE *resolvedp, const char *unresolved, VALUE l
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)) {
Expand Down
8 changes: 8 additions & 0 deletions test/ruby/test_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,14 @@ def test_realdirpath
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
Expand Down

0 comments on commit 5212b7f

Please sign in to comment.