MCPcopy Create free account
hub / github.com/apache/mesos / parseVersion

Function parseVersion

src/linux/perf.cpp:212–226  ·  view source on GitHub ↗

Since there is a lot of variety in perf(1) version strings across distributions, we parse just the first 2 version components, which is enough of a version number to implement perf::supported().

Source from the content-addressed store, hash-verified

210// components, which is enough of a version number to implement
211// perf::supported().
212Try<Version> parseVersion(const string& output)
213{
214 // Trim off the leading 'perf version ' text to convert.
215 string trimmed = strings::remove(
216 strings::trim(output), "perf version ", strings::PREFIX);
217
218 vector<string> components = strings::split(trimmed, ".");
219
220 // perf(1) always has a version with least 2 components.
221 if (components.size() > 2) {
222 components.resize(2);
223 }
224
225 return Version::parse(strings::join(".", components));
226}
227
228
229bool supported(const Version& version)

Callers 2

TEST_FFunction · 0.85
versionFunction · 0.85

Calls 6

trimFunction · 0.85
splitFunction · 0.85
removeFunction · 0.70
parseFunction · 0.70
joinFunction · 0.50
sizeMethod · 0.45

Tested by 1

TEST_FFunction · 0.68