mirror of
https://github.com/nmap/nmap.git
synced 2025-12-09 22:21:29 +00:00
Don't consider "\r" an end of line.
This commit is contained in:
@@ -4,15 +4,14 @@
|
|||||||
|
|
||||||
--This function reads a line of at most 8096 bytes (or whatever the first
|
--This function reads a line of at most 8096 bytes (or whatever the first
|
||||||
--parameter says) from standard input. Returns the string and a boolean value
|
--parameter says) from standard input. Returns the string and a boolean value
|
||||||
--that is true if we hit the newline (defined as "\r" or "\n") or false if the
|
--that is true if we hit the newline (defined as "\n") or false if the line had
|
||||||
--line had to be truncated. This is here because io.stdin:read("*line") could
|
--to be truncated. This is here because io.stdin:read("*line") could read to
|
||||||
--read to memory exhaustion if we received gigabytes of characters with no
|
--memory exhaustion if we received gigabytes of characters with no newline.
|
||||||
--newline.
|
|
||||||
function read_line(max_len)
|
function read_line(max_len)
|
||||||
local ret = ""
|
local ret = ""
|
||||||
for i = 1, (max_len or 8096) do
|
for i = 1, (max_len or 8096) do
|
||||||
local chr = io.read(1)
|
local chr = io.read(1)
|
||||||
if chr == "\r" or chr == "\n" then
|
if chr == "\n" then
|
||||||
return ret, true
|
return ret, true
|
||||||
end
|
end
|
||||||
ret = ret .. chr
|
ret = ret .. chr
|
||||||
|
|||||||
@@ -40,14 +40,14 @@ end
|
|||||||
|
|
||||||
--Read a line of at most 8096 bytes (or whatever the first parameter says)
|
--Read a line of at most 8096 bytes (or whatever the first parameter says)
|
||||||
--from standard input. Returns the string and a boolean value that is true if
|
--from standard input. Returns the string and a boolean value that is true if
|
||||||
--we hit the newline (defined as "\r" or "\n") or false if the line had to be
|
--we hit the newline (defined as "\n") or false if the line had to be
|
||||||
--truncated. This is here because io.stdin:read("*line") could read to memory
|
--truncated. This is here because io.stdin:read("*line") could read to memory
|
||||||
--exhaustion if we received gigabytes of characters with no newline.
|
--exhaustion if we received gigabytes of characters with no newline.
|
||||||
function read_line(max_len)
|
function read_line(max_len)
|
||||||
local ret = ""
|
local ret = ""
|
||||||
for i = 1, (max_len or 8096) do
|
for i = 1, (max_len or 8096) do
|
||||||
local chr = io.read(1)
|
local chr = io.read(1)
|
||||||
if chr == "\r" or chr == "\n" then
|
if chr == "\n" then
|
||||||
return ret, true
|
return ret, true
|
||||||
end
|
end
|
||||||
ret = ret .. chr
|
ret = ret .. chr
|
||||||
|
|||||||
Reference in New Issue
Block a user