From ccc0c4a65f712218c7b7160a5170ce1011c34234 Mon Sep 17 00:00:00 2001 From: Lucas Betschart Date: Thu, 28 Dec 2017 23:22:04 +0100 Subject: [PATCH] Fix --help and -? options Stop on invalid options Fixes 52 and 53 --- main.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/main.cpp b/main.cpp index 9ef50628..346e18ab 100644 --- a/main.cpp +++ b/main.cpp @@ -74,28 +74,28 @@ class CDnsSeedOpts { {"testnet", no_argument, &fUseTestNet, 1}, {"wipeban", no_argument, &fWipeBan, 1}, {"wipeignore", no_argument, &fWipeBan, 1}, - {"help", no_argument, 0, 'h'}, + {"help", no_argument, 0, '?'}, {0, 0, 0, 0} }; int option_index = 0; - int c = getopt_long(argc, argv, "h:n:m:t:a:p:d:o:i:k:w:", long_options, &option_index); + int c = getopt_long(argc, argv, "h:n:m:t:a:p:d:o:i:k:w:?", long_options, &option_index); if (c == -1) break; switch (c) { case 'h': { host = optarg; break; } - + case 'm': { mbox = optarg; break; } - + case 'n': { ns = optarg; break; } - + case 't': { int n = strtol(optarg, NULL, 10); if (n > 0 && n < 1000) nThreads = n; @@ -174,7 +174,10 @@ class CDnsSeedOpts { filter_whitelist.insert(NODE_NETWORK_LIMITED | NODE_WITNESS | NODE_BLOOM); // x40c } if (host != NULL && ns == NULL) showHelp = true; - if (showHelp) fprintf(stderr, help, argv[0]); + if (showHelp) { + fprintf(stderr, help, argv[0]); + exit(0); + } } };