aboutsummaryrefslogtreecommitdiff
path: root/v_windows/v/vlib/semver/compare.v
diff options
context:
space:
mode:
authorIndrajith K L2022-12-03 17:00:20 +0530
committerIndrajith K L2022-12-03 17:00:20 +0530
commitf5c4671bfbad96bf346bd7e9a21fc4317b4959df (patch)
tree2764fc62da58f2ba8da7ed341643fc359873142f /v_windows/v/vlib/semver/compare.v
downloadcli-tools-windows-master.tar.gz
cli-tools-windows-master.tar.bz2
cli-tools-windows-master.zip
Adds most of the toolsHEADmaster
Diffstat (limited to 'v_windows/v/vlib/semver/compare.v')
-rw-r--r--v_windows/v/vlib/semver/compare.v59
1 files changed, 59 insertions, 0 deletions
diff --git a/v_windows/v/vlib/semver/compare.v b/v_windows/v/vlib/semver/compare.v
new file mode 100644
index 0000000..0b51d29
--- /dev/null
+++ b/v_windows/v/vlib/semver/compare.v
@@ -0,0 +1,59 @@
+module semver
+
+// * Private functions.
+[inline]
+fn version_satisfies(ver Version, input string) bool {
+ range := parse_range(input) or { return false }
+ return range.satisfies(ver)
+}
+
+fn compare_eq(v1 Version, v2 Version) bool {
+ return v1.major == v2.major && v1.minor == v2.minor && v1.patch == v2.patch
+ && v1.prerelease == v2.prerelease
+}
+
+fn compare_gt(v1 Version, v2 Version) bool {
+ if v1.major < v2.major {
+ return false
+ }
+ if v1.major > v2.major {
+ return true
+ }
+ if v1.minor < v2.minor {
+ return false
+ }
+ if v1.minor > v2.minor {
+ return true
+ }
+ return v1.patch > v2.patch
+}
+
+fn compare_lt(v1 Version, v2 Version) bool {
+ if v1.major > v2.major {
+ return false
+ }
+ if v1.major < v2.major {
+ return true
+ }
+ if v1.minor > v2.minor {
+ return false
+ }
+ if v1.minor < v2.minor {
+ return true
+ }
+ return v1.patch < v2.patch
+}
+
+fn compare_ge(v1 Version, v2 Version) bool {
+ if compare_eq(v1, v2) {
+ return true
+ }
+ return compare_gt(v1, v2)
+}
+
+fn compare_le(v1 Version, v2 Version) bool {
+ if compare_eq(v1, v2) {
+ return true
+ }
+ return compare_lt(v1, v2)
+}