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().
| 210 | // components, which is enough of a version number to implement |
| 211 | // perf::supported(). |
| 212 | Try<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 | |
| 229 | bool supported(const Version& version) |