aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nt/gnulib-cfg.mk1
-rw-r--r--nt/mingw-cfg.site4
-rw-r--r--src/emacs.c26
-rw-r--r--src/w32.c15
-rw-r--r--src/w32.h1
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
62OMIT_GNULIB_MODULE_sys_time = true 62OMIT_GNULIB_MODULE_sys_time = true
63OMIT_GNULIB_MODULE_sys_types = true 63OMIT_GNULIB_MODULE_sys_types = true
64OMIT_GNULIB_MODULE_unistd = true 64OMIT_GNULIB_MODULE_unistd = true
65OMIT_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
86gl_cv_func_symlink_works=yes 86gl_cv_func_symlink_works=yes
87ac_cv_func_readlinkat=yes 87ac_cv_func_readlinkat=yes
88ac_cv_func_faccessat=yes 88ac_cv_func_faccessat=yes
89# Avoid compiling Gnulib's canonicalize-lgpl.c, which fails
90ac_cv_func_canonicalize_file_name=yes
91ac_cv_func_realpath="not-needed"
92gl_cv_func_realpath_works="no-but-not-needed-so-yes"
89# Implemented in w32.c 93# Implemented in w32.c
90ac_cv_func_fcntl=yes 94ac_cv_func_fcntl=yes
91gl_cv_func_fcntl_f_dupfd_cloexec=yes 95gl_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
715load_pdump_find_executable (const char* argv0, char **exename) 715load_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
789static enum pdumper_load_result 808static 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,
diff --git a/src/w32.c b/src/w32.c
index 833ff4c7e4a..b2d1ffcf82b 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -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. */
9995char *
9996w32_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
diff --git a/src/w32.h b/src/w32.h
index 3790583bfc8..3ef78ecdee2 100644
--- a/src/w32.h
+++ b/src/w32.h
@@ -185,6 +185,7 @@ extern MultiByteToWideChar_Proc pMultiByteToWideChar;
185extern WideCharToMultiByte_Proc pWideCharToMultiByte; 185extern WideCharToMultiByte_Proc pWideCharToMultiByte;
186extern DWORD multiByteToWideCharFlags; 186extern DWORD multiByteToWideCharFlags;
187 187
188extern char *w32_my_exename (void);
188extern const char *w32_relocate (const char *); 189extern const char *w32_relocate (const char *);
189 190
190extern void init_environment (char **); 191extern void init_environment (char **);