From 110b0d35b0535bc659900c4a7e8f095cf0ff437a Mon Sep 17 00:00:00 2001 From: batrick Date: Fri, 30 Sep 2011 06:54:53 +0000 Subject: [PATCH] Fixed a bug I introduced in r23911 that caused some "rules" to not mark a script as selected by name. Removed some dead code. --- nse_main.lua | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/nse_main.lua b/nse_main.lua index 496028656..ad4a6001d 100644 --- a/nse_main.lua +++ b/nse_main.lua @@ -395,6 +395,9 @@ do filename); end local basename = match(filename, "([^/\\]+)$") or filename; + if selected_by_name then + print_debug(2, "Script %s was selected by name.", basename); + end local short_basename = match(filename, "([^/\\]+)%.nse$") or match(filename, "([^/\\]+)%.[^.]*$") or filename; local file_closure = assert(loadfile(filename)); @@ -570,14 +573,13 @@ local function get_chosen_scripts (rules) end local env = {m = m}; - local script; for globalized_rule, rule_table in pairs(entry_rules) do if setfenv(rule_table.compiled_rule, env)() then -- run the compiled rule used_rules[rule_table.original_rule] = true; local t, path = cnse.fetchscript(filename); if t == "file" then if not files_loaded[path] then - chosen_scripts[#chosen_scripts+1] = Script.new(path); + chosen_scripts[#chosen_scripts+1] = Script.new(path, selected_by_name); files_loaded[path] = true; -- do not break so other rules can be marked as used end @@ -587,12 +589,6 @@ local function get_chosen_scripts (rules) end end end - if script then - script.selected_by_name = selected_by_name; - if script.selected_by_name then - print_debug(2, "Script %s was selected by name.", script.basename); - end - end end setfenv(db_closure, {Entry = entry}); @@ -610,7 +606,6 @@ local function get_chosen_scripts (rules) elseif t == "file" and not files_loaded[path] then local script = Script.new(path, true); chosen_scripts[#chosen_scripts+1] = script; - print_debug(2, "Script %s was selected by name.", path); files_loaded[path] = true; elseif t == "directory" then for f in cnse.dir(path) do