Skip to content

Commit af14aed

Browse files
committed
Merge branch 'devBranch1' of https://github.com/badasahog/data.table into devBranch1
2 parents 0759383 + 0bc19be commit af14aed

File tree

8 files changed

+31
-29
lines changed

8 files changed

+31
-29
lines changed

R/print.data.table.R

Lines changed: 10 additions & 8 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)

man/fread.Rd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ Background :\cr
139139
\url{https://stackoverflow.com/a/9818473/403310}\cr
140140
\url{https://stackoverflow.com/questions/9608950/reading-huge-files-using-memory-mapped-files}
141141
142-
finagler = "to get or achieve by guile or manipulation" \url{https://dictionary.reference.com/browse/finagler}
142+
finagle = "to obtain (something) by indirect or involved means", \url{https://www.merriam-webster.com/dictionary/finagler}
143143
144144
On YAML, see \url{https://yaml.org/}.
145145
}

man/fwrite.Rd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fwrite(x, file = "", append = FALSE, quote = "auto",
5757
\item{nThread}{The number of threads to use. Experiment to see what works best for your data on your hardware.}
5858
\item{showProgress}{ Display a progress meter on the console? Ignored when \code{file==""}. }
5959
\item{compress}{If \code{compress = "auto"} and if \code{file} ends in \code{.gz} then output format is gzipped csv else csv. If \code{compress = "none"}, output format is always csv. If \code{compress = "gzip"} then format is gzipped csv. Output to the console is never gzipped even if \code{compress = "gzip"}. By default, \code{compress = "auto"}.}
60-
\item{compressLevel}{Level of compression between 1 and 9, 6 by default. See \url{https://linux.die.net/man/1/gzip} for details.}
60+
\item{compressLevel}{Level of compression between 1 and 9, 6 by default. See \url{https://www.gnu.org/software/gzip/manual/html_node/Invoking-gzip.html} for details.}
6161
\item{yaml}{If \code{TRUE}, \code{fwrite} will output a CSVY file, that is, a CSV file with metadata stored as a YAML header, using \code{\link[yaml]{as.yaml}}. See \code{Details}. }
6262
\item{bom}{If \code{TRUE} a BOM (Byte Order Mark) sequence (EF BB BF) is added at the beginning of the file; format 'UTF-8 with BOM'.}
6363
\item{verbose}{Be chatty and report timings?}

src/assign.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ const char *memrecycle(const SEXP target, const SEXP where, const int start, con
10461046
switch (TYPEOF(source)) {
10471047
case RAWSXP:
10481048
if (mc) {
1049-
memcpy(td, RAW(source), slen*sizeof(Rbyte)); break;
1049+
memcpy(td, RAW_RO(source), slen*sizeof(Rbyte)); break;
10501050
} else BODY(Rbyte, RAW, Rbyte, val, td[i]=cval)
10511051
case LGLSXP: BODY(int, LOGICAL, Rbyte, val==1, td[i]=cval)
10521052
case INTSXP: BODY(int, INTEGER, Rbyte, (val>255 || val<0) ? 0 : val, td[i]=cval)
@@ -1063,7 +1063,7 @@ const char *memrecycle(const SEXP target, const SEXP where, const int start, con
10631063
case RAWSXP: BODY(Rbyte, RAW, int, val!=0, td[i]=cval)
10641064
case LGLSXP:
10651065
if (mc) {
1066-
memcpy(td, LOGICAL(source), slen*sizeof(int)); break;
1066+
memcpy(td, LOGICAL_RO(source), slen*sizeof(int)); break;
10671067
} else BODY(int, LOGICAL, int, val, td[i]=cval)
10681068
case INTSXP: BODY(int, INTEGER, int, val==NA_INTEGER ? NA_LOGICAL : val!=0, td[i]=cval)
10691069
case REALSXP:
@@ -1080,7 +1080,7 @@ const char *memrecycle(const SEXP target, const SEXP where, const int start, con
10801080
case LGLSXP: // same as INTSXP ...
10811081
case INTSXP:
10821082
if (mc) {
1083-
memcpy(td, INTEGER(source), slen*sizeof(int)); break;
1083+
memcpy(td, INTEGER_RO(source), slen*sizeof(int)); break;
10841084
} else BODY(int, INTEGER, int, val, td[i]=cval)
10851085
case REALSXP:
10861086
if (sourceIsI64)
@@ -1100,7 +1100,7 @@ const char *memrecycle(const SEXP target, const SEXP where, const int start, con
11001100
case REALSXP:
11011101
if (sourceIsI64) {
11021102
if (mc) {
1103-
memcpy(td, (int64_t *)REAL(source), slen*sizeof(int64_t)); break;
1103+
memcpy(td, (const int64_t *)REAL_RO(source), slen*sizeof(int64_t)); break;
11041104
} else BODY(int64_t, REAL, int64_t, val, td[i]=cval)
11051105
} else BODY(double, REAL, int64_t, within_int64_repres(val) ? val : NA_INTEGER64, td[i]=cval)
11061106
case CPLXSXP: BODY(Rcomplex, COMPLEX, int64_t, ISNAN(val.r) ? NA_INTEGER64 : (int64_t)val.r, td[i]=cval)
@@ -1115,7 +1115,7 @@ const char *memrecycle(const SEXP target, const SEXP where, const int start, con
11151115
case REALSXP:
11161116
if (!sourceIsI64) {
11171117
if (mc) {
1118-
memcpy(td, (double *)REAL(source), slen*sizeof(double)); break;
1118+
memcpy(td, (const double *)REAL_RO(source), slen*sizeof(double)); break;
11191119
} else BODY(double, REAL, double, val, td[i]=cval)
11201120
} else BODY(int64_t, REAL, double, val==NA_INTEGER64 ? NA_REAL : val, td[i]=cval)
11211121
case CPLXSXP: BODY(Rcomplex, COMPLEX, double, val.r, td[i]=cval)
@@ -1136,7 +1136,7 @@ const char *memrecycle(const SEXP target, const SEXP where, const int start, con
11361136
else BODY(double, REAL, double, ISNAN(val)?(im=NA_REAL,NA_REAL):(im=0.0,val), td[i].r=cval;td[i].i=im)
11371137
case CPLXSXP:
11381138
if (mc) {
1139-
memcpy(td, COMPLEX(source), slen*sizeof(Rcomplex)); break;
1139+
memcpy(td, COMPLEX_RO(source), slen*sizeof(Rcomplex)); break;
11401140
} else BODY(Rcomplex, COMPLEX, Rcomplex, val, td[i]=cval)
11411141
default: COERCE_ERROR("complex");
11421142
}

src/dogroups.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -541,11 +541,11 @@ SEXP growVector(SEXP x, const R_len_t newlen)
541541
return newx;
542542
}
543543
switch (TYPEOF(x)) {
544-
case RAWSXP: memcpy(RAW(newx), RAW(x), len*SIZEOF(x)); break;
545-
case LGLSXP: memcpy(LOGICAL(newx), LOGICAL(x), len*SIZEOF(x)); break;
546-
case INTSXP: memcpy(INTEGER(newx), INTEGER(x), len*SIZEOF(x)); break;
547-
case REALSXP: memcpy(REAL(newx), REAL(x), len*SIZEOF(x)); break;
548-
case CPLXSXP: memcpy(COMPLEX(newx), COMPLEX(x), len*SIZEOF(x)); break;
544+
case RAWSXP: memcpy(RAW(newx), RAW_RO(x), len*SIZEOF(x)); break;
545+
case LGLSXP: memcpy(LOGICAL(newx), LOGICAL_RO(x), len*SIZEOF(x)); break;
546+
case INTSXP: memcpy(INTEGER(newx), INTEGER_RO(x), len*SIZEOF(x)); break;
547+
case REALSXP: memcpy(REAL(newx), REAL_RO(x), len*SIZEOF(x)); break;
548+
case CPLXSXP: memcpy(COMPLEX(newx), COMPLEX_RO(x), len*SIZEOF(x)); break;
549549
case STRSXP : {
550550
const SEXP *xd = SEXPPTR_RO(x);
551551
for (int i=0; i<len; ++i)

src/forder.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ void radix_r(const int from, const int to, const int radix) {
997997
for (int r=radix+1; r<nradix; r++) {
998998
const uint8_t *restrict ksub = key[r]+from;
999999
for (int i=0; i<my_n; i++) ((uint8_t *)TMP)[i] = ksub[o[i]];
1000-
memcpy((uint8_t *restrict)(key[r]+from), (uint8_t *)TMP, my_n);
1000+
memcpy((uint8_t *restrict)(key[r]+from), (const uint8_t *)TMP, my_n);
10011001
}
10021002
free(TMP);
10031003
TEND(8)
@@ -1291,7 +1291,7 @@ void radix_r(const int from, const int to, const int radix) {
12911291
ksub += len;
12921292
}
12931293
}
1294-
memcpy(key[radix+1+r]+from, (uint8_t *)TMP, my_n);
1294+
memcpy(key[radix+1+r]+from, (const uint8_t *)TMP, my_n);
12951295
}
12961296
free(TMP);
12971297
}

src/fread.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1316,7 +1316,7 @@ int freadMain(freadMainArgs _args) {
13161316
if (verbose) DTPRINT(_(" Using %d threads (omp_get_max_threads()=%d, nth=%d)\n"), nth, maxth, args.nth);
13171317
}
13181318

1319-
uint64_t ui64 = NA_FLOAT64_I64;
1319+
const uint64_t ui64 = NA_FLOAT64_I64;
13201320
memcpy(&NA_FLOAT64, &ui64, 8);
13211321

13221322
int64_t nrowLimit = args.nrowLimit;

src/utils.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,19 +232,19 @@ SEXP copyAsPlain(SEXP x) {
232232
}
233233
switch (TYPEOF(x)) {
234234
case RAWSXP:
235-
memcpy(RAW(ans), RAW(x), n*sizeof(Rbyte));
235+
memcpy(RAW(ans), RAW_RO(x), n*sizeof(Rbyte));
236236
break;
237237
case LGLSXP:
238-
memcpy(LOGICAL(ans), LOGICAL(x), n*sizeof(int));
238+
memcpy(LOGICAL(ans), LOGICAL_RO(x), n*sizeof(int));
239239
break;
240240
case INTSXP:
241-
memcpy(INTEGER(ans), INTEGER(x), n*sizeof(int)); // covered by 10:1 after test 178
241+
memcpy(INTEGER(ans), INTEGER_RO(x), n*sizeof(int)); // covered by 10:1 after test 178
242242
break;
243243
case REALSXP:
244-
memcpy(REAL(ans), REAL(x), n*sizeof(double)); // covered by as.Date("2013-01-01")+seq(1,1000,by=10) after test 1075
244+
memcpy(REAL(ans), REAL_RO(x), n*sizeof(double)); // covered by as.Date("2013-01-01")+seq(1,1000,by=10) after test 1075
245245
break;
246246
case CPLXSXP:
247-
memcpy(COMPLEX(ans), COMPLEX(x), n*sizeof(Rcomplex));
247+
memcpy(COMPLEX(ans), COMPLEX_RO(x), n*sizeof(Rcomplex));
248248
break;
249249
case STRSXP: {
250250
const SEXP *xp=STRING_PTR_RO(x); // covered by as.character(as.hexmode(1:500)) after test 642

0 commit comments

Comments
 (0)