From e6ac5796bc10a53591a0983b0cfd92d13ac30d9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 2 Feb 2024 14:25:46 +0100 Subject: [PATCH] bumped simplecpp to 1.1.1 (#5938) --- externals/simplecpp/simplecpp.cpp | 16 +++++++++++++--- externals/simplecpp/simplecpp.h | 4 +++- lib/preprocessor.cpp | 2 ++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/externals/simplecpp/simplecpp.cpp b/externals/simplecpp/simplecpp.cpp index e8636aaafe1..d9fd008766e 100644 --- a/externals/simplecpp/simplecpp.cpp +++ b/externals/simplecpp/simplecpp.cpp @@ -385,7 +385,10 @@ class FileStream : public simplecpp::TokenList::Stream { , lastCh(0) , lastStatus(0) { - assert(file != nullptr); + if (!file) { + const std::vector location; + throw simplecpp::Output(location, simplecpp::Output::FILE_NOT_FOUND, "File is missing: " + filename); + } init(); } @@ -442,8 +445,15 @@ simplecpp::TokenList::TokenList(std::istream &istr, std::vector &fi simplecpp::TokenList::TokenList(const std::string &filename, std::vector &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) diff --git a/externals/simplecpp/simplecpp.h b/externals/simplecpp/simplecpp.h index e5745a1aa51..5ad44a09421 100644 --- a/externals/simplecpp/simplecpp.h +++ b/externals/simplecpp/simplecpp.h @@ -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 &files, Output::Type id, const std::string & errMsg ) : type(id), location(files), msg(errMsg) {} Location location; std::string msg; }; diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index 71014e717fb..b07d644aacb 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -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: @@ -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; }