Unix command line parsing
Move a bunch of stuff out of main() into new early_options(): '-dpath'
playground directory handling, '-s ...' show scores instead of playing,
and the 'argcheck()' options: --version, --showpaths, --dumpenums,
and --debug (not to be confused with -D). Also introduce
| --nethackrc=filename
| --no-nethackrc
to control RC file without using NETHACKOPTIONS so that that is still
available for setting other options. They can start with either one
or two dashes. --no-nethackrc is just --nethackrc=/dev/null under the
hood. '-dpath' can now be '--directory=path' or '--directory path'
but the old syntax should still work. '-s ...' can be '--scores ...'.
Basic call sequence in unixmain relating to options is now
|main() {
| early_options(argc, argv[]);
| initoptions(); /* process sysconf, .nethackrc, NETHACKOPTIONS */
| process_options(possibly_modified_argc, possibly_modified_argv[]);
|}
Options processed by early_options() that don't terminate the program
are moved to the end of argv[], with argc reduced accordingly. Then
process_options() only sees the ones that early_options() declines to
handle.
Most early options were using plain exit() instead of nh_terminate()
so not performing any nethack-specific cleanup. However, since they
run before the game starts, there wasn't much cleanup being overlooked.
chdirx() takes a boolean as second argument but all its callers were
passing int (with value of 1 or 0, so it still worked after being
implicitly fixed by prototype). Change them to pass TRUE or FALSE.
argcheck() was refusing (argc,argv[]) with count of 1 but then it was
checking 0..N-1 rather than 1..N-1, so it tested whether argv[0] was
an argument instead of skipping that as the program name. Change to
allow count of 1 with modified argv that has an option name in argv[0].
That happens to fit well with how early_options() wanted to use it.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.788 $ $NHDT-Date: 1644610217 2022/02/11 20:10:17 $
|
||||
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.799 $ $NHDT-Date: 1645223893 2022/02/18 22:38:13 $
|
||||
|
||||
General Fixes and Modified Features
|
||||
-----------------------------------
|
||||
@@ -1232,6 +1232,7 @@ Unix: add "ec2-user" to the list of user names 'sysconf' classifies as generic
|
||||
Unix: work-around a build issue in ubuntu 21.10 by using ifdef to skip the
|
||||
define of warn_unused_result to empty string in tradstdc.h whenever
|
||||
__linux__ is defined during build unless GCC_URWARN is also defined
|
||||
Unix: re-do command line parsing
|
||||
user_sounds: move the message hook from inside individual window display ports
|
||||
to the core where it allows MSGTYP_NOSHOW msgtyp's to still trigger
|
||||
sounds to correct a reported github issue; also fixes a past reported
|
||||
@@ -1470,6 +1471,9 @@ tty: if a message is marked urgent, override message suppression initiated
|
||||
by user having typed ESC at previous --More-- prompt
|
||||
Unix: can define NOSUSPEND in config.h or src/Makefile's CFLAGS to prevent
|
||||
unixconf.h from enabling SUSPEND without need to modify unixconf.h
|
||||
Unix: support --nethackrc=filename on the command line; same effect as
|
||||
NETHACKOPTIONS='@filename' but leaves NETHACKOPTIONS available for
|
||||
specifying options; --no-nethackrc is same as --nethackrc=/dev/null
|
||||
X11: implement 'selectsaved', restore via menu of saved games
|
||||
X11: echo getline prompt and response (wishes, applying names) to message
|
||||
window and dumplog message history
|
||||
|
||||
Reference in New Issue
Block a user