mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2026-01-01 06:09:03 +03:00
Implement support for Lua 5.1
This commit is contained in:
committed by
Victor Hora
parent
eed6b5f86d
commit
dee9898449
@@ -101,4 +101,29 @@ static const struct luaL_Reg mscLuaLib[] = {
|
||||
} // namespace engine
|
||||
} // namespace modsecurity
|
||||
|
||||
#ifdef WITH_LUA
|
||||
#if defined LUA_VERSION_NUM && LUA_VERSION_NUM < 502
|
||||
/*
|
||||
** Adapted from Lua 5.2.0
|
||||
*/
|
||||
#define LUA_OK 0
|
||||
|
||||
static void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup) {
|
||||
luaL_checkstack(L, nup + 1, "too many upvalues");
|
||||
|
||||
for (; l->name != NULL; l++) { /* fill the table with given functions */
|
||||
int i;
|
||||
lua_pushstring(L, l->name);
|
||||
for (i = 0; i < nup; i++) /* copy upvalues to the top */
|
||||
lua_pushvalue(L, -(nup + 1));
|
||||
lua_pushcclosure(L, l->func, nup); /* closure with those upvalues */
|
||||
lua_settable(L, -(nup + 3));
|
||||
}
|
||||
|
||||
lua_pop(L, nup); /* remove upvalues */
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SRC_ENGINE_LUA_H_
|
||||
|
||||
Reference in New Issue
Block a user