Merge branch 'relaxed-regex-plugins' into dev

Conflicts:
	docs/LOOT Metadata Syntax.html
This commit is contained in:
Oliver Hamlet
2015-07-15 17:39:23 +01:00
3 changed files with 10 additions and 6 deletions
+2 -1
View File
@@ -422,7 +422,7 @@ nav: 0
<table>
<thead><tr><th>Key Name<th>Data Type<th>Required<th>Notes
<tbody>
<tr><td><code>name</code><td>string<td>&#x2713;<td>Can be an exact plugin filename or a regular expression plugin filename. If the period that precedes the file extension has been escaped (eg. <code>\.esp</code>, <code>\.esm</code>), the string is treated as a regular expression, otherwise it is treated as an exact filename.
<tr><td><code>name</code><td>string<td>&#x2713;<td>Can be an exact plugin filename or a regular expression plugin filename. If the filename contains any of the characters <code>:\*?|</code>, the string will be treated as a regular expression, otherwise it will be treated as an exact filename. For example, <code>Example\.esm</code> will be treated as a regular expression, as it contains a <code>\</code> character.
<tr><td><code>enabled</code><td>boolean<td>&#x2717;<td>Enables or disables use of the plugin object. Used for user rules, but no reason to use it in the masterlist. If unspecified, defaults to <code>true</code>.
<tr><td><code>priority</code><td>integer<td>&#x2717;<td>Modifies plugin position relative to others that change one or more of the same records, but which are otherwise unrelated (ie. neither plugin lists the other as a master, requirement, or in its <code>after</code> list). Plugins that don't change any of the same records are not compared, unless:
<ul>
@@ -598,6 +598,7 @@ msg:
<tr><td>Location <code>ver</code> key<td colspan="3">Yes<td>No
<tr><td>Location <code>name</code> key<td colspan="3">No<td>Yes
<tr><td><code>many("<var>regex</var>")</code> condition function<td colspan="3">No<td>Yes
<tr><td>Regex plugin entries<td colspan="3">Must end with <code>\.esp</code> or <code>\.esm</code>.<td>Must contain any of <code>:\*?|</code>
</table>
<h2 id="license">License</h2>
+4 -1
View File
@@ -355,7 +355,10 @@ namespace loot {
}
bool PluginMetadata::IsRegexPlugin() const {
return boost::iends_with(name, "\\.esm") || boost::iends_with(name, "\\.esp");
// Treat as regex if the plugin filename contains any of ":\*?|" as
// they are not valid Windows filename characters, but have meaning
// in regexes.
return strpbrk(name.c_str(), ":\\*?|") != nullptr;
}
bool PluginMetadata::IsPriorityExplicit() const {
@@ -601,19 +601,19 @@ TEST_F(PluginMetadata, IsRegexPlugin) {
EXPECT_FALSE(pm.IsRegexPlugin());
pm = loot::PluginMetadata("Blank[[:blank:]]- Different.esm");
EXPECT_FALSE(pm.IsRegexPlugin());
EXPECT_TRUE(pm.IsRegexPlugin());
pm = loot::PluginMetadata("Blank\\.esm");
EXPECT_TRUE(pm.IsRegexPlugin());
pm = loot::PluginMetadata("Blank - (Different )*Master Dependent.esm");
EXPECT_FALSE(pm.IsRegexPlugin());
EXPECT_TRUE(pm.IsRegexPlugin());
pm = loot::PluginMetadata("Blank - (Different )?Master Dependent.esm");
EXPECT_FALSE(pm.IsRegexPlugin());
EXPECT_TRUE(pm.IsRegexPlugin());
pm = loot::PluginMetadata("Blank.es(p|m)");
EXPECT_FALSE(pm.IsRegexPlugin());
EXPECT_TRUE(pm.IsRegexPlugin());
}
TEST_F(PluginMetadata, YamlEmitter) {