Skip to content

Commit

Permalink
Merge pull request #35 from edavidaja/24-sub-millisecond-regex
Browse files Browse the repository at this point in the history
update regex to handle sub-millisecond response times
  • Loading branch information
gaborcsardi authored Aug 22, 2024
2 parents 78903e3 + 09d50c0 commit 455a00a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# pingr (development version)

* `ping()` now handles sub-millisecond response times (#24).

# pingr 2.0.3

* `ping_port()` now correctly prints the port if `version = TRUE`.
Expand Down
4 changes: 2 additions & 2 deletions R/ping-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ ping <- function(destination, continuous = FALSE, verbose = continuous,

if (!continuous) {
timings <- grep(os$regex, output, value = TRUE, perl = TRUE)
times <- sub(os$regex, "\\1", timings, perl = TRUE)
times <- sub(os$regex, "\\2", timings, perl = TRUE)
res <- as.numeric(times)
length(res) <- count
res
Expand Down Expand Up @@ -132,7 +132,7 @@ ping_os <- function(destination, continuous, count, timeout) {
)
}

list(cmd = cmd, env = env, regex = "^.*time=(.+)[ ]?ms.*$")
list(cmd = cmd, env = env, regex = "^.*time(=|<)(.+)[ ]?ms.*$")
}

#' Is the computer online?
Expand Down

0 comments on commit 455a00a

Please sign in to comment.