@@ -317,20 +317,20 @@ Token nextToken(Token tkn) throws IOException {
317317 c = in .readAgain ();
318318
319319 // empty line detection: eol AND (last char was EOL or beginning)
320- while (format .isEmptyLinesIgnored () && eol
321- && ( lastChar == '\n'
322- || lastChar == '\r'
323- || lastChar == ExtendedBufferedReader . UNDEFINED )
324- && ! isEndOfFile ( lastChar )) {
325- // go on char ahead ...
326- lastChar = c ;
327- c = in . read ( );
328- eol = isEndOfLine ( c );
329- c = in . readAgain ();
330- // reached end of file without any content (empty line at the end)
331- if ( isEndOfFile ( c )) {
332- tkn . type = EOF ;
333- return tkn ;
320+ if (format .isEmptyLinesIgnored ()) {
321+ while ( eol
322+ && ( lastChar == '\n' || lastChar == '\r' || lastChar == ExtendedBufferedReader . UNDEFINED )
323+ && ! isEndOfFile ( lastChar )) {
324+ // go on char ahead ...
325+ lastChar = c ;
326+ c = in . read () ;
327+ eol = isEndOfLine ( c );
328+ c = in . readAgain ( );
329+ // reached end of file without any content (empty line at the end)
330+ if ( isEndOfFile ( c )) {
331+ tkn . type = EOF ;
332+ return tkn ;
333+ }
334334 }
335335 }
336336
@@ -343,11 +343,14 @@ Token nextToken(Token tkn) throws IOException {
343343 // important: make sure a new char gets consumed in each iteration
344344 while (!tkn .isReady && tkn .type != EOF ) {
345345 // ignore whitespaces at beginning of a token
346- while (format .isLeadingSpacesIgnored () && isWhitespace (c ) && !eol ) {
347- wsBuf .append ((char ) c );
348- c = in .read ();
349- eol = isEndOfLine (c );
346+ if (format .isLeadingSpacesIgnored ()) {
347+ while (isWhitespace (c ) && !eol ) {
348+ wsBuf .append ((char ) c );
349+ c = in .read ();
350+ eol = isEndOfLine (c );
351+ }
350352 }
353+
351354 // ok, start of token reached: comment, encapsulated, or token
352355 if (c == format .getCommentStart ()) {
353356 // ignore everything till end of line and continue (incr linecount)
0 commit comments