summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-05-19 15:51:51 (GMT)
committerBrad King <brad.king@kitware.com>2016-05-19 15:59:25 (GMT)
commitf4d3c44cc774871f6924304f1f0d3b05fd060f1a (patch)
tree5fd914a3ffb8a719481cc555838e73df9d6d9a83 /Source
parente0da6c3b562f7fd25b83b00c432f016439c24c22 (diff)
downloadCMake-f4d3c44cc774871f6924304f1f0d3b05fd060f1a.zip
CMake-f4d3c44cc774871f6924304f1f0d3b05fd060f1a.tar.gz
CMake-f4d3c44cc774871f6924304f1f0d3b05fd060f1a.tar.bz2
Fix support for large RPATH updates (#16105)
Avoid using a KWSys RegularExpression to search for RPATH substrings. It cannot handle large expressions.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmSystemTools.cxx48
1 files changed, 22 insertions, 26 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index bb52441..ed83069 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -2135,37 +2135,33 @@ bool cmSystemTools::GuessLibraryInstallName(std::string const& fullPath,
std::string::size_type cmSystemToolsFindRPath(std::string const& have,
std::string const& want)
{
- // Search for the desired rpath.
- std::string::size_type pos = have.find(want);
-
- // If the path is not present we are done.
- if (pos == std::string::npos) {
- return pos;
- }
+ std::string::size_type pos = 0;
+ while (pos < have.size()) {
+ // Look for an occurrence of the string.
+ std::string::size_type const beg = have.find(want, pos);
+ if (beg == std::string::npos) {
+ return std::string::npos;
+ }
- // Build a regex to match a properly separated path instance.
- std::string regex_str = "(^|:)(";
- for (std::string::const_iterator i = want.begin(); i != want.end(); ++i) {
- int ch = *i;
- if (!(('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z') ||
- ('0' <= ch && ch <= '9'))) {
- // Escape the non-alphanumeric character.
- regex_str += "\\";
+ // Make sure it is separated from preceding entries.
+ if (beg > 0 && have[beg - 1] != ':') {
+ pos = beg + 1;
+ continue;
}
- // Store the character.
- regex_str.append(1, static_cast<char>(ch));
- }
- regex_str += ")(:|$)";
- // Look for the separated path.
- cmsys::RegularExpression regex(regex_str.c_str());
- if (regex.find(have)) {
+ // Make sure it is separated from following entries.
+ std::string::size_type const end = beg + want.size();
+ if (end < have.size() && have[end] != ':') {
+ pos = beg + 1;
+ continue;
+ }
+
// Return the position of the path portion.
- return regex.start(2);
- } else {
- // The desired rpath was not found.
- return std::string::npos;
+ return beg;
}
+
+ // The desired rpath was not found.
+ return std::string::npos;
}
#endif