diff --git a/nselib/match.lua b/nselib/match.lua
index fc0103296..ab1a70d13 100644
--- a/nselib/match.lua
+++ b/nselib/match.lua
@@ -12,11 +12,11 @@ _ENV = stdnse.module("match", stdnse.seeall)
--various functions for use with nse's nsock:receive_buf - function
-- e.g.
--- sock:receive_buf(regex("myregexpattern")) - does a match using pcre- regular-
--- - expressions
--- sock:receive_buf(numbytes(80)) - is the buffered version of
--- sock:receive_bytes(80) - i.e. it returns
--- exactly 80 bytes and no more
+-- sock:receive_buf(regex("myregexpattern"), true) - does a match using pcre
+-- regular expressions
+-- sock:receive_buf(numbytes(80), true) - is the buffered version of
+-- sock:receive_bytes(80) - i.e. it
+-- returns exactly 80 bytes and no more
--- Return a function that allows delimiting with a regular expression.
--
@@ -24,7 +24,7 @@ _ENV = stdnse.module("match", stdnse.seeall)
-- give script developers the ability to use regular expressions for delimiting
-- instead of Lua's string patterns.
-- @param pattern The regex.
--- @usage sock:receive_buf(match.regex("myregexpattern"))
+-- @usage sock:receive_buf(match.regex("myregexpattern"), true)
-- @see nmap.receive_buf
-- @see pcre.exec
regex = function(pattern)
@@ -42,8 +42,12 @@ end
-- sock:receive_bytes(n) in case a script requires more than one
-- fixed-size chunk, as the unbuffered version may return more bytes than
-- requested and thus would require you to do the parsing on your own.
+--
+-- The keeppattern parameter to receive_buf should be set to
+-- true, otherwise the string returned will be 1 less than
+-- num
-- @param num Number of bytes.
--- @usage sock:receive_buf(match.numbytes(80))
+-- @usage sock:receive_buf(match.numbytes(80), true)
-- @see nmap.receive_buf
numbytes = function(num)
local n = num
diff --git a/nselib/nmap.luadoc b/nselib/nmap.luadoc
index 0488c8e2c..509fe7149 100644
--- a/nselib/nmap.luadoc
+++ b/nselib/nmap.luadoc
@@ -608,6 +608,7 @@ function receive_bytes(n)
-- @return Status (true or false).
-- @return Data (if status is true) or error string (if status is false).
-- @see new_socket
+-- @see match
-- @usage local status, line = socket:receive_buf("\r?\n", false)
function receive_buf(delimiter, keeppattern)