Skip to content
Snippets Groups Projects
Commit ff0c3e27 authored by Niels Möller's avatar Niels Möller
Browse files

(main): Deleted -?, and fixed handling of bad options.

Rev: nettle/examples/next-prime.c:1.5
parent f963dd31
No related branches found
No related tags found
No related merge requests found
...@@ -61,26 +61,27 @@ main(int argc, char **argv) ...@@ -61,26 +61,27 @@ main(int argc, char **argv)
clock_t start; clock_t start;
clock_t end; clock_t end;
enum { OPT_FACTORIAL = -100 }; enum { OPT_HELP = 300 };
static const struct option options[] = static const struct option options[] =
{ {
/* Name, args, flag, val */ /* Name, args, flag, val */
{ "help", no_argument, NULL, '?' }, { "help", no_argument, NULL, OPT_HELP },
{ "verbose", no_argument, NULL, 'v' }, { "verbose", no_argument, NULL, 'v' },
{ "factorial", no_argument, NULL, 'f' }, { "factorial", no_argument, NULL, 'f' },
{ "sieve-limit", required_argument, NULL, 's' }, { "sieve-limit", required_argument, NULL, 's' },
{ NULL, 0, NULL, 0} { 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) switch (c)
{ {
case 'v': case 'v':
verbose = 1; verbose = 1;
break; break;
case '?': case OPT_HELP:
usage(); usage();
return EXIT_FAILURE; return EXIT_SUCCESS;
case 'f': case 'f':
factorial = 1; factorial = 1;
break; break;
...@@ -92,6 +93,8 @@ main(int argc, char **argv) ...@@ -92,6 +93,8 @@ main(int argc, char **argv)
return EXIT_FAILURE; return EXIT_FAILURE;
} }
break; break;
case '?':
return EXIT_FAILURE;
default: default:
abort(); abort();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment