File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -298,6 +298,8 @@ class simplecpp::TokenList::Stream {
298298
299299protected:
300300 void init () {
301+ // initialize since we use peek() in getAndSkipBOM()
302+ isUtf16 = false ;
301303 bom = getAndSkipBOM ();
302304 isUtf16 = (bom == 0xfeff || bom == 0xfffe );
303305 }
@@ -336,6 +338,7 @@ class simplecpp::TokenList::Stream {
336338 }
337339
338340 unsigned short bom;
341+ protected:
339342 bool isUtf16;
340343};
341344
@@ -387,7 +390,14 @@ class FileStream : public simplecpp::TokenList::Stream {
387390 return ch;
388391 }
389392 virtual void unget () {
390- ungetc (lastCh, file);
393+ if (isUtf16) {
394+ // TODO: use ungetc() as well
395+ // UTF-16 has subsequent unget() calls
396+ fseek (file, -1 , SEEK_CUR);
397+ }
398+ else
399+ ungetc (lastCh, file);
400+
391401 }
392402 virtual bool good () {
393403 return lastCh != EOF;
You can’t perform that action at this time.
0 commit comments