mirror of
https://github.com/msberends/AMR.git
synced 2026-03-19 13:42:25 +01:00
Fix regexec() calls: remove perl=TRUE unsupported in older R
regexec() only gained the perl argument in R 4.1.0. The CI matrix covers oldrel-1 through oldrel-4 (R 3.x/4.0.x), so perl=TRUE caused an 'unused argument' error on every message_() call in those environments. All four affected regexec() calls use POSIX-extended compatible patterns, so dropping perl=TRUE is safe. https://claude.ai/code/session_01XHWLohiSTdZvCutwD7ag2b
This commit is contained in:
@@ -433,7 +433,7 @@ cli_to_plain <- function(msg, envir = parent.frame()) {
|
|||||||
|
|
||||||
apply_sub <- function(msg, pattern, formatter) {
|
apply_sub <- function(msg, pattern, formatter) {
|
||||||
while (grepl(pattern, msg, perl = TRUE)) {
|
while (grepl(pattern, msg, perl = TRUE)) {
|
||||||
m <- regexec(pattern, msg, perl = TRUE)
|
m <- regexec(pattern, msg)
|
||||||
matches <- regmatches(msg, m)[[1]]
|
matches <- regmatches(msg, m)[[1]]
|
||||||
if (length(matches) < 2L) break
|
if (length(matches) < 2L) break
|
||||||
full_match <- matches[1L]
|
full_match <- matches[1L]
|
||||||
@@ -462,12 +462,12 @@ cli_to_plain <- function(msg, envir = parent.frame()) {
|
|||||||
msg <- apply_sub(msg, "\\{\\.emph (\\{[^}]+\\}|[^}]+)\\}", function(c) paste0("*", resolve(c), "*"))
|
msg <- apply_sub(msg, "\\{\\.emph (\\{[^}]+\\}|[^}]+)\\}", function(c) paste0("*", resolve(c), "*"))
|
||||||
msg <- apply_sub(msg, "\\{\\.help ([^}]+)\\}", function(c) {
|
msg <- apply_sub(msg, "\\{\\.help ([^}]+)\\}", function(c) {
|
||||||
# Handle [display text](topic) markdown link format: extract just the display text
|
# Handle [display text](topic) markdown link format: extract just the display text
|
||||||
m <- regmatches(c, regexec("^\\[(.*)\\]\\([^)]*\\)$", c, perl = TRUE))[[1L]]
|
m <- regmatches(c, regexec("^\\[(.*)\\]\\([^)]*\\)$", c))[[1L]]
|
||||||
if (length(m) >= 2L) m[2L] else paste0("`", resolve(c), "`")
|
if (length(m) >= 2L) m[2L] else paste0("`", resolve(c), "`")
|
||||||
})
|
})
|
||||||
msg <- apply_sub(msg, "\\{\\.topic ([^}]+)\\}", function(c) {
|
msg <- apply_sub(msg, "\\{\\.topic ([^}]+)\\}", function(c) {
|
||||||
# Handle [display text](topic) markdown link format: extract just the display text
|
# Handle [display text](topic) markdown link format: extract just the display text
|
||||||
m <- regmatches(c, regexec("^\\[(.*)\\]\\([^)]*\\)$", c, perl = TRUE))[[1L]]
|
m <- regmatches(c, regexec("^\\[(.*)\\]\\([^)]*\\)$", c))[[1L]]
|
||||||
if (length(m) >= 2L) m[2L] else paste0("?", resolve(c))
|
if (length(m) >= 2L) m[2L] else paste0("?", resolve(c))
|
||||||
})
|
})
|
||||||
msg <- apply_sub(msg, "\\{\\.url (\\{[^}]+\\}|[^}]+)\\}", function(c) resolve(c))
|
msg <- apply_sub(msg, "\\{\\.url (\\{[^}]+\\}|[^}]+)\\}", function(c) resolve(c))
|
||||||
@@ -475,7 +475,7 @@ cli_to_plain <- function(msg, envir = parent.frame()) {
|
|||||||
|
|
||||||
# bare {variable} or {expression} -> evaluate in caller's environment
|
# bare {variable} or {expression} -> evaluate in caller's environment
|
||||||
while (grepl("\\{[^{}]+\\}", msg)) {
|
while (grepl("\\{[^{}]+\\}", msg)) {
|
||||||
m <- regexec("\\{([^{}]+)\\}", msg, perl = TRUE)
|
m <- regexec("\\{([^{}]+)\\}", msg)
|
||||||
matches <- regmatches(msg, m)[[1]]
|
matches <- regmatches(msg, m)[[1]]
|
||||||
if (length(matches) < 2L) break
|
if (length(matches) < 2L) break
|
||||||
full_match <- matches[1L]
|
full_match <- matches[1L]
|
||||||
|
|||||||
Reference in New Issue
Block a user