diff options
author | Marcel Hlopko <hlopko@google.com> | 2021-02-15 13:39:30 +0100 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2021-02-15 14:04:52 +0100 |
commit | e92dcf2a3f9130a5053299384ce901269c6f161f (patch) | |
tree | d7e7303a16ef46033c58bc967bb9b3f1ecf30c78 | |
parent | b1c417882662c26398aae6c961b8a503ea8a27e7 (diff) |
Make clang version parsing logic more robust
Previously the function assumed that the version number appeared in the
third word. This PR adds a heuristic - take the first word that starts
with a number.
This way we can also parse: `debian clang version 11.0` that my clang
reports.
-rw-r--r-- | src/lib.rs | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -2444,10 +2444,12 @@ pub struct ClangVersion { pub fn clang_version() -> ClangVersion { ensure_libclang_is_loaded(); + //Debian clang version 11.0.1-2 let raw_v: String = clang::extract_clang_version(); let split_v: Option<Vec<&str>> = raw_v .split_whitespace() - .nth(2) + .filter(|t| t.chars().next().map_or(false, |v| v.is_ascii_digit())) + .next() .map(|v| v.split('.').collect()); match split_v { Some(v) => { |