Commit c3bf10c2 authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

(file-truename): Don't use expand-file-name to merge

a link target into the previous dir.  Handle .. and . explicitly.
parent a135645a
......@@ -329,6 +329,10 @@ containing it, until no links are left at any level."
;; If these are equal, we have the (or a) root directory.
(or (string= dir dirfile)
(setq dir (file-name-as-directory (file-truename dirfile))))
(if (equal ".." (file-name-nondirectory filename))
(directory-file-name (file-name-directory (directory-file-name dir)))
(if (equal "." (file-name-nondirectory filename))
(directory-file-name dir)
;; Put it back on the file name.
(setq filename (concat dir (file-name-nondirectory filename)))
;; Is the file name the name of a link?
......@@ -336,9 +340,14 @@ containing it, until no links are left at any level."
(if target
;; Yes => chase that link, then start all over
;; since the link may point to a directory name that uses links.
(file-truename (expand-file-name target dir))
;; We can't safely use expand-file-name here
;; since target might look like foo/../bar where foo
;; is itself a link. Instead, we handle . and .. above.
(if (file-name-absolute-p target)
(file-truename target)
(file-truename (concat dir target)))
;; No, we are done!
filename)))))
filename)))))))
(defun file-chase-links (filename)
"Chase links in FILENAME until a name that is not a link.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment