From 7562e8b172983d4e7c0761632762e333bdd6ee86 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Tue, 19 Oct 2021 21:42:04 +0200 Subject: [PATCH] patterns: Fixed #include not properly searching all include folders --- .../source/pattern_language/preprocessor.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/plugins/libimhex/source/pattern_language/preprocessor.cpp b/plugins/libimhex/source/pattern_language/preprocessor.cpp index a82cd3515..acb740dbb 100644 --- a/plugins/libimhex/source/pattern_language/preprocessor.cpp +++ b/plugins/libimhex/source/pattern_language/preprocessor.cpp @@ -63,17 +63,19 @@ namespace hex::pl { } offset += 1; + std::string includePath = includeFile; + if (includeFile[0] != '/') { - std::string tempPath = includeFile; for (const auto &dir : hex::getPath(ImHexPath::PatternsInclude)) { - tempPath = hex::format("{0}/{1}", dir.c_str(), includeFile.c_str()); - if (std::filesystem::exists(includeFile)) + std::string tempPath = hex::format("{0}/{1}", dir.c_str(), includeFile.c_str()); + if (std::filesystem::exists(tempPath)) { + includePath = tempPath; break; + } } - includeFile = tempPath; } - File file(includeFile, File::Mode::Read); + File file(includePath, File::Mode::Read); if (!file.isValid()) throwPreprocessorError(hex::format("{0}: No such file or directory", includeFile.c_str()), lineNumber);