aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrea Corallo2021-04-14 15:04:19 +0200
committerAndrea Corallo2021-04-14 15:45:20 +0200
commit0c1fc9d581ad64efc96c1efccbb4d057796ef807 (patch)
treee71485bf39a01106ba8f3f0ab8c3e15f1e2c2d35
parentb064ddd3f600ed28e62b09d556ecced5f80d9883 (diff)
downloademacs-0c1fc9d581ad64efc96c1efccbb4d057796ef807.tar.gz
emacs-0c1fc9d581ad64efc96c1efccbb4d057796ef807.zip
* Fix native-comp startup for symliked binary (bug#44128)
* src/emacs.c (real_filename): New function. (set_invocation_vars, load_pdump): Make use of.
-rw-r--r--src/emacs.c36
1 files changed, 27 insertions, 9 deletions
diff --git a/src/emacs.c b/src/emacs.c
index e5940ce1de6..f0d75f5c20d 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -440,6 +440,28 @@ terminate_due_to_signal (int sig, int backtrace_limit)
440 exit (1); 440 exit (1);
441} 441}
442 442
443/* Return the real filename following symlinks in case.
444 The caller should deallocate the returned buffer. */
445
446static char *
447real_filename (char *filename)
448{
449 char *real_name;
450#ifdef WINDOWSNT
451 /* w32_my_exename resolves symlinks internally, so no need to
452 call realpath. */
453 real_name = xmalloc (strlen (filename));
454 strcpy (real_name, filename);
455 return real_name;
456#else
457 real_name = realpath (filename, NULL);
458 if (!real_name)
459 fatal ("could not resolve realpath of \"%s\": %s",
460 filename, strerror (errno));
461 return real_name;
462#endif
463}
464
443/* Set `invocation-name' `invocation-directory'. */ 465/* Set `invocation-name' `invocation-directory'. */
444 466
445static void 467static void
@@ -475,6 +497,10 @@ set_invocation_vars (char *argv0, char const *original_pwd)
475 if (! NILP (handler)) 497 if (! NILP (handler))
476 raw_name = concat2 (slash_colon, raw_name); 498 raw_name = concat2 (slash_colon, raw_name);
477 499
500 char *filename = real_filename (SSDATA (raw_name));
501 raw_name = build_unibyte_string (filename);
502 xfree (filename);
503
478 Vinvocation_name = Ffile_name_nondirectory (raw_name); 504 Vinvocation_name = Ffile_name_nondirectory (raw_name);
479 Vinvocation_directory = Ffile_name_directory (raw_name); 505 Vinvocation_directory = Ffile_name_directory (raw_name);
480 506
@@ -888,17 +914,9 @@ load_pdump (int argc, char **argv, char const *original_pwd)
888 the dump in the hardcoded location. */ 914 the dump in the hardcoded location. */
889 if (dump_file && *dump_file) 915 if (dump_file && *dump_file)
890 { 916 {
891#ifdef WINDOWSNT 917 char *real_exename = real_filename (dump_file);
892 /* w32_my_exename resolves symlinks internally, so no need to
893 call realpath. */
894#else
895 char *real_exename = realpath (dump_file, NULL);
896 if (!real_exename)
897 fatal ("could not resolve realpath of \"%s\": %s",
898 dump_file, strerror (errno));
899 xfree (dump_file); 918 xfree (dump_file);
900 dump_file = real_exename; 919 dump_file = real_exename;
901#endif
902 ptrdiff_t exenamelen = strlen (dump_file); 920 ptrdiff_t exenamelen = strlen (dump_file);
903#ifndef WINDOWSNT 921#ifndef WINDOWSNT
904 bufsize = exenamelen + 1; 922 bufsize = exenamelen + 1;