From: PatR Date: Thu, 17 Nov 2022 07:41:07 +0000 (-0800) Subject: fix 'nethack --scores' X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a96b3d0b03dca1b9750c3fc04c5ffedf7f483522;p=nethack fix 'nethack --scores' The command line parsing in unixmain.c accepted --scores as an alternative to -s but prscore() in topten.c didn't. --- diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index bc689a644..dccda09f2 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1420,6 +1420,7 @@ if hero's steed got hit by knockback effect, impossible "no monster to remove" would occur (plus more warnings if 'sanity_check' was On) the #saveoptions command included options changed via doset_simple() but not ones changed via full doset() +fix 'nethack --scores' as alias for 'nethack -s' curses: 'msg_window' option wasn't functional for curses unless the binary also included tty support diff --git a/src/topten.c b/src/topten.c index b39f9ffe7..0b89c06d1 100644 --- a/src/topten.c +++ b/src/topten.c @@ -1146,10 +1146,13 @@ prscore(int argc, char **argv) boolean match_found = FALSE; register int i; char pbuf[BUFSZ]; + unsigned ln = 0; int uid = -1; const char *player0; - if (argc < 2 || strncmp(argv[1], "-s", 2)) { + if (argc < 2 || (ln = Strlen(argv[1])) < 2 + || (strncmp(argv[1], "-s", 2) + && (ln < 4 || strncmp(argv[1], "--scores", ln)))) { raw_printf("prscore: bad arguments (%d)", argc); return; } @@ -1177,11 +1180,12 @@ prscore(int argc, char **argv) init_done = TRUE; } - if (!argv[1][2]) { /* plain "-s" */ + /* 'ln' is 2 for -s, longer for --scores */ + if (!argv[1][ln]) { /* plain "-s" */ argc--; argv++; } else - argv[1] += 2; + argv[1] += ln; if (argc > 1 && !strcmp(argv[1], "-v")) { current_ver = FALSE;