Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions src/data.table.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
#include "myomp.h"
#include "types.h"
#include "po.h"
#ifdef WIN32 // positional specifiers (%n$) used in translations; #4402
//# define snprintf _sprintf_p // the non-n one in Windows takes n anyway so there's no separate _snprintf_f
#endif
#define sprintf USE_SNPRINTF_NOT_SPRINTF // prevent use of sprintf in data.table source; force us to use n always

// #include <signal.h> // the debugging machinery + breakpoint aidee
// raise(SIGINT);

Expand Down
1 change: 1 addition & 0 deletions src/dt_stdio.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#define DT_STDIO_H
#if defined(__MINGW32__) || (defined __MINGW64__)
#define __USE_MINGW_ANSI_STDIO 1
#define _XOPEN_SOURCE 1
#include <stdio.h>
#define PRId64 "lld"
#define PRIu64 "llu"
Expand Down
4 changes: 2 additions & 2 deletions src/fmelt.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ SEXP getvarcols(SEXP DT, SEXP dtnames, Rboolean varfactor, Rboolean verbose, str
const int thislen = data->narm ? length(VECTOR_ELT(data->naidx, j)) : data->nrow;
if (thislen==0) continue; // so as not to bump level
char buff[20];
sprintf(buff, "%d", level++);
snprintf(buff, 20, "%d", level++);
SEXP str = PROTECT(mkChar(buff));
for (int k=0; k<thislen; ++k) SET_STRING_ELT(target, ansloc++, str);
UNPROTECT(1);
Expand Down Expand Up @@ -566,7 +566,7 @@ SEXP getvarcols(SEXP DT, SEXP dtnames, Rboolean varfactor, Rboolean verbose, str
const int thislen = data->narm ? length(VECTOR_ELT(data->naidx, j)) : data->nrow;
if (thislen==0) continue; // so as not to bump level
char buff[20];
sprintf(buff, "%d", nlevel+1);
snprintf(buff, 20, "%d", nlevel+1);
SET_STRING_ELT(levels, nlevel++, mkChar(buff)); // generate levels = 1:nlevels
for (int k=0; k<thislen; ++k) td[ansloc++] = nlevel;
}
Expand Down
2 changes: 1 addition & 1 deletion src/freadR.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ bool userOverride(int8_t *type, lenOff *colNames, const char *anchor, const int
SEXP elem;
if (colNames==NULL || colNames[i].len<=0) {
char buff[12];
sprintf(buff,"V%d",i+1);
snprintf(buff,12,"V%d",i+1);
elem = mkChar(buff); // no PROTECT as passed immediately to SET_STRING_ELT
} else {
elem = mkCharLenCE(anchor+colNames[i].off, colNames[i].len, ienc); // no PROTECT as passed immediately to SET_STRING_ELT
Expand Down
6 changes: 3 additions & 3 deletions src/rbindlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ SEXP rbindlist(SEXP l, SEXP usenamesArg, SEXP fillArg, SEXP idcolArg)
}
}

if (!foundName) { static char buff[12]; sprintf(buff,"V%d",j+1), SET_STRING_ELT(ansNames, idcol+j, mkChar(buff)); foundName=buff; }
if (!foundName) { static char buff[12]; snprintf(buff,12,"V%d",j+1), SET_STRING_ELT(ansNames, idcol+j, mkChar(buff)); foundName=buff; }
if (factor) maxType=INTSXP; // if any items are factors then a factor is created (could be an option)
if (int64 && maxType!=REALSXP)
error(_("Internal error: column %d of result is determined to be integer64 but maxType=='%s' != REALSXP"), j+1, type2char(maxType)); // # nocov
Expand Down Expand Up @@ -379,12 +379,12 @@ SEXP rbindlist(SEXP l, SEXP usenamesArg, SEXP fillArg, SEXP idcolArg)
const int tl = TRUELENGTH(s);
if (tl>=last) { // if tl>=0 then also tl>=last because last<=0
if (tl>=0) {
sprintf(warnStr, // not direct warning as we're inside tl region
snprintf(warnStr, 1000, // not direct warning as we're inside tl region
_("Column %d of item %d is an ordered factor but level %d ['%s'] is missing from the ordered levels from column %d of item %d. " \
"Each set of ordered factor levels should be an ordered subset of the first longest. A regular factor will be created for this column."),
w+1, i+1, k+1, CHAR(s), longestW+1, longestI+1);
} else {
sprintf(warnStr,
snprintf(warnStr, 1000,
_("Column %d of item %d is an ordered factor with '%s'<'%s' in its levels. But '%s'<'%s' in the ordered levels from column %d of item %d. " \
"A regular factor will be created for this column due to this ambiguity."),
w+1, i+1, CHAR(levelsD[k-1]), CHAR(s), CHAR(s), CHAR(levelsD[k-1]), longestW+1, longestI+1);
Expand Down