bump simplecpp

This commit is contained in:
Daniel Marjamäki 2016-07-29 13:05:35 +02:00
parent 63aa2fbed0
commit 30354ee026
2 changed files with 17 additions and 13 deletions

View File

@ -96,7 +96,7 @@ void simplecpp::Location::adjust(const std::string &str) {
return;
}
for (unsigned int i = 0U; i < str.size(); ++i) {
for (std::size_t i = 0U; i < str.size(); ++i) {
col++;
if (str[i] == '\n' || str[i] == '\r') {
col = 0;
@ -288,6 +288,10 @@ static unsigned short getAndSkipBOM(std::istream &istr) {
return 0;
}
bool isNameChar(unsigned char ch) {
return std::isalnum(ch) || ch == '_' || ch == '$';
}
void simplecpp::TokenList::readfile(std::istream &istr, const std::string &filename, OutputList *outputList)
{
std::stack<simplecpp::Location> loc;
@ -344,8 +348,8 @@ void simplecpp::TokenList::readfile(std::istream &istr, const std::string &filen
TokenString currentToken;
// number or name
if (std::isalnum(ch) || ch == '_') {
while (istr.good() && (std::isalnum(ch) || ch == '_')) {
if (isNameChar(ch)) {
while (istr.good() && isNameChar(ch)) {
currentToken += ch;
ch = readChar(istr,bom);
}
@ -1440,7 +1444,7 @@ bool hasFile(const std::map<std::string, simplecpp::TokenList *> &filedata, cons
}
}
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)
std::map<std::string, simplecpp::TokenList*> simplecpp::load(const simplecpp::TokenList &rawtokens, std::vector<std::string> &fileNumbers, const simplecpp::DUI &dui, simplecpp::OutputList *outputList)
{
std::map<std::string, simplecpp::TokenList*> ret;
@ -1487,7 +1491,7 @@ std::map<std::string, simplecpp::TokenList*> simplecpp::load(const simplecpp::To
return ret;
}
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)
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)
{
std::map<std::string, std::size_t> sizeOfType(rawtokens.sizeOfType);
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
err.type = rawtok->str == ERROR ? Output::ERROR : Output::WARNING;
err.location = rawtok->location;
for (const Token *tok = rawtok->next; tok && sameline(rawtok,tok); tok = tok->next) {
if (!err.msg.empty() && std::isalnum((unsigned char)tok->str[0]))
if (!err.msg.empty() && isNameChar(tok->str[0]))
err.msg += ' ';
err.msg += tok->str;
}
@ -1765,7 +1769,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
const Macro &macro = macroIt->second;
const std::list<Location> &usage = macro.usage();
for (std::list<Location>::const_iterator usageIt = usage.begin(); usageIt != usage.end(); ++usageIt) {
struct MacroUsage mu(usageIt->files);
MacroUsage mu(usageIt->files);
mu.macroName = macro.name();
mu.macroLocation = macro.defineLocation();
mu.useLocation = *usageIt;

View File

@ -105,9 +105,9 @@ public:
}
void flags() {
name = (str[0] == '_' || std::isalpha(str[0]));
name = (std::isalpha((unsigned char)str[0]) || str[0] == '_' || str[0] == '$');
comment = (str.compare(0, 2, "//") == 0 || str.compare(0, 2, "/*") == 0);
number = std::isdigit(str[0]) || (str.size() > 1U && str[0] == '-' && std::isdigit(str[1]));
number = std::isdigit((unsigned char)str[0]) || (str.size() > 1U && str[0] == '-' && std::isdigit((unsigned char)str[1]));
op = (str.size() == 1U) ? str[0] : '\0';
}
@ -120,9 +120,9 @@ public:
bool startsWithOneOf(const char c[]) const;
bool endsWithOneOf(const char c[]) const;
char op;
const TokenString &str;
TokenString macro;
char op;
bool comment;
bool name;
bool number;
@ -162,7 +162,7 @@ struct SIMPLECPP_LIB Output {
std::string msg;
};
typedef std::list<struct Output> OutputList;
typedef std::list<Output> OutputList;
/** List of tokens. */
class SIMPLECPP_LIB TokenList {
@ -271,7 +271,7 @@ struct SIMPLECPP_LIB DUI {
std::list<std::string> includePaths;
};
SIMPLECPP_LIB std::map<std::string, TokenList*> load(const TokenList &rawtokens, std::vector<std::string> &filenames, const struct DUI &dui, OutputList *outputList = 0);
SIMPLECPP_LIB std::map<std::string, TokenList*> load(const TokenList &rawtokens, std::vector<std::string> &filenames, const DUI &dui, OutputList *outputList = 0);
/**
* Preprocess
@ -287,7 +287,7 @@ SIMPLECPP_LIB std::map<std::string, TokenList*> load(const TokenList &rawtokens,
*
* @todo simplify interface
*/
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);
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);
}
#endif