Skip to content

Commit

Permalink
bumped simplecpp to 1.1.1 (#5938)
Browse files Browse the repository at this point in the history
  • Loading branch information
danmar committed Feb 2, 2024
1 parent 998ffe3 commit e6ac579
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
16 changes: 13 additions & 3 deletions externals/simplecpp/simplecpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,10 @@ class FileStream : public simplecpp::TokenList::Stream {
, lastCh(0)
, lastStatus(0)
{
assert(file != nullptr);
if (!file) {
const std::vector<std::string> location;
throw simplecpp::Output(location, simplecpp::Output::FILE_NOT_FOUND, "File is missing: " + filename);
}
init();
}

Expand Down Expand Up @@ -442,8 +445,15 @@ simplecpp::TokenList::TokenList(std::istream &istr, std::vector<std::string> &fi
simplecpp::TokenList::TokenList(const std::string &filename, std::vector<std::string> &filenames, OutputList *outputList)
: frontToken(nullptr), backToken(nullptr), files(filenames)
{
FileStream stream(filename);
readfile(stream,filename,outputList);
try
{
FileStream stream(filename);
readfile(stream,filename,outputList);
}
catch(const simplecpp::Output & e) // TODO handle extra type of errors
{
outputList->push_back(e);
}
}

simplecpp::TokenList::TokenList(const TokenList &other) : frontToken(nullptr), backToken(nullptr), files(other.files)
Expand Down
4 changes: 3 additions & 1 deletion externals/simplecpp/simplecpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,10 @@ namespace simplecpp {
SYNTAX_ERROR,
PORTABILITY_BACKSLASH,
UNHANDLED_CHAR_ERROR,
EXPLICIT_INCLUDE_NOT_FOUND
EXPLICIT_INCLUDE_NOT_FOUND,
FILE_NOT_FOUND
} type;
explicit Output(const std::vector<std::string> &files, Output::Type id, const std::string & errMsg ) : type(id), location(files), msg(errMsg) {}
Location location;
std::string msg;
};
Expand Down
2 changes: 2 additions & 0 deletions lib/preprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,7 @@ bool Preprocessor::hasErrors(const simplecpp::Output &output)
case simplecpp::Output::SYNTAX_ERROR:
case simplecpp::Output::UNHANDLED_CHAR_ERROR:
case simplecpp::Output::EXPLICIT_INCLUDE_NOT_FOUND:
case simplecpp::Output::FILE_NOT_FOUND:
return true;
case simplecpp::Output::WARNING:
case simplecpp::Output::MISSING_HEADER:
Expand Down Expand Up @@ -891,6 +892,7 @@ void Preprocessor::reportOutput(const simplecpp::OutputList &outputList, bool sh
error(out.location.file(), out.location.line, out.msg);
break;
case simplecpp::Output::EXPLICIT_INCLUDE_NOT_FOUND:
case simplecpp::Output::FILE_NOT_FOUND:
error(emptyString, 0, out.msg);
break;
}
Expand Down

0 comments on commit e6ac579

Please sign in to comment.