From: Andrea Corallo Date: Sat, 30 May 2020 10:13:38 +0000 (+0100) Subject: * Avoid calling Ffile_exists_p too early X-Git-Tag: emacs-28.0.90~2727^2~608 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=15c121ee0b5cbe005548eeba09dd54b145b2e258;p=emacs.git * 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. --- diff --git a/src/pdumper.c b/src/pdumper.c index b40a29c02ac..19dbacca896 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