Skip to content

Commit 5a44552

Browse files
committed
Merge branch 'master' into froll2025
2 parents 105c8e2 + b70d026 commit 5a44552

23 files changed

+119
-100
lines changed

.ci/linters/c/alloc_linter.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ alloc_linter = function(c_obj) {
66
lines = c_obj$lines
77
# Be a bit more precise to avoid mentions in comments, and allow
88
# malloc(0) to be used for convenience (e.g. #6757)
9-
alloc_lines = grep(R"{=\s*([(]\w+\s*[*][)])?[mc]alloc[(][^0]}", lines)
9+
alloc_lines = grep(R"{=\s*([(]\s*\w+\s*[*]\s*[)])?\s*[mc]alloc[(][^0]}", lines)
1010
if (!length(alloc_lines)) return()
1111
# int *tmp=(int*)malloc(...); or just int tmp=malloc(...);
1212
alloc_keys = lines[alloc_lines] |>
@@ -31,7 +31,7 @@ alloc_linter = function(c_obj) {
3131
cat("FILE: ", c_obj$path, "; LINES: ", head(bad_lines_idx, 1L), "-", tail(bad_lines_idx, 1L), "\n", sep="")
3232
writeLines(lines[bad_lines_idx])
3333
cat(strrep("-", max(nchar(lines[bad_lines_idx]))), "\n", sep="")
34-
stop("Expected the malloc()/calloc() usage above to be followed immediately by error checking.", call.=FALSE)
34+
stop("Expected the malloc()/calloc() usage above to be followed immediately by error checking (using '!', not '==NULL').", call.=FALSE)
3535
}
3636
})
3737
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@malloc_return_value_cast expression@
2+
type T;
3+
expression E;
4+
@@
5+
- (T)
6+
malloc(E)

DESCRIPTION

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,5 +100,6 @@ Authors@R: c(
100100
person("Vincent", "Rocher", role="ctb"),
101101
person("Vijay", "Lulla", role="ctb"),
102102
person("Aljaž", "Sluga", role="ctb"),
103-
person("Bill", "Evans", role="ctb")
103+
person("Bill", "Evans", role="ctb"),
104+
person("Reino", "Bruner", role="ctb")
104105
)

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ microbenchmark::microbenchmark(
6363

6464
7. `fwrite()` now avoids a crash when translating strings into a different encoding, [#6883](https://github.com/Rdatatable/data.table/issues/6883). Thanks @filipemsc for the report and @aitap for the fix.
6565

66+
8. `fread()` no longer warns on certain systems on R 4.5.0+ where the file owner can't be resolved, [#6918](https://github.com/Rdatatable/data.table/issues/6918). Thanks @ProfFancyPants for the report and PR.
6667

6768
## NOTES
6869

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/fread.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ yaml=FALSE, tmpdir=tempdir(), tz="UTC")
8888
on.exit(unlink(tmpFile), add=TRUE)
8989
# nocov end
9090
}
91-
file_info = file.info(file)
91+
file_info = file.info(file, extra_cols=FALSE)
9292
if (is.na(file_info$size)) stopf("File '%s' does not exist or is non-readable. getwd()=='%s'", file, getwd())
9393
if (isTRUE(file_info$isdir)) stopf("File '%s' is a directory. Not yet implemented.", file) # Could use dir.exists(), but we already ran file.info().
9494
if (!file_info$size) {

R/print.data.table.R

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ print.data.table = function(x, topn=getOption("datatable.print.topn"),
1919
stopf("Valid options for col.names are 'auto', 'top', and 'none'")
2020
if (length(trunc.cols) != 1L || !is.logical(trunc.cols) || is.na(trunc.cols))
2121
stopf("Valid options for trunc.cols are TRUE and FALSE")
22+
stopifnot(isTRUEorFALSE(class))
2223
if (col.names == "none" && class)
2324
warningf("Column classes will be suppressed when col.names is 'none'")
2425
if (!shouldPrint(x)) {
@@ -52,11 +53,11 @@ print.data.table = function(x, topn=getOption("datatable.print.topn"),
5253
))
5354
}
5455
if (any(dim(x)==0L)) {
55-
class = if (is.data.table(x)) "table" else "frame" # a data.frame could be passed to print.data.table() directly, #3363
56+
x_class = if (is.data.table(x)) "data.table" else "data.frame" # a data.frame could be passed to print.data.table() directly, #3363
5657
if (all(dim(x)==0L)) {
57-
catf("Null data.%s (0 rows and 0 cols)\n", class) # See FAQ 2.5 and NEWS item in v1.8.9
58+
catf("Null %s (0 rows and 0 cols)\n", x_class) # See FAQ 2.5 and NEWS item in v1.8.9
5859
} else {
59-
catf("Empty data.%s (%d rows and %d cols)", class, NROW(x), NCOL(x))
60+
catf("Empty %s (%d rows and %d cols)", x_class, NROW(x), NCOL(x))
6061
if (length(x)>0L) cat(": ",paste(head(names(x),6L),collapse=","),if(length(x)>6L)"...",sep="") # notranslate
6162
cat("\n") # notranslate
6263
}
@@ -94,7 +95,7 @@ print.data.table = function(x, topn=getOption("datatable.print.topn"),
9495
if (is.null(names(x)) || !any(nzchar(names(x), keepNA=TRUE)))
9596
# fixes bug #97 and #545
9697
colnames(toprint)=rep("", ncol(toprint))
97-
if (isTRUE(class) && col.names != "none") {
98+
if (class && col.names != "none") {
9899
#Matching table for most common types & their abbreviations
99100
class_abb = c(list = "<list>", integer = "<int>", numeric = "<num>",
100101
character = "<char>", Date = "<Date>", complex = "<cplx>",
@@ -105,8 +106,9 @@ print.data.table = function(x, topn=getOption("datatable.print.topn"),
105106
if ( length(idx <- which(is.na(abbs))) ) abbs[idx] = paste0("<", classes[idx], ">")
106107
toprint = rbind(abbs, toprint)
107108
rownames(toprint)[1L] = ""
109+
} else {
110+
abbs = ""
108111
}
109-
if (isFALSE(class) || (isTRUE(class) && col.names == "none")) abbs = ""
110112
if (quote) colnames(toprint) <- paste0('"', old <- colnames(toprint), '"')
111113
if (isTRUE(trunc.cols)) {
112114
# allow truncation of columns to print only what will fit in console PR #4074
@@ -131,9 +133,9 @@ print.data.table = function(x, topn=getOption("datatable.print.topn"),
131133
}
132134
if (printdots) {
133135
if (isFALSE(row.names)) {
134-
toprint = rbind(head(toprint, topn + isTRUE(class)), "---", tail(toprint, topn)) # 4083
136+
toprint = rbind(head(toprint, topn + class), "---", tail(toprint, topn)) # 4083
135137
} else {
136-
toprint = rbind(head(toprint, topn + isTRUE(class)), "---"="", tail(toprint, topn))
138+
toprint = rbind(head(toprint, topn + class), "---"="", tail(toprint, topn))
137139
}
138140
rownames(toprint) = format(rownames(toprint), justify="right")
139141
print_default(toprint)
@@ -145,7 +147,7 @@ print.data.table = function(x, topn=getOption("datatable.print.topn"),
145147
toprint = rbind(
146148
toprint,
147149
matrix(if (quote) old else colnames(toprint), nrow=1L), # see #97
148-
if (isTRUE(class)) matrix(if (trunc.cols) abbs[cols_to_print] else abbs, nrow=1L) # #6902
150+
if (class) matrix(if (trunc.cols) abbs[cols_to_print] else abbs, nrow=1L) # #6902
149151
)
150152
print_default(toprint)
151153
invisible(x)
@@ -169,7 +171,7 @@ shouldPrint = function(x) {
169171
# for removing the head (column names) of matrix output entirely,
170172
# as opposed to printing a blank line, for excluding col.names per PR #1483
171173
# 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))
174+
cut_colnames = function(x) writeLines(grepv("^\\s*(?:[0-9]+:|---)", capture.output(x)))
173175

174176
# for printing the dims for list columns #3671; used by format.data.table()
175177
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]])

inst/tests/tests.Rraw

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21147,3 +21147,11 @@ dt = data.table(id = 1:25)
2114721147
test(2314.1, any(grepl("<int>", tail(capture.output(print(dt, class = TRUE)), 2))), TRUE)
2114821148
# Test that class=TRUE with col.names="top" doesn't show classes at bottom
2114921149
test(2314.2, !any(grepl("<int>", tail(capture.output(print(dt, class = TRUE, col.names = "top")), 2))), TRUE)
21150+
21151+
# forder.c coverage
21152+
N <- 70000L
21153+
DT <- data.table(i = rep(2:1, c(1L, N-1L)))
21154+
test(2315.1, tail(DT[order(i), i], 2L), 1:2)
21155+
# wider range of numbers needed for further coverage
21156+
DT[1L, i := 1000L]
21157+
test(2315.2, tail(DT[order(i), i], 2L), c(1L, 1000L))

0 commit comments

Comments
 (0)