diff options
| author | Daniel Colascione | 2019-06-23 18:19:08 -0700 |
|---|---|---|
| committer | Daniel Colascione | 2019-06-23 18:19:08 -0700 |
| commit | b9ac4f815ebaa1acb0d045fe9583f665efa6f628 (patch) | |
| tree | f2bfcf685bb9f83a67c5f70fe8e4f65ef16d8690 /src | |
| parent | f3b1b5fb5034de026adc41cf2403cff42f4a0b67 (diff) | |
| download | emacs-b9ac4f815ebaa1acb0d045fe9583f665efa6f628.tar.gz emacs-b9ac4f815ebaa1acb0d045fe9583f665efa6f628.zip | |
Fix locating pdump by symlink
* admin/merge-gnulib (GNULIB_MODULES): Add canonicalize-lgpl module
* build-aux/config.guess, build-aux/gitlog-to-changelog,
build-aux/update-copyright, lib/canonicalize-lgpl.c,
lib/gnulib.mk.in, lib/malloca.c, lib/malloca.h, lib/pathmax.h,
m4/canonicalize.m4, m4/double-slash-root.m4, m4/gnulib-comp.m4,
m4/malloca.m4, my/pathmax.4: copy from GNUlib or regenerate from
update
* src/emacs.c: find dump by canonical path
Diffstat (limited to 'src')
| -rw-r--r-- | src/emacs.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/emacs.c b/src/emacs.c index fd46540ce22..6463c1be1b7 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -709,9 +709,6 @@ load_pdump (int argc, char **argv) | |||
| 709 | { | 709 | { |
| 710 | const char *const suffix = ".pdmp"; | 710 | const char *const suffix = ".pdmp"; |
| 711 | enum pdumper_load_result result; | 711 | enum pdumper_load_result result; |
| 712 | #ifdef WINDOWSNT | ||
| 713 | size_t argv0_len; | ||
| 714 | #endif | ||
| 715 | 712 | ||
| 716 | /* TODO: maybe more thoroughly scrub process environment in order to | 713 | /* TODO: maybe more thoroughly scrub process environment in order to |
| 717 | make this use case (loading a pdumper image in an unexeced emacs) | 714 | make this use case (loading a pdumper image in an unexeced emacs) |
| @@ -747,17 +744,23 @@ load_pdump (int argc, char **argv) | |||
| 747 | } | 744 | } |
| 748 | 745 | ||
| 749 | /* Look for a dump file in the same directory as the executable; it | 746 | /* Look for a dump file in the same directory as the executable; it |
| 750 | should have the same basename. */ | 747 | should have the same basename. If the directory name is, however, |
| 748 | a symbolic link, resolve the symbolic symbolic link first. */ | ||
| 749 | |||
| 750 | char* argv0 = realpath (argv[0], NULL); | ||
| 751 | if (!argv0) | ||
| 752 | fatal ("could not resolve realpath of \"%s\": %s", | ||
| 753 | argv0, strerror (errno)); | ||
| 751 | 754 | ||
| 752 | dump_file = alloca (strlen (argv[0]) + strlen (suffix) + 1); | 755 | dump_file = alloca (strlen (argv0) + strlen (suffix) + 1); |
| 753 | #ifdef DOS_NT | 756 | #ifdef DOS_NT |
| 754 | /* Remove the .exe extension if present. */ | 757 | /* Remove the .exe extension if present. */ |
| 755 | argv0_len = strlen (argv[0]); | 758 | size_t argv0_len = strlen (argv0); |
| 756 | if (argv0_len >= 4 && c_strcasecmp (argv[0] + argv0_len - 4, ".exe") == 0) | 759 | if (argv0_len >= 4 && c_strcasecmp (argv0 + argv0_len - 4, ".exe") == 0) |
| 757 | sprintf (dump_file, "%.*s%s", (int)(argv0_len - 4), argv[0], suffix); | 760 | sprintf (dump_file, "%.*s%s", (int)(argv0_len - 4), argv0, suffix); |
| 758 | else | 761 | else |
| 759 | #endif | 762 | #endif |
| 760 | sprintf (dump_file, "%s%s", argv[0], suffix); | 763 | sprintf (dump_file, "%s%s", argv0, suffix); |
| 761 | 764 | ||
| 762 | result = pdumper_load (dump_file); | 765 | result = pdumper_load (dump_file); |
| 763 | if (result == PDUMPER_LOAD_SUCCESS) | 766 | if (result == PDUMPER_LOAD_SUCCESS) |
| @@ -790,17 +793,17 @@ load_pdump (int argc, char **argv) | |||
| 790 | 793 | ||
| 791 | if (result == PDUMPER_LOAD_FILE_NOT_FOUND) | 794 | if (result == PDUMPER_LOAD_FILE_NOT_FOUND) |
| 792 | { | 795 | { |
| 793 | /* Finally, look for basename(argv[0])+".pdmp" in PATH_EXEC. | 796 | /* Finally, look for basename(argv0)+".pdmp" in PATH_EXEC. |
| 794 | This way, they can rename both the executable and its pdump | 797 | This way, they can rename both the executable and its pdump |
| 795 | file in PATH_EXEC, and have several Emacs configurations in | 798 | file in PATH_EXEC, and have several Emacs configurations in |
| 796 | the same versioned libexec subdirectory. */ | 799 | the same versioned libexec subdirectory. */ |
| 797 | char *p, *last_sep = NULL; | 800 | char *p, *last_sep = NULL; |
| 798 | for (p = argv[0]; *p; p++) | 801 | for (p = argv0; *p; p++) |
| 799 | { | 802 | { |
| 800 | if (IS_DIRECTORY_SEP (*p)) | 803 | if (IS_DIRECTORY_SEP (*p)) |
| 801 | last_sep = p; | 804 | last_sep = p; |
| 802 | } | 805 | } |
| 803 | argv0_base = last_sep ? last_sep + 1 : argv[0]; | 806 | argv0_base = last_sep ? last_sep + 1 : argv0; |
| 804 | dump_file = alloca (strlen (path_exec) | 807 | dump_file = alloca (strlen (path_exec) |
| 805 | + 1 | 808 | + 1 |
| 806 | + strlen (argv0_base) | 809 | + strlen (argv0_base) |