mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Disable the isolated version number regex.
It seems to catch mostly false positives. Also use a vector for the version regexes, so no magic number is required.
This commit is contained in:
@@ -109,15 +109,15 @@ namespace loot {
|
||||
|
||||
/// Array used to try each of the expressions defined above using
|
||||
/// an iteration for each of them.
|
||||
const regex version_checks[7] = {
|
||||
const std::vector<boost::regex> version_checks({
|
||||
regex(regex1, regex::ECMAScript | regex::icase),
|
||||
regex(regex2, regex::ECMAScript | regex::icase),
|
||||
regex(regex3, regex::ECMAScript | regex::icase),
|
||||
regex(regex4, regex::ECMAScript | regex::icase),
|
||||
regex(regex5, regex::ECMAScript | regex::icase), //This incorrectly identifies "OBSE v19" where 19 is any integer.
|
||||
regex(regex6, regex::ECMAScript | regex::icase), //This is responsible for metallicow's false positive.
|
||||
//regex(regex6, regex::ECMAScript | regex::icase), //This is responsible for metallicow's false positive.
|
||||
regex(regex7, regex::ECMAScript | regex::icase)
|
||||
};
|
||||
});
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Helper functions
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
namespace loot {
|
||||
/// Array used to try each of the expressions defined using
|
||||
/// an iteration for each of them.
|
||||
extern const boost::regex version_checks[7];
|
||||
extern const std::vector<boost::regex> version_checks;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Helper functions
|
||||
|
||||
@@ -421,7 +421,7 @@ namespace loot {
|
||||
string text = boost::locale::conv::to_utf<char>(file->getDescription(), "Windows-1252", boost::locale::conv::stop);
|
||||
|
||||
BOOST_LOG_TRIVIAL(trace) << name << ": " << "Attempting to read the version from the description.";
|
||||
for (size_t i = 0; i < 7; ++i) {
|
||||
for (size_t i = 0; i < version_checks.size(); ++i) {
|
||||
smatch what;
|
||||
if (regex_search(text, what, version_checks[i])) {
|
||||
//Use the first sub-expression match.
|
||||
|
||||
Reference in New Issue
Block a user