MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / isPreReleaseOrBuild

Function isPreReleaseOrBuild

lib/validator/component_name.cpp:205–230  ·  view source on GitHub ↗

Validates a dot-separated pre-release or build identifier segment. Each identifier is [0-9A-Za-z-]+. Numeric identifiers must not have leading zeros.

Source from the content-addressed store, hash-verified

203// Each identifier is [0-9A-Za-z-]+.
204// Numeric identifiers must not have leading zeros.
205bool isPreReleaseOrBuild(std::string_view V, bool CheckLeadingZeros) {
206 if (V.empty())
207 return false;
208 size_t Start = 0;
209 while (Start < V.size()) {
210 size_t DotPos = V.find('.', Start);
211 std::string_view Ident =
212 (DotPos == V.npos) ? V.substr(Start) : V.substr(Start, DotPos - Start);
213 if (Ident.empty())
214 return false;
215 for (char C : Ident) {
216 if (!isalnum(C) && C != '-')
217 return false;
218 }
219 if (CheckLeadingZeros) {
220 bool AllDigits = std::all_of(Ident.begin(), Ident.end(),
221 [](char C) { return isdigit(C); });
222 if (AllDigits && Ident.size() > 1 && Ident[0] == '0')
223 return false;
224 }
225 if (DotPos == V.npos)
226 break;
227 Start = DotPos + 1;
228 }
229 return true;
230}
231
232// MAJOR.MINOR.PATCH[-prerelease][+build] per semver.org 2.0
233bool isValidSemver(std::string_view V) {

Callers 1

isValidSemverFunction · 0.85

Calls 6

substrMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45
findMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected