Skip to content

Commit 1f32390

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

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

simplecpp.cpp

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

267265
return ch;

0 commit comments

Comments
 (0)