1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

Use an iterator instead of building an intermediate table for format_output

This commit is contained in:
dmiller
2018-10-18 01:08:11 +00:00
parent 93edeefa3c
commit 39cfbdf4e2

View File

@@ -39,6 +39,7 @@ local sub = string.sub
local gsub = string.gsub
local char = string.char
local byte = string.byte
local gmatch = string.gmatch
local concat = table.concat;
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))
elseif(type(value) == 'string') then
local lines = splitlines(value)
for j, line in ipairs(lines) do
-- ensure it ends with a newline
if sub(value, -1) ~= "\n" then value = value .. "\n" end
for line in gmatch(value, "([^\r\n]-)\n") do
insert(output, format("%s %s%s\n",
format_get_indent(indent),
prefix, line))