Commit 0c1fc9d5 authored by Andrea Corallo's avatar Andrea Corallo
Browse files

* Fix native-comp startup for symliked binary (bug#44128)

	* src/emacs.c (real_filename): New function.
	(set_invocation_vars, load_pdump): Make use of.
parent b064ddd3
Pipeline #10313 failed with stages
in 45 minutes and 35 seconds
......@@ -440,6 +440,28 @@ terminate_due_to_signal (int sig, int backtrace_limit)
exit (1);
}
/* Return the real filename following symlinks in case.
The caller should deallocate the returned buffer. */
static char *
real_filename (char *filename)
{
char *real_name;
#ifdef WINDOWSNT
/* w32_my_exename resolves symlinks internally, so no need to
call realpath. */
real_name = xmalloc (strlen (filename));
strcpy (real_name, filename);
return real_name;
#else
real_name = realpath (filename, NULL);
if (!real_name)
fatal ("could not resolve realpath of \"%s\": %s",
filename, strerror (errno));
return real_name;
#endif
}
/* Set `invocation-name' `invocation-directory'. */
static void
......@@ -475,6 +497,10 @@ set_invocation_vars (char *argv0, char const *original_pwd)
if (! NILP (handler))
raw_name = concat2 (slash_colon, raw_name);
char *filename = real_filename (SSDATA (raw_name));
raw_name = build_unibyte_string (filename);
xfree (filename);
Vinvocation_name = Ffile_name_nondirectory (raw_name);
Vinvocation_directory = Ffile_name_directory (raw_name);
......@@ -888,17 +914,9 @@ load_pdump (int argc, char **argv, char const *original_pwd)
the dump in the hardcoded location. */
if (dump_file && *dump_file)
{
#ifdef WINDOWSNT
/* w32_my_exename resolves symlinks internally, so no need to
call realpath. */
#else
char *real_exename = realpath (dump_file, NULL);
if (!real_exename)
fatal ("could not resolve realpath of \"%s\": %s",
dump_file, strerror (errno));
char *real_exename = real_filename (dump_file);
xfree (dump_file);
dump_file = real_exename;
#endif
ptrdiff_t exenamelen = strlen (dump_file);
#ifndef WINDOWSNT
bufsize = exenamelen + 1;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment