bump simplecpp to rev a6124eec2bdab9eb6c06c87e024a94709ce6e9ee
This commit is contained in:
parent
b607e83648
commit
87b08fd405
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
#include <cstdlib>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
@ -32,6 +33,7 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stack>
|
#include <stack>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
|
#if defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
@ -392,8 +394,14 @@ void simplecpp::TokenList::readfile(std::istream &istr, const std::string &filen
|
||||||
loc.push(location);
|
loc.push(location);
|
||||||
location.fileIndex = fileIndex(cback()->str.substr(1U, cback()->str.size() - 2U));
|
location.fileIndex = fileIndex(cback()->str.substr(1U, cback()->str.size() - 2U));
|
||||||
location.line = 1U;
|
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
|
// #endfile
|
||||||
else if (lastline == "# endfile" && !loc.empty()) {
|
else if (lastline == "# endfile" && !loc.empty()) {
|
||||||
location = loc.top();
|
location = loc.top();
|
||||||
|
@ -870,7 +878,8 @@ std::string simplecpp::TokenList::lastLine(int maxsize) const {
|
||||||
continue;
|
continue;
|
||||||
if (!ret.empty())
|
if (!ret.empty())
|
||||||
ret = ' ' + ret;
|
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)
|
if (++count > maxsize)
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -1567,6 +1576,14 @@ namespace simplecpp {
|
||||||
#ifdef SIMPLECPP_WINDOWS
|
#ifdef SIMPLECPP_WINDOWS
|
||||||
|
|
||||||
static bool realFileName(const std::vector<TCHAR> &buf, std::ostream &ostr) {
|
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;
|
WIN32_FIND_DATA FindFileData;
|
||||||
HANDLE hFind = FindFirstFile(&buf[0], &FindFileData);
|
HANDLE hFind = FindFirstFile(&buf[0], &FindFileData);
|
||||||
if (hFind == INVALID_HANDLE_VALUE)
|
if (hFind == INVALID_HANDLE_VALUE)
|
||||||
|
@ -1640,7 +1657,13 @@ void simplifySizeof(simplecpp::TokenList &expr, const std::map<std::string, std:
|
||||||
if (tok->str != "sizeof")
|
if (tok->str != "sizeof")
|
||||||
continue;
|
continue;
|
||||||
simplecpp::Token *tok1 = tok->next;
|
simplecpp::Token *tok1 = tok->next;
|
||||||
|
if (!tok1) {
|
||||||
|
throw std::runtime_error("missed sizeof argument");
|
||||||
|
}
|
||||||
simplecpp::Token *tok2 = tok1->next;
|
simplecpp::Token *tok2 = tok1->next;
|
||||||
|
if (!tok2) {
|
||||||
|
throw std::runtime_error("missed sizeof argument");
|
||||||
|
}
|
||||||
if (tok1->op == '(') {
|
if (tok1->op == '(') {
|
||||||
tok1 = tok1->next;
|
tok1 = tok1->next;
|
||||||
while (tok2->op != ')')
|
while (tok2->op != ')')
|
||||||
|
@ -1838,8 +1861,6 @@ std::map<std::string, simplecpp::TokenList*> simplecpp::load(const simplecpp::To
|
||||||
if (!f.is_open())
|
if (!f.is_open())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ret[header2] = 0;
|
|
||||||
|
|
||||||
TokenList *tokens = new TokenList(f, fileNumbers, header2, outputList);
|
TokenList *tokens = new TokenList(f, fileNumbers, header2, outputList);
|
||||||
ret[header2] = tokens;
|
ret[header2] = tokens;
|
||||||
if (tokens->front())
|
if (tokens->front())
|
||||||
|
|
|
@ -50,7 +50,7 @@ typedef std::string TokenString;
|
||||||
*/
|
*/
|
||||||
class SIMPLECPP_LIB Location {
|
class SIMPLECPP_LIB Location {
|
||||||
public:
|
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) {
|
Location &operator=(const Location &other) {
|
||||||
if (this != &other) {
|
if (this != &other) {
|
||||||
|
@ -152,7 +152,7 @@ private:
|
||||||
|
|
||||||
/** Output from preprocessor */
|
/** Output from preprocessor */
|
||||||
struct SIMPLECPP_LIB Output {
|
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 {
|
enum Type {
|
||||||
ERROR, /* #error */
|
ERROR, /* #error */
|
||||||
WARNING, /* #warning */
|
WARNING, /* #warning */
|
||||||
|
@ -170,7 +170,7 @@ typedef std::list<Output> OutputList;
|
||||||
/** List of tokens. */
|
/** List of tokens. */
|
||||||
class SIMPLECPP_LIB TokenList {
|
class SIMPLECPP_LIB TokenList {
|
||||||
public:
|
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(std::istream &istr, std::vector<std::string> &filenames, const std::string &filename=std::string(), OutputList *outputList = 0);
|
||||||
TokenList(const TokenList &other);
|
TokenList(const TokenList &other);
|
||||||
~TokenList();
|
~TokenList();
|
||||||
|
@ -262,7 +262,7 @@ private:
|
||||||
|
|
||||||
/** Tracking how macros are used */
|
/** Tracking how macros are used */
|
||||||
struct SIMPLECPP_LIB MacroUsage {
|
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;
|
std::string macroName;
|
||||||
Location macroLocation;
|
Location macroLocation;
|
||||||
Location useLocation;
|
Location useLocation;
|
||||||
|
|
Loading…
Reference in New Issue