1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-09 06:01:28 +00:00

Consolidate "contains" functions into stdnse.contains

These implementations were all functionally identical. The replacement
has an extra feature of returning the index where the value was found,
currently unused.
This commit is contained in:
dmiller
2014-01-16 22:57:33 +00:00
parent 197f28265f
commit 726b259b20
9 changed files with 28 additions and 109 deletions

View File

@@ -122,21 +122,11 @@ action = function(host, port)
return #output > 0 and stdnse.strjoin("\n", output) or nil
end
local function contains(t, elem)
local _, e
for _, e in ipairs(t) do
if e == elem then
return true
end
end
return false
end
function filter_out(t, filter)
local result = {}
local _, e, f
for _, e in ipairs(t) do
if not contains(filter, e) then
if not stdnse.contains(filter, e) then
result[#result + 1] = e
end
end