From 9cf2b1bac9d0253ea85ab54da6102508f7147233 Mon Sep 17 00:00:00 2001 From: nhmall Date: Sun, 16 Aug 2026 07:09:22 -0400 Subject: [PATCH] early arg support for older platforms The startup had fallen behind NetHack 5.0 startup for other platforms, and lacked support for some of the early command line options. Following this, if PC_EARLY_OPTIONS is defined in pcconf.h, the port will support those options, such as --version, --showpaths, --dumpenums, etc.) Currently, MSDOS #defines's PC_EARLY_OPTIONS, but AMIGA, ATARI, and MAC68K do not. --- include/pcconf.h | 6 +++++- sys/share/pcmain.c | 13 +++++++++++++ sys/share/pcsys.c | 7 +++++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/include/pcconf.h b/include/pcconf.h index 8b580b03a..bdcc8e56b 100644 --- a/include/pcconf.h +++ b/include/pcconf.h @@ -148,9 +148,13 @@ LEVELDIR, SAVEDIR, BONESDIR, DATADIR, \ SCOREDIR, LOCKDIR, CONFIGDIR, and TROUBLEDIR. \ */ - #endif /* MSDOS configuration stuff */ +/* include early argument processing --dumpenums etc. */ +#if defined(MSDOS) +#define PC_EARLY_OPTIONS +#endif + #ifndef PATHLEN #define PATHLEN 64 /* maximum pathlength */ #endif diff --git a/sys/share/pcmain.c b/sys/share/pcmain.c index 50e7316ab..3f5e2fd5f 100644 --- a/sys/share/pcmain.c +++ b/sys/share/pcmain.c @@ -116,6 +116,10 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/ startup(); #endif +#if defined(PC_EARLY_OPTIONS) + program_state.early_options = 1; +#endif + #ifdef TOS if (*argv[0]) { /* only a CLI can give us argv[0] */ gh.hname = argv[0]; @@ -124,6 +128,9 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/ #endif gh.hname = "NetHack"; /* used for syntax messages */ +#if defined(PC_EARLY_OPTIONS) + early_init(argc, argv); +#endif choose_windows(DEFAULT_WINDOW_SYS); @@ -266,6 +273,12 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/ #endif ami_wininit_data(WININIT); #endif + +#if defined(PC_EARLY_OPTIONS) + early_options(&argc, &argv, &dir); + program_state.early_options = 0; +#endif + initoptions(); #ifdef NOCWD_ASSUMPTIONS diff --git a/sys/share/pcsys.c b/sys/share/pcsys.c index c26b1f4ea..9e9f9aab0 100644 --- a/sys/share/pcsys.c +++ b/sys/share/pcsys.c @@ -155,8 +155,11 @@ getreturn(const char *str) msmsg("Hit %s.", str); #endif #endif - while (pgetchar() != '\n') - ; +#if defined(PC_EARLY_OPTIONS) + if (isatty(STDOUT_FILENO)) +#endif + while (pgetchar() != '\n') + ; return; }