We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
From https://docs.npmjs.com/misc/semver#caret-ranges-123-025-004
^1.2.3 := >=1.2.3 <2.0.0
Note >= 1.2.3, i.e., !(< 1.2.3). 1.2.3-alpha < 1.2.3 per semver, but semver_satisfies(1.2.3, 1.2.3-alpha, ^) == 1.
>= 1.2.3
!(< 1.2.3)
1.2.3-alpha < 1.2.3
semver_satisfies(1.2.3, 1.2.3-alpha, ^) == 1
Note that < 2.0.0 and 2.0.0-alpha < 2.0.0, but semver_satisfies(1.2.3, 2.0.0-alpha, ^) == 0
< 2.0.0
2.0.0-alpha < 2.0.0
semver_satisfies(1.2.3, 2.0.0-alpha, ^) == 0
#include <assert.h> #include <stdio.h> #include "semver.h" int satisfies(const char *sv1, const char *sv2, const char *op) { semver_t v1, v2; int rc; rc = semver_parse(sv1, &v1); assert(!rc); rc = semver_parse(sv2, &v2); assert(!rc); rc = semver_satisfies(v1, v2, op); semver_free(&v1); semver_free(&v2); return rc; } int main(int argc, char *argv[]) { struct bundle { const char *sv1; const char *sv2; } cases [] = { {"1.2.3", "1.2.3"}, {"1.2.3", "1.2.3-alpha"}, /* 1.2.3 > 1.2.3-alpha ! */ {"1.2.3", "2.0.0"}, {"1.2.3", "2.0.0-alpha"}, /* 2.0.0-alpha < 2.0.0 ! */ }; size_t num_cases = sizeof(cases) / sizeof(struct bundle), i; for (i=0; i < num_cases; ++i) printf("%s ^ %s = %d\n", cases[i].sv1, cases[i].sv2, satisfies(cases[i].sv1, cases[i].sv2, "^")); return 0; }
outputs
1.2.3 ^ 1.2.3 = 1 1.2.3 ^ 1.2.3-alpha = 1 # should be 0 1.2.3 ^ 2.0.0 = 0 1.2.3 ^ 2.0.0-alpha = 0 # should be 1
The text was updated successfully, but these errors were encountered:
No branches or pull requests
From https://docs.npmjs.com/misc/semver#caret-ranges-123-025-004
Note
>= 1.2.3
, i.e.,!(< 1.2.3)
.1.2.3-alpha < 1.2.3
per semver, butsemver_satisfies(1.2.3, 1.2.3-alpha, ^) == 1
.Note that
< 2.0.0
and2.0.0-alpha < 2.0.0
, butsemver_satisfies(1.2.3, 2.0.0-alpha, ^) == 0
outputs
The text was updated successfully, but these errors were encountered: