Skip to content

Commit

Permalink
Bump simplecpp (fix #11991)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Sep 26, 2023
1 parent 57bbb17 commit 4ae5203
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion externals/simplecpp/simplecpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ void simplecpp::TokenList::combineOperators()
if (tok->previous && tok->previous->number && sameline(tok->previous, tok)) {
tok->setstr(tok->previous->str() + '.');
deleteToken(tok->previous);
if (isFloatSuffix(tok->next) || (tok->next && tok->next->startsWithOneOf("AaBbCcDdEeFfPp"))) {
if (sameline(tok, tok->next) && (isFloatSuffix(tok->next) || (tok->next && tok->next->startsWithOneOf("AaBbCcDdEeFfPp")))) {
tok->setstr(tok->str() + tok->next->str());
deleteToken(tok->next);
}
Expand Down
6 changes: 5 additions & 1 deletion externals/simplecpp/simplecpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ namespace simplecpp {
name = (std::isalpha(static_cast<unsigned char>(string[0])) || string[0] == '_' || string[0] == '$')
&& (std::memchr(string.c_str(), '\'', string.size()) == nullptr);
comment = string.size() > 1U && string[0] == '/' && (string[1] == '/' || string[1] == '*');
number = std::isdigit(static_cast<unsigned char>(string[0])) || (string.size() > 1U && (string[0] == '-' || string[0] == '+') && std::isdigit(static_cast<unsigned char>(string[1])));
number = isNumberLike(string);
op = (string.size() == 1U && !name && !comment && !number) ? string[0] : '\0';
}

Expand All @@ -135,6 +135,10 @@ namespace simplecpp {
bool isOneOf(const char ops[]) const;
bool startsWithOneOf(const char c[]) const;
bool endsWithOneOf(const char c[]) const;
static bool SIMPLECPP_LIB isNumberLike(const std::string& str) {
return std::isdigit(static_cast<unsigned char>(str[0])) ||
(str.size() > 1U && (str[0] == '-' || str[0] == '+') && std::isdigit(static_cast<unsigned char>(str[1])));
}

TokenString macro;
char op;
Expand Down

0 comments on commit 4ae5203

Please sign in to comment.