]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix bug #4674 with UNCs in file-relative-name.
authorEli Zaretskii <eliz@gnu.org>
Sat, 4 Dec 2010 12:52:04 +0000 (14:52 +0200)
committerEli Zaretskii <eliz@gnu.org>
Sat, 4 Dec 2010 12:52:04 +0000 (14:52 +0200)
 files.el (file-relative-name): Handle UNC file names on DOS/Windows.
 Also fixes bug#4673.

lisp/ChangeLog
lisp/files.el

index f6514c1657796da74a33b486764439dd85fd8ae8..aaa55e9abfeb2a08ff3410ed2946b9ae8f5071e3 100644 (file)
@@ -1,3 +1,8 @@
+2010-12-04  Eli Zaretskii  <eliz@gnu.org>
+
+       * files.el (file-relative-name): Handle UNC file names on
+       DOS/Windows.  (Bug#4674)
+
 2010-12-02  Glenn Morris  <rgm@gnu.org>
 
        * ps-print.el (ps-line-lengths-internal, ps-nb-pages):
index 4901c3872cd57d172eab361f79bb544793fae1dc..97dce0fc1e590834e4a126e7f55f2bb80d930e2d 100644 (file)
@@ -4054,11 +4054,29 @@ on a DOS/Windows machine, it returns FILENAME in expanded form."
           (dremote (file-remote-p directory)))
       (if ;; Conditions for separate trees
          (or
-          ;; Test for different drives on DOS/Windows
+          ;; Test for different filesystems on DOS/Windows
           (and
            ;; Should `cygwin' really be included here?  --stef
            (memq system-type '(ms-dos cygwin windows-nt))
-           (not (eq t (compare-strings filename 0 2 directory 0 2))))
+           (or
+            ;; Test for different drive letters
+            (not (eq t (compare-strings filename 0 2 directory 0 2)))
+            ;; Test for UNCs on different servers
+            (not (eq t (compare-strings
+                        (progn
+                          (if (string-match "\\`//\\([^:/]+\\)/" filename)
+                              (match-string 1 filename)
+                            ;; Windows file names cannot have ? in
+                            ;; them, so use that to detect when
+                            ;; neither FILENAME nor DIRECTORY is a
+                            ;; UNC.
+                            "?"))
+                        0 nil
+                        (progn
+                          (if (string-match "\\`//\\([^:/]+\\)/" directory)
+                              (match-string 1 directory)
+                            "?"))
+                        0 nil t)))))
           ;; Test for different remote file system identification
           (not (equal fremote dremote)))
          filename