diff --git a/DESCRIPTION b/DESCRIPTION index c95147789..d00656a84 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: tinytex Type: Package Title: Helper Functions to Install and Maintain TeX Live, and Compile LaTeX Documents -Version: 0.47.2 +Version: 0.47.3 Authors@R: c( person("Yihui", "Xie", role = c("aut", "cre", "cph"), email = "xie@yihui.name", comment = c(ORCID = "0000-0003-0645-5666")), person(given = "Posit Software, PBC", role = c("cph", "fnd")), diff --git a/R/latex.R b/R/latex.R index da37a8015..d2f667fee 100644 --- a/R/latex.R +++ b/R/latex.R @@ -298,7 +298,7 @@ tweak_aux = function(aux, x = read_lines(aux)) { writeLines(x, aux) } -needs_rerun = function(log, text = xfun::read_utf8(log)) { +needs_rerun = function(log, text = read_lines(log)) { any(grepl( '(Rerun to get |Please \\(?re\\)?run | Rerun LaTeX\\.)', text, useBytes = TRUE @@ -314,7 +314,7 @@ system2_quiet = function(..., error = NULL, logfile = NULL, fail_rerun = TRUE) { # run the command quietly if possible res = system2(..., stdout = if (use_file_stdout()) f1 else FALSE, stderr = f2) - if (is.character(logfile) && file.exists(f2) && length(e <- xfun::read_utf8(f2))) { + if (is.character(logfile) && file.exists(f2) && length(e <- read_lines(f2))) { i = grep('^\\s*$', e, invert = TRUE) e[i] = paste('!', e[i]) # prepend ! to non-empty error messages cat('', e, file = logfile, sep = '\n', append = TRUE) diff --git a/R/utils.R b/R/utils.R index c498c298d..8497ce87a 100644 --- a/R/utils.R +++ b/R/utils.R @@ -19,4 +19,11 @@ xfun_session_info = function() { paste(c('LaTeX version used: ', paste0(' ', info)), collapse = '\n') } -read_lines = function(...) readLines(..., warn = FALSE) +# read a file without warning, and discard lines with invalid characters to +# avoid warnings in the grep() family (invalid lines in log files should be safe +# to discard in this package, although it isn't so in general) +read_lines = function(...) { + x = readLines(..., warn = FALSE) + x[!validEnc(x)] = '' + x +}