fix #4027 - unix command line parsing bug
'nethack --show' is rejected, which is ok, but the feedback is 'prscore: bad arguments (2)' which is pretty confusing. Reject any --s unless it's the start of --scores or --showpath[s]. 'nethack --show' will be rejected as "Unknown option: --show." 'nethack -show' is still accepted and will report that it can't find any scores for how as it always has (assuming that there aren't any score entries for "how" :-).
This commit is contained in:
+3
-1
@@ -1,4 +1,4 @@
|
|||||||
$NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.1277 $ $NHDT-Date: 1698899752 2023/11/02 04:35:52 $
|
$NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.1286 $ $NHDT-Date: 1699233285 2023/11/06 01:14:45 $
|
||||||
|
|
||||||
General Fixes and Modified Features
|
General Fixes and Modified Features
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
@@ -1809,6 +1809,8 @@ tty: if a group accelerator matched a menu command ('^' in menu for '/')
|
|||||||
it wouldn't work to select, just to manipulate the menu
|
it wouldn't work to select, just to manipulate the menu
|
||||||
Unix: after lua changes to Makefiles, 'make spotless' for dat subdirectory
|
Unix: after lua changes to Makefiles, 'make spotless' for dat subdirectory
|
||||||
left some generated data files which should have been deleted
|
left some generated data files which should have been deleted
|
||||||
|
Unix: reject "--sX" on command line except if "X" is "cores" (so "--scores");
|
||||||
|
single dash form still accepts "-sX" to lookup scores for "X"
|
||||||
Windows: new tile additions in win/share did not trigger the creation of a new
|
Windows: new tile additions in win/share did not trigger the creation of a new
|
||||||
NetHackW.res file
|
NetHackW.res file
|
||||||
Windows: nhl_loadlua() was missing the RDBMODE argument on the [dlb_]fopen(),
|
Windows: nhl_loadlua() was missing the RDBMODE argument on the [dlb_]fopen(),
|
||||||
|
|||||||
+13
-4
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.7 unixmain.c $NHDT-Date: 1693359574 2023/08/30 01:39:34 $ $NHDT-Branch: keni-crashweb2 $:$NHDT-Revision: 1.117 $ */
|
/* NetHack 3.7 unixmain.c $NHDT-Date: 1699233290 2023/11/06 01:14:50 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.118 $ */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/*-Copyright (c) Robert Patrick Rankin, 2011. */
|
/*-Copyright (c) Robert Patrick Rankin, 2011. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
@@ -606,7 +606,8 @@ early_options(int *argc_p, char ***argv_p, char **hackdir_p)
|
|||||||
/*
|
/*
|
||||||
* Both *argc_p and *argv_p account for the program name as (*argv_p)[0];
|
* Both *argc_p and *argv_p account for the program name as (*argv_p)[0];
|
||||||
* local argc and argv impicitly discard that (by starting 'ndx' at 1).
|
* local argc and argv impicitly discard that (by starting 'ndx' at 1).
|
||||||
* argcheck() doesn't mind, prscore() (via scores_only()) does.
|
* argcheck() doesn't mind, prscore() (via scores_only()) does (for the
|
||||||
|
* number of args it gets passed, not for the value of argv[0]).
|
||||||
*/
|
*/
|
||||||
for (ndx = 1; ndx < *argc_p; ndx += (consumed ? 0 : 1)) {
|
for (ndx = 1; ndx < *argc_p; ndx += (consumed ? 0 : 1)) {
|
||||||
consumed = 0;
|
consumed = 0;
|
||||||
@@ -687,8 +688,16 @@ early_options(int *argc_p, char ***argv_p, char **hackdir_p)
|
|||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
}
|
}
|
||||||
/* check for "-s" request to show scores */
|
/* check for "-s" request to show scores */
|
||||||
if (lopt(arg,
|
if (lopt(arg, ((ArgValDisallowed | ArgErrComplain)
|
||||||
(ArgValDisallowed | ArgNamOneLetter | ArgErrComplain),
|
/* only accept one-letter if there is just one
|
||||||
|
dash; reject "--s" because prscore() via
|
||||||
|
scores_only() doesn't understand it */
|
||||||
|
| ((origarg[1] != '-') ? ArgNamOneLetter : 0)),
|
||||||
|
/* [ought to omit val-disallowed and accept
|
||||||
|
--scores=foo since -s foo and -sfoo are
|
||||||
|
allowed, but -s form can take more than one
|
||||||
|
space-separated argument and --scores=foo
|
||||||
|
isn't suited for that] */
|
||||||
"-scores", origarg, &argc, &argv)) {
|
"-scores", origarg, &argc, &argv)) {
|
||||||
/* at this point, argv[0] contains "-scores" or a leading
|
/* at this point, argv[0] contains "-scores" or a leading
|
||||||
substring of it; prscore() (via scores_only()) expects
|
substring of it; prscore() (via scores_only()) expects
|
||||||
|
|||||||
Reference in New Issue
Block a user