diff --git a/source/dub/semver.d b/source/dub/semver.d index 01c276e..dd68102 100644 --- a/source/dub/semver.d +++ b/source/dub/semver.d @@ -26,7 +26,7 @@ Validates a version string according to the SemVer specification. */ bool isValidVersion(string ver) -{ +pure @nogc { // NOTE: this is not by spec, but to ensure sane input if (ver.length > 256) return false; @@ -102,7 +102,7 @@ /** Determines if a given valid SemVer version has a pre-release suffix. */ -bool isPreReleaseVersion(string ver) +bool isPreReleaseVersion(string ver) pure @nogc in { assert(isValidVersion(ver)); } body { foreach (i; 0 .. 2) { @@ -136,7 +136,7 @@ equal, and a positive number otherwise. */ int compareVersions(string a, string b) -{ +pure @nogc { // compare a.b.c numerically if (auto ret = compareNumber(a, b)) return ret; assert(a[0] == '.' && b[0] == '.'); @@ -225,7 +225,8 @@ See_Also: `expandVersion` */ -string bumpVersion(string ver) { +string bumpVersion(string ver) +pure { // Cut off metadata and prerelease information. auto mi = ver.indexOfAny("+-"); if (mi > 0) ver = ver[0..mi]; @@ -258,7 +259,8 @@ See_Also: `bumpVersion` */ -string expandVersion(string ver) { +string expandVersion(string ver) +pure { auto mi = ver.indexOfAny("+-"); auto sub = ""; if (mi > 0) { @@ -282,7 +284,7 @@ } private int compareIdentifier(ref string a, ref string b) -{ +pure @nogc { bool anumber = true; bool bnumber = true; bool aempty = true, bempty = true; @@ -312,7 +314,7 @@ } private int compareNumber(ref string a, ref string b) -{ +pure @nogc { int res = 0; while (true) { if (a[0] != b[0] && res == 0) res = a[0] - b[0]; @@ -325,7 +327,7 @@ } private bool isValidIdentifierChain(string str, bool allow_leading_zeros = false) -{ +pure @nogc { if (str.length == 0) return false; while (str.length) { auto end = str.indexOf('.'); @@ -338,7 +340,7 @@ } private bool isValidIdentifier(string str, bool allow_leading_zeros = false) -{ +pure @nogc { if (str.length < 1) return false; bool numeric = true; @@ -361,7 +363,7 @@ } private bool isValidNumber(string str) -{ +pure @nogc { if (str.length < 1) return false; foreach (ch; str) if (ch < '0' || ch > '9') @@ -374,7 +376,7 @@ } private sizediff_t indexOfAny(string str, in char[] chars) -{ +pure @nogc { sizediff_t ret = -1; foreach (ch; chars) { auto idx = str.indexOf(ch);