splitVersion
lib.splitVersion
Primop
Docs pulled from | This Revision | 11 minutes ago
Nixpkgs manual
Break a version string into its component parts.
Type
splitVersion :: String -> [String]
Examples
splitVersion usage example
splitVersion "1.2.3"
=> ["1" "2" "3"]
Nix manual
Takes 1 arguments
s
Split a string representing a version into its components, by the
same version splitting logic underlying the version comparison in
nix-env -u.
Noogle detected
Implementation
This function is implemented in c++ and is part of the native nix runtime.
static void prim_splitVersion(EvalState & state, const PosIdx pos, Value ** args, Value & v)
{
auto version =
state.forceStringNoCtx(*args[0], pos, "while evaluating the first argument passed to builtins.splitVersion");
auto iter = version.cbegin();
Strings components;
while (iter != version.cend()) {
auto component = nextComponent(iter, version.cend());
if (component.empty())
break;
components.emplace_back(component);
}
auto list = state.buildList(components.size());
for (const auto & [n, component] : enumerate(components))
(list[n] = state.allocValue())->mkString(std::move(component), state.mem);
v.mkList(list);
}
Implementation
The following is the current implementation of this function.
splitVersion