aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2021-03-03 19:58:20 +0200
committerEli Zaretskii2021-03-03 19:58:20 +0200
commite5a0d4c42583fe38e38ab7782b8928ca54f82fad (patch)
tree6c4012732de4c9f204bab4d8037139bc76763f5a /src
parent4f90b0b6e6249597cf2e1450b5b9d7f6522c049f (diff)
downloademacs-e5a0d4c42583fe38e38ab7782b8928ca54f82fad.tar.gz
emacs-e5a0d4c42583fe38e38ab7782b8928ca54f82fad.zip
Avoid aborting on MS-Windows at startup
* src/emacs.c (set_invocation_vars) [WINDOWSNT]: If argv0 is not an absolute file name, obtain the absolute file name of the Emacs executable from 'w32_my_exename'.
Diffstat (limited to 'src')
-rw-r--r--src/emacs.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/emacs.c b/src/emacs.c
index d541b41f3f1..ec62c19e388 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -37,6 +37,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
37#include <fcntl.h> 37#include <fcntl.h>
38#include <sys/socket.h> 38#include <sys/socket.h>
39#include <mbstring.h> 39#include <mbstring.h>
40#include <filename.h> /* for IS_ABSOLUTE_FILE_NAME */
40#include "w32.h" 41#include "w32.h"
41#include "w32heap.h" 42#include "w32heap.h"
42#endif 43#endif
@@ -433,6 +434,12 @@ set_invocation_vars (char *argv0, char const *original_pwd)
433 { 434 {
434 char argv0_1[MAX_UTF8_PATH]; 435 char argv0_1[MAX_UTF8_PATH];
435 436
437 /* Avoid calling 'openp' below, as we aren't ready for that yet:
438 emacs_dir is not yet defined in the environment, and therefore
439 emacs_root_dir, called by expand-file-name, will abort. */
440 if (!IS_ABSOLUTE_FILE_NAME (argv0))
441 argv0 = w32_my_exename ();
442
436 if (filename_from_ansi (argv0, argv0_1) == 0) 443 if (filename_from_ansi (argv0, argv0_1) == 0)
437 raw_name = build_unibyte_string (argv0_1); 444 raw_name = build_unibyte_string (argv0_1);
438 else 445 else
@@ -451,6 +458,11 @@ set_invocation_vars (char *argv0, char const *original_pwd)
451 Vinvocation_name = Ffile_name_nondirectory (raw_name); 458 Vinvocation_name = Ffile_name_nondirectory (raw_name);
452 Vinvocation_directory = Ffile_name_directory (raw_name); 459 Vinvocation_directory = Ffile_name_directory (raw_name);
453 460
461#ifdef WINDOWSNT
462 eassert (!NILP (Vinvocation_directory)
463 && !NILP (Ffile_name_absolute_p (Vinvocation_directory)));
464#endif
465
454 /* If we got no directory in argv0, search PATH to find where 466 /* If we got no directory in argv0, search PATH to find where
455 Emacs actually came from. */ 467 Emacs actually came from. */
456 if (NILP (Vinvocation_directory)) 468 if (NILP (Vinvocation_directory))