Skip to content

Commit a5db777

Browse files
committed
simplified newline handling in TokenList::Stream::readChar()
1 parent d06accf commit a5db777

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

simplecpp.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -252,17 +252,15 @@ class simplecpp::TokenList::Stream {
252252
// Handling of newlines..
253253
if (ch == '\r') {
254254
ch = '\n';
255-
if (bom == 0 && static_cast<char>(peek()) == '\n')
256-
(void)get();
257-
else if (isUtf16) {
258-
const int c1 = get();
255+
256+
int ch2 = get();
257+
if (isUtf16) {
259258
const int c2 = get();
260-
const int ch16 = makeUtf16Char(c1, c2);
261-
if (ch16 != '\n') {
262-
unget();
263-
unget();
264-
}
259+
ch2 = makeUtf16Char(ch2, c2);
265260
}
261+
262+
if (ch2 != '\n')
263+
ungetChar();
266264
}
267265

268266
return ch;

0 commit comments

Comments
 (0)