Skip to content

Commit

Permalink
minor fixes (return error on unrecognized option)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevengj committed Feb 25, 2006
1 parent af67fa9 commit 95450e7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
5 changes: 3 additions & 2 deletions libbench2/bench-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
*/

/* $Id: bench-main.c,v 1.18 2006-02-25 02:25:48 athena Exp $ */
/* $Id: bench-main.c,v 1.19 2006-02-25 04:13:49 stevenj Exp $ */

#include "bench.h"
#include "my-getopt.h"
Expand Down Expand Up @@ -169,7 +169,8 @@ int bench_main(int argc, char *argv[])

case '?':
/* my_getopt() already printed an error message. */
break;
cleanup();
return 1;

default:
abort ();
Expand Down
5 changes: 5 additions & 0 deletions libbench2/my-getopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ int my_getopt(int argc, char *argv[], const struct my_option *optarray)
++p;
switch (l->argtype) {
case NOARG:
if (*p) {
fprintf(stderr, "option -%c does not "
"take an argument\n", l->short_name);
return '?';
}
ok1:
return l->short_name;
case OPTARG:
Expand Down
7 changes: 4 additions & 3 deletions tools/fftw-wisdom.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static int prob_size_cmp(const void *p1_, const void *p2_)
static struct my_option options[] =
{
{"help", NOARG, 'h'},
{"version", OPTARG, 'V'},
{"version", NOARG, 'V'},
{"verbose", OPTARG, 'v'},

{"canonical", NOARG, 'c'},
Expand Down Expand Up @@ -271,8 +271,9 @@ int bench_main(int argc, char *argv[])
#endif

case '?':
/* `getopt_long' already printed an error message. */
break;
/* `my_getopt' already printed an error message. */
cleanup();
return EXIT_FAILURE;

default:
abort ();
Expand Down

0 comments on commit 95450e7

Please sign in to comment.