diff options
author | Daniel Kahn Gillmor <[email protected]> | 2017-01-10 20:59:36 +0000 |
---|---|---|
committer | Daniel Kahn Gillmor <[email protected]> | 2017-01-11 07:32:20 +0000 |
commit | 7249ab0f95d1f6cb8ee61eefedc79801bb56398f (patch) | |
tree | 2a14a0042e1fbbf3b18f10b820c69a6797896000 /common/argparse.c | |
parent | systemd-user: Enable "systemctl --user reload {dirmngr,gpg-agent}" (diff) | |
download | gnupg-7249ab0f95d1f6cb8ee61eefedc79801bb56398f.tar.gz gnupg-7249ab0f95d1f6cb8ee61eefedc79801bb56398f.zip |
common: Avoid unnecessary ambiguity in argparse.
* common/argparse.c (find_long_option): Avoid unnecessary ambiguity.
--
If two struct ARGPARSE_OPTS share a prefix in their long_opt name, but
have the exact same short_opt and flags, they are aliases and not
distinct options. Avoid reporting this as an ambiguity, so that (for
example) both --clearsign and --clear-sign can be invoked as --clear.
Signed-off-by: Daniel Kahn Gillmor <[email protected]>
Debian-Bug-Id: 850475
Diffstat (limited to '')
-rw-r--r-- | common/argparse.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/common/argparse.c b/common/argparse.c index dce725af9..d395229ad 100644 --- a/common/argparse.c +++ b/common/argparse.c @@ -898,7 +898,9 @@ find_long_option( ARGPARSE_ARGS *arg, int j; for(j=i+1; opts[j].short_opt; j++ ) { if( opts[j].long_opt - && !strncmp( opts[j].long_opt, keyword, n ) ) + && !strncmp( opts[j].long_opt, keyword, n ) + && !(opts[j].short_opt == opts[i].short_opt + && opts[j].flags == opts[i].flags ) ) return -2; /* abbreviation is ambiguous */ } return i; |