comparison lisp/files.el @ 3263:82b564084ce6

(file-chase-links): Handle leading .. in symlink target.
author Richard M. Stallman <rms@gnu.org>
date Sat, 29 May 1993 20:13:58 +0000
parents eecf2c0ca9b9
children 3b3717164db0
comparison
equal deleted inserted replaced
3262:4ece9a6d1f37 3263:82b564084ce6
349 unlike `file-truename'." 349 unlike `file-truename'."
350 (let (tem (count 100) (newname filename)) 350 (let (tem (count 100) (newname filename))
351 (while (setq tem (file-symlink-p newname)) 351 (while (setq tem (file-symlink-p newname))
352 (if (= count 0) 352 (if (= count 0)
353 (error "Apparent cycle of symbolic links for %s" filename)) 353 (error "Apparent cycle of symbolic links for %s" filename))
354 ;; Handle `..' by hand, since it needs to work in the
355 ;; target of any directory symlink.
356 ;; This code is not quite complete; it does not handle
357 ;; embedded .. in some cases such as ./../foo and foo/bar/../../../lose.
358 (while (string-match "\\.\\./" tem)
359 (setq tem (substring tem 3))
360 (setq newname (file-name-as-directory
361 ;; Do the .. by hand.
362 (directory-file-name
363 (file-name-directory
364 ;; Chase links in the default dir of the symlink.
365 (file-chase-links
366 (directory-file-name
367 (file-name-directory newname))))))))
354 (setq newname (expand-file-name tem (file-name-directory newname))) 368 (setq newname (expand-file-name tem (file-name-directory newname)))
355 (setq count (1- count))) 369 (setq count (1- count)))
356 newname)) 370 newname))
357 371
358 (defun switch-to-buffer-other-window (buffer) 372 (defun switch-to-buffer-other-window (buffer)