diff options
| author | Eli Zaretskii | 2019-06-24 20:06:34 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2019-06-24 20:06:34 +0300 |
| commit | 9f5f5ae6386fe1ea9f31bd760d7ffd293d274502 (patch) | |
| tree | ca27cef4db5fd9e02be339e8a8765b5c8dfe9342 /src | |
| parent | 38502cd44d58a92f378b0e6915a5360f32f6f1ab (diff) | |
| download | emacs-9f5f5ae6386fe1ea9f31bd760d7ffd293d274502.tar.gz emacs-9f5f5ae6386fe1ea9f31bd760d7ffd293d274502.zip | |
Fix MS-Windows build as followup to pdumper executable lookup
* src/w32.c (w32_my_exename): New function.
* src/w32.h (w32_my_exename): Add prototype.
* src/emacs.c (load_pdump_find_executable) [WINDOWSNT]: Find
the actual file name of the program without looking along
PATH, by calling w32_my_exename.
* nt/mingw-cfg.site (ac_cv_func_canonicalize_file_name)
(ac_cv_func_realpath, gl_cv_func_realpath_works): Disable
testing.
* nt/gnulib-cfg.mk (OMIT_GNULIB_MODULE_canonicalize-lgpl): Set
to true.
Diffstat (limited to 'src')
| -rw-r--r-- | src/emacs.c | 26 | ||||
| -rw-r--r-- | src/w32.c | 15 | ||||
| -rw-r--r-- | src/w32.h | 1 |
3 files changed, 41 insertions, 1 deletions
diff --git a/src/emacs.c b/src/emacs.c index a26eacbe786..1ddd10b8051 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -715,6 +715,24 @@ static enum pdumper_load_result | |||
| 715 | load_pdump_find_executable (const char* argv0, char **exename) | 715 | load_pdump_find_executable (const char* argv0, char **exename) |
| 716 | { | 716 | { |
| 717 | enum pdumper_load_result result; | 717 | enum pdumper_load_result result; |
| 718 | #ifdef WINDOWSNT | ||
| 719 | result = PDUMPER_LOAD_ERROR; | ||
| 720 | *exename = NULL; | ||
| 721 | char *prog_fname = w32_my_exename (); | ||
| 722 | if (prog_fname) | ||
| 723 | { | ||
| 724 | result = PDUMPER_LOAD_OOM; | ||
| 725 | /* Use xstrdup, so as to call our private implementation of | ||
| 726 | malloc, since the caller calls our free. */ | ||
| 727 | char *ret = xstrdup (prog_fname); | ||
| 728 | if (ret) | ||
| 729 | { | ||
| 730 | *exename = ret; | ||
| 731 | result = PDUMPER_LOAD_SUCCESS; | ||
| 732 | } | ||
| 733 | } | ||
| 734 | return result; | ||
| 735 | #else /* !WINDOWSNT */ | ||
| 718 | char *candidate = NULL; | 736 | char *candidate = NULL; |
| 719 | 737 | ||
| 720 | /* If the executable name contains a slash, we have some kind of | 738 | /* If the executable name contains a slash, we have some kind of |
| @@ -784,6 +802,7 @@ load_pdump_find_executable (const char* argv0, char **exename) | |||
| 784 | out: | 802 | out: |
| 785 | free (candidate); | 803 | free (candidate); |
| 786 | return result; | 804 | return result; |
| 805 | #endif /* !WINDOWSNT */ | ||
| 787 | } | 806 | } |
| 788 | 807 | ||
| 789 | static enum pdumper_load_result | 808 | static enum pdumper_load_result |
| @@ -848,10 +867,15 @@ load_pdump (int argc, char **argv) | |||
| 848 | the dump in the hardcoded location. */ | 867 | the dump in the hardcoded location. */ |
| 849 | if (exename) | 868 | if (exename) |
| 850 | { | 869 | { |
| 870 | #ifdef WINDOWSNT | ||
| 871 | real_exename = exename; | ||
| 872 | exename = NULL; | ||
| 873 | #else | ||
| 851 | real_exename = realpath (exename, NULL); | 874 | real_exename = realpath (exename, NULL); |
| 852 | if (!real_exename) | 875 | if (!real_exename) |
| 853 | fatal ("could not resolve realpath of \"%s\": %s", | 876 | fatal ("could not resolve realpath of \"%s\": %s", |
| 854 | exename, strerror (errno)); | 877 | exename, strerror (errno)); |
| 878 | #endif | ||
| 855 | size_t real_exename_length = strlen (real_exename); | 879 | size_t real_exename_length = strlen (real_exename); |
| 856 | if (strip_suffix) | 880 | if (strip_suffix) |
| 857 | { | 881 | { |
| @@ -920,7 +944,7 @@ load_pdump (int argc, char **argv) | |||
| 920 | + strlen (suffix) | 944 | + strlen (suffix) |
| 921 | + 1); | 945 | + 1); |
| 922 | #ifdef DOS_NT | 946 | #ifdef DOS_NT |
| 923 | argv0_len = strlen (argv0_base); | 947 | size_t argv0_len = strlen (argv0_base); |
| 924 | if (argv0_len >= 4 | 948 | if (argv0_len >= 4 |
| 925 | && c_strcasecmp (argv0_base + argv0_len - 4, ".exe") == 0) | 949 | && c_strcasecmp (argv0_base + argv0_len - 4, ".exe") == 0) |
| 926 | sprintf (dump_file, "%s%c%.*s%s", path_exec, DIRECTORY_SEP, | 950 | sprintf (dump_file, "%s%c%.*s%s", path_exec, DIRECTORY_SEP, |
| @@ -9988,6 +9988,21 @@ w32_relocate (const char *epath_dir) | |||
| 9988 | return epath_dir; | 9988 | return epath_dir; |
| 9989 | } | 9989 | } |
| 9990 | 9990 | ||
| 9991 | /* Return the full absolute name of the running executable. | ||
| 9992 | |||
| 9993 | Note: this function is called early during startup, when Unicode | ||
| 9994 | file name are not yet supported. */ | ||
| 9995 | char * | ||
| 9996 | w32_my_exename (void) | ||
| 9997 | { | ||
| 9998 | static char exename[MAX_PATH]; | ||
| 9999 | if (!GetModuleFileNameA (NULL, exename, MAX_PATH)) | ||
| 10000 | return NULL; | ||
| 10001 | /* FIXME: Resolve possible symlinks in the last component of | ||
| 10002 | exename, i.e. if the executable itself is a symlink. */ | ||
| 10003 | return exename; | ||
| 10004 | } | ||
| 10005 | |||
| 9991 | /* | 10006 | /* |
| 9992 | globals_of_w32 is used to initialize those global variables that | 10007 | globals_of_w32 is used to initialize those global variables that |
| 9993 | must always be initialized on startup even when the global variable | 10008 | must always be initialized on startup even when the global variable |
| @@ -185,6 +185,7 @@ extern MultiByteToWideChar_Proc pMultiByteToWideChar; | |||
| 185 | extern WideCharToMultiByte_Proc pWideCharToMultiByte; | 185 | extern WideCharToMultiByte_Proc pWideCharToMultiByte; |
| 186 | extern DWORD multiByteToWideCharFlags; | 186 | extern DWORD multiByteToWideCharFlags; |
| 187 | 187 | ||
| 188 | extern char *w32_my_exename (void); | ||
| 188 | extern const char *w32_relocate (const char *); | 189 | extern const char *w32_relocate (const char *); |
| 189 | 190 | ||
| 190 | extern void init_environment (char **); | 191 | extern void init_environment (char **); |