diff options
author | Karel Klic <kklic@redhat.com> | 2011-03-03 12:21:35 +0100 |
---|---|---|
committer | Karel Klic <kklic@redhat.com> | 2011-03-03 12:21:35 +0100 |
commit | e2f9efcd7893a472c178cef23ee5d61a0947cb50 (patch) | |
tree | 1ee544f24c493b7c9e9870b62b0d9d8e321350ca | |
parent | 63945d813c8fe237771854c18a878ef79816901a (diff) | |
download | abrt-e2f9efcd7893a472c178cef23ee5d61a0947cb50.tar.gz abrt-e2f9efcd7893a472c178cef23ee5d61a0947cb50.tar.xz abrt-e2f9efcd7893a472c178cef23ee5d61a0947cb50.zip |
parse_options: handle options without short variant
-rw-r--r-- | src/lib/parse_options.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/lib/parse_options.c b/src/lib/parse_options.c index 4f2b2a2b..d9ce8a2f 100644 --- a/src/lib/parse_options.c +++ b/src/lib/parse_options.c @@ -89,6 +89,7 @@ unsigned parse_opts(int argc, char **argv, const struct options *opt, { int help = 0; int size = parse_opt_size(opt); + const int LONGOPT_OFFSET = 256; struct strbuf *shortopts = strbuf_new(); @@ -99,7 +100,10 @@ unsigned parse_opts(int argc, char **argv, const struct options *opt, { curopt->name = opt[ii].long_name; /*curopt->flag = 0; - xzalloc did it */ - curopt->val = opt[ii].short_name; + if (opt[ii].short_name) + curopt->val = opt[ii].short_name; + else + curopt->val = LONGOPT_OFFSET + ii; switch (opt[ii].type) { @@ -168,7 +172,7 @@ unsigned parse_opts(int argc, char **argv, const struct options *opt, for (ii = 0; ii < size; ++ii) { - if (opt[ii].short_name == c) + if (opt[ii].short_name == c || LONGOPT_OFFSET + ii == c) { if (ii < sizeof(retval)*8) retval |= (1 << ii); |