diff options
| -rw-r--r-- | nt/gnulib-cfg.mk | 1 | ||||
| -rw-r--r-- | nt/mingw-cfg.site | 4 | ||||
| -rw-r--r-- | src/emacs.c | 26 | ||||
| -rw-r--r-- | src/w32.c | 15 | ||||
| -rw-r--r-- | src/w32.h | 1 |
5 files changed, 46 insertions, 1 deletions
diff --git a/nt/gnulib-cfg.mk b/nt/gnulib-cfg.mk index 09cd5822578..91f30ec7149 100644 --- a/nt/gnulib-cfg.mk +++ b/nt/gnulib-cfg.mk | |||
| @@ -62,3 +62,4 @@ OMIT_GNULIB_MODULE_sys_stat = true | |||
| 62 | OMIT_GNULIB_MODULE_sys_time = true | 62 | OMIT_GNULIB_MODULE_sys_time = true |
| 63 | OMIT_GNULIB_MODULE_sys_types = true | 63 | OMIT_GNULIB_MODULE_sys_types = true |
| 64 | OMIT_GNULIB_MODULE_unistd = true | 64 | OMIT_GNULIB_MODULE_unistd = true |
| 65 | OMIT_GNULIB_MODULE_canonicalize-lgpl = true | ||
diff --git a/nt/mingw-cfg.site b/nt/mingw-cfg.site index e15d14cc392..dfdca3926f9 100644 --- a/nt/mingw-cfg.site +++ b/nt/mingw-cfg.site | |||
| @@ -86,6 +86,10 @@ gl_cv_func_readlink_works=yes | |||
| 86 | gl_cv_func_symlink_works=yes | 86 | gl_cv_func_symlink_works=yes |
| 87 | ac_cv_func_readlinkat=yes | 87 | ac_cv_func_readlinkat=yes |
| 88 | ac_cv_func_faccessat=yes | 88 | ac_cv_func_faccessat=yes |
| 89 | # Avoid compiling Gnulib's canonicalize-lgpl.c, which fails | ||
| 90 | ac_cv_func_canonicalize_file_name=yes | ||
| 91 | ac_cv_func_realpath="not-needed" | ||
| 92 | gl_cv_func_realpath_works="no-but-not-needed-so-yes" | ||
| 89 | # Implemented in w32.c | 93 | # Implemented in w32.c |
| 90 | ac_cv_func_fcntl=yes | 94 | ac_cv_func_fcntl=yes |
| 91 | gl_cv_func_fcntl_f_dupfd_cloexec=yes | 95 | gl_cv_func_fcntl_f_dupfd_cloexec=yes |
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 **); |