From 063d7d89d7ae053be611f4de3d1baceddf407c07 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Thu, 10 Aug 2023 10:50:35 +0300 Subject: [PATCH] Fix the -x switch in non-X builds * src/emacs.c (main): Move the handling of the -x switch out of the HAVE_X_WINDOWS condition, and simplify the rest of the code by avoiding code duplication in HAVE_X_WINDOWS and !HAVE_X_WINDOWS cases. (Bug#65048) --- src/emacs.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/emacs.c b/src/emacs.c index e63b0924282..dde305edbc2 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -2007,15 +2007,16 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem } #endif /* HAVE_NS */ -#ifdef HAVE_X_WINDOWS /* Stupid kludge to catch command-line display spec. We can't handle this argument entirely in window system dependent code because we don't even know which window system dependent code to run until we've recognized this argument. */ { - char *displayname = 0; int count_before = skip_args; +#ifdef HAVE_X_WINDOWS + char *displayname = 0; + /* Skip any number of -d options, but only use the last one. */ while (!only_version) { @@ -2045,12 +2046,15 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem } argv[count_before + 1] = (char *) "-d"; } +#endif /* HAVE_X_WINDOWS */ if (! no_site_lisp) { - if (argmatch (argv, argc, "-Q", "--quick", 3, NULL, &skip_args) + + if (argmatch (argv, argc, "-Q", "--quick", 3, NULL, &skip_args) || argmatch (argv, argc, "-quick", 0, 2, NULL, &skip_args)) - no_site_lisp = 1; + no_site_lisp = 1; + } if (argmatch (argv, argc, "-x", 0, 1, &junk, &skip_args)) @@ -2066,18 +2070,6 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem /* Don't actually discard this arg. */ skip_args = count_before; } -#else /* !HAVE_X_WINDOWS */ - if (! no_site_lisp) - { - int count_before = skip_args; - - if (argmatch (argv, argc, "-Q", "--quick", 3, NULL, &skip_args) - || argmatch (argv, argc, "-quick", 0, 2, NULL, &skip_args)) - no_site_lisp = 1; - - skip_args = count_before; - } -#endif /* argmatch must not be used after here, except when building temacs