Unix: fix 'nethack -u name'

Using '-u name' rather than '-uname' was being treated as '--usage'
for any value of 'name'.

'-uname' worked as intended unless name was 'sage' (or leading
substring of it).  That's still the case after this fix, where the
space after -u is now necessary for that special case name.
This commit is contained in:
PatR
2022-11-22 14:53:43 -08:00
parent 6bf42b8891
commit e0867661b4
2 changed files with 7 additions and 1 deletions

View File

@@ -1422,6 +1422,8 @@ if hero's steed got hit by knockback effect, impossible "no monster to remove"
the #saveoptions command included options changed via doset_simple() but not
ones changed via full doset()
fix 'nethack --scores' as alias for 'nethack -s'
adding command line 'nethack --usage' broke 'nethack -u name' (however,
'nethack -uname' still worked for names other than "sage")
curses: 'msg_window' option wasn't functional for curses unless the binary
also included tty support

View File

@@ -343,7 +343,7 @@ lopt(
goto loptnotallowed;
l = (int) (p ? (long) (p - arg) : (long) strlen(arg));
if (!strncmp(arg, optname, l)) {
if ((l > 2 || oneletterok) && !strncmp(arg, optname, l)) {
/* "-windowtype[=foo]" */
if (p)
++p; /* past '=' or ':' */
@@ -356,6 +356,10 @@ lopt(
/* "-w..." but not "-w[indowtype[=foo]]" */
if (!p) {
p = &arg[2]; /* past 'w' of "-wfoo" */
#if 0 /* -x:value could work but is not supported (callers don't expect it) */
} else if (p == arg + 2) {
++p; /* past ':' of "-w:foo" */
#endif
} else {
/* "-w...=foo" but not "-w[indowtype]=foo" */
goto loptbail;