changeset 50505:b4cb33eddbaa

(file-chase-links): New arg LIMIT. After that many iterations, just return what we've got.
author Richard M. Stallman <rms@gnu.org>
date Wed, 09 Apr 2003 01:34:38 +0000
parents e907858b9aef
children 6cc9a6c84a94
files lisp/files.el
diffstat 1 files changed, 11 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/files.el	Wed Apr 09 01:33:27 2003 +0000
+++ b/lisp/files.el	Wed Apr 09 01:34:38 2003 +0000
@@ -738,14 +738,19 @@
 		  (setq done t))))))))
     filename))
 
-(defun file-chase-links (filename)
+(defun file-chase-links (filename &optional limit)
   "Chase links in FILENAME until a name that is not a link.
-Does not examine containing directories for links,
-unlike `file-truename'."
-  (let (tem (count 100) (newname filename))
-    (while (setq tem (file-symlink-p newname))
+Unlike `file-truename', this does not check whether a parent
+directory name is a symbolic link.
+If the optional argument LIMIT is a number,
+it means chase no more than that many links and then stop."
+  (let (tem (newname filename)
+	    (count 0)
+	    (max (max limit 100)))
+    (while (and (or (null limit) (< count limit))
+		(setq tem (file-symlink-p newname)))
       (save-match-data
-	(if (= count 0)
+	(if (= count max)
 	    (error "Apparent cycle of symbolic links for %s" filename))
 	;; In the context of a link, `//' doesn't mean what Emacs thinks.
 	(while (string-match "//+" tem)