Skip to content

Commit 700dc90

Browse files
committed
simplified newline handling in TokenList::Stream::readChar()
1 parent fa5e7e3 commit 700dc90

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
@@ -254,17 +254,15 @@ class simplecpp::TokenList::Stream {
254254
// Handling of newlines..
255255
if (ch == '\r') {
256256
ch = '\n';
257-
if (bom == 0 && static_cast<char>(peek()) == '\n')
258-
(void)get();
259-
else if (isUtf16) {
260-
const int c1 = get();
257+
258+
int ch2 = get();
259+
if (isUtf16) {
261260
const int c2 = get();
262-
const int ch16 = makeUtf16Char(c1, c2);
263-
if (ch16 != '\n') {
264-
unget();
265-
unget();
266-
}
261+
ch2 = makeUtf16Char(ch2, c2);
267262
}
263+
264+
if (ch2 != '\n')
265+
ungetChar();
268266
}
269267

270268
return ch;

0 commit comments

Comments
 (0)