changeset 1231:f1090e965244

(file-relative-name): Rewritten so unrelativizable file names win.
author Roland McGrath <roland@gnu.org>
date Sun, 27 Sep 1992 02:40:49 +0000
parents f882f7a19c60
children 2c56a159c9b6
files lisp/files.el
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/files.el	Sun Sep 27 02:27:00 1992 +0000
+++ b/lisp/files.el	Sun Sep 27 02:40:49 1992 +0000
@@ -943,9 +943,17 @@
 	directory (file-name-as-directory (if directory
 					      (expand-file-name directory)
 					      default-directory)))
-  (while (not (string-match (concat "^" (regexp-quote directory)) filename))
-    (setq directory (file-name-directory (substring directory 0 -1))))
-  (substring filename (match-end 0)))
+  (let ((strip (lambda (directory)
+		 (cond ((string= directory "/")
+			filename)
+		       ((string-match (concat "^" (regexp-quote directory))
+				      filename)
+			(substring filename (match-end 0)))
+		       (t
+			(funcall strip
+				 (file-name-directory (substring directory
+								 0 -1))))))))
+    (funcall strip directory)))
 
 (defun save-buffer (&optional args)
   "Save current buffer in visited file if modified.  Versions described below.