From: Niels Möller Date: Tue, 26 Oct 2010 09:47:37 +0000 (+0200) Subject: (main): Deleted -?, and fixed handling of bad options. X-Git-Tag: nettle_2.2_release_20110711~218 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ff0c3e278b8be890e556e94bb3665c844e9789eb;p=thirdparty%2Fnettle.git (main): Deleted -?, and fixed handling of bad options. Rev: nettle/examples/next-prime.c:1.5 --- diff --git a/examples/next-prime.c b/examples/next-prime.c index 5283eccd..889c84a4 100644 --- a/examples/next-prime.c +++ b/examples/next-prime.c @@ -61,26 +61,27 @@ main(int argc, char **argv) clock_t start; clock_t end; - enum { OPT_FACTORIAL = -100 }; + enum { OPT_HELP = 300 }; + static const struct option options[] = { /* Name, args, flag, val */ - { "help", no_argument, NULL, '?' }, + { "help", no_argument, NULL, OPT_HELP }, { "verbose", no_argument, NULL, 'v' }, { "factorial", no_argument, NULL, 'f' }, { "sieve-limit", required_argument, NULL, 's' }, { NULL, 0, NULL, 0} }; - while ( (c = getopt_long(argc, argv, "v?s:", options, NULL)) != -1) + while ( (c = getopt_long(argc, argv, "vs:", options, NULL)) != -1) switch (c) { case 'v': verbose = 1; break; - case '?': + case OPT_HELP: usage(); - return EXIT_FAILURE; + return EXIT_SUCCESS; case 'f': factorial = 1; break; @@ -92,6 +93,8 @@ main(int argc, char **argv) return EXIT_FAILURE; } break; + case '?': + return EXIT_FAILURE; default: abort();