Fix support for large RPATH updates (#16105)
Avoid using a KWSys RegularExpression to search for RPATH substrings. It cannot handle large expressions.
This commit is contained in:
parent
e0da6c3b56
commit
f4d3c44cc7
|
@ -2135,37 +2135,33 @@ bool cmSystemTools::GuessLibraryInstallName(std::string const& fullPath,
|
||||||
std::string::size_type cmSystemToolsFindRPath(std::string const& have,
|
std::string::size_type cmSystemToolsFindRPath(std::string const& have,
|
||||||
std::string const& want)
|
std::string const& want)
|
||||||
{
|
{
|
||||||
// Search for the desired rpath.
|
std::string::size_type pos = 0;
|
||||||
std::string::size_type pos = have.find(want);
|
while (pos < have.size()) {
|
||||||
|
// Look for an occurrence of the string.
|
||||||
// If the path is not present we are done.
|
std::string::size_type const beg = have.find(want, pos);
|
||||||
if (pos == std::string::npos) {
|
if (beg == std::string::npos) {
|
||||||
return pos;
|
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 += "\\";
|
|
||||||
}
|
}
|
||||||
// Store the character.
|
|
||||||
regex_str.append(1, static_cast<char>(ch));
|
|
||||||
}
|
|
||||||
regex_str += ")(:|$)";
|
|
||||||
|
|
||||||
// Look for the separated path.
|
// Make sure it is separated from preceding entries.
|
||||||
cmsys::RegularExpression regex(regex_str.c_str());
|
if (beg > 0 && have[beg - 1] != ':') {
|
||||||
if (regex.find(have)) {
|
pos = beg + 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 the position of the path portion.
|
||||||
return regex.start(2);
|
return beg;
|
||||||
} else {
|
|
||||||
// The desired rpath was not found.
|
|
||||||
return std::string::npos;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The desired rpath was not found.
|
||||||
|
return std::string::npos;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue