From: Stefan Monnier Date: Sun, 13 Mar 2022 04:51:22 +0000 (-0500) Subject: Flocate_file_internal: Protect from `.eln` remapping X-Git-Tag: emacs-29.0.90~1931^2~1168 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=20d9c4b59fe8f9cc94230292ceab9d4d2b74c696;p=emacs.git Flocate_file_internal: Protect from `.eln` remapping Don't use `openp`s functionality to remap `.elc` files to `.eln` files since `locate-file` is not specific to ELisp files. This should be not just simpler but more robust than the current hack which tries to undo the damage after the fact. * src/lread.c (Flocate_file_internal): Don't map `.elc` to `.eln`. * lisp/files.el (locate-file): Simplify accordingly. --- diff --git a/lisp/files.el b/lisp/files.el index 7be93662b1c..eca8cba93f2 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -987,20 +987,7 @@ one or more of those symbols." (logior (if (memq 'executable predicate) 1 0) (if (memq 'writable predicate) 2 0) (if (memq 'readable predicate) 4 0)))) - (let ((file (locate-file-internal filename path suffixes predicate))) - (if (and file (string-match "\\.eln\\'" file)) - ;; This is all a bit of a mess. We pass in a list of suffixes - ;; that doesn't include .eln, but with a nativecomp emacs, we - ;; get the .eln file back. We then map that to the .el file. - ;; But `load-history' has the .elc file, so that's the file we - ;; return here (if it exists). - (let* ((el (gethash (file-name-nondirectory file) comp-eln-to-el-h)) - (elc (replace-regexp-in-string "\\.el\\'" ".elc" el))) - (if (and (member ".elc" suffixes) - (file-exists-p elc)) - elc - el)) - file))) + (locate-file-internal filename path suffixes predicate)) (defun locate-file-completion-table (dirs suffixes string pred action) "Do completion for file names passed to `locate-file'." diff --git a/src/lread.c b/src/lread.c index 0486a98883c..d7b56c5087e 100644 --- a/src/lread.c +++ b/src/lread.c @@ -1661,7 +1661,7 @@ directories, make sure the PREDICATE function returns `dir-ok' for them. */) (Lisp_Object filename, Lisp_Object path, Lisp_Object suffixes, Lisp_Object predicate) { Lisp_Object file; - int fd = openp (path, filename, suffixes, &file, predicate, false, false); + int fd = openp (path, filename, suffixes, &file, predicate, false, true); if (NILP (predicate) && fd >= 0) emacs_close (fd); return file;