emacs-diffs
[Top][All Lists]
Advanced

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

feature/native-comp 15c121e: * Avoid calling Ffile_exists_p too early


From: Andrea Corallo
Subject: feature/native-comp 15c121e: * Avoid calling Ffile_exists_p too early
Date: Sat, 30 May 2020 06:46:19 -0400 (EDT)

branch: feature/native-comp
commit 15c121ee0b5cbe005548eeba09dd54b145b2e258
Author: Andrea Corallo <akrl@sdf.org>
Commit: Andrea Corallo <akrl@sdf.org>

    * Avoid calling Ffile_exists_p too early
    
    Being quite early in startup initialization is better not to rely on
    Ffile_exists_p, this call Ffile_expand and not all the necessary
    initialization already happened.
    
        * src/pdumper.c (dump_do_dump_relocation): Use fopen instead of
        Ffile_exists_p.
---
 src/pdumper.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/src/pdumper.c b/src/pdumper.c
index b40a29c..19dbacc 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -5301,17 +5301,25 @@ dump_do_dump_relocation (const uintptr_t dump_base,
        if (!CONSP (comp_u->file))
          error ("Trying to load incoherent dumped .eln");
 
+       /* Check just once if this is a local build or Emacs was installed.  */
        if (installation_state == UNKNOWN)
-         /* Check just once if is a local build or Emacs got installed. */
-         installation_state =
-           NILP (Ffile_exists_p (concat2 (Vinvocation_directory,
-                                          XCAR (comp_u->file))))
-           ? LOCAL_BUILD : INSTALLED;
+         {
+           char *fname = SSDATA (concat2 (Vinvocation_directory,
+                                          XCAR (comp_u->file)));
+           FILE *file;
+           if ((file = fopen (fname, "r")))
+             {
+               fclose (file);
+               installation_state = INSTALLED;
+             }
+           else
+             installation_state = LOCAL_BUILD;
+         }
 
        comp_u->file =
          concat2 (Vinvocation_directory,
-                  installation_state == LOCAL_BUILD
-                  ? XCDR (comp_u->file) : XCAR (comp_u->file));
+                  installation_state == INSTALLED
+                  ? XCAR (comp_u->file) : XCDR (comp_u->file));
 #ifdef WINDOWSNT
        comp_u->cfile = xlispstrdup (comp_u->file);
 #endif



reply via email to

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