|
| 1 | +From d8ecdabd1065d60d7fcab1d71fea359c652cee68 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Tim Snyder <snyder.tim@gmail.com> |
| 3 | +Date: Sat, 25 Feb 2023 00:00:34 +0000 |
| 4 | +Subject: [PATCH] force prefix to c-strings for relocation |
| 5 | + |
| 6 | +is update of fix for cppcheck-feedstock#8 |
| 7 | +--- |
| 8 | + cli/cppcheckexecutor.cpp | 5 +++-- |
| 9 | + gui/helpdialog.cpp | 3 ++- |
| 10 | + gui/mainwindow.cpp | 3 ++- |
| 11 | + gui/projectfile.cpp | 6 +++--- |
| 12 | + gui/projectfiledialog.cpp | 5 +++-- |
| 13 | + lib/cppcheck.cpp | 9 +++++---- |
| 14 | + lib/library.cpp | 3 ++- |
| 15 | + lib/platform.cpp | 2 +- |
| 16 | + lib/settings.cpp | 5 +++-- |
| 17 | + 9 files changed, 24 insertions(+), 17 deletions(-) |
| 18 | + |
| 19 | +diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp |
| 20 | +index 81202d54e..a0bda3afe 100644 |
| 21 | +--- a/cli/cppcheckexecutor.cpp |
| 22 | ++++ b/cli/cppcheckexecutor.cpp |
| 23 | +@@ -283,9 +283,10 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck) |
| 24 | + const std::list<ErrorMessage::FileLocation> callstack; |
| 25 | + const std::string msg("Failed to load std.cfg. Your Cppcheck installation is broken, please re-install."); |
| 26 | + #ifdef FILESDIR |
| 27 | ++ const std::string filesdir(std::string(FILESDIR).c_str()); |
| 28 | + const std::string details("The Cppcheck binary was compiled with FILESDIR set to \"" |
| 29 | +- FILESDIR "\" and will therefore search for " |
| 30 | +- "std.cfg in " FILESDIR "/cfg."); |
| 31 | ++ + filesdir + "\" and will therefore search for " |
| 32 | ++ "std.cfg in " + filesdir + "/cfg."); |
| 33 | + #else |
| 34 | + const std::string cfgfolder(Path::fromNativeSeparators(Path::getPathFromFilename(settings.exename)) + "cfg"); |
| 35 | + const std::string details("The Cppcheck binary was compiled without FILESDIR set. Either the " |
| 36 | +diff --git a/gui/helpdialog.cpp b/gui/helpdialog.cpp |
| 37 | +index e9aac0689..02de809ae 100644 |
| 38 | +--- a/gui/helpdialog.cpp |
| 39 | ++++ b/gui/helpdialog.cpp |
| 40 | +@@ -56,7 +56,8 @@ static QString getHelpFile() |
| 41 | + << (QApplication::applicationDirPath() + "/help") |
| 42 | + << QApplication::applicationDirPath(); |
| 43 | + #ifdef FILESDIR |
| 44 | +- const QString filesdir = FILESDIR; |
| 45 | ++ std::string stdfilesdir(std::string(FILESDIR).c_str()); |
| 46 | ++ const QString filesdir = stdfilesdir; |
| 47 | + paths << (filesdir + "/help") |
| 48 | + << filesdir; |
| 49 | + #endif |
| 50 | +diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp |
| 51 | +index 9188ffe62..da0c16721 100644 |
| 52 | +--- a/gui/mainwindow.cpp |
| 53 | ++++ b/gui/mainwindow.cpp |
| 54 | +@@ -803,7 +803,8 @@ Library::Error MainWindow::loadLibrary(Library *library, const QString &filename |
| 55 | + |
| 56 | + #ifdef FILESDIR |
| 57 | + // Try to load the library from FILESDIR/cfg.. |
| 58 | +- const QString filesdir = FILESDIR; |
| 59 | ++ std::string stdfilesdir(std::string(FILESDIR).c_str()); |
| 60 | ++ const QString filesdir = stdfilesdir; |
| 61 | + if (!filesdir.isEmpty()) { |
| 62 | + ret = library->load(nullptr, (filesdir+"/cfg/"+filename).toLatin1()); |
| 63 | + if (ret.errorcode != Library::ErrorCode::FILE_NOT_FOUND) |
| 64 | +diff --git a/gui/projectfile.cpp b/gui/projectfile.cpp |
| 65 | +index 03e02338a..5be61c867 100644 |
| 66 | +--- a/gui/projectfile.cpp |
| 67 | ++++ b/gui/projectfile.cpp |
| 68 | +@@ -1101,11 +1101,11 @@ QString ProjectFile::getAddonFilePath(QString filesDir, const QString &addon) |
| 69 | + filesDir += "/"; |
| 70 | + |
| 71 | + QStringList searchPaths; |
| 72 | +- searchPaths << filesDir << (filesDir + "addons/") << (filesDir + "../addons/") |
| 73 | ++ searchPaths << filesDir << (filesDir + "addons/") << (filesDir + "../addons/"); |
| 74 | + #ifdef FILESDIR |
| 75 | +- << (QLatin1String(FILESDIR) + "/addons/") |
| 76 | ++ std::string stdfilesdir(std::string(FILESDIR).c_str()); |
| 77 | ++ searchPaths << (QLatin1String(stdfilesdir) + "/addons/"); |
| 78 | + #endif |
| 79 | +- ; |
| 80 | + |
| 81 | + for (const QString& path : searchPaths) { |
| 82 | + QString f = path + addon + ".py"; |
| 83 | +diff --git a/gui/projectfiledialog.cpp b/gui/projectfiledialog.cpp |
| 84 | +index 2eca3c2a7..81e106c88 100644 |
| 85 | +--- a/gui/projectfiledialog.cpp |
| 86 | ++++ b/gui/projectfiledialog.cpp |
| 87 | +@@ -108,8 +108,9 @@ ProjectFileDialog::ProjectFileDialog(ProjectFile *projectFile, bool premium, QWi |
| 88 | + QStringList searchPaths; |
| 89 | + searchPaths << appPath << appPath + "/cfg" << inf.canonicalPath(); |
| 90 | + #ifdef FILESDIR |
| 91 | +- if (FILESDIR[0]) |
| 92 | +- searchPaths << FILESDIR << FILESDIR "/cfg"; |
| 93 | ++ std::string filesdir(std::string(FILESDIR).c_str()); |
| 94 | ++ if (filesdir[0]) |
| 95 | ++ searchPaths << filesdir << filesdir + "/cfg"; |
| 96 | + #endif |
| 97 | + if (!datadir.isEmpty()) |
| 98 | + searchPaths << datadir << datadir + "/cfg"; |
| 99 | +diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp |
| 100 | +index da577d71d..681650324 100644 |
| 101 | +--- a/lib/cppcheck.cpp |
| 102 | ++++ b/lib/cppcheck.cpp |
| 103 | +@@ -103,10 +103,11 @@ namespace { |
| 104 | + return exepath + "addons/" + fileName; |
| 105 | + |
| 106 | + #ifdef FILESDIR |
| 107 | +- if (Path::fileExists(FILESDIR + ("/" + fileName))) |
| 108 | +- return FILESDIR + ("/" + fileName); |
| 109 | +- if (Path::fileExists(FILESDIR + ("/addons/" + fileName))) |
| 110 | +- return FILESDIR + ("/addons/" + fileName); |
| 111 | ++ std::string filesdir(std::string(FILESDIR).c_str()); |
| 112 | ++ if (Path::fileExists(filesdir + ("/" + fileName))) |
| 113 | ++ return filesdir + ("/" + fileName); |
| 114 | ++ if (Path::fileExists(filesdir + ("/addons/" + fileName))) |
| 115 | ++ return filesdir + ("/addons/" + fileName); |
| 116 | + #endif |
| 117 | + return ""; |
| 118 | + } |
| 119 | +diff --git a/lib/library.cpp b/lib/library.cpp |
| 120 | +index 14f7aa4da..5acf5896d 100644 |
| 121 | +--- a/lib/library.cpp |
| 122 | ++++ b/lib/library.cpp |
| 123 | +@@ -103,7 +103,8 @@ Library::Error Library::load(const char exename[], const char path[]) |
| 124 | + |
| 125 | + std::list<std::string> cfgfolders; |
| 126 | + #ifdef FILESDIR |
| 127 | +- cfgfolders.emplace_back(FILESDIR "/cfg"); |
| 128 | ++ std::string filesdir(std::string(FILESDIR).c_str()); |
| 129 | ++ cfgfolders.emplace_back(filesdir + "/cfg"); |
| 130 | + #endif |
| 131 | + if (exename) { |
| 132 | + const std::string exepath(Path::fromNativeSeparators(Path::getPathFromFilename(exename))); |
| 133 | +diff --git a/lib/platform.cpp b/lib/platform.cpp |
| 134 | +index ade5f4541..4615dc0c8 100644 |
| 135 | +--- a/lib/platform.cpp |
| 136 | ++++ b/lib/platform.cpp |
| 137 | +@@ -172,7 +172,7 @@ bool cppcheck::Platform::loadPlatformFile(const char exename[], const std::strin |
| 138 | + filenames.push_back(Path::getPathFromFilename(Path::fromNativeSeparators(exename)) + "platforms/" + filename + ".xml"); |
| 139 | + } |
| 140 | + #ifdef FILESDIR |
| 141 | +- std::string filesdir = FILESDIR; |
| 142 | ++ std::string filesdir(std::string(FILESDIR).c_str()); |
| 143 | + if (!filesdir.empty() && filesdir[filesdir.size()-1] != '/') |
| 144 | + filesdir += '/'; |
| 145 | + filenames.push_back(filesdir + ("platforms/" + filename)); |
| 146 | +diff --git a/lib/settings.cpp b/lib/settings.cpp |
| 147 | +index 94d455afb..5d06feca1 100644 |
| 148 | +--- a/lib/settings.cpp |
| 149 | ++++ b/lib/settings.cpp |
| 150 | +@@ -82,8 +82,9 @@ void Settings::loadCppcheckCfg() |
| 151 | + { |
| 152 | + std::string fileName = Path::getPathFromFilename(exename) + "cppcheck.cfg"; |
| 153 | + #ifdef FILESDIR |
| 154 | +- if (Path::fileExists(FILESDIR "/cppcheck.cfg")) |
| 155 | +- fileName = FILESDIR "/cppcheck.cfg"; |
| 156 | ++ std::string filesdir(std::string(FILESDIR).c_str()); |
| 157 | ++ if (Path::fileExists(filesdir + "/cppcheck.cfg")) |
| 158 | ++ fileName = filesdir + "/cppcheck.cfg"; |
| 159 | + #endif |
| 160 | + |
| 161 | + std::ifstream fin(fileName); |
| 162 | +-- |
| 163 | +2.39.1 |
| 164 | + |
0 commit comments