Added pattern matching to remove API

This commit is contained in:
Jason Perkins 2012-01-30 16:48:35 -05:00
parent 0747211b6c
commit d7e850ef17
3 changed files with 24 additions and 5 deletions

View File

@ -3,6 +3,7 @@
--------
* Completely overhauled the platform support; too many changes to list
* Added remove...() API to remove values from list fields
* Added debugformat with C7 support for Visual Studio
* The error message for invalid flags now includes the offending value
* The include() function will now include each file only once

View File

@ -243,13 +243,19 @@
function oven.removefromfield(field, removes)
if field and removes then
for index, value in ipairs(field) do
for key, pattern in ipairs(removes) do
if pattern == value then
table.remove(field, index)
break
for key, pattern in ipairs(removes) do
pattern = path.wildcards(pattern):lower()
local i = 1
while i <= #field do
local value = field[i]:lower()
if value:match(pattern) == value then
table.remove(field, i)
else
i = i + 1
end
end
end
end
end

View File

@ -264,3 +264,15 @@
cfg = oven.bake(sln)
test.isequal("Symbols|Optimize", table.concat(cfg.flags, "|"))
end
--
-- Remove should also accept wildcards.
--
function suite.remove_onWildcard()
defines { "WIN32", "WIN64", "LINUX", "MACOSX" }
removedefines { "WIN*" }
cfg = oven.bake(sln)
test.isequal("LINUX|MACOSX", table.concat(cfg.defines, "|"))
end