diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-06-29 01:43:37 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-06-29 01:43:37 +0300 |
commit | 1de4bd512440c175f4b9dfed947d58f3d420bcb3 (patch) | |
tree | a2f6eab753b1a9c2093819f32627d9d7e5ce114e | |
parent | d78bfa616320cba4943c9cf0f28f3bb4ed335fa0 (diff) | |
download | smap-1de4bd512440c175f4b9dfed947d58f3d420bcb3.tar.gz smap-1de4bd512440c175f4b9dfed947d58f3d420bcb3.tar.bz2 |
Fix getopt.m4
* src/getopt.m4 (GETOPT): If long_index is not given, expect
no arguments and bail out if some are given.
-rw-r--r-- | src/getopt.m4 | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/getopt.m4 b/src/getopt.m4 index df72e7b..93ff55f 100644 --- a/src/getopt.m4 +++ b/src/getopt.m4 @@ -238,7 +238,7 @@ define([<END>],[< divert(-1) undefine([<SELECTOR>])>]) -dnl GETOPT(argc, argv, [long_index]) +dnl GETOPT(argc, argv, [long_index], [onerr]) dnl Emit option parsing code. Arguments: dnl dnl argc Name of the 1st argument to getopt_long. @@ -266,7 +266,12 @@ define([<GETOPT>],[< undivert(4) } } - ifelse([<$3>],,,[<$3 = optind;>]) + ifelse([<$3>],,[< + if (optind < argc) { + fprintf(stderr, "%s: unexpected arguments\n", $2[0]); + exit(EX_USAGE); + } +>],[<$3 = optind;>]) } >]) |