From 193d2247e3937b1d2500573009772cd3cea0dd7e Mon Sep 17 00:00:00 2001 From: Roy Storey Date: Wed, 27 Feb 2019 22:49:31 +1300 Subject: [PATCH 1/2] really set to last line --- inst/tests/issue_3400_fread.txt | Bin 0 -> 37 bytes inst/tests/tests.Rraw | 3 +++ src/fread.c | 5 ++++- 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 inst/tests/issue_3400_fread.txt diff --git a/inst/tests/issue_3400_fread.txt b/inst/tests/issue_3400_fread.txt new file mode 100644 index 0000000000000000000000000000000000000000..17b2ee2f61df472338b36f63aa58d4bf3a8646e6 GIT binary patch literal 37 ocmYeaP2zG?P;gREaON^pP%u(ZFy=A_(}r9OCJG9s3JPXi0D5@^!~g&Q literal 0 HcmV?d00001 diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index e2aafc2e3f..409b045919 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -13583,6 +13583,9 @@ qcall = quote(b := .(.Primitive("sum")(1, 2))) # such calls can be issued by dca d = data.table(a=1L) test(1996.2, d[, eval(qcall)], data.table(a=1L, b=3)) +# issue #3400 +DT <- fread("A B C\n1 2 3\n3 2 1", header = TRUE) +test(1997.1, fread(testDir("issue_3400_fread.txt"), skip=1, header=TRUE), DT) ################################### # Add new tests above this line # diff --git a/src/fread.c b/src/fread.c index 98bd4222c1..33efb785d1 100644 --- a/src/fread.c +++ b/src/fread.c @@ -2148,7 +2148,10 @@ int freadMain(freadMainArgs _args) { while (*tch==' ') tch++; // multiple sep=' ' at the tLineStart does not mean sep. We're at tLineStart because the fast branch above doesn't run when sep=' ' fieldStart = tch; skip_white(&tch); - if (*tch=='\0') continue; // empty last line + if (*tch=='\0') { + nrowLimit = myNrow; + continue; // empty last line + } if (eol(&tch) && skipEmptyLines) { tch++; continue; } tch = fieldStart; // in case tabs at the beginning of the first field need to be included } From 751af17e56f68f7b55169c14e3bbfc76ed439c40 Mon Sep 17 00:00:00 2001 From: Matt Dowle Date: Fri, 12 Apr 2019 16:06:22 -0700 Subject: [PATCH 2/2] Fix my typo when resolving merge conflict --- inst/tests/tests.Rraw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index ab6a6b1546..e6cb6615f2 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -14009,7 +14009,7 @@ setindex(DT, y) test(2024, DT[y==6, v:=10L, verbose=TRUE], output=c("Constructing irows for.*", "Reorder irows for.*")) # fread embedded NULL, #3400 -test(2025, fread(testDir("issue_3400_fread.txt"), skip=1, header=TRUE), data.table(A=INT(1,3), B=INT(2,2), C=INT(3,1)) +test(2025, fread(testDir("issue_3400_fread.txt"), skip=1, header=TRUE), data.table(A=INT(1,3), B=INT(2,2), C=INT(3,1))) ###################################