From 1935316a12875e04b27c0c1857e3917a1c7a8831 Mon Sep 17 00:00:00 2001 From: meep-eep Date: Mon, 10 Jan 2005 08:49:05 +0000 Subject: [PATCH] Moved -h/-? handling to preParseOptions(). git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1441 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/ChangeLog | 2 ++ sc2/src/starcon2.c | 28 ++++++++++++++-------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/sc2/ChangeLog b/sc2/ChangeLog index 78c4cc346..7202e02d5 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,6 @@ Changes towards version 0.4: +- Not initialising the various systems when -h/-? is supplied (bug #656), + from Nic - F10 works when playing the intro (bug #665), from fOSSiL - Game clock counter overflow fix (bug #668) - [collective effort] - Cocoa hooks for MacOS X, from Nic diff --git a/sc2/src/starcon2.c b/sc2/src/starcon2.c index ac6a45070..bffc2c2e4 100644 --- a/sc2/src/starcon2.c +++ b/sc2/src/starcon2.c @@ -147,6 +147,12 @@ main (int argc, char *argv[]) UQM_MAJOR_VERSION, UQM_MINOR_VERSION, UQM_EXTRA_VERSION, __DATE__, __TIME__); + if (options.runMode == runMode_usage) + { + usage (stdout); + return EXIT_SUCCESS; + } + /* mem_init () uses mutexes. Mutex creation cannot use the memory system until the memory system is rewritten to rely on a thread-safe allocator. @@ -162,13 +168,6 @@ main (int argc, char *argv[]) return optionsResult; } - if (options.runMode == runMode_usage) - { - usage(stdout); - // TODO: various uninitialisations - return EXIT_SUCCESS; - } - /* TODO: Once threading is gone, these become local variables again. In the meantime, they must be global so that @@ -283,9 +282,10 @@ static int preParseOptions(int argc, char *argv[], struct options_struct *options) { /* - "pre-process" the cmdline args looking for a -l ("logfile") - option. If it was given, redirect stderr to the named file - */ + * "pre-process" the cmdline args looking for a -l ("logfile") + * option. If it was given, redirect stderr to the named file. + * Also handle the switches were normal operation is inhibited. + */ opterr = 0; for (;;) { @@ -300,6 +300,10 @@ preParseOptions(int argc, char *argv[], struct options_struct *options) options->logFile = optarg; break; } + case '?': + case 'h': + options->runMode = runMode_usage; + return EXIT_SUCCESS; } } optind = 1; @@ -533,10 +537,6 @@ parseOptions(int argc, char *argv[], struct options_struct *options) longOptions[optionIndex].name); badArg = TRUE; break; - case '?': - case 'h': - options->runMode = runMode_usage; - return EXIT_SUCCESS; break; } }