diff --git a/docs/licenses/MIT b/docs/licenses/MIT new file mode 100644 index 000000000..afc74b357 --- /dev/null +++ b/docs/licenses/MIT @@ -0,0 +1,19 @@ +Copyright (c) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/nselib/re.lua b/nselib/re.lua index 3b9974fd9..76308a19f 100644 --- a/nselib/re.lua +++ b/nselib/re.lua @@ -1,3 +1,64 @@ +--- +-- Regular Expression functions +-- +-- This is the re.lua module included in the LPeg distribution (http://www.inf.puc-rio.br/~roberto/lpeg/re.html) +-- +-- @class module +-- @name re +-- @copyright 2008-2010 Lua.org, PUC-Rio. (https://svn.nmap.org/nmap/docs/licenses/MIT) + +--- Compiles the given string and returns an equivalent LPeg pattern. +-- +-- The given string may define either an expression or a grammar. The optional +-- defs table provides extra Lua values to be used by the pattern. +-- @class function +-- @name compile +-- @param string +-- @param defs Optional +-- @return an LPeg pattern + +--- Searches the given pattern in the given subject. +-- +-- If it finds a match, returns the index where this occurrence starts and the +-- index where it ends. Otherwise, returns nil. +-- +-- An optional numeric argument init makes the search starts at that position +-- in the subject string. As usual in Lua libraries, a negative value counts +-- from the end. +-- @class function +-- @name find +-- @param subject +-- @param pattern +-- @param init Optional +-- @return index where the occurrence starts or nil +-- @return index where the occurrence ends + +--- Global substitution. +-- +-- Does a global substitution, replacing all occurrences of pattern in the +-- given subject by replacement. +-- @class function +-- @name gsub +-- @param subject +-- @param pattern +-- @param replacement +-- @return index where occurrence starts or pattern captures + +--- Matches the given pattern against the given subject +-- +-- Matches the given pattern against the given subject, returning all captures. +-- @class function +-- @name match +-- @param subject +-- @param pattern +-- @param init Optional +-- @return pattern captures + +--- Updates the pre-defined character classes to the current locale. +-- +-- @class function +-- @name updatelocale + -- $Id: re.lua,v 1.44 2013/03/26 20:11:40 roberto Exp $ -- imported functions and modules @@ -254,6 +315,7 @@ local re = { updatelocale = updatelocale, } -if version == "Lua 5.1" then _G.re = re end +-- NSE uses Lua 5.2 +--if version == "Lua 5.1" then _G.re = re end return re