Skip to content

Commit

Permalink
Merge pull request #41 from rdsharma/ngx_lua
Browse files Browse the repository at this point in the history
Add ngx_lua standard globals
  • Loading branch information
mpeterv committed Oct 13, 2015
2 parents c5ba158 + 329dfff commit b38cd57
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/luacheck/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ together with used ones.]])
lua53 - globals of Lua 5.3;
lua53c - globals of Lua 5.3 with LUA_COMPAT_5_2;
luajit - globals of LuaJIT 2.0;
ngx_lua - globals of Openresty lua-nginx-module with LuaJIT 2.0;
min - intersection of globals of Lua 5.1, Lua 5.2,
Lua 5.3 and LuaJIT 2.0;
max - union of globals of Lua 5.1, Lua 5.2, Lua 5.3
Expand Down
11 changes: 10 additions & 1 deletion src/luacheck/stds.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ stds.luajit = {
"pcall", "print", "rawequal", "rawget", "rawset", "require", "select", "setfenv",
"setmetatable", "string", "table", "tonumber", "tostring", "type", "unpack", "xpcall"}

stds.ngx_lua = {
_G = true, package = true, "_VERSION", "arg", "assert", "bit", "collectgarbage", "coroutine",
"debug", "dofile", "error", "gcinfo", "getfenv", "getmetatable", "io", "ipairs", "jit",
"load", "loadfile", "loadstring", "math", "module", "newproxy", "ndk", "ngx", "next", "os",
"pairs", "pcall", "print", "rawequal", "rawget", "rawset", "require", "select", "setfenv",
"setmetatable", "string", "table", "tonumber", "tostring", "type", "unpack", "xpcall"}

local min = {_G = true, package = true}
local std_sets = {}

Expand All @@ -57,7 +64,9 @@ for name, std in pairs(stds) do
end

for global in pairs(std_sets.lua51) do
if std_sets.lua52[global] and std_sets.lua53[global] and std_sets.luajit[global] then
if std_sets.lua52[global] and std_sets.lua53[global]
and std_sets.luajit[global] and std_sets.ngx_lua[global]
then
table.insert(min, global)
end
end
Expand Down

0 comments on commit b38cd57

Please sign in to comment.