mirror of
https://github.com/nmap/nmap.git
synced 2025-12-07 13:11:28 +00:00
Use an iterator instead of building an intermediate table for format_output
This commit is contained in:
@@ -39,6 +39,7 @@ local sub = string.sub
|
|||||||
local gsub = string.gsub
|
local gsub = string.gsub
|
||||||
local char = string.char
|
local char = string.char
|
||||||
local byte = string.byte
|
local byte = string.byte
|
||||||
|
local gmatch = string.gmatch
|
||||||
|
|
||||||
local concat = table.concat;
|
local concat = table.concat;
|
||||||
local insert = table.insert;
|
local insert = table.insert;
|
||||||
@@ -561,9 +562,9 @@ local function format_output_sub(status, data, indent)
|
|||||||
insert(output, format_output_sub(status, value, new_indent))
|
insert(output, format_output_sub(status, value, new_indent))
|
||||||
|
|
||||||
elseif(type(value) == 'string') then
|
elseif(type(value) == 'string') then
|
||||||
local lines = splitlines(value)
|
-- ensure it ends with a newline
|
||||||
|
if sub(value, -1) ~= "\n" then value = value .. "\n" end
|
||||||
for j, line in ipairs(lines) do
|
for line in gmatch(value, "([^\r\n]-)\n") do
|
||||||
insert(output, format("%s %s%s\n",
|
insert(output, format("%s %s%s\n",
|
||||||
format_get_indent(indent),
|
format_get_indent(indent),
|
||||||
prefix, line))
|
prefix, line))
|
||||||
|
|||||||
Reference in New Issue
Block a user