Skip to content

Commit a76ab40

Browse files
committed
Merge branch 'master' into col_class_at_bottom
2 parents 536e139 + d28cce9 commit a76ab40

File tree

5 files changed

+26
-16
lines changed

5 files changed

+26
-16
lines changed

.github/workflows/R-CMD-check.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ jobs:
2727
# GHA does run these jobs concurrently but even so reducing the load seems like a good idea.
2828
- {os: windows-latest, r: 'devel'}
2929
# - {os: macOS-latest, r: 'release'} # test-coverage.yaml uses macOS
30-
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
31-
# - {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest", http-user-agent: "R/4.1.0 (ubuntu-20.04) R (4.1.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" }
30+
- {os: ubuntu-24.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
31+
# - {os: ubuntu-24.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest", http-user-agent: "R/4.1.0 (ubuntu-24.04) R (4.1.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" }
3232
# GLCI covers R-devel; no need to delay contributors in dev due to changes in R-devel in recent days
3333

3434
env:
@@ -64,7 +64,7 @@ jobs:
6464
while read -r cmd
6565
do
6666
eval sudo $cmd
67-
done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))')
67+
done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "24.04"))')
6868
6969
- name: Install dependencies
7070
run: |

_pkgdown.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ url: https://rdatatable.gitlab.io/data.table
22

33
template:
44
bootstrap: 5
5+
light-switch: true
56

67
development:
78
version_tooltip: "Development version"
@@ -18,7 +19,7 @@ home:
1819
navbar:
1920
structure:
2021
left: [home, introduction, articles, news, benchmarks, presentations, communityarticles, reference]
21-
right: [github]
22+
right: [search, github, lightswitch]
2223
components:
2324
home:
2425
icon: fas fa-home fa-lg

inst/tests/tests.Rraw

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21130,9 +21130,14 @@ test(2311.2, nlevels(DT$V1), 2L) # used to be 3
2113021130
DF = list(rep(iconv("\uf8", from = "UTF-8", to = "latin1"), 2e6))
2113121131
test(2312, fwrite(DF, nullfile(), encoding = "UTF-8", nThread = 2L), NULL)
2113221132

21133+
# avoid memcpy of 0-length inputs
21134+
test(2313,
21135+
melt(data.table(a=numeric(), b=numeric(), c=numeric()), id.vars=c('a', 'b')),
21136+
data.table(a=numeric(), b=numeric(), variable=factor(levels='c'), value=numeric()))
21137+
2113321138
# Testing column footer display with col.names options in print.data.table #6902
2113421139
dt = data.table(id = 1:25)
2113521140
# Test with class=TRUE shows classes at bottom with default col.names="auto"
21136-
test(2313.1, any(grepl("<int>", tail(capture.output(print(dt, class = TRUE)), 2))), TRUE)
21141+
test(2314.1, any(grepl("<int>", tail(capture.output(print(dt, class = TRUE)), 2))), TRUE)
2113721142
# Test that class=TRUE with col.names="top" doesn't show classes at bottom
21138-
test(2313.2, !any(grepl("<int>", tail(capture.output(print(dt, class = TRUE, col.names = "top")), 2))), TRUE)
21143+
test(2314.2, !any(grepl("<int>", tail(capture.output(print(dt, class = TRUE, col.names = "top")), 2))), TRUE)

src/fmelt.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -552,23 +552,23 @@ SEXP getvaluecols(SEXP DT, SEXP dtnames, Rboolean valfactor, Rboolean verbose, s
552552
//TODO complex value type: case CPLXSXP: { } break;
553553
case REALSXP : {
554554
double *dtarget = REAL(target);
555-
const double *dthiscol = REAL(thiscol);
555+
const double *dthiscol = REAL_RO(thiscol);
556556
if (data->narm) {
557557
for (int k=0; k<thislen; ++k)
558558
dtarget[counter + k] = dthiscol[ithisidx[k]-1];
559-
} else {
559+
} else if (data->nrow) {
560560
memcpy(dtarget + j*data->nrow, dthiscol, data->nrow*size);
561561
}
562562
}
563563
break;
564564
case INTSXP :
565565
case LGLSXP : {
566566
int *itarget = INTEGER(target);
567-
const int *ithiscol = INTEGER(thiscol);
567+
const int *ithiscol = INTEGER_RO(thiscol);
568568
if (data->narm) {
569569
for (int k=0; k<thislen; ++k)
570570
itarget[counter + k] = ithiscol[ithisidx[k]-1];
571-
} else {
571+
} else if (data->nrow) {
572572
memcpy(itarget + j*data->nrow, ithiscol, data->nrow*size);
573573
}
574574
} break;
@@ -704,7 +704,7 @@ SEXP getidcols(SEXP DT, SEXP dtnames, Rboolean verbose, struct processData *data
704704
switch(TYPEOF(thiscol)) {
705705
case REALSXP : {
706706
double *dtarget = REAL(target);
707-
const double *dthiscol = REAL(thiscol);
707+
const double *dthiscol = REAL_RO(thiscol);
708708
if (data->narm) {
709709
for (int j=0; j<data->lmax; ++j) {
710710
SEXP thisidx = VECTOR_ELT(data->not_NA_indices, j);
@@ -714,7 +714,7 @@ SEXP getidcols(SEXP DT, SEXP dtnames, Rboolean verbose, struct processData *data
714714
dtarget[counter + k] = dthiscol[ithisidx[k]-1];
715715
counter += thislen;
716716
}
717-
} else {
717+
} else if (data->nrow) {
718718
for (int j=0; j<data->lmax; ++j)
719719
memcpy(dtarget + j*data->nrow, dthiscol, data->nrow*size);
720720
}
@@ -723,7 +723,7 @@ SEXP getidcols(SEXP DT, SEXP dtnames, Rboolean verbose, struct processData *data
723723
case INTSXP :
724724
case LGLSXP : {
725725
int *itarget = INTEGER(target);
726-
const int *ithiscol = INTEGER(thiscol);
726+
const int *ithiscol = INTEGER_RO(thiscol);
727727
if (data->narm) {
728728
for (int j=0; j<data->lmax; ++j) {
729729
SEXP thisidx = VECTOR_ELT(data->not_NA_indices, j);
@@ -733,7 +733,7 @@ SEXP getidcols(SEXP DT, SEXP dtnames, Rboolean verbose, struct processData *data
733733
itarget[counter + k] = ithiscol[ithisidx[k]-1];
734734
counter += thislen;
735735
}
736-
} else {
736+
} else if (data->nrow) {
737737
for (int j=0; j<data->lmax; ++j)
738738
memcpy(itarget + j*data->nrow, ithiscol, data->nrow*size);
739739
}

src/forder.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,10 @@ static void range_str(const SEXP *x, int n, uint64_t *out_min, uint64_t *out_max
362362
}
363363
// now use the 1-1 mapping from ustr to ustr2 to get the ordering back into original ustr, being careful to reset tl to 0
364364
int *tl = (int *)malloc(ustr_n * sizeof(int));
365-
if (!tl)
365+
if (!tl) {
366+
free(ustr3); // # nocov
366367
STOP(_("Failed to alloc tl when converting strings to UTF8")); // # nocov
368+
}
367369
const SEXP *tt = STRING_PTR_RO(ustr2);
368370
for (int i=0; i<ustr_n; i++) tl[i] = TRUELENGTH(tt[i]); // fetches the o in ustr3 into tl which is ordered by ustr
369371
for (int i=0; i<ustr_n; i++) SET_TRUELENGTH(ustr3[i], 0); // reset to 0 tl of the UTF8 (and possibly non-UTF in ustr too)
@@ -664,8 +666,10 @@ SEXP forder(SEXP DT, SEXP by, SEXP retGrpArg, SEXP retStatsArg, SEXP sortGroupsA
664666
for (int b=0; b<nbyte; b++) {
665667
if (key[nradix+b]==NULL) {
666668
uint8_t *tt = calloc(nrow, sizeof(uint8_t)); // 0 initialize so that NA's can just skip (NA is always the 0 offset)
667-
if (!tt)
669+
if (!tt) {
670+
free(key); // # nocov
668671
STOP(_("Unable to allocate %"PRIu64" bytes of working memory"), (uint64_t)nrow*sizeof(uint8_t)); // # nocov
672+
}
669673
key[nradix+b] = tt;
670674
}
671675
}

0 commit comments

Comments
 (0)