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:
Oliver Hamlet
2015-01-09 22:43:45 +00:00
parent ec54264618
commit a48b3df76b
3 changed files with 5 additions and 5 deletions
+3 -3
View File
@@ -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
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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.