From: Thierry Volpiatto <thierry.volpiatto@gmail.com>
To: Lars Magne Ingebrigtsen <larsi@gnus.org>
Cc: emacs-devel@gnu.org
Subject: Re: [Emacs-diffs] master 11cf3e9: Implement a new function directory-files-recursively
Date: Sun, 14 Dec 2014 09:48:55 +0100 [thread overview]
Message-ID: <87vbler4zs.fsf@gmail.com> (raw)
In-Reply-To: <m31to34p1l.fsf@stories.gnus.org>
Lars Magne Ingebrigtsen <larsi@gnus.org> writes:
> Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:
>
>> Also it seems the function is still inflooping even with the check of
>> file-symlink-p (a bug of file-name-all-completions ?).
>
> Do you know what causes this loop? Some kind of symlink that
> `file-name-all-completions' handles incorrectly or something?
Ok I found the bug.
To reproduce:
mkdir -p ~/tmp/test/test1/test2/
touch ~/tmp/test/test1/test2/foo.txt
ln -s ~/tmp/test/ ~/tmp/test/test
(directory-files-recursively "~/tmp/test" "")
=>
--8<---------------cut here---------------start------------->8---
Debugger entered--Lisp error: (file-error "Opening directory" "trop de niveaux de liens symboliques" "/home/thierry/tmp/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/")
file-name-all-completions("" "/home/thierry/tmp/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/")
(sort (file-name-all-completions "" dir) (quote string<))
(let ((--dolist-tail-- (sort (file-name-all-completions "" dir) (quote string<)))) (while --dolist-tail-- (let ((file (car --dolist-tail--))) (if (member file (quote ("./" "../"))) nil (if (= (aref file (1- ...)) 47) (let ((path ...)) (if (file-symlink-p path) nil (setq result ...)) (if (and include-directories ...) (progn ...))) (if (string-match match file) (progn (setq files ...))))) (setq --dolist-tail-- (cdr --dolist-tail--)))))
(let ((result nil) (files nil)) (let ((--dolist-tail-- (sort (file-name-all-completions "" dir) (quote string<)))) (while --dolist-tail-- (let ((file (car --dolist-tail--))) (if (member file (quote ("./" "../"))) nil (if (= (aref file ...) 47) (let (...) (if ... nil ...) (if ... ...)) (if (string-match match file) (progn ...)))) (setq --dolist-tail-- (cdr --dolist-tail--))))) (nconc result (nreverse files)))
directory-files-recursively("/home/thierry/tmp/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/test/" "" nil)
(nconc result (directory-files-recursively path match include-directories))
(setq result (nconc result (directory-files-recursively path match include-directories)))
(if (file-symlink-p path) nil (setq result (nconc result (directory-files-recursively path match include-directories))))
(let ((path (expand-file-name file dir))) (if (file-symlink-p path) nil (setq result (nconc result (directory-files-recursively path match include-directories)))) (if (and include-directories (string-match match (substring file 0 (1- (length file))))) (progn (setq result (nconc result (list path))))))
(if (= (aref file (1- (length file))) 47) (let ((path (expand-file-name file dir))) (if (file-symlink-p path) nil (setq result (nconc result (directory-files-recursively path match include-directories)))) (if (and include-directories (string-match match (substring file 0 (1- (length file))))) (progn (setq result (nconc result (list path)))))) (if (string-match match file) (progn (setq files (cons (expand-file-name file dir) files)))))
(if (member file (quote ("./" "../"))) nil (if (= (aref file (1- (length file))) 47) (let ((path (expand-file-name file dir))) (if (file-symlink-p path) nil (setq result (nconc result (directory-files-recursively path match include-directories)))) (if (and include-directories (string-match match (substring file 0 (1- ...)))) (progn (setq result (nconc result (list path)))))) (if (string-match match file) (progn (setq files (cons (expand-file-name file dir) files))))))
(let ((file (car --dolist-tail--))) (if (member file (quote ("./" "../"))) nil (if (= (aref file (1- (length file))) 47) (let ((path (expand-file-name file dir))) (if (file-symlink-p path) nil (setq result (nconc result (directory-files-recursively path match include-directories)))) (if (and include-directories (string-match match (substring file 0 ...))) (progn (setq result (nconc result ...))))) (if (string-match match file) (progn (setq files (cons (expand-file-name file dir) files)))))) (setq --dolist-tail-- (cdr --dolist-tail--)))
(while --dolist-tail-- (let ((file (car --dolist-tail--))) (if (member file (quote ("./" "../"))) nil (if (= (aref file (1- (length file))) 47) (let ((path (expand-file-name file dir))) (if (file-symlink-p path) nil (setq result (nconc result ...))) (if (and include-directories (string-match match ...)) (progn (setq result ...)))) (if (string-match match file) (progn (setq files (cons ... files)))))) (setq --dolist-tail-- (cdr --dolist-tail--))))
(let ((--dolist-tail-- (sort (file-name-all-completions "" dir) (quote string<)))) (while --dolist-tail-- (let ((file (car --dolist-tail--))) (if (member file (quote ("./" "../"))) nil (if (= (aref file (1- ...)) 47) (let ((path ...)) (if (file-symlink-p path) nil (setq result ...)) (if (and include-directories ...) (progn ...))) (if (string-match match file) (progn (setq files ...))))) (setq --dolist-tail-- (cdr --dolist-tail--)))))
(let ((result nil) (files nil)) (let ((--dolist-tail-- (sort (file-name-all-completions "" dir) (quote string<)))) (while --dolist-tail-- (let ((file (car --dolist-tail--))) (if (member file (quote ("./" "../"))) nil (if (= (aref file ...) 47) (let (...) (if ... nil ...) (if ... ...)) (if (string-match match file) (progn ...)))) (setq --dolist-tail-- (cdr --dolist-tail--))))) (nconc result (nreverse files)))
--8<---------------cut here---------------end--------------->8---
Now patch directory-files-recursively:
--8<---------------cut here---------------start------------->8---
diff --git a/lisp/files.el b/lisp/files.el
index 40972d4..ae55b1f 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -774,7 +774,7 @@ If INCLUDE-DIRECTORIES, also include directories that have matching names."
(if (= (aref file (1- (length file))) ?/)
(let ((path (expand-file-name file dir)))
;; Don't follow symlinks to other directories.
- (unless (file-symlink-p path)
+ (unless (file-symlink-p (directory-file-name path))
(setq result (nconc result (directory-files-recursively
path match include-directories))))
(when (and include-directories
--8<---------------cut here---------------end--------------->8---
(directory-files-recursively "~/tmp/test" "")
=>
("/home/thierry/tmp/test/test1/test2/foo.txt")
--
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997
next prev parent reply other threads:[~2014-12-14 8:48 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20141209062121.9440.90058@vcs.savannah.gnu.org>
[not found] ` <E1XyEAj-0002Ss-EK@vcs.savannah.gnu.org>
2014-12-10 0:42 ` [Emacs-diffs] master 11cf3e9: Implement a new function directory-files-recursively Stefan Monnier
2014-12-10 4:39 ` Lars Magne Ingebrigtsen
2014-12-10 5:09 ` Lars Magne Ingebrigtsen
2014-12-10 5:35 ` Lars Magne Ingebrigtsen
2014-12-10 14:56 ` Stefan Monnier
2014-12-10 17:34 ` Thierry Volpiatto
2014-12-11 14:40 ` Lars Magne Ingebrigtsen
2014-12-11 17:23 ` Stefan Monnier
2014-12-13 7:35 ` Thierry Volpiatto
2014-12-13 14:12 ` Lars Magne Ingebrigtsen
2014-12-13 21:18 ` Thierry Volpiatto
2014-12-14 8:48 ` Thierry Volpiatto [this message]
2014-12-13 14:42 ` Lars Magne Ingebrigtsen
2014-12-13 14:46 ` Lars Magne Ingebrigtsen
2014-12-13 15:10 ` Lars Magne Ingebrigtsen
2014-12-14 5:02 ` Stefan Monnier
2014-12-10 7:58 ` Leo Liu
2014-12-10 8:48 ` Andreas Schwab
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87vbler4zs.fsf@gmail.com \
--to=thierry.volpiatto@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=larsi@gnus.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.