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

ruby-changes:16484

From: usa <ko1@a...>
Date: Tue, 29 Jun 2010 14:20:23 +0900 (JST)
Subject: [ruby-changes:16484] Ruby:r28473 (trunk): * file.c (rb_realpath_internal, realpath_rec): skip UNC share root

usa	2010-06-29 14:20:06 +0900 (Tue, 29 Jun 2010)

  New Revision: 28473

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

  Log:
    * file.c (rb_realpath_internal, realpath_rec): skip UNC share root
      on DOSISH platforms.
      http://pc12.2ch.net/test/read.cgi/tech/1272248179/600

  Modified files:
    trunk/ChangeLog
    trunk/file.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 28472)
+++ ChangeLog	(revision 28473)
@@ -1,3 +1,9 @@
+Tue Jun 29 14:18:21 2010  NAKAMURA Usaku  <usa@r...>
+
+	* file.c (rb_realpath_internal, realpath_rec): skip UNC share root
+	  on DOSISH platforms.
+	  http://pc12.2ch.net/test/read.cgi/tech/1272248179/600
+
 Tue Jun 29 11:52:33 2010  Narihiro Nakamura  <authorNari@g...>
 
 	* gc.c (unlink_heap_slot, slot_sweep): unlink heaps_slot of
Index: file.c
===================================================================
--- file.c	(revision 28472)
+++ file.c	(revision 28473)
@@ -2699,6 +2699,18 @@
     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 @@
                     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 @@
     }
 
     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 @@
 
     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 @@
 
     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:

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

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