Skip to content

Commit e77137e

Browse files
committed
simplify header handling
1 parent 3e73565 commit e77137e

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/fread.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2312,17 +2312,16 @@ int freadMain(freadMainArgs _args)
23122312
// consider different cases line ending after column names
23132313
if (ch == eof || *ch == '\0') {
23142314
pos = ch;
2315-
} else if (*ch == '\n' || *ch == '\r') {
2316-
if (eol(&ch)) {
2317-
if (ch < eof) ch++;
2315+
} else {
2316+
const char *lineEnd = ch;
2317+
if (eol(&lineEnd)) {
2318+
if (lineEnd < eof) lineEnd++;
2319+
pos = lineEnd;
2320+
} else if (ch > sof && (ch[-1] == '\n' || ch[-1] == '\r')) { // trimmed a comment and now on next row's first byte
23182321
pos = ch;
23192322
} else {
23202323
INTERNAL_STOP("reading colnames ending on '%c'", *ch); // # nocov
23212324
}
2322-
} else if (ch > sof && (ch[-1] == '\n' || ch[-1] == '\r')) { // trimmed a comment and now on next rows first byte
2323-
pos = ch;
2324-
} else {
2325-
INTERNAL_STOP("reading colnames ending on '%c'", *ch); // # nocov
23262325
}
23272326
// now on first data row (row after column names)
23282327
// when fill=TRUE and column names shorter (test 1635.2), leave calloc initialized lenOff.len==0

0 commit comments

Comments
 (0)