Skip to content

Commit 30354ee

Browse files
committed
bump simplecpp
1 parent 63aa2fb commit 30354ee

2 files changed

Lines changed: 17 additions & 13 deletions

File tree

externals/simplecpp/simplecpp.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ void simplecpp::Location::adjust(const std::string &str) {
9696
return;
9797
}
9898

99-
for (unsigned int i = 0U; i < str.size(); ++i) {
99+
for (std::size_t i = 0U; i < str.size(); ++i) {
100100
col++;
101101
if (str[i] == '\n' || str[i] == '\r') {
102102
col = 0;
@@ -288,6 +288,10 @@ static unsigned short getAndSkipBOM(std::istream &istr) {
288288
return 0;
289289
}
290290

291+
bool isNameChar(unsigned char ch) {
292+
return std::isalnum(ch) || ch == '_' || ch == '$';
293+
}
294+
291295
void simplecpp::TokenList::readfile(std::istream &istr, const std::string &filename, OutputList *outputList)
292296
{
293297
std::stack<simplecpp::Location> loc;
@@ -344,8 +348,8 @@ void simplecpp::TokenList::readfile(std::istream &istr, const std::string &filen
344348
TokenString currentToken;
345349

346350
// number or name
347-
if (std::isalnum(ch) || ch == '_') {
348-
while (istr.good() && (std::isalnum(ch) || ch == '_')) {
351+
if (isNameChar(ch)) {
352+
while (istr.good() && isNameChar(ch)) {
349353
currentToken += ch;
350354
ch = readChar(istr,bom);
351355
}
@@ -1440,7 +1444,7 @@ bool hasFile(const std::map<std::string, simplecpp::TokenList *> &filedata, cons
14401444
}
14411445
}
14421446

1443-
std::map<std::string, simplecpp::TokenList*> simplecpp::load(const simplecpp::TokenList &rawtokens, std::vector<std::string> &fileNumbers, const struct simplecpp::DUI &dui, simplecpp::OutputList *outputList)
1447+
std::map<std::string, simplecpp::TokenList*> simplecpp::load(const simplecpp::TokenList &rawtokens, std::vector<std::string> &fileNumbers, const simplecpp::DUI &dui, simplecpp::OutputList *outputList)
14441448
{
14451449
std::map<std::string, simplecpp::TokenList*> ret;
14461450

@@ -1487,7 +1491,7 @@ std::map<std::string, simplecpp::TokenList*> simplecpp::load(const simplecpp::To
14871491
return ret;
14881492
}
14891493

1490-
void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenList &rawtokens, std::vector<std::string> &files, const std::map<std::string, simplecpp::TokenList *> &filedata, const struct simplecpp::DUI &dui, simplecpp::OutputList *outputList, std::list<struct simplecpp::MacroUsage> *macroUsage)
1494+
void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenList &rawtokens, std::vector<std::string> &files, const std::map<std::string, simplecpp::TokenList *> &filedata, const simplecpp::DUI &dui, simplecpp::OutputList *outputList, std::list<simplecpp::MacroUsage> *macroUsage)
14911495
{
14921496
std::map<std::string, std::size_t> sizeOfType(rawtokens.sizeOfType);
14931497
sizeOfType.insert(std::pair<std::string, std::size_t>(std::string("char"), sizeof(char)));
@@ -1562,7 +1566,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
15621566
err.type = rawtok->str == ERROR ? Output::ERROR : Output::WARNING;
15631567
err.location = rawtok->location;
15641568
for (const Token *tok = rawtok->next; tok && sameline(rawtok,tok); tok = tok->next) {
1565-
if (!err.msg.empty() && std::isalnum((unsigned char)tok->str[0]))
1569+
if (!err.msg.empty() && isNameChar(tok->str[0]))
15661570
err.msg += ' ';
15671571
err.msg += tok->str;
15681572
}
@@ -1765,7 +1769,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
17651769
const Macro &macro = macroIt->second;
17661770
const std::list<Location> &usage = macro.usage();
17671771
for (std::list<Location>::const_iterator usageIt = usage.begin(); usageIt != usage.end(); ++usageIt) {
1768-
struct MacroUsage mu(usageIt->files);
1772+
MacroUsage mu(usageIt->files);
17691773
mu.macroName = macro.name();
17701774
mu.macroLocation = macro.defineLocation();
17711775
mu.useLocation = *usageIt;

externals/simplecpp/simplecpp.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ class SIMPLECPP_LIB Token {
105105
}
106106

107107
void flags() {
108-
name = (str[0] == '_' || std::isalpha(str[0]));
108+
name = (std::isalpha((unsigned char)str[0]) || str[0] == '_' || str[0] == '$');
109109
comment = (str.compare(0, 2, "//") == 0 || str.compare(0, 2, "/*") == 0);
110-
number = std::isdigit(str[0]) || (str.size() > 1U && str[0] == '-' && std::isdigit(str[1]));
110+
number = std::isdigit((unsigned char)str[0]) || (str.size() > 1U && str[0] == '-' && std::isdigit((unsigned char)str[1]));
111111
op = (str.size() == 1U) ? str[0] : '\0';
112112
}
113113

@@ -120,9 +120,9 @@ class SIMPLECPP_LIB Token {
120120
bool startsWithOneOf(const char c[]) const;
121121
bool endsWithOneOf(const char c[]) const;
122122

123-
char op;
124123
const TokenString &str;
125124
TokenString macro;
125+
char op;
126126
bool comment;
127127
bool name;
128128
bool number;
@@ -162,7 +162,7 @@ struct SIMPLECPP_LIB Output {
162162
std::string msg;
163163
};
164164

165-
typedef std::list<struct Output> OutputList;
165+
typedef std::list<Output> OutputList;
166166

167167
/** List of tokens. */
168168
class SIMPLECPP_LIB TokenList {
@@ -271,7 +271,7 @@ struct SIMPLECPP_LIB DUI {
271271
std::list<std::string> includePaths;
272272
};
273273

274-
SIMPLECPP_LIB std::map<std::string, TokenList*> load(const TokenList &rawtokens, std::vector<std::string> &filenames, const struct DUI &dui, OutputList *outputList = 0);
274+
SIMPLECPP_LIB std::map<std::string, TokenList*> load(const TokenList &rawtokens, std::vector<std::string> &filenames, const DUI &dui, OutputList *outputList = 0);
275275

276276
/**
277277
* Preprocess
@@ -287,7 +287,7 @@ SIMPLECPP_LIB std::map<std::string, TokenList*> load(const TokenList &rawtokens,
287287
*
288288
* @todo simplify interface
289289
*/
290-
SIMPLECPP_LIB void preprocess(TokenList &output, const TokenList &rawtokens, std::vector<std::string> &files, const std::map<std::string, TokenList*> &filedata, const struct DUI &dui, OutputList *outputList = 0, std::list<struct MacroUsage> *macroUsage = 0);
290+
SIMPLECPP_LIB void preprocess(TokenList &output, const TokenList &rawtokens, std::vector<std::string> &files, const std::map<std::string, TokenList*> &filedata, const DUI &dui, OutputList *outputList = 0, std::list<MacroUsage> *macroUsage = 0);
291291
}
292292

293293
#endif

0 commit comments

Comments
 (0)