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

ruby-changes:15072

From: nobu <ko1@a...>
Date: Tue, 16 Mar 2010 11:24:13 +0900 (JST)
Subject: [ruby-changes:15072] Ruby:r26948 (trunk): * file.c (file_expand_path): ignore dname if it has different

nobu	2010-03-16 11:23:51 +0900 (Tue, 16 Mar 2010)

  New Revision: 26948

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

  Log:
    * file.c (file_expand_path): ignore dname if it has different
      drive letter or UNC.

  Modified files:
    trunk/ChangeLog
    trunk/file.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 26947)
+++ ChangeLog	(revision 26948)
@@ -1,3 +1,8 @@
+Tue Mar 16 11:23:42 2010  Nobuyoshi Nakada  <nobu@r...>
+
+	* file.c (file_expand_path): ignore dname if it has different
+	  drive letter or UNC.
+
 Tue Mar 16 07:16:56 2010  Tanaka Akira  <akr@f...>
 
 	* tool/transcode-tblgen.rb: redundant loop removed.
Index: file.c
===================================================================
--- file.c	(revision 26947)
+++ file.c	(revision 26948)
@@ -2518,6 +2518,12 @@
 # define CharNext(p) ((p) + 1)
 #endif
 
+#if defined(DOSISH_UNC)
+#define has_unc(buf) (isdirsep((buf)[0]) && isdirsep((buf)[1]))
+#else
+#define has_unc(buf) 0
+#endif
+
 #ifdef DOSISH_DRIVE_LETTER
 static inline int
 has_drive_letter(const char *buf)
@@ -2556,6 +2562,19 @@
     }
     return drvcwd;
 }
+
+static inline int
+not_same_drive(VALUE path, int drive)
+{
+    const char *p = RSTRING_PTR(path);
+    if (RSTRING_LEN(path) < 2) return 0;
+    if (has_drive_letter(p)) {
+	return TOLOWER(p[0]) != TOLOWER(drive);
+    }
+    else {
+	return has_unc(p);
+    }
+}
 #endif
 
 static inline char *
@@ -2781,7 +2800,7 @@
 	else {
 	    /* specified drive, but not full path */
 	    int same = 0;
-	    if (!NIL_P(dname)) {
+	    if (!NIL_P(dname) || !not_same_drive(dname, s[0])) {
 		file_expand_path(dname, Qnil, abs_mode, result);
 		BUFINIT();
 		if (has_drive_letter(p) && TOLOWER(p[0]) == TOLOWER(s[0])) {

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

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