[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Emacs-diffs] master 11cf3e9: Implement a new function directory-fil
From: |
Thierry Volpiatto |
Subject: |
Re: [Emacs-diffs] master 11cf3e9: Implement a new function directory-files-recursively |
Date: |
Sun, 14 Dec 2014 09:48:55 +0100 |
Lars Magne Ingebrigtsen <address@hidden> writes:
> Thierry Volpiatto <address@hidden> 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
- Re: [Emacs-diffs] master 11cf3e9: Implement a new function directory-files-recursively, (continued)
- Re: [Emacs-diffs] master 11cf3e9: Implement a new function directory-files-recursively, Lars Magne Ingebrigtsen, 2014/12/09
- Re: [Emacs-diffs] master 11cf3e9: Implement a new function directory-files-recursively, Lars Magne Ingebrigtsen, 2014/12/10
- Re: [Emacs-diffs] master 11cf3e9: Implement a new function directory-files-recursively, Lars Magne Ingebrigtsen, 2014/12/10
- Re: [Emacs-diffs] master 11cf3e9: Implement a new function directory-files-recursively, Stefan Monnier, 2014/12/10
- Re: [Emacs-diffs] master 11cf3e9: Implement a new function directory-files-recursively, Thierry Volpiatto, 2014/12/10
- Re: [Emacs-diffs] master 11cf3e9: Implement a new function directory-files-recursively, Lars Magne Ingebrigtsen, 2014/12/11
- Re: [Emacs-diffs] master 11cf3e9: Implement a new function directory-files-recursively, Stefan Monnier, 2014/12/11
- Re: [Emacs-diffs] master 11cf3e9: Implement a new function directory-files-recursively, Thierry Volpiatto, 2014/12/13
- Re: [Emacs-diffs] master 11cf3e9: Implement a new function directory-files-recursively, Lars Magne Ingebrigtsen, 2014/12/13
- Re: [Emacs-diffs] master 11cf3e9: Implement a new function directory-files-recursively, Thierry Volpiatto, 2014/12/13
- Re: [Emacs-diffs] master 11cf3e9: Implement a new function directory-files-recursively,
Thierry Volpiatto <=
- Re: [Emacs-diffs] master 11cf3e9: Implement a new function directory-files-recursively, Lars Magne Ingebrigtsen, 2014/12/13
- Re: [Emacs-diffs] master 11cf3e9: Implement a new function directory-files-recursively, Lars Magne Ingebrigtsen, 2014/12/13
- Re: [Emacs-diffs] master 11cf3e9: Implement a new function directory-files-recursively, Lars Magne Ingebrigtsen, 2014/12/13
- Re: [Emacs-diffs] master 11cf3e9: Implement a new function directory-files-recursively, Stefan Monnier, 2014/12/14
- Re: [Emacs-diffs] master 11cf3e9: Implement a new function directory-files-recursively, Leo Liu, 2014/12/10
- Re: [Emacs-diffs] master 11cf3e9: Implement a new function directory-files-recursively, Andreas Schwab, 2014/12/10