diff --git a/simplecpp.cpp b/simplecpp.cpp index 7afc17ab..55264794 100644 --- a/simplecpp.cpp +++ b/simplecpp.cpp @@ -276,7 +276,10 @@ class simplecpp::TokenList::Stream { } unsigned char peekChar() { - auto ch = static_cast(peek()); + const int pk = peek(); + auto ch = static_cast(pk); + if (pk == EOF) + return ch; // For UTF-16 encoded files the BOM is 0xfeff/0xfffe. If the // character is non-ASCII character then replace it with 0xff