]> git.eshelyaron.com Git - emacs.git/commitdiff
* Avoid calling Ffile_exists_p too early
authorAndrea Corallo <akrl@sdf.org>
Sat, 30 May 2020 10:13:38 +0000 (11:13 +0100)
committerAndrea Corallo <akrl@sdf.org>
Sat, 30 May 2020 10:45:19 +0000 (11:45 +0100)
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

index b40a29c02acae6a72d80324fdd03c51990aa5e2c..19dbacca89640a735610e4b14443011aab8da34c 100644 (file)
@@ -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