summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-06-29 05:20:06 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-06-29 05:20:06 +0000
commite2f4729d42555b285d6da595f7e3de733f023e27 (patch)
treefc21c2a01ed3d148cfb8e5216292c6b8056a2e24 /file.c
parent12b76ec890836ee650b7985851116594d6469309 (diff)
* file.c (rb_realpath_internal, realpath_rec): skip UNC share root
on DOSISH platforms. http://pc12.2ch.net/test/read.cgi/tech/1272248179/600 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/file.c b/file.c
index 5254c2255c..cd69a587aa 100644
--- a/file.c
+++ b/file.c
@@ -2699,6 +2699,18 @@ rb_path_skip_prefix(const char *path)
return (char *)path;
}
+static inline char *
+skipprefixroot(const char *path)
+{
+#if defined(DOSISH_UNC) || defined(DOSISH_DRIVE_LETTER)
+ char *p = skipprefix(path);
+ while (isdirsep(*p)) p++;
+ return p;
+#else
+ return skiproot(path);
+#endif
+}
+
#define strrdirsep rb_path_last_separator
char *
rb_path_last_separator(const char *path)
@@ -3247,7 +3259,7 @@ realpath_rec(long *prefixlenp, VALUE *resolvedp, char *unresolved, VALUE loopche
rb_hash_aset(loopcheck, testpath, ID2SYM(resolving));
link = rb_file_s_readlink(rb_cFile, testpath);
link_prefix = RSTRING_PTR(link);
- link_names = skiproot(link_prefix);
+ link_names = skipprefixroot(link_prefix);
link_prefixlen = link_names - link_prefix;
if (link_prefixlen == 0) {
realpath_rec(prefixlenp, resolvedp, link_names, loopcheck, strict, *unresolved_firstsep == '\0');
@@ -3294,7 +3306,7 @@ rb_realpath_internal(VALUE basedir, VALUE path, int strict)
}
ptr = RSTRING_PTR(unresolved_path);
- path_names = skiproot(ptr);
+ path_names = skipprefixroot(ptr);
if (ptr != path_names) {
resolved = rb_enc_str_new(ptr, path_names - ptr,
rb_enc_get(unresolved_path));
@@ -3303,7 +3315,7 @@ rb_realpath_internal(VALUE basedir, VALUE path, int strict)
if (!NIL_P(basedir)) {
ptr = RSTRING_PTR(basedir);
- basedir_names = skiproot(ptr);
+ basedir_names = skipprefixroot(ptr);
if (ptr != basedir_names) {
resolved = rb_enc_str_new(ptr, basedir_names - ptr,
rb_enc_get(basedir));
@@ -3313,7 +3325,7 @@ rb_realpath_internal(VALUE basedir, VALUE path, int strict)
curdir = rb_dir_getwd();
ptr = RSTRING_PTR(curdir);
- curdir_names = skiproot(ptr);
+ curdir_names = skipprefixroot(ptr);
resolved = rb_enc_str_new(ptr, curdir_names - ptr, rb_enc_get(curdir));
root_found: