emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 20d9c4b59f: Flocate_file_internal: Protect from `.eln` remapping


From: Stefan Monnier
Subject: master 20d9c4b59f: Flocate_file_internal: Protect from `.eln` remapping
Date: Sat, 12 Mar 2022 23:51:29 -0500 (EST)

branch: master
commit 20d9c4b59fe8f9cc94230292ceab9d4d2b74c696
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    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.
---
 lisp/files.el | 15 +--------------
 src/lread.c   |  2 +-
 2 files changed, 2 insertions(+), 15 deletions(-)

diff --git a/lisp/files.el b/lisp/files.el
index 7be93662b1..eca8cba93f 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 0486a98883..d7b56c5087 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;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]