Skip to content

Commit b951dd9

Browse files
Merge pull request #6952 from Rdatatable/grepv
Use new grepv internally (with backport)
2 parents 7a8eca1 + 5b2df46 commit b951dd9

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

R/data.table.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ replace_dot_alias = function(e) {
904904
if (length(byvars) == 1L) tt = byvars
905905
else {
906906
# take the first variable that is (1) not eval (#3758) and (2) starts with a character that can't start a variable name
907-
tt = grep("^eval$|^[^[:alpha:]. ]", byvars, invert=TRUE, value=TRUE)
907+
tt = grepv("^eval$|^[^[:alpha:]. ]", byvars, invert=TRUE)
908908
# byvars but exclude functions or `0`+`1` becomes `+`
909909
tt = if (length(tt)) tt[1L] else all.vars(bysubl[[jj+1L]])[1L]
910910
}

R/print.data.table.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ shouldPrint = function(x) {
169169
# for removing the head (column names) of matrix output entirely,
170170
# as opposed to printing a blank line, for excluding col.names per PR #1483
171171
# be sure to remove colnames from any row where they exist, #4270
172-
cut_colnames = function(x) writeLines(grep("^\\s*(?:[0-9]+:|---)", capture.output(x), value=TRUE))
172+
cut_colnames = function(x) writeLines(grepv("^\\s*(?:[0-9]+:|---)", capture.output(x)))
173173

174174
# for printing the dims for list columns #3671; used by format.data.table()
175175
paste_dims = function(x) {

R/test.data.table.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ test = function(num,x,y=TRUE,error=NULL,warning=NULL,message=NULL,output=NULL,no
458458
# if a warning containing this string occurs, ignore it. First need for #4182 where warning about 'timedatectl' only
459459
# occurs in R 3.4, and maybe only on docker too not for users running test.data.table().
460460
stopifnot(is.character(ignore.warning), !anyNA(ignore.warning), nchar(ignore.warning)>=1L)
461-
for (msg in ignore.warning) observed = grep(msg, observed, value=TRUE, invert=TRUE) # allow multiple for translated messages rather than relying on '|' to always work
461+
for (msg in ignore.warning) observed = grepv(msg, observed, invert=TRUE) # allow multiple for translated messages rather than relying on '|' to always work
462462
}
463463
if (length(expected) != length(observed) && (!foreign || is.null(ignore.warning))) {
464464
# nocov start

R/utils.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ nan_is_na = function(x) {
2424
# R 4.4.0
2525
if (!exists("%||%", "package:base")) `%||%` <- function(x, y) if (is.null(x)) y else x # nolint: coalesce_linter.
2626

27+
# R 4.5.0
28+
if (!exists("grepv", "package:base")) grepv <- function(...) grep(..., value=TRUE)
29+
2730
internal_error = function(...) {
2831
e1 = gettext("Internal error in")
2932
e2 = deparse(head(tail(sys.calls(), 2L), 1L)[[1L]][[1L]])

0 commit comments

Comments
 (0)