summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorDan Nicholson <dbn.lists@gmail.com>2012-04-21 11:08:12 -0700
committerDan Nicholson <dbn.lists@gmail.com>2012-05-10 05:51:35 -0700
commita83a14c2911d1969d5a79029ac1624bdf317373c (patch)
tree55ff006b5cd9a5aa087a4adabb19d47e5dfcd987 /main.c
parent5fc77a96b7a1114e296f968037342f060d4bc34b (diff)
Unify handling of operator and command line option version checking
The code for --exact/atleast/max-version was taking a different path than the handling of operators like =/>=/<=. Make the long option versions override the operators and take place during the standard package checking stage. This also means that --print-errors is respected. Fixes Freedesktop #8653
Diffstat (limited to 'main.c')
-rw-r--r--main.c48
1 files changed, 20 insertions, 28 deletions
diff --git a/main.c b/main.c
index 88375de..3937b65 100644
--- a/main.c
+++ b/main.c
@@ -469,6 +469,26 @@ main (int argc, char **argv)
Package *req;
RequiredVersion *ver = iter->data;
+ /* override requested versions with cmdline options */
+ if (required_exact_version)
+ {
+ g_free (ver->version);
+ ver->comparison = EQUAL;
+ ver->version = g_strdup (required_exact_version);
+ }
+ else if (required_atleast_version)
+ {
+ g_free (ver->version);
+ ver->comparison = GREATER_THAN_EQUAL;
+ ver->version = g_strdup (required_atleast_version);
+ }
+ else if (required_max_version)
+ {
+ g_free (ver->version);
+ ver->comparison = LESS_THAN_EQUAL;
+ ver->version = g_strdup (required_max_version);
+ }
+
if (want_short_errors)
req = get_package_quiet (ver->name);
else
@@ -656,34 +676,6 @@ main (int argc, char **argv)
}
}
- if (required_exact_version)
- {
- Package *pkg = packages->data;
-
- if (compare_versions (pkg->version, required_exact_version) == 0)
- return 0;
- else
- return 1;
- }
- else if (required_atleast_version)
- {
- Package *pkg = packages->data;
-
- if (compare_versions (pkg->version, required_atleast_version) >= 0)
- return 0;
- else
- return 1;
- }
- else if (required_max_version)
- {
- Package *pkg = packages->data;
-
- if (compare_versions (pkg->version, required_max_version) <= 0)
- return 0;
- else
- return 1;
- }
-
/* Print all flags; then print a newline at the end. */
need_newline = FALSE;