Skip to content

Instantly share code, notes, and snippets.

@aaronjg
Last active May 23, 2018 22:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronjg/f39e5966687ca004dab5a10e7655c648 to your computer and use it in GitHub Desktop.
Save aaronjg/f39e5966687ca004dab5a10e7655c648 to your computer and use it in GitHub Desktop.
scan.c long vector patch
--- R-3.5.0/src/main/scan.c 2017-03-23 16:03:34.000000000 -0700
+++ ../R-3.5.0/src/main/scan.c 2018-05-23 15:01:36.128291864 -0700
@@ -484,7 +484,7 @@
error(_("scan() expected '%s', got '%s'"), what, got);
}
-static void extractItem(char *buffer, SEXP ans, int i, LocalData *d)
+static void extractItem(char *buffer, SEXP ans, R_xlen_t i, LocalData *d)
{
char *endp;
switch(TYPEOF(ans)) {
@@ -550,7 +550,8 @@
int flush, SEXP stripwhite, int blskip, LocalData *d)
{
SEXP ans, bns;
- int blocksize, c, i, n, linesread, nprev,strip, bch;
+ R_xlen_t blocksize, n, nprev, i;
+ int c, linesread, strip, bch;
char *buffer;
R_StringBuffer strBuf = {NULL, 0, MAXELTSIZE};
@@ -582,7 +583,7 @@
if (n == blocksize) {
/* enlarge the vector*/
bns = ans;
- if(blocksize > INT_MAX/2) error(_("too many items"));
+ if(blocksize > R_XLEN_T_MAX/2) error(_("too many items"));
blocksize = 2 * blocksize;
ans = allocVector(type, blocksize);
UNPROTECT(1);
@@ -732,7 +733,7 @@
sprintf(ConsolePrompt, "%d: ", n + 1);
}
if (n == blksize && colsread == 0) {
- if(blksize > INT_MAX/2) error(_("too many items"));
+ if(blksize > R_XLEN_T_MAX/2) error(_("too many items"));
blksize = 2 * blksize;
for (i = 0; i < nc; i++) {
old = VECTOR_ELT(ans, i);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment