Skip to content

Commit

Permalink
Wildcards for delete
Browse files Browse the repository at this point in the history
  • Loading branch information
Swamp Ig committed May 10, 2014
1 parent 22ccd1e commit 979ec0a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Tests/ValueDelete.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ MMTEST
-multiVal = dummy
// Indexed
-multiVal2,0 = dummy
// Wildcard
-num*ic = dummy
}
}

Expand All @@ -35,7 +37,6 @@ MMTEST_EXPECT
{
name = module1
multiVal2 = two
numeric = 0
}
}
}
15 changes: 14 additions & 1 deletion moduleManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,20 @@ public ConfigNode ModifyNode(ConfigNode original, ConfigNode mod)
if (v != null)
newNode.values.Remove(v);
}
else
else if (valName.Contains('*') || valName.Contains('?'))
{
// Delete all matching wildcard
ConfigNode.Value last = null;
while (true)
{
ConfigNode.Value v = FindValueIn(newNode, valName, index++);
if (v == last)
break;
last = v;
newNode.values.Remove(v);
}
}
else
{
// Default is to delete ALL values that match. (backwards compatibility)
newNode.RemoveValues(valName);
Expand Down

0 comments on commit 979ec0a

Please sign in to comment.