Skip to content

Commit e6ac579

Browse files
authored
bumped simplecpp to 1.1.1 (#5938)
1 parent 998ffe3 commit e6ac579

3 files changed

Lines changed: 18 additions & 4 deletions

File tree

externals/simplecpp/simplecpp.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,10 @@ class FileStream : public simplecpp::TokenList::Stream {
385385
, lastCh(0)
386386
, lastStatus(0)
387387
{
388-
assert(file != nullptr);
388+
if (!file) {
389+
const std::vector<std::string> location;
390+
throw simplecpp::Output(location, simplecpp::Output::FILE_NOT_FOUND, "File is missing: " + filename);
391+
}
389392
init();
390393
}
391394

@@ -442,8 +445,15 @@ simplecpp::TokenList::TokenList(std::istream &istr, std::vector<std::string> &fi
442445
simplecpp::TokenList::TokenList(const std::string &filename, std::vector<std::string> &filenames, OutputList *outputList)
443446
: frontToken(nullptr), backToken(nullptr), files(filenames)
444447
{
445-
FileStream stream(filename);
446-
readfile(stream,filename,outputList);
448+
try
449+
{
450+
FileStream stream(filename);
451+
readfile(stream,filename,outputList);
452+
}
453+
catch(const simplecpp::Output & e) // TODO handle extra type of errors
454+
{
455+
outputList->push_back(e);
456+
}
447457
}
448458

449459
simplecpp::TokenList::TokenList(const TokenList &other) : frontToken(nullptr), backToken(nullptr), files(other.files)

externals/simplecpp/simplecpp.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,10 @@ namespace simplecpp {
180180
SYNTAX_ERROR,
181181
PORTABILITY_BACKSLASH,
182182
UNHANDLED_CHAR_ERROR,
183-
EXPLICIT_INCLUDE_NOT_FOUND
183+
EXPLICIT_INCLUDE_NOT_FOUND,
184+
FILE_NOT_FOUND
184185
} type;
186+
explicit Output(const std::vector<std::string> &files, Output::Type id, const std::string & errMsg ) : type(id), location(files), msg(errMsg) {}
185187
Location location;
186188
std::string msg;
187189
};

lib/preprocessor.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,7 @@ bool Preprocessor::hasErrors(const simplecpp::Output &output)
752752
case simplecpp::Output::SYNTAX_ERROR:
753753
case simplecpp::Output::UNHANDLED_CHAR_ERROR:
754754
case simplecpp::Output::EXPLICIT_INCLUDE_NOT_FOUND:
755+
case simplecpp::Output::FILE_NOT_FOUND:
755756
return true;
756757
case simplecpp::Output::WARNING:
757758
case simplecpp::Output::MISSING_HEADER:
@@ -891,6 +892,7 @@ void Preprocessor::reportOutput(const simplecpp::OutputList &outputList, bool sh
891892
error(out.location.file(), out.location.line, out.msg);
892893
break;
893894
case simplecpp::Output::EXPLICIT_INCLUDE_NOT_FOUND:
895+
case simplecpp::Output::FILE_NOT_FOUND:
894896
error(emptyString, 0, out.msg);
895897
break;
896898
}

0 commit comments

Comments
 (0)