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)
This commit is contained in:
Eli Zaretskii 2023-08-10 10:50:35 +03:00
parent 5a7fb0b39b
commit 063d7d89d7

View file

@ -2007,15 +2007,16 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
} }
#endif /* HAVE_NS */ #endif /* HAVE_NS */
#ifdef HAVE_X_WINDOWS
/* Stupid kludge to catch command-line display spec. We can't /* Stupid kludge to catch command-line display spec. We can't
handle this argument entirely in window system dependent code handle this argument entirely in window system dependent code
because we don't even know which window system dependent code because we don't even know which window system dependent code
to run until we've recognized this argument. */ to run until we've recognized this argument. */
{ {
char *displayname = 0;
int count_before = skip_args; int count_before = skip_args;
#ifdef HAVE_X_WINDOWS
char *displayname = 0;
/* Skip any number of -d options, but only use the last one. */ /* Skip any number of -d options, but only use the last one. */
while (!only_version) 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"; argv[count_before + 1] = (char *) "-d";
} }
#endif /* HAVE_X_WINDOWS */
if (! no_site_lisp) 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)) || 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)) 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. */ /* Don't actually discard this arg. */
skip_args = count_before; 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, /* argmatch must not be used after here,
except when building temacs except when building temacs