bump simplecpp to rev a6124eec2bdab9eb6c06c87e024a94709ce6e9ee

This commit is contained in:
Daniel Marjamäki 2016-11-06 12:29:13 +01:00
parent b607e83648
commit 87b08fd405
2 changed files with 29 additions and 8 deletions

View File

@ -20,6 +20,7 @@
#include <algorithm>
#include <cctype>
#include <cstdlib>
#include <limits>
#include <list>
#include <map>
@ -32,6 +33,7 @@
#include <fstream>
#include <iostream>
#include <stack>
#include <string>
#if defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
#include <windows.h>
@ -392,8 +394,14 @@ void simplecpp::TokenList::readfile(std::istream &istr, const std::string &filen
loc.push(location);
location.fileIndex = fileIndex(cback()->str.substr(1U, cback()->str.size() - 2U));
location.line = 1U;
} else if (lastline == "# line %num%") {
loc.push(location);
location.line = std::atol(cback()->str.c_str());
} else if (lastline == "# line %num% %str%") {
loc.push(location);
location.fileIndex = fileIndex(cback()->str.substr(1U, cback()->str.size() - 2U));
location.line = std::atol(cback()->previous->str.c_str());
}
// #endfile
else if (lastline == "# endfile" && !loc.empty()) {
location = loc.top();
@ -870,7 +878,8 @@ std::string simplecpp::TokenList::lastLine(int maxsize) const {
continue;
if (!ret.empty())
ret = ' ' + ret;
ret = (tok->str[0] == '\"' ? std::string("%str%") : tok->str) + ret;
ret = (tok->str[0] == '\"' ? std::string("%str%")
: std::isdigit(static_cast<unsigned char>(tok->str[0])) ? std::string("%num%") : tok->str) + ret;
if (++count > maxsize)
return "";
}
@ -1567,6 +1576,14 @@ namespace simplecpp {
#ifdef SIMPLECPP_WINDOWS
static bool realFileName(const std::vector<TCHAR> &buf, std::ostream &ostr) {
// Detect root directory, see simplecpp:realFileName returns the wrong root path #45
if ((buf.size()==2 || (buf.size()>2 && buf[2]=='\0'))
&& std::isalpha(buf[0]) && buf[1]==':')
{
ostr << (char)buf[0];
ostr << (char)buf[1];
return true;
}
WIN32_FIND_DATA FindFileData;
HANDLE hFind = FindFirstFile(&buf[0], &FindFileData);
if (hFind == INVALID_HANDLE_VALUE)
@ -1640,7 +1657,13 @@ void simplifySizeof(simplecpp::TokenList &expr, const std::map<std::string, std:
if (tok->str != "sizeof")
continue;
simplecpp::Token *tok1 = tok->next;
if (!tok1) {
throw std::runtime_error("missed sizeof argument");
}
simplecpp::Token *tok2 = tok1->next;
if (!tok2) {
throw std::runtime_error("missed sizeof argument");
}
if (tok1->op == '(') {
tok1 = tok1->next;
while (tok2->op != ')')
@ -1838,8 +1861,6 @@ std::map<std::string, simplecpp::TokenList*> simplecpp::load(const simplecpp::To
if (!f.is_open())
continue;
ret[header2] = 0;
TokenList *tokens = new TokenList(f, fileNumbers, header2, outputList);
ret[header2] = tokens;
if (tokens->front())

View File

@ -50,7 +50,7 @@ typedef std::string TokenString;
*/
class SIMPLECPP_LIB Location {
public:
Location(const std::vector<std::string> &f) : files(f), fileIndex(0), line(1U), col(0U) {}
explicit Location(const std::vector<std::string> &f) : files(f), fileIndex(0), line(1U), col(0U) {}
Location &operator=(const Location &other) {
if (this != &other) {
@ -152,7 +152,7 @@ private:
/** Output from preprocessor */
struct SIMPLECPP_LIB Output {
Output(const std::vector<std::string> &files) : type(ERROR), location(files) {}
explicit Output(const std::vector<std::string> &files) : type(ERROR), location(files) {}
enum Type {
ERROR, /* #error */
WARNING, /* #warning */
@ -170,7 +170,7 @@ typedef std::list<Output> OutputList;
/** List of tokens. */
class SIMPLECPP_LIB TokenList {
public:
TokenList(std::vector<std::string> &filenames);
explicit TokenList(std::vector<std::string> &filenames);
TokenList(std::istream &istr, std::vector<std::string> &filenames, const std::string &filename=std::string(), OutputList *outputList = 0);
TokenList(const TokenList &other);
~TokenList();
@ -262,7 +262,7 @@ private:
/** Tracking how macros are used */
struct SIMPLECPP_LIB MacroUsage {
MacroUsage(const std::vector<std::string> &f) : macroLocation(f), useLocation(f) {}
explicit MacroUsage(const std::vector<std::string> &f) : macroLocation(f), useLocation(f) {}
std::string macroName;
Location macroLocation;
Location useLocation;