mirror of
https://github.com/nmap/nmap.git
synced 2025-12-07 13:11:28 +00:00
Updated to Lua 5.1.3 (Bug fix release)
Updated stdnse to include tobinary, toocal, and tohex functions. Minor optimizations to listop.lua
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lstrlib.c,v 1.130 2005/12/29 15:32:11 roberto Exp $
|
||||
** $Id: lstrlib.c,v 1.132.1.3 2007/12/28 15:32:23 roberto Exp $
|
||||
** Standard library for string operations and pattern-matching
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@@ -629,10 +629,6 @@ static void add_value (MatchState *ms, luaL_Buffer *b, const char *s,
|
||||
lua_gettable(L, 3);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
luaL_argerror(L, 3, "string/function/table expected");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!lua_toboolean(L, -1)) { /* nil or false? */
|
||||
lua_pop(L, 1);
|
||||
@@ -648,11 +644,15 @@ static int str_gsub (lua_State *L) {
|
||||
size_t srcl;
|
||||
const char *src = luaL_checklstring(L, 1, &srcl);
|
||||
const char *p = luaL_checkstring(L, 2);
|
||||
int tr = lua_type(L, 3);
|
||||
int max_s = luaL_optint(L, 4, srcl+1);
|
||||
int anchor = (*p == '^') ? (p++, 1) : 0;
|
||||
int n = 0;
|
||||
MatchState ms;
|
||||
luaL_Buffer b;
|
||||
luaL_argcheck(L, tr == LUA_TNUMBER || tr == LUA_TSTRING ||
|
||||
tr == LUA_TFUNCTION || tr == LUA_TTABLE, 3,
|
||||
"string/function/table expected");
|
||||
luaL_buffinit(L, &b);
|
||||
ms.L = L;
|
||||
ms.src_init = src;
|
||||
@@ -703,6 +703,10 @@ static void addquoted (lua_State *L, luaL_Buffer *b, int arg) {
|
||||
luaL_addchar(b, *s);
|
||||
break;
|
||||
}
|
||||
case '\r': {
|
||||
luaL_addlstring(b, "\\r", 2);
|
||||
break;
|
||||
}
|
||||
case '\0': {
|
||||
luaL_addlstring(b, "\\000", 4);
|
||||
break;
|
||||
@@ -719,7 +723,7 @@ static void addquoted (lua_State *L, luaL_Buffer *b, int arg) {
|
||||
|
||||
static const char *scanformat (lua_State *L, const char *strfrmt, char *form) {
|
||||
const char *p = strfrmt;
|
||||
while (strchr(FLAGS, *p)) p++; /* skip flags */
|
||||
while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++; /* skip flags */
|
||||
if ((size_t)(p - strfrmt) >= sizeof(FLAGS))
|
||||
luaL_error(L, "invalid format (repeated flags)");
|
||||
if (isdigit(uchar(*p))) p++; /* skip width */
|
||||
@@ -805,7 +809,8 @@ static int str_format (lua_State *L) {
|
||||
}
|
||||
}
|
||||
default: { /* also treat cases `pnLlh' */
|
||||
return luaL_error(L, "invalid option to " LUA_QL("format"));
|
||||
return luaL_error(L, "invalid option " LUA_QL("%%%c") " to "
|
||||
LUA_QL("format"), *(strfrmt - 1));
|
||||
}
|
||||
}
|
||||
luaL_addlstring(&b, buff, strlen(buff));
|
||||
|
||||
Reference in New Issue
Block a user