Skip to content

Commit f8dd24c

Browse files
committed
build.rs: support _XX and -patchXX HDF5 versions
1 parent d520413 commit f8dd24c

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

libhdf5-sys/build.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,13 @@ impl Version {
2727
}
2828

2929
pub fn parse(s: &str) -> Option<Self> {
30-
let s = s.lines().next()?.trim();
31-
let s = s.rfind('_').map(|i| &s[..i]).unwrap_or(s);
32-
let mut parts = s.split('.');
33-
let v = Self::new(
34-
parts.next()?.parse().ok()?,
35-
parts.next()?.parse().ok()?,
36-
parts.next()?.parse().ok()?,
37-
);
38-
parts.next().map_or(Some(v), |_| None)
30+
let re = Regex::new(r"^(1)\.(8|10)\.(\d\d?)(_\d+)?(-patch\d+)?$").ok()?;
31+
let captures = re.captures(s)?;
32+
Some(Self {
33+
major: captures.get(1).and_then(|c| c.as_str().parse::<u8>().ok())?,
34+
minor: captures.get(2).and_then(|c| c.as_str().parse::<u8>().ok())?,
35+
micro: captures.get(3).and_then(|c| c.as_str().parse::<u8>().ok())?,
36+
})
3937
}
4038

4139
pub fn is_valid(&self) -> bool {

0 commit comments

Comments
 (0)