Skip to content

Commit 0ae163d

Browse files
committed
bump simplecpp (utf-8 handling, fix problem with multiline non-functionLike macro where replacement list starts with '(')
1 parent 766e81c commit 0ae163d

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

externals/simplecpp/simplecpp.cpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -298,11 +298,15 @@ static unsigned short getAndSkipBOM(std::istream &istr) {
298298
return 0;
299299
}
300300

301-
if (ch1 == 0xef && istr.peek() == 0xbb && istr.peek() == 0xbf) {
302-
// Skip BOM 0xefbbbf
303-
(void)istr.get();
304-
(void)istr.get();
305-
(void)istr.get();
301+
// Skip UTF-8 BOM 0xefbbbf
302+
if (ch1 == 0xef) {
303+
istr.get();
304+
if (istr.get() == 0xbb && istr.peek() == 0xbf) {
305+
(void)istr.get();
306+
} else {
307+
istr.unget();
308+
istr.unget();
309+
}
306310
}
307311

308312
return 0;
@@ -339,7 +343,8 @@ void simplecpp::TokenList::readfile(std::istream &istr, const std::string &filen
339343
location.line += multiline + 1;
340344
multiline = 0U;
341345
}
342-
location.col = 1;
346+
if (!multiline)
347+
location.col = 1;
343348

344349
if (oldLastToken != cback()) {
345350
oldLastToken = cback();
@@ -462,7 +467,11 @@ void simplecpp::TokenList::readfile(std::istream &istr, const std::string &filen
462467
}
463468

464469
push_back(new Token(currentToken, location));
465-
location.adjust(currentToken);
470+
471+
if (multiline)
472+
location.col += currentToken.size();
473+
else
474+
location.adjust(currentToken);
466475
}
467476

468477
combineOperators();

0 commit comments

Comments
 (0)