Skip to content

Commit

Permalink
Fix countfields() on the last line of file
Browse files Browse the repository at this point in the history
Closes #2543
  • Loading branch information
st-pasha committed Jan 2, 2018
1 parent 4c427ab commit 69d8ccf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -11187,6 +11187,8 @@ DT = setNames(data.frame(a = 1, b = 2, c = 3, d = 4), c(NA, "b", "c", NA))
setnames(DT, c('a', 'b', 'c', 'd'))
test(1853, names(DT), c('a', 'b', 'c', 'd'))

test(1854, fread("A,B\n "), data.table(A=logical(), B=logical())) # 2543

##########################

# TODO: Tests involving GForce functions needs to be run with optimisation level 1 and 2, so that both functions are tested all the time.
Expand Down
2 changes: 1 addition & 1 deletion src/fread.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ static inline int countfields(const char **pch)
const char *ch = *pch;
if (sep==' ') while (*ch==' ') ch++; // multiple sep==' ' at the start does not mean sep
skip_white(&ch);
if (eol(&ch)) {
if (eol(&ch) || ch==eof) {
*pch = ch+1;
return 0;
}
Expand Down

0 comments on commit 69d8ccf

Please sign in to comment.