summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Nicholson <dbn.lists@gmail.com>2012-12-11 11:01:59 -0800
committerDan Nicholson <dbn.lists@gmail.com>2012-12-11 11:59:40 -0800
commit548ba5b223b28370f1ebad51dd7ae298e4be1428 (patch)
tree63f5b85e20ed2268754dee3bae3544d44c9a29c0
parentec11c93ef843c30d93d182ca940b78a052d0560c (diff)
downloadpkg-config-548ba5b223b28370f1ebad51dd7ae298e4be1428.tar.gz
Imply --exists when --atleast/exact/max-version passed
The --atleast/exact/max-version help description implied that it would return as --exists does. However, this would only occur if no other output options were set. Freedesktop #54389 (https://bugs.freedesktop.org/show_bug.cgi?id=54389)
-rwxr-xr-xcheck/check-print-options6
-rwxr-xr-xcheck/check-version36
-rw-r--r--main.c28
3 files changed, 49 insertions, 21 deletions
diff --git a/check/check-print-options b/check/check-print-options
index 17aec1d..a2a41e7 100755
--- a/check/check-print-options
+++ b/check/check-print-options
@@ -52,3 +52,9 @@ RESULT="public-dep >= 1
private-dep >= 1"
run_test --print-requires --print-requires-private requires-test
run_test --print-requires-private --print-requires requires-test
+
+# --exists and --atleast/exact/max-version can be mixed
+RESULT=""
+run_test --exists --atleast-version=1.0.0 simple
+run_test --exists --exact-version=1.0.0 simple
+run_test --exists --max-version=1.0.0 simple
diff --git a/check/check-version b/check/check-version
index f777ffc..e52cf4d 100755
--- a/check/check-version
+++ b/check/check-version
@@ -19,74 +19,74 @@ v3=1.0.1
# exact version testing
EXPECT_RETURN=1
RESULT="Requested 'simple = $v1' but version of Simple test is $v2"
-run_test --exists --print-errors simple = $v1
+run_test --print-errors simple = $v1
EXPECT_RETURN=1
RESULT="Requested 'simple = $v1' but version of Simple test is $v2"
-run_test --exists --print-errors --exact-version=$v1 simple
+run_test --print-errors --exact-version=$v1 simple
EXPECT_RETURN=0
RESULT=""
-run_test --exists --print-errors simple = $v2
+run_test --print-errors simple = $v2
EXPECT_RETURN=0
RESULT=""
-run_test --exists --print-errors --exact-version=$v2 simple
+run_test --print-errors --exact-version=$v2 simple
EXPECT_RETURN=1
RESULT="Requested 'simple = $v3' but version of Simple test is $v2"
-run_test --exists --print-errors simple = $v3
+run_test --print-errors simple = $v3
EXPECT_RETURN=1
RESULT="Requested 'simple = $v3' but version of Simple test is $v2"
-run_test --exists --print-errors --exact-version=$v3 simple
+run_test --print-errors --exact-version=$v3 simple
# atleast version testing
EXPECT_RETURN=0
RESULT=""
-run_test --exists --print-errors simple \>= $v1
+run_test --print-errors simple \>= $v1
EXPECT_RETURN=0
RESULT=""
-run_test --exists --print-errors --atleast-version=$v1 simple
+run_test --print-errors --atleast-version=$v1 simple
EXPECT_RETURN=0
RESULT=""
-run_test --exists --print-errors simple \>= $v2
+run_test --print-errors simple \>= $v2
EXPECT_RETURN=0
RESULT=""
-run_test --exists --print-errors --atleast-version=$v2 simple
+run_test --print-errors --atleast-version=$v2 simple
EXPECT_RETURN=1
RESULT="Requested 'simple >= $v3' but version of Simple test is $v2"
-run_test --exists --print-errors simple \>= $v3
+run_test --print-errors simple \>= $v3
EXPECT_RETURN=1
RESULT="Requested 'simple >= $v3' but version of Simple test is $v2"
-run_test --exists --print-errors --atleast-version=$v3 simple
+run_test --print-errors --atleast-version=$v3 simple
# max version testing
EXPECT_RETURN=1
RESULT="Requested 'simple <= $v1' but version of Simple test is $v2"
-run_test --exists --print-errors simple \<= $v1
+run_test --print-errors simple \<= $v1
EXPECT_RETURN=1
RESULT="Requested 'simple <= $v1' but version of Simple test is $v2"
-run_test --exists --print-errors --max-version=$v1 simple
+run_test --print-errors --max-version=$v1 simple
EXPECT_RETURN=0
RESULT=""
-run_test --exists --print-errors simple \<= $v2
+run_test --print-errors simple \<= $v2
EXPECT_RETURN=0
RESULT=""
-run_test --exists --print-errors --max-version=$v2 simple
+run_test --print-errors --max-version=$v2 simple
EXPECT_RETURN=0
RESULT=""
-run_test --exists --print-errors simple \<= $v3
+run_test --print-errors simple \<= $v3
EXPECT_RETURN=0
RESULT=""
-run_test --exists --print-errors --max-version=$v3 simple
+run_test --print-errors --max-version=$v3 simple
diff --git a/main.c b/main.c
index e0e0e57..edc6a78 100644
--- a/main.c
+++ b/main.c
@@ -177,6 +177,13 @@ output_opt_cb (const char *opt, const char *arg, gpointer data,
(want_requires_private && strcmp (opt, "--print-requires") == 0))
bad_opt = FALSE;
+ /* --exists allowed with --atleast/exact/max-version */
+ if (want_exists &&
+ (strcmp (opt, "--atleast-version") == 0 ||
+ strcmp (opt, "--exact-version") == 0 ||
+ strcmp (opt, "--max-version") == 0))
+ bad_opt = FALSE;
+
if (bad_opt)
{
fprintf (stderr, "Ignoring incompatible output option \"%s\"\n",
@@ -211,6 +218,21 @@ output_opt_cb (const char *opt, const char *arg, gpointer data,
want_variable_list = TRUE;
else if (strcmp (opt, "--uninstalled") == 0)
want_uninstalled = TRUE;
+ else if (strcmp (opt, "--atleast-version") == 0)
+ {
+ required_atleast_version = g_strdup (arg);
+ want_exists = TRUE;
+ }
+ else if (strcmp (opt, "--exact-version") == 0)
+ {
+ required_exact_version = g_strdup (arg);
+ want_exists = TRUE;
+ }
+ else if (strcmp (opt, "--max-version") == 0)
+ {
+ required_max_version = g_strdup (arg);
+ want_exists = TRUE;
+ }
else if (strcmp (opt, "--list-all") == 0)
want_list = TRUE;
else if (strcmp (opt, "--print-provides") == 0)
@@ -406,11 +428,11 @@ static const GOptionEntry options_table[] = {
{ "uninstalled", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
&output_opt_cb, "return 0 if the uninstalled version of one or more "
"module(s) or their dependencies will be used", NULL },
- { "atleast-version", 0, 0, G_OPTION_ARG_STRING, &required_atleast_version,
+ { "atleast-version", 0, 0, G_OPTION_ARG_CALLBACK, &output_opt_cb,
"return 0 if the module is at least version VERSION", "VERSION" },
- { "exact-version", 0, 0, G_OPTION_ARG_STRING, &required_exact_version,
+ { "exact-version", 0, 0, G_OPTION_ARG_CALLBACK, &output_opt_cb,
"return 0 if the module is at exactly version VERSION", "VERSION" },
- { "max-version", 0, 0, G_OPTION_ARG_STRING, &required_max_version,
+ { "max-version", 0, 0, G_OPTION_ARG_CALLBACK, &output_opt_cb,
"return 0 if the module is at no newer than version VERSION", "VERSION" },
{ "list-all", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
&output_opt_cb, "list all known packages", NULL },