mirror of
https://github.com/nmap/nmap.git
synced 2026-02-05 04:56:34 +00:00
Move a reused function out to file scope
This commit is contained in:
@@ -278,6 +278,9 @@ function tooctal(n)
|
||||
return format("%o", n)
|
||||
end
|
||||
|
||||
local tohex_helper = function(b)
|
||||
return format("%02x", byte(b))
|
||||
end
|
||||
--- Encode a string or integer in hexadecimal (12 becomes "c", "AB" becomes
|
||||
-- "4142").
|
||||
--
|
||||
@@ -303,9 +306,7 @@ function tohex( s, options )
|
||||
if type( s ) == "number" then
|
||||
hex = format("%x", s)
|
||||
elseif type( s ) == 'string' then
|
||||
hex = gsub(s, ".", function(b)
|
||||
return format("%02x", byte(b))
|
||||
end)
|
||||
hex = gsub(s, ".", tohex_helper)
|
||||
else
|
||||
error( "Type not supported in tohex(): " .. type(s), 2 )
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user