@@ -2258,17 +2258,7 @@ int freadMain(freadMainArgs _args)
22582258 if (verbose ) DTPRINT (_ ("[08] Assign column names\n" ));
22592259
22602260 ch = pos ; // back to start of first row (column names if header==true)
2261- // Skip leading comment lines before parsing header
2262- if (args .header != false && commentChar ) {
2263- while (ch < eof ) {
2264- ch = skip_to_comment_or_nonwhite (ch );
2265- if (ch < eof && * ch == commentChar ) {
2266- ch = skip_to_nextline (ch , eof );
2267- } else break ;
2268- }
2269- pos = ch ;
2270- colNamesAnchor = pos ;
2271- }
2261+
22722262 if (args .header == false) {
22732263 colNames = NULL ; // userOverride will assign V1, V2, etc
22742264 } else {
@@ -2302,27 +2292,9 @@ int freadMain(freadMainArgs _args)
23022292 if (ch [1 ] == '\r' || ch [1 ] == '\n' || ch [1 ] == '\0' ) { ch ++ ; break ; }
23032293 }
23042294 }
2305- if (commentChar ) {
2306- // fast-trim trailing comment text after the header names
2307- const char * commentPos = skip_to_comment_or_nonwhite (ch );
2308- if (commentPos < eof && * commentPos == commentChar ) {
2309- ch = skip_to_eol (commentPos , eof );
2310- }
2311- }
2312- // consider different cases line ending after column names
2313- if (ch == eof || * ch == '\0' ) {
2314- pos = 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
2321- pos = ch ;
2322- } else {
2323- INTERNAL_STOP ("reading colnames ending on '%c'" , * ch ); // # nocov
2324- }
2325- }
2295+ if (eol (& ch )) pos = ++ ch ;
2296+ else if (* ch == '\0' ) pos = ch ;
2297+ else INTERNAL_STOP ("reading colnames ending on '%c'" , * ch ); // # nocov
23262298 // now on first data row (row after column names)
23272299 // when fill=TRUE and column names shorter (test 1635.2), leave calloc initialized lenOff.len==0
23282300 }
0 commit comments