Skip to content
18 changes: 9 additions & 9 deletions inst/tests/nafill.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,15 @@ test(4.03, colnamesInt(dt, 1), 1L)
test(4.04, colnamesInt(dt, c("a","d")), c(1L, 3L))
test(4.05, colnamesInt(dt, c(1L, 3L)), c(1L, 3L))
test(4.06, colnamesInt(dt, c(1, 3)), c(1L, 3L))
test(4.07, colnamesInt(dt, c("a", "e")), error="specify non existing column*.*e")
test(4.08, colnamesInt(dt, c(1L, 4L)), error="specify non existing column*.*4")
test(4.09, colnamesInt(dt, c(1, 4)), error="specify non existing column*.*4")
test(4.10, colnamesInt(dt, c("a", NA)), error="specify non existing column*.*NA")
test(4.11, colnamesInt(dt, c(1L, NA)), error="specify non existing column")
test(4.12, colnamesInt(dt, c(1, NA)), error="specify non existing column")
test(4.13, colnamesInt(dt, c("a","d","a"), check_dups=TRUE), error="specify duplicated column")
test(4.14, colnamesInt(dt, c(1L, 3L, 1L), check_dups=TRUE), error="specify duplicated column")
test(4.15, colnamesInt(dt, c(1, 3, 1), check_dups=TRUE), error="specify duplicated column")
test(4.07, colnamesInt(dt, c("a", "e")), error="received non-existing column*.*e")
test(4.08, colnamesInt(dt, c(1L, 4L)), error="received non-existing column*.*4")
test(4.09, colnamesInt(dt, c(1, 4)), error="received non-existing column*.*4")
test(4.10, colnamesInt(dt, c("a", NA)), error="received non-existing column*.*NA")
test(4.11, colnamesInt(dt, c(1L, NA)), error="received non-existing column")
test(4.12, colnamesInt(dt, c(1, NA)), error="received non-existing column")
test(4.13, colnamesInt(dt, c("a","d","a"), check_dups=TRUE), error="received duplicate column(s)")
test(4.14, colnamesInt(dt, c(1L, 3L, 1L), check_dups=TRUE), error="received duplicate column(s)")
test(4.15, colnamesInt(dt, c(1, 3, 1), check_dups=TRUE), error="received duplicate column(s)")
test(4.16, colnamesInt(dt, list("a")), error="must be character or numeric")
test(4.17, colnamesInt(dt, NA), error="must be character or numeric")
test(4.18, colnamesInt(dt, character()), integer())
Expand Down
69 changes: 35 additions & 34 deletions inst/tests/tests.Rraw

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions src/assign.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ static int _selfrefok(SEXP x, Rboolean checkNames, Rboolean verbose) {
if (verbose) Rprintf(_(".internal.selfref ptr is NULL. This is expected and normal for a data.table loaded from disk. Please remember to always setDT() immediately after loading to prevent unexpected behavior. If this table was not loaded from disk or you've already run setDT(), please report to data.table issue tracker.\n"));
return -1;
}
if (!isNull(p)) error(_("Internal error: .internal.selfref ptr is not NULL or R_NilValue")); // # nocov
if (!isNull(p)) error(_("Internal error: .internal.selfref ptr is neither NULL nor R_NilValue")); // # nocov
tag = R_ExternalPtrTag(v);
if (!(isNull(tag) || isString(tag))) error(_("Internal error: .internal.selfref tag isn't NULL or a character vector")); // # nocov
if (!(isNull(tag) || isString(tag))) error(_("Internal error: .internal.selfref tag is neither NULL nor a character vector")); // # nocov
names = getAttrib(x, R_NamesSymbol);
if (names!=tag && isString(names) && !ALTREP(names)) // !ALTREP for #4734
SET_TRUELENGTH(names, LENGTH(names));
Expand Down Expand Up @@ -246,7 +246,8 @@ int checkOverAlloc(SEXP x)
}

SEXP alloccolwrapper(SEXP dt, SEXP overAllocArg, SEXP verbose) {
if (!isLogical(verbose) || length(verbose)!=1) error(_("verbose must be TRUE or FALSE"));
if (!IS_TRUE_OR_FALSE(verbose))
error(_("%s must be TRUE or FALSE"), "verbose");
int overAlloc = checkOverAlloc(overAllocArg);
SEXP ans = PROTECT(alloccol(dt, length(dt)+overAlloc, LOGICAL(verbose)[0]));

Expand Down Expand Up @@ -311,7 +312,7 @@ SEXP assign(SEXP dt, SEXP rows, SEXP cols, SEXP newcolnames, SEXP values)
SEXP names = PROTECT(getAttrib(dt, R_NamesSymbol)); protecti++;
if (isNull(names)) error(_("dt passed to assign has no names"));
if (length(names)!=oldncol)
error(_("Internal error in assign: length of names (%d) is not length of dt (%d)"),length(names),oldncol); // # nocov
error(_("Internal error: length of names (%d) is not length of dt (%d)"), length(names), oldncol); // # nocov
if (isNull(dt)) {
error(_("data.table is NULL; malformed. A null data.table should be an empty list. typeof() should always return 'list' for data.table.")); // # nocov
// Not possible to test because R won't permit attributes be attached to NULL (which is good and we like); warning from R 3.4.0+ tested by 944.5
Expand All @@ -336,7 +337,7 @@ SEXP assign(SEXP dt, SEXP rows, SEXP cols, SEXP newcolnames, SEXP values)
const int *rowsd = INTEGER(rows);
for (int i=0; i<targetlen; ++i) {
if ((rowsd[i]<0 && rowsd[i]!=NA_INTEGER) || rowsd[i]>nrow)
error(_("i[%d] is %d which is out of range [1,nrow=%d]."),i+1,rowsd[i],nrow); // set() reaches here (test 2005.2); := reaches the same error in subset.c first
error(_("i[%d] is %d which is out of range [1,nrow=%d]"), i+1, rowsd[i], nrow); // set() reaches here (test 2005.2); := reaches the same error in subset.c first
if (rowsd[i]>=1) numToDo++;
}
if (verbose) Rprintf(_("Assigning to %d row subset of %d rows\n"), numToDo, nrow);
Expand Down
8 changes: 4 additions & 4 deletions src/between.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ SEXP between(SEXP x, SEXP lower, SEXP upper, SEXP incbounds, SEXP NAboundsArg, S
error(_("Incompatible vector lengths: length(x)==%d length(lower)==%d length(upper)==%d. Each should be either length 1 or the length of the longest."), nx, nl, nu);
}
const int longestBound = MAX(nl, nu); // just for when check=TRUE
if (!isLogical(incbounds) || LOGICAL(incbounds)[0]==NA_LOGICAL)
error(_("incbounds must be TRUE or FALSE"));
if (!IS_TRUE_OR_FALSE(incbounds))
error(_("%s must be TRUE or FALSE"), "incbounds");
const bool open = !LOGICAL(incbounds)[0];
if (!isLogical(NAboundsArg) || LOGICAL(NAboundsArg)[0]==FALSE)
error(_("NAbounds must be TRUE or NA"));
const bool NAbounds = LOGICAL(NAboundsArg)[0]==TRUE;
if (!isLogical(checkArg) || LOGICAL(checkArg)[0]==NA_LOGICAL)
error(_("check must be TRUE or FALSE"));
if (!IS_TRUE_OR_FALSE(checkArg))
error(_("%s must be TRUE or FALSE"), "check");
const bool check = LOGICAL(checkArg)[0];
const bool verbose = GetVerbose();

Expand Down
4 changes: 3 additions & 1 deletion src/bmerge.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ SEXP bmerge(SEXP idt, SEXP xdt, SEXP icolsArg, SEXP xcolsArg, SEXP isorted, SEXP
int xt = TYPEOF(VECTOR_ELT(xdt, xcols[col]-1));
if (iN && it!=xt) error(_("typeof x.%s (%s) != typeof i.%s (%s)"), CHAR(STRING_ELT(getAttrib(xdt,R_NamesSymbol),xcols[col]-1)), type2char(xt), CHAR(STRING_ELT(getAttrib(idt,R_NamesSymbol),icols[col]-1)), type2char(it));
if (iN && it!=LGLSXP && it!=INTSXP && it!=REALSXP && it!=STRSXP)
error(_("Type '%s' not supported for joining/merging"), type2char(it));
error(_("Type '%s' is not supported for joining/merging"), type2char(it));
}

// rollArg, rollendsArg
Expand Down Expand Up @@ -368,6 +368,8 @@ void bmerge_r(int xlowIn, int xuppIn, int ilowIn, int iuppIn, int col, int thisg
}
break;
// supported types were checked up front to avoid handling an error here in (future) parallel region
default:
error(_("Type '%s' is not supported for joining/merging"), type2char(TYPEOF(xc)));
}

if (xlow<xupp-1 || rollLow || rollUpp) { // if value found, xlow and xupp surround it, unlike standard binary search where low falls on it
Expand Down
2 changes: 1 addition & 1 deletion src/cj.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ SEXP cj(SEXP base_list) {
}
} break;
default:
error(_("Type '%s' not supported by CJ."), type2char(TYPEOF(source)));
error(_("Type '%s' is not supported by CJ."), type2char(TYPEOF(source)));
}
eachrep *= thislen;
}
Expand Down
2 changes: 1 addition & 1 deletion src/coalesce.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ SEXP coalesce(SEXP x, SEXP inplaceArg) {
}
} break;
default:
error(_("Unsupported type: %s"), type2char(TYPEOF(first))); // e.g. raw is tested
error(_("Type '%s' is not supported"), type2char(TYPEOF(first))); // e.g. raw is tested
}
UNPROTECT(nprotect);
return first;
Expand Down
2 changes: 1 addition & 1 deletion src/dogroups.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ SEXP dogroups(SEXP dt, SEXP dtcols, SEXP groups, SEXP grpcols, SEXP jiscols, SEX
// starts can now be NA (<0): if (INTEGER(starts)[0]<0 || INTEGER(lens)[0]<0) error(_("starts[1]<0 or lens[1]<0"));
if (!isNull(jiscols) && LENGTH(order) && !LOGICAL(on)[0]) error(_("Internal error: jiscols not NULL but o__ has length")); // # nocov
if (!isNull(xjiscols) && LENGTH(order) && !LOGICAL(on)[0]) error(_("Internal error: xjiscols not NULL but o__ has length")); // # nocov
if(!isEnvironment(env)) error(_("'env' should be an environment"));
if(!isEnvironment(env)) error(_("env is not an environment"));
ngrp = length(starts); // the number of groups (nrow(groups) will be larger when by)
ngrpcols = length(grpcols);
nrowgroups = length(VECTOR_ELT(groups,0));
Expand Down
4 changes: 2 additions & 2 deletions src/fifelse.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ SEXP fifelseR(SEXP l, SEXP a, SEXP b, SEXP na) {
}
} break;
default:
error(_("Type %s is not supported."), type2char(ta));
error(_("Type '%s' is not supported"), type2char(ta));
}

SEXP l_names = PROTECT(getAttrib(l, R_NamesSymbol)); nprotect++;
Expand Down Expand Up @@ -388,7 +388,7 @@ SEXP fcaseR(SEXP na, SEXP rho, SEXP args) {
}
} break;
default:
error(_("Type %s is not supported."), type2char(TYPEOF(outs)));
error(_("Type '%s' is not supported"), type2char(TYPEOF(outs)));
}
UNPROTECT(2); // this cons and outs
if (l==0) {
Expand Down
2 changes: 1 addition & 1 deletion src/fmelt.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ static void preprocess(SEXP DT, SEXP id, SEXP measure, SEXP varnames, SEXP valna
else error(_("When 'measure.vars' is either not specified or a character/integer vector, 'value.name' must be a character vector of length =1."));
}
if (length(varnames) != 1)
error(_("'variable.name' must be a character/integer vector of length=1."));
error(_("'variable.name' must be a character/integer vector of length 1."));
data->leach = (int *)R_alloc(data->lvalues, sizeof(int));
data->isidentical = (int *)R_alloc(data->lvalues, sizeof(int));
data->isfactor = (int *)R_alloc(data->lvalues, sizeof(int));
Expand Down
8 changes: 4 additions & 4 deletions src/forder.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,11 +455,11 @@ SEXP forder(SEXP DT, SEXP by, SEXP retGrpArg, SEXP sortGroupsArg, SEXP ascArg, S
STOP(_("Column %d is length %d which differs from length of column 1 (%d), are you attempting to order by a list column?\n"), INTEGER(by)[i], length(VECTOR_ELT(DT, INTEGER(by)[i]-1)), nrow);
if (TYPEOF(VECTOR_ELT(DT, by_i-1)) == CPLXSXP) n_cplx++;
}
if (!isLogical(retGrpArg) || LENGTH(retGrpArg)!=1 || INTEGER(retGrpArg)[0]==NA_LOGICAL)
STOP(_("retGrp must be TRUE or FALSE"));
if (!IS_TRUE_OR_FALSE(retGrpArg))
STOP(_("%s must be TRUE or FALSE"), "retGrp");
retgrp = LOGICAL(retGrpArg)[0]==TRUE;
if (!isLogical(sortGroupsArg) || LENGTH(sortGroupsArg)!=1 || INTEGER(sortGroupsArg)[0]==NA_LOGICAL )
STOP(_("sort must be TRUE or FALSE"));
if (!IS_TRUE_OR_FALSE(sortGroupsArg))
STOP(_("%s must be TRUE or FALSE"), "sort");
sortType = LOGICAL(sortGroupsArg)[0]==TRUE; // if sortType is 1, it is later flipped between +1/-1 according to ascArg. Otherwise ascArg is ignored when sortType==0
if (!retgrp && !sortType)
STOP(_("At least one of retGrp= or sort= must be TRUE"));
Expand Down
8 changes: 4 additions & 4 deletions src/frank.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
SEXP dt_na(SEXP x, SEXP cols) {
int n=0, elem;

if (!isNewList(x)) error(_("Internal error. Argument 'x' to Cdt_na is type '%s' not 'list'"), type2char(TYPEOF(x))); // # nocov
if (!isInteger(cols)) error(_("Internal error. Argument 'cols' to Cdt_na is type '%s' not 'integer'"), type2char(TYPEOF(cols))); // # nocov
if (!isNewList(x)) error(_("Internal error. Argument '%s' to %s is type '%s' not '%s'"), "x", "Cdt_na", type2char(TYPEOF(x)), "list"); // # nocov
if (!isInteger(cols)) error(_("Internal error. Argument '%s' to %s is type '%s' not '%s'"), "cols", "Cdt_na", type2char(TYPEOF(cols)), "integer"); // # nocov
for (int i=0; i<LENGTH(cols); ++i) {
elem = INTEGER(cols)[i];
if (elem<1 || elem>LENGTH(x))
Expand Down Expand Up @@ -184,8 +184,8 @@ SEXP frank(SEXP xorderArg, SEXP xstartArg, SEXP xlenArg, SEXP ties_method) {
// internal version of anyNA for data.tables
SEXP anyNA(SEXP x, SEXP cols) {
int n=0;
if (!isNewList(x)) error(_("Internal error. Argument 'x' to CanyNA is type '%s' not 'list'"), type2char(TYPEOF(x))); // #nocov
if (!isInteger(cols)) error(_("Internal error. Argument 'cols' to CanyNA is type '%s' not 'integer'"), type2char(TYPEOF(cols))); // # nocov
if (!isNewList(x)) error(_("Internal error. Argument '%s' to %s is type '%s' not '%s'"), "x", "CanyNA", type2char(TYPEOF(x)), "list"); // #nocov
if (!isInteger(cols)) error(_("Internal error. Argument '%s' to %s is type '%s' not '%s'"), "cols", "CanyNA", type2char(TYPEOF(cols)), "integer"); // # nocov
for (int i=0; i<LENGTH(cols); ++i) {
const int elem = INTEGER(cols)[i];
if (elem<1 || elem>LENGTH(x))
Expand Down
2 changes: 1 addition & 1 deletion src/fread.c
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +1355,7 @@ int freadMain(freadMainArgs _args) {
const char* fnam = args.filename;
#ifndef WIN32
int fd = open(fnam, O_RDONLY);
if (fd==-1) STOP(_("file not found: %s"),fnam);
if (fd==-1) STOP(_("File not found: %s"),fnam);
struct stat stat_buf;
if (fstat(fd, &stat_buf) == -1) {
close(fd); // # nocov
Expand Down
14 changes: 7 additions & 7 deletions src/frollR.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ SEXP frollfunR(SEXP fun, SEXP obj, SEXP k, SEXP fill, SEXP algo, SEXP align, SEX
if (xlength(k) == 0) // check that window is non zero length
error(_("n must be non 0 length"));

if (!isLogical(adaptive) || length(adaptive) != 1 || LOGICAL(adaptive)[0] == NA_LOGICAL)
error(_("adaptive must be TRUE or FALSE"));
if (!IS_TRUE_OR_FALSE(adaptive))
error(_("%s must be TRUE or FALSE"), "adaptive");
bool badaptive = LOGICAL(adaptive)[0];

R_len_t nk = 0; // number of rolling windows, for adaptive might be atomic to be wrapped into list, 0 for clang -Wall
Expand Down Expand Up @@ -91,7 +91,7 @@ SEXP frollfunR(SEXP fun, SEXP obj, SEXP k, SEXP fill, SEXP algo, SEXP align, SEX
}

if (!IS_TRUE_OR_FALSE(narm))
error(_("na.rm must be TRUE or FALSE"));
error(_("%s must be TRUE or FALSE"), "na.rm");

if (!isLogical(hasna) || length(hasna)!=1)
error(_("hasNA must be TRUE, FALSE or NA"));
Expand All @@ -106,7 +106,7 @@ SEXP frollfunR(SEXP fun, SEXP obj, SEXP k, SEXP fill, SEXP algo, SEXP align, SEX
else if (!strcmp(CHAR(STRING_ELT(align, 0)), "left"))
ialign = -1;
else
error(_("Internal error: invalid align argument in rolling function, should have been caught before. please report to data.table issue tracker.")); // # nocov
error(_("Internal error: invalid %s argument in %s function should have been caught earlier. Please report to the data.table issue tracker."), "align", "rolling"); // # nocov

if (badaptive && ialign!=1)
error(_("using adaptive TRUE and align argument different than 'right' is not implemented"));
Expand Down Expand Up @@ -138,7 +138,7 @@ SEXP frollfunR(SEXP fun, SEXP obj, SEXP k, SEXP fill, SEXP algo, SEXP align, SEX
} else if (!strcmp(CHAR(STRING_ELT(fun, 0)), "sum")) {
sfun = SUM;
} else {
error(_("Internal error: invalid fun argument in rolling function, should have been caught before. please report to data.table issue tracker.")); // # nocov
error(_("Internal error: invalid %s argument in %s function should have been caught earlier. Please report to the data.table issue tracker."), "fun", "rolling"); // # nocov
}

if (length(fill) != 1)
Expand All @@ -160,7 +160,7 @@ SEXP frollfunR(SEXP fun, SEXP obj, SEXP k, SEXP fill, SEXP algo, SEXP align, SEX
else if (!strcmp(CHAR(STRING_ELT(algo, 0)), "exact"))
ialgo = 1; // exact = 1
else
error(_("Internal error: invalid algo argument in rolling function, should have been caught before. please report to data.table issue tracker.")); // # nocov
error(_("Internal error: invalid %s argument in %s function should have been caught earlier. Please report to the data.table issue tracker."), "algo", "rolling"); // # nocov

int* iik = NULL;
if (!badaptive) {
Expand Down Expand Up @@ -250,7 +250,7 @@ SEXP frollapplyR(SEXP fun, SEXP obj, SEXP k, SEXP fill, SEXP align, SEXP rho) {
} else if (!strcmp(CHAR(STRING_ELT(align, 0)), "left")) {
ialign = -1;
} else {
error(_("Internal error: invalid align argument in rolling function, should have been caught before. please report to data.table issue tracker.")); // # nocov
error(_("Internal error: invalid %s argument in %s function should have been caught earlier. Please report to the data.table issue tracker."), "align", "rolling"); // # nocov
}

if (length(fill) != 1)
Expand Down
6 changes: 3 additions & 3 deletions src/fsort.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ int qsort_cmp(const void *a, const void *b) {
SEXP fsort(SEXP x, SEXP verboseArg) {
double t[10];
t[0] = wallclock();
if (!isLogical(verboseArg) || LENGTH(verboseArg)!=1 || LOGICAL(verboseArg)[0]==NA_LOGICAL)
error(_("verbose must be TRUE or FALSE"));
if (!IS_TRUE_OR_FALSE(verboseArg))
error(_("%s must be TRUE or FALSE"), "verbose");
Rboolean verbose = LOGICAL(verboseArg)[0];
if (!isNumeric(x)) error(_("x must be a vector of type 'double' currently"));
if (!isNumeric(x)) error(_("x must be a vector of type double currently"));
// TODO: not only detect if already sorted, but if it is, just return x to save the duplicate

SEXP ansVec = PROTECT(allocVector(REALSXP, xlength(x)));
Expand Down
Loading