+++ /dev/null
-Description: Fix autopkgtest on i386
- This patch fixes the autopkgtest for pinger on the i386 arch
-Author: Tom Forbes <tom@tomforb.es>
-Origin: upstream
-Applied-Upstream: e44eb9d4a50e54e89a17efc1f2e1e171392651e1
-Reviewed-by: Matthias Geiger <matthias.geiger1024@tutanota.de>
-Last-Update: 2022-12-18
----
-This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
-diff --git a/src/bsd.rs b/src/bsd.rs
-index 1113206..34d63ee 100644
---- a/src/bsd.rs
-+++ b/src/bsd.rs
-@@ -3,7 +3,7 @@ use regex::Regex;
- use std::time::Duration;
-
- lazy_static! {
-- static ref RE: Regex = Regex::new(r"time=(?:(?P<time>[0-9\.]+)\s+ms)").unwrap();
-+ static ref RE: Regex = Regex::new(r"time=(?:(?P<ms>[0-9]+).(?P<ns>[0-9]+)\s+ms)").unwrap();
- }
-
- #[derive(Default)]
-diff --git a/src/lib.rs b/src/lib.rs
-index 35b76d1..469468b 100644
---- a/src/lib.rs
-+++ b/src/lib.rs
-@@ -12,7 +12,7 @@ use crate::linux::{detect_linux_ping, LinuxPingType};
- /// PingResult::Pong(duration, line) => println!("{:?} (line: {})", duration, line),
- /// PingResult::Timeout(_) => println!("Timeout!"),
- /// PingResult::Unknown(line) => println!("Unknown line: {}", line),
--/// PingResult::PingExited(_code, _stderr) => {},
-+/// PingResult::PingExited(_code, _stderr) => {}
- /// }
- /// }
- /// ```
-@@ -109,13 +109,22 @@ pub trait Parser: Default {
-
- fn extract_regex(&self, regex: &Regex, line: String) -> Option<PingResult> {
- let cap = regex.captures(&line)?;
-- let time = cap
-- .name("time")
-- .expect("No capture group named 'time'")
-+ let ms = cap
-+ .name("ms")
-+ .expect("No capture group named 'ms'")
- .as_str()
-- .parse::<f32>()
-- .expect("time cannot be parsed as f32");
-- let duration = Duration::from_micros((time * 1000f32) as u64);
-+ .parse::<u64>()
-+ .ok()?;
-+ let ns = match cap.name("ns") {
-+ None => 0,
-+ Some(cap) => {
-+ let matched_str = cap.as_str();
-+ let number_of_digits = matched_str.len() as u32;
-+ let fractional_ms = matched_str.parse::<u64>().ok()?;
-+ fractional_ms * (10u64.pow(6 - number_of_digits))
-+ }
-+ };
-+ let duration = Duration::from_millis(ms) + Duration::from_nanos(ns);
- Some(PingResult::Pong(duration, line))
- }
- }
-diff --git a/src/linux.rs b/src/linux.rs
-index 433c589..5b42769 100644
---- a/src/linux.rs
-+++ b/src/linux.rs
-@@ -86,7 +86,8 @@ impl Pinger for AlpinePinger {
- }
-
- lazy_static! {
-- static ref UBUNTU_RE: Regex = Regex::new(r"(?i-u)time=(?P<time>\d+(?:\.\d+)?) *ms").unwrap();
-+ static ref UBUNTU_RE: Regex =
-+ Regex::new(r"(?i-u)time=(?P<ms>\d+)(?:\.(?P<ns>\d+))? *ms").unwrap();
- }
-
- #[derive(Default)]
-diff --git a/src/macos.rs b/src/macos.rs
-index d33451f..ec48fa4 100644
---- a/src/macos.rs
-+++ b/src/macos.rs
-@@ -3,7 +3,7 @@ use regex::Regex;
- use std::time::Duration;
-
- lazy_static! {
-- static ref RE: Regex = Regex::new(r"time=(?:(?P<time>[0-9\.]+)\s+ms)").unwrap();
-+ static ref RE: Regex = Regex::new(r"time=(?:(?P<ms>[0-9]+).(?P<ns>[0-9]+)\s+ms)").unwrap();
- }
-
- #[derive(Default)]
-diff --git a/src/windows.rs b/src/windows.rs
-index c6dbcc0..883009a 100644
---- a/src/windows.rs
-+++ b/src/windows.rs
-@@ -9,7 +9,7 @@ use std::time::Duration;
- use winping::{Buffer, Pinger as WinPinger};
-
- lazy_static! {
-- static ref RE: Regex = Regex::new(r"(?ix-u)time=(?P<time>\d+(?:\.\d+)?)ms").unwrap();
-+ static ref RE: Regex = Regex::new(r"(?ix-u)time=(?P<ms>\d+)(?:\.(?P<ns>\d+))?").unwrap();
- }
-
- #[derive(Default)]