summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorDan Nicholson <dbn.lists@gmail.com>2012-12-11 11:30:13 -0800
committerDan Nicholson <dbn.lists@gmail.com>2012-12-11 11:59:40 -0800
commit9cd35c624f24b978cdcae9e24a1ca87bad88bf9e (patch)
tree7425a5314eb20e3f46daefe3a45a32a61ff16a02 /main.c
parent548ba5b223b28370f1ebad51dd7ae298e4be1428 (diff)
Enforce that only the first --atleast/exact/max-version option honored
This provides the user with output matching the behavior of the code. When multiple --atleast/exact/max-version options are supplied, only the first will be honored.
Diffstat (limited to 'main.c')
-rw-r--r--main.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/main.c b/main.c
index edc6a78..8365213 100644
--- a/main.c
+++ b/main.c
@@ -156,6 +156,8 @@ static gboolean
output_opt_cb (const char *opt, const char *arg, gpointer data,
GError **error)
{
+ static gboolean vercmp_opt_set = FALSE;
+
/* only allow one output mode, with a few exceptions */
if (output_opt_set)
{
@@ -178,7 +180,7 @@ output_opt_cb (const char *opt, const char *arg, gpointer data,
bad_opt = FALSE;
/* --exists allowed with --atleast/exact/max-version */
- if (want_exists &&
+ if (want_exists && !vercmp_opt_set &&
(strcmp (opt, "--atleast-version") == 0 ||
strcmp (opt, "--exact-version") == 0 ||
strcmp (opt, "--max-version") == 0))
@@ -222,16 +224,19 @@ output_opt_cb (const char *opt, const char *arg, gpointer data,
{
required_atleast_version = g_strdup (arg);
want_exists = TRUE;
+ vercmp_opt_set = TRUE;
}
else if (strcmp (opt, "--exact-version") == 0)
{
required_exact_version = g_strdup (arg);
want_exists = TRUE;
+ vercmp_opt_set = TRUE;
}
else if (strcmp (opt, "--max-version") == 0)
{
required_max_version = g_strdup (arg);
want_exists = TRUE;
+ vercmp_opt_set = TRUE;
}
else if (strcmp (opt, "--list-all") == 0)
want_list = TRUE;