From 41c8e90e5ae22c0a35611b8e9db5b3726478ed93 Mon Sep 17 00:00:00 2001 From: Tal500 Date: Wed, 21 May 2025 15:40:17 +0300 Subject: [PATCH 01/14] Update simplecpp.cpp --- externals/simplecpp/simplecpp.cpp | 85 ++++++++++++++++++++----------- 1 file changed, 56 insertions(+), 29 deletions(-) diff --git a/externals/simplecpp/simplecpp.cpp b/externals/simplecpp/simplecpp.cpp index d1fa91bf532..58ccb1407bd 100755 --- a/externals/simplecpp/simplecpp.cpp +++ b/externals/simplecpp/simplecpp.cpp @@ -2719,14 +2719,38 @@ static std::string toAbsolutePath(const std::string& path) { return simplecpp::simplifyPath(path); } -static std::pair extractRelativePathFromAbsolute(const std::string& absolutepath) { - static const std::string prefix = currentDirectory() + "/"; - if (startsWith_(absolutepath, prefix)) { - const std::size_t size = prefix.size(); - return std::make_pair(absolutepath.substr(size, absolutepath.size() - size), true); +// templated function for compiler optimization opportunities +template +static std::string dirPath(const std::string& path) { + const std::size_t firstSlash = path.find_last_of("\\/"); + if (firstSlash == std::string::npos) { + return ""; } - // otherwise - return std::make_pair("", false); + return path.substr(0, firstSlash + (withTrailingSlash ? 1U : 0U)); +} + +static std::string omitPathTrailingSlash(const std::string& path) { + if (endsWith(path, "/")) { + return path.substr(0, path.size() - 1U); + } + return path; +} + +static std::string extractRelativePathFromAbsolute(const std::string& absoluteSimplifiedPath, const std::string& prefixSimplifiedAbsoluteDir = currentDirectory()) { + const std::string normalizedAbsolutePath = omitPathTrailingSlash(absoluteSimplifiedPath); + std::string currentPrefix = omitPathTrailingSlash(prefixSimplifiedAbsoluteDir); + std::string leadingParenting; + while (!startsWith_(normalizedAbsolutePath, currentPrefix)) { + leadingParenting = "../" + leadingParenting; + currentPrefix = dirPath(currentPrefix); + } + const std::size_t size = currentPrefix.size(); + std::string relativeFromMeetingPath = normalizedAbsolutePath.substr(size, normalizedAbsolutePath.size() - size); + if (startsWith_(relativeFromMeetingPath, "/")) { + // omit the leading slash + relativeFromMeetingPath = relativeFromMeetingPath.substr(1, relativeFromMeetingPath.size()); + } + return leadingParenting + relativeFromMeetingPath; } static std::string openHeader(std::ifstream &f, const simplecpp::DUI &dui, const std::string &sourcefile, const std::string &header, bool systemheader); @@ -3145,19 +3169,26 @@ static std::string openHeader(std::ifstream &f, const std::string &path) return ""; } +// templated function for compiler optimization opportunities +template static std::string getRelativeFileName(const std::string &baseFile, const std::string &header) { - std::string path; - if (baseFile.find_first_of("\\/") != std::string::npos) - path = baseFile.substr(0, baseFile.find_last_of("\\/") + 1U) + header; - else - path = header; - return simplecpp::simplifyPath(path); + const std::string baseFileSimplified = simplecpp::simplifyPath(baseFile); + const std::string baseFileNormalized = (expandBaseWithAbsolutePath && !isAbsolutePath(baseFileSimplified)) ? (currentDirectory() + "/" + baseFileSimplified) : baseFileSimplified; + + const std::string headerSimplified = simplecpp::simplifyPath(header); + const std::string path = isAbsolutePath(headerSimplified) ? headerSimplified : (dirPath(baseFileNormalized) + headerSimplified); + if (exactRelative) { + const std::string absolutePath = expandBaseWithAbsolutePath ? path : toAbsolutePath(path); + const std::string absoluteBaseFile = expandBaseWithAbsolutePath ? baseFileNormalized : toAbsolutePath(baseFileNormalized); + return extractRelativePathFromAbsolute(absolutePath, dirPath(absoluteBaseFile)); + } + return path; } static std::string openHeaderRelative(std::ifstream &f, const std::string &sourcefile, const std::string &header) { - return openHeader(f, getRelativeFileName(sourcefile, header)); + return openHeader(f, getRelativeFileName(sourcefile, header)); } // returns the simplified header path: @@ -3174,8 +3205,8 @@ static std::string getIncludePathFileName(const std::string &includePath, const std::string basePath = toAbsolutePath(includePath); if (!basePath.empty() && basePath[basePath.size()-1U]!='/' && basePath[basePath.size()-1U]!='\\') basePath += '/'; - const std::string absolutesimplifiedHeaderPath = basePath + simplifiedHeader; - return extractRelativePathFromAbsolute(absolutesimplifiedHeaderPath).first; + const std::string absoluteSimplifiedHeaderPath = basePath + simplifiedHeader; + return extractRelativePathFromAbsolute(absoluteSimplifiedHeaderPath); } static std::string openHeaderIncludePath(std::ifstream &f, const simplecpp::DUI &dui, const std::string &header) @@ -3210,22 +3241,18 @@ static std::string findPathInMapBothRelativeAndAbsolute(const std::map relativeExtractedResult = extractRelativePathFromAbsolute(path); - if (relativeExtractedResult.second) { - const std::string relativePath = relativeExtractedResult.first; - if (filedata.find(relativePath) != filedata.end()) { - return relativePath; - } - } + alternativePath = extractRelativePathFromAbsolute(simplecpp::simplifyPath(path)); } else { - const std::string absolutePath = toAbsolutePath(path); - if (filedata.find(absolutePath) != filedata.end()) { - return absolutePath; - } + alternativePath = toAbsolutePath(path); + } + + if (filedata.find(alternativePath) != filedata.end()) { + return alternativePath; } - // otherwise return ""; } @@ -3243,7 +3270,7 @@ static std::string getFileIdPath(const std::map(sourcefile, header);// unknown if absolute or relative, but always simplified const std::string match = findPathInMapBothRelativeAndAbsolute(filedata, relativeOrAbsoluteFilename); if (!match.empty()) { return match; From ce043fe3a59904f82b8992bb6085b8b28cbecd8f Mon Sep 17 00:00:00 2001 From: Tal500 Date: Wed, 21 May 2025 17:31:48 +0300 Subject: [PATCH 02/14] Update asan.yml - temp tests --- .github/workflows/asan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/asan.yml b/.github/workflows/asan.yml index 3e8fc4053f1..76ebfb288e8 100644 --- a/.github/workflows/asan.yml +++ b/.github/workflows/asan.yml @@ -74,7 +74,7 @@ jobs: # TODO: disable all warnings - name: CMake run: | - cmake -S . -B cmake.output -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DUSE_QT6=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DUSE_MATCHCOMPILER=Verify -DANALYZE_ADDRESS=On -DENABLE_CHECK_INTERNAL=On -DUSE_BOOST=On -DCPPCHK_GLIBCXX_DEBUG=Off -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DDISABLE_DMAKE=On -DFILESDIR= -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache + cmake -S . -B cmake.output -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DUSE_QT6=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DUSE_MATCHCOMPILER=Verify -DANALYZE_ADDRESS=On -DENABLE_CHECK_INTERNAL=On -DUSE_BOOST=On -DCPPCHK_GLIBCXX_DEBUG=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DDISABLE_DMAKE=On -DFILESDIR= -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache env: CC: clang-20 CXX: clang++-20 From 7af62243fd0dc8c09bb3e210a69baef5c6abcde9 Mon Sep 17 00:00:00 2001 From: Tal500 Date: Wed, 21 May 2025 18:08:04 +0300 Subject: [PATCH 03/14] try to fix the leak sanitizer error by potentially delete the token in the load loop --- externals/simplecpp/simplecpp.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/externals/simplecpp/simplecpp.cpp b/externals/simplecpp/simplecpp.cpp index 58ccb1407bd..16bbdd95bd7 100755 --- a/externals/simplecpp/simplecpp.cpp +++ b/externals/simplecpp/simplecpp.cpp @@ -3294,6 +3294,18 @@ static bool hasFile(const std::map &filedat return !getFileIdPath(filedata, sourcefile, header, dui, systemheader).empty(); } +struct PotentionalDeletor { + explicit PotentionalDeletor(T* ptr = nullptr) : ptr(ptr) {} + ~PotentionalDeletor() { + delete ptr;// note: deleting nullptr is just a no-op + } + + T* ptr; + +private: + PotentionalDeletor(const PotentionalDeletor&); // intentionally unimplemented +}; + std::map simplecpp::load(const simplecpp::TokenList &rawtokens, std::vector &filenames, const simplecpp::DUI &dui, simplecpp::OutputList *outputList) { #ifdef SIMPLECPP_WINDOWS @@ -3338,9 +3350,12 @@ std::map simplecpp::load(const simplecpp::To } for (const Token *rawtok = rawtokens.cfront(); rawtok || !filelist.empty(); rawtok = rawtok ? rawtok->next : nullptr) { + PotentionalDeletor rawtokDeletor; if (rawtok == nullptr) { + // In this case, pop the filelist back token, and mark it for delete after this iteration rawtok = filelist.back(); filelist.pop_back(); + rawtokDeletor.ptr = rawtok; } if (rawtok->op != '#' || sameline(rawtok->previousSkipComments(), rawtok)) From 0b54be5f1ad7c9b35a8c2a71d62f64f9286eeed0 Mon Sep 17 00:00:00 2001 From: Tal500 Date: Wed, 21 May 2025 18:10:46 +0300 Subject: [PATCH 04/14] Update simplecpp.cpp --- externals/simplecpp/simplecpp.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/externals/simplecpp/simplecpp.cpp b/externals/simplecpp/simplecpp.cpp index 16bbdd95bd7..d1937a89517 100755 --- a/externals/simplecpp/simplecpp.cpp +++ b/externals/simplecpp/simplecpp.cpp @@ -3294,6 +3294,7 @@ static bool hasFile(const std::map &filedat return !getFileIdPath(filedata, sourcefile, header, dui, systemheader).empty(); } +template struct PotentionalDeletor { explicit PotentionalDeletor(T* ptr = nullptr) : ptr(ptr) {} ~PotentionalDeletor() { From 07288483712326ad247b2d3e2f3160db96567044 Mon Sep 17 00:00:00 2001 From: Tal500 Date: Wed, 21 May 2025 18:30:51 +0300 Subject: [PATCH 05/14] do not load tokens twice --- externals/simplecpp/simplecpp.cpp | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/externals/simplecpp/simplecpp.cpp b/externals/simplecpp/simplecpp.cpp index d1937a89517..a2800b380a6 100755 --- a/externals/simplecpp/simplecpp.cpp +++ b/externals/simplecpp/simplecpp.cpp @@ -3294,19 +3294,6 @@ static bool hasFile(const std::map &filedat return !getFileIdPath(filedata, sourcefile, header, dui, systemheader).empty(); } -template -struct PotentionalDeletor { - explicit PotentionalDeletor(T* ptr = nullptr) : ptr(ptr) {} - ~PotentionalDeletor() { - delete ptr;// note: deleting nullptr is just a no-op - } - - T* ptr; - -private: - PotentionalDeletor(const PotentionalDeletor&); // intentionally unimplemented -}; - std::map simplecpp::load(const simplecpp::TokenList &rawtokens, std::vector &filenames, const simplecpp::DUI &dui, simplecpp::OutputList *outputList) { #ifdef SIMPLECPP_WINDOWS @@ -3351,12 +3338,9 @@ std::map simplecpp::load(const simplecpp::To } for (const Token *rawtok = rawtokens.cfront(); rawtok || !filelist.empty(); rawtok = rawtok ? rawtok->next : nullptr) { - PotentionalDeletor rawtokDeletor; if (rawtok == nullptr) { - // In this case, pop the filelist back token, and mark it for delete after this iteration rawtok = filelist.back(); filelist.pop_back(); - rawtokDeletor.ptr = rawtok; } if (rawtok->op != '#' || sameline(rawtok->previousSkipComments(), rawtok)) @@ -3382,6 +3366,8 @@ std::map simplecpp::load(const simplecpp::To if (!f.is_open()) continue; f.close(); + if (ret.find(header2) != ret.end()) + continue; TokenList *tokens = new TokenList(header2, filenames, outputList); if (dui.removeComments) From 7ee9e6a9f555b8cb905e39e7aa1ca18d37c98ba7 Mon Sep 17 00:00:00 2001 From: Tal500 Date: Wed, 21 May 2025 19:17:07 +0300 Subject: [PATCH 06/14] try to throw on weird potential case --- externals/simplecpp/simplecpp.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/externals/simplecpp/simplecpp.cpp b/externals/simplecpp/simplecpp.cpp index a2800b380a6..9db49e212bb 100755 --- a/externals/simplecpp/simplecpp.cpp +++ b/externals/simplecpp/simplecpp.cpp @@ -3659,6 +3659,9 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL TokenList * const tokens = new TokenList(header2, files, outputList); if (dui.removeComments) tokens->removeComments(); + if (filedata.find(header2) != filedata.end()) { + throw "header2 is already there!" + header2; + } filedata[header2] = tokens; } } From 4a436651e69aae46f95b090243791ed5fac611b8 Mon Sep 17 00:00:00 2001 From: Tal500 Date: Wed, 21 May 2025 19:50:33 +0300 Subject: [PATCH 07/14] try to use paths better --- externals/simplecpp/simplecpp.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/externals/simplecpp/simplecpp.cpp b/externals/simplecpp/simplecpp.cpp index 9db49e212bb..4b39820aeba 100755 --- a/externals/simplecpp/simplecpp.cpp +++ b/externals/simplecpp/simplecpp.cpp @@ -3181,14 +3181,14 @@ static std::string getRelativeFileName(const std::string &baseFile, const std::s if (exactRelative) { const std::string absolutePath = expandBaseWithAbsolutePath ? path : toAbsolutePath(path); const std::string absoluteBaseFile = expandBaseWithAbsolutePath ? baseFileNormalized : toAbsolutePath(baseFileNormalized); - return extractRelativePathFromAbsolute(absolutePath, dirPath(absoluteBaseFile)); + return extractRelativePathFromAbsolute(absolutePath); } return path; } static std::string openHeaderRelative(std::ifstream &f, const std::string &sourcefile, const std::string &header) { - return openHeader(f, getRelativeFileName(sourcefile, header)); + return openHeader(f, getRelativeFileName(sourcefile, header)); } // returns the simplified header path: @@ -3366,8 +3366,6 @@ std::map simplecpp::load(const simplecpp::To if (!f.is_open()) continue; f.close(); - if (ret.find(header2) != ret.end()) - continue; TokenList *tokens = new TokenList(header2, filenames, outputList); if (dui.removeComments) From aa07c7a6dd0638ba83b39126b2bb52b8d018e022 Mon Sep 17 00:00:00 2001 From: Tal500 Date: Wed, 21 May 2025 20:08:03 +0300 Subject: [PATCH 08/14] more temp printing --- externals/simplecpp/simplecpp.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/externals/simplecpp/simplecpp.cpp b/externals/simplecpp/simplecpp.cpp index 4b39820aeba..a4ab44852f6 100755 --- a/externals/simplecpp/simplecpp.cpp +++ b/externals/simplecpp/simplecpp.cpp @@ -3658,6 +3658,8 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL if (dui.removeComments) tokens->removeComments(); if (filedata.find(header2) != filedata.end()) { + std::cout << "header: " << header << "header2: " << header2 << std::endl; + std::cerr << "header: " << header << "header2: " << header2 << std::endl; throw "header2 is already there!" + header2; } filedata[header2] = tokens; From 606891d33b90d715626495737500c75a4acd1fa7 Mon Sep 17 00:00:00 2001 From: Tal500 Date: Wed, 21 May 2025 20:24:36 +0300 Subject: [PATCH 09/14] more temp printing --- externals/simplecpp/simplecpp.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/externals/simplecpp/simplecpp.cpp b/externals/simplecpp/simplecpp.cpp index a4ab44852f6..619028aec4a 100755 --- a/externals/simplecpp/simplecpp.cpp +++ b/externals/simplecpp/simplecpp.cpp @@ -3658,8 +3658,8 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL if (dui.removeComments) tokens->removeComments(); if (filedata.find(header2) != filedata.end()) { - std::cout << "header: " << header << "header2: " << header2 << std::endl; - std::cerr << "header: " << header << "header2: " << header2 << std::endl; + std::cout << "header: " << header << " header2: " << header2 << " source: " << rawtok->location.file() << " systemheader: " << systemheader << std::endl; + std::cerr << "header: " << header << " header2: " << header2 << " source: " << rawtok->location.file() << " systemheader: " << systemheader << std::endl; throw "header2 is already there!" + header2; } filedata[header2] = tokens; From bd3a5e9b355ec35da64164d7b8b631b4843cfd3d Mon Sep 17 00:00:00 2001 From: Tal500 Date: Wed, 21 May 2025 20:50:55 +0300 Subject: [PATCH 10/14] more temp printing --- externals/simplecpp/simplecpp.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/externals/simplecpp/simplecpp.cpp b/externals/simplecpp/simplecpp.cpp index 619028aec4a..e2dfd7651ac 100755 --- a/externals/simplecpp/simplecpp.cpp +++ b/externals/simplecpp/simplecpp.cpp @@ -3227,6 +3227,8 @@ static std::string openHeader(std::ifstream &f, const simplecpp::DUI &dui, const // prefer first to search the header relatively to source file if found, when not a system header if (!systemheader) { std::string relativeHeader = openHeaderRelative(f, sourcefile, header); + if (endsWith(header, "aboutdialog.h"))// temp printing + std::cout << "relativeHeader: " << relativeHeader << " sourcefile: " << sourcefile << " header: " << header << std::endl; if (!relativeHeader.empty()) { return relativeHeader; } From c40e3c7c17cdecc1d13d34c7f62b395ece07f47e Mon Sep 17 00:00:00 2001 From: Tal500 Date: Wed, 21 May 2025 21:03:10 +0300 Subject: [PATCH 11/14] Update simplecpp.cpp: simplify path --- externals/simplecpp/simplecpp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/externals/simplecpp/simplecpp.cpp b/externals/simplecpp/simplecpp.cpp index e2dfd7651ac..bf7def44f9d 100755 --- a/externals/simplecpp/simplecpp.cpp +++ b/externals/simplecpp/simplecpp.cpp @@ -3174,7 +3174,7 @@ template static std::string getRelativeFileName(const std::string &baseFile, const std::string &header) { const std::string baseFileSimplified = simplecpp::simplifyPath(baseFile); - const std::string baseFileNormalized = (expandBaseWithAbsolutePath && !isAbsolutePath(baseFileSimplified)) ? (currentDirectory() + "/" + baseFileSimplified) : baseFileSimplified; + const std::string baseFileNormalized = (expandBaseWithAbsolutePath && !isAbsolutePath(baseFileSimplified)) ? simplecpp::simplifyPath(currentDirectory() + "/" + baseFileSimplified) : baseFileSimplified; const std::string headerSimplified = simplecpp::simplifyPath(header); const std::string path = isAbsolutePath(headerSimplified) ? headerSimplified : (dirPath(baseFileNormalized) + headerSimplified); From 61ab252016d55640bf0d6b1a2db363faefe133b4 Mon Sep 17 00:00:00 2001 From: Tal500 Date: Wed, 21 May 2025 21:16:45 +0300 Subject: [PATCH 12/14] Update simplecpp.cpp: simplify a second path --- externals/simplecpp/simplecpp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/externals/simplecpp/simplecpp.cpp b/externals/simplecpp/simplecpp.cpp index bf7def44f9d..8645d693649 100755 --- a/externals/simplecpp/simplecpp.cpp +++ b/externals/simplecpp/simplecpp.cpp @@ -3177,7 +3177,7 @@ static std::string getRelativeFileName(const std::string &baseFile, const std::s const std::string baseFileNormalized = (expandBaseWithAbsolutePath && !isAbsolutePath(baseFileSimplified)) ? simplecpp::simplifyPath(currentDirectory() + "/" + baseFileSimplified) : baseFileSimplified; const std::string headerSimplified = simplecpp::simplifyPath(header); - const std::string path = isAbsolutePath(headerSimplified) ? headerSimplified : (dirPath(baseFileNormalized) + headerSimplified); + const std::string path = isAbsolutePath(headerSimplified) ? headerSimplified : simplecpp::simplifyPath(dirPath(baseFileNormalized) + headerSimplified); if (exactRelative) { const std::string absolutePath = expandBaseWithAbsolutePath ? path : toAbsolutePath(path); const std::string absoluteBaseFile = expandBaseWithAbsolutePath ? baseFileNormalized : toAbsolutePath(baseFileNormalized); From 132709e1d5f72649dcd799d35a78a3c2beb5cd9b Mon Sep 17 00:00:00 2001 From: Tal500 Date: Thu, 22 May 2025 10:54:56 +0300 Subject: [PATCH 13/14] Update simplecpp.cpp: change the temp printing --- externals/simplecpp/simplecpp.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/externals/simplecpp/simplecpp.cpp b/externals/simplecpp/simplecpp.cpp index 8645d693649..74f208024ec 100755 --- a/externals/simplecpp/simplecpp.cpp +++ b/externals/simplecpp/simplecpp.cpp @@ -3227,7 +3227,7 @@ static std::string openHeader(std::ifstream &f, const simplecpp::DUI &dui, const // prefer first to search the header relatively to source file if found, when not a system header if (!systemheader) { std::string relativeHeader = openHeaderRelative(f, sourcefile, header); - if (endsWith(header, "aboutdialog.h"))// temp printing + if (endsWith(header, "filelister.h"))// temp printing std::cout << "relativeHeader: " << relativeHeader << " sourcefile: " << sourcefile << " header: " << header << std::endl; if (!relativeHeader.empty()) { return relativeHeader; @@ -3368,6 +3368,10 @@ std::map simplecpp::load(const simplecpp::To if (!f.is_open()) continue; f.close(); + if (ret.find(header2) != ret.end()) { + std::cout << "in ret: header: " << header << " header2: " << header2 << " source: " << rawtok->location.file() << " systemheader: " << systemheader << std::endl; + abort(); + } TokenList *tokens = new TokenList(header2, filenames, outputList); if (dui.removeComments) @@ -3661,8 +3665,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL tokens->removeComments(); if (filedata.find(header2) != filedata.end()) { std::cout << "header: " << header << " header2: " << header2 << " source: " << rawtok->location.file() << " systemheader: " << systemheader << std::endl; - std::cerr << "header: " << header << " header2: " << header2 << " source: " << rawtok->location.file() << " systemheader: " << systemheader << std::endl; - throw "header2 is already there!" + header2; + abort(); } filedata[header2] = tokens; } From e2300542fb2d2544ec8cd3f677904fe8ee14568d Mon Sep 17 00:00:00 2001 From: Tal500 Date: Thu, 22 May 2025 12:25:27 +0300 Subject: [PATCH 14/14] Update simplecpp.cpp --- externals/simplecpp/simplecpp.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/externals/simplecpp/simplecpp.cpp b/externals/simplecpp/simplecpp.cpp index 74f208024ec..6824547a6e2 100755 --- a/externals/simplecpp/simplecpp.cpp +++ b/externals/simplecpp/simplecpp.cpp @@ -3205,8 +3205,10 @@ static std::string getIncludePathFileName(const std::string &includePath, const std::string basePath = toAbsolutePath(includePath); if (!basePath.empty() && basePath[basePath.size()-1U]!='/' && basePath[basePath.size()-1U]!='\\') basePath += '/'; - const std::string absoluteSimplifiedHeaderPath = basePath + simplifiedHeader; - return extractRelativePathFromAbsolute(absoluteSimplifiedHeaderPath); + const std::string absoluteSimplifiedHeaderPath = simplecpp::simplifyPath(basePath + simplifiedHeader); + // std::cout << "absoluteSimplifiedHeaderPath: " << absoluteSimplifiedHeaderPath << std::endl; + // preserve absoluteness/relativieness of the including dir + return isAbsolutePath(includePath) ? absoluteSimplifiedHeaderPath : extractRelativePathFromAbsolute(absoluteSimplifiedHeaderPath); } static std::string openHeaderIncludePath(std::ifstream &f, const simplecpp::DUI &dui, const std::string &header) @@ -3227,8 +3229,8 @@ static std::string openHeader(std::ifstream &f, const simplecpp::DUI &dui, const // prefer first to search the header relatively to source file if found, when not a system header if (!systemheader) { std::string relativeHeader = openHeaderRelative(f, sourcefile, header); - if (endsWith(header, "filelister.h"))// temp printing - std::cout << "relativeHeader: " << relativeHeader << " sourcefile: " << sourcefile << " header: " << header << std::endl; + // if (endsWith(header, "filelister.h"))// temp printing + // std::cout << "relativeHeader: " << relativeHeader << " sourcefile: " << sourcefile << " header: " << header << std::endl; if (!relativeHeader.empty()) { return relativeHeader; } @@ -3266,6 +3268,7 @@ static std::string getFileIdPath(const std::map(sourcefile, header);// unknown if absolute or relative, but always simplified const std::string match = findPathInMapBothRelativeAndAbsolute(filedata, relativeOrAbsoluteFilename); + // std::cout << "relativeOrAbsoluteFilename: " << relativeOrAbsoluteFilename << " match: " << match << std::endl; if (!match.empty()) { return match; } @@ -3283,6 +3287,7 @@ static std::string getFileIdPath(const std::map::const_iterator it = dui.includePaths.begin(); it != dui.includePaths.end(); ++it) { const std::string match = findPathInMapBothRelativeAndAbsolute(filedata, getIncludePathFileName(*it, header)); + // std::cout << "match: " << match << std::endl; if (!match.empty()) { return match; }