Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Message fixes for the C code #6504

Merged
merged 20 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/fmelt.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ SEXP whichwrapper(SEXP x, SEXP val) {

static const char *concat(SEXP vec, SEXP idx) {
if (!isString(vec)) error(_("concat: 'vec' must be a character vector"));
if (!isInteger(idx) || length(idx) < 0) error(_("concat: 'idx' must be an integer vector of length >= 0"));
if (!isInteger(idx)) error(_("concat: 'idx' must be an integer vector"));
MichaelChirico marked this conversation as resolved.
Show resolved Hide resolved

static char ans[1024]; // so only one call to concat() per calling warning/error
int nidx=length(idx), nvec=length(vec);
Expand Down Expand Up @@ -802,7 +802,7 @@ SEXP fmelt(SEXP DT, SEXP id, SEXP measure, SEXP varfactor, SEXP valfactor, SEXP
}
int protecti=0;
dtnames = PROTECT(getAttrib(DT, R_NamesSymbol)); protecti++;
if (isNull(dtnames)) error(_("names(data) is NULL. Please report to data.table-help"));
if (isNull(dtnames)) error(_("names(data) is NULL. Please report to the data.table issue tracker"));
MichaelChirico marked this conversation as resolved.
Show resolved Hide resolved
if (LOGICAL(narmArg)[0] == TRUE) narm = TRUE;
if (LOGICAL(verboseArg)[0] == TRUE) verbose = TRUE;
struct processData data;
Expand Down
5 changes: 4 additions & 1 deletion src/fread.c
Original file line number Diff line number Diff line change
Expand Up @@ -2035,7 +2035,10 @@ int freadMain(freadMainArgs _args) {
}
if (verbose) {
if (sampleLines==0) {
DTPRINT(_(" 'header' determined to be %s because there are%s number fields in the first and only row\n"), args.header?"TRUE":"FALSE", args.header?_(" no"):"");
if (args.header)
MichaelChirico marked this conversation as resolved.
Show resolved Hide resolved
DTPRINT(_(" 'header' determined to be TRUE because there are no number fields in the first and only row\n"));
else
DTPRINT(_(" 'header' determined to be FALSE because there are number fields in the first and only row\n"));
MichaelChirico marked this conversation as resolved.
Show resolved Hide resolved
} else {
if (args.header)
DTPRINT(_(" 'header' determined to be true because all columns are type string and a better guess is not possible\n"));
Expand Down
10 changes: 6 additions & 4 deletions src/fsort.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,13 @@ SEXP fsort(SEXP x, SEXP verboseArg) {

if (verbose) {
Rprintf(_("Top 20 MSB counts: ")); for(int i=0; i<MIN(MSBsize,20); i++) Rprintf(_("%"PRId64" "), (int64_t)msbCounts[order[i]]); Rprintf(_("\n"));
Rprintf(_("Reduced MSBsize from %zu to "), MSBsize);
}
while (MSBsize>0 && msbCounts[order[MSBsize-1]] < 2) MSBsize--;
if (verbose) {
Rprintf(_("%zu by excluding 0 and 1 counts\n"), MSBsize);
{
MichaelChirico marked this conversation as resolved.
Show resolved Hide resolved
size_t oldMSBsize = MSBsize;
while (MSBsize>0 && msbCounts[order[MSBsize-1]] < 2) MSBsize--;
if (verbose) {
Rprintf(_("Reduced MSBsize from %zu to %zu by excluding 0 and 1 counts\n"), oldMSBsize, MSBsize);
MichaelChirico marked this conversation as resolved.
Show resolved Hide resolved
}
}

bool failed=false, alloc_fail=false, non_monotonic=false; // shared bools only ever assigned true; no need for atomic or critical assign
Expand Down
6 changes: 3 additions & 3 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@ void attribute_visible R_init_data_table(DllInfo *info)
if (ld != 0.0) error(_("Checking memset(&ld, 0, sizeof(long double)); ld == (long double)0.0 %s"), msg);

// Check unsigned cast used in fread.c. This isn't overflow/underflow, just cast.
if ((uint_fast8_t)('0'-'/') != 1) error(_("The ascii character '/' is not just before '0'"));
if ((uint_fast8_t)('0'-'/') != 1) error(_("Unlike the very common case, e.g. ASCII, the character '/' is not just before '0'."));
if ((uint_fast8_t)('/'-'0') < 10) error(_("The C expression (uint_fast8_t)('/'-'0')<10 is true. Should be false."));
if ((uint_fast8_t)(':'-'9') != 1) error(_("The ascii character ':' is not just after '9'"));
if ((uint_fast8_t)(':'-'9') != 1) error(_("Unlike the very common case, e.g. ASCII, the character ':' is not just after '9'."));
if ((uint_fast8_t)('9'-':') < 10) error(_("The C expression (uint_fast8_t)('9'-':')<10 is true. Should be false."));

// Variables rather than #define for NA_INT64 to ensure correct usage; i.e. not casted
Expand Down Expand Up @@ -364,7 +364,7 @@ SEXP beforeR340(void) {
extern int *_Last_updated; // assign.c

SEXP initLastUpdated(SEXP var) {
if (!isInteger(var) || LENGTH(var)!=1) error(_(".Last.value in namespace is not a length 1 integer"));
if (!isInteger(var) || LENGTH(var)!=1) error(_(".Last.updated in namespace is not a length 1 integer"));
_Last_updated = INTEGER(var);
return R_NilValue;
}
Expand Down
Loading