Skip to content

Commit 4cc9e60

Browse files
Update simplecpp.cpp
1 parent 14a44eb commit 4cc9e60

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

simplecpp.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -276,16 +276,18 @@ class simplecpp::TokenList::Stream {
276276
}
277277

278278
unsigned char peekChar() {
279-
auto ch = static_cast<unsigned char>(peek());
279+
const int pk = peek();
280+
auto ch = static_cast<unsigned char>(pk);
281+
if (pk == EOF)
282+
return ch;
280283

281284
// For UTF-16 encoded files the BOM is 0xfeff/0xfffe. If the
282285
// character is non-ASCII character then replace it with 0xff
283286
if (isUtf16) {
284287
(void)get();
285-
const int ch2 = peek();
286-
if (ch2 != EOF)
287-
unget();
288-
const int ch16 = makeUtf16Char(ch, static_cast<unsigned char>(ch2));
288+
const int ch2 = static_cast<unsigned char>(peek());
289+
unget();
290+
const int ch16 = makeUtf16Char(ch, ch2);
289291
ch = static_cast<unsigned char>(((ch16 >= 0x80) ? 0xff : ch16));
290292
}
291293

0 commit comments

Comments
 (0)