# HG changeset patch # User jbe # Date 1334498673 -7200 # Node ID 3d43a5cf17c1c263d52c15b8a5a73ac7bf233f97 # Parent 4f38db8354b0bb71e7d85cd8875241c2dd76d058 Compatibility with Lua 5.2 diff -r 4f38db8354b0 -r 3d43a5cf17c1 framework/accelerator/webmcp_accelerator.c --- a/framework/accelerator/webmcp_accelerator.c Tue Apr 03 00:56:02 2012 +0200 +++ b/framework/accelerator/webmcp_accelerator.c Sun Apr 15 16:04:33 2012 +0200 @@ -53,7 +53,11 @@ lua_pushvalue(L, 1); lua_gettable(L, -2); // get table by reference passed as 1st argument lua_getfield(L, -1, "string_fragments"); +#ifdef LUA_VERSION_NUM >= 502 + j = lua_rawlen(L, -1); +#else j = lua_objlen(L, -1); +#endif for (i=2; i<=argc; i++) { lua_pushvalue(L, i); lua_rawseti(L, -2, ++j); @@ -71,7 +75,11 @@ lua_getfield(L, -2, "_active_slot"); lua_gettable(L, -2); lua_getfield(L, -1, "string_fragments"); +#ifdef LUA_VERSION_NUM >= 502 + j = lua_rawlen(L, -1); +#else j = lua_objlen(L, -1); +#endif for (i=1; i<=argc; i++) { lua_pushvalue(L, i); lua_rawseti(L, -2, ++j); @@ -108,7 +116,11 @@ tag_given = 1; } } +#ifdef LUA_VERSION_NUM >= 502 + j = lua_rawlen(L, 5); +#else j = lua_objlen(L, 5); +#endif if (tag_given) { lua_pushliteral(L, "<"); lua_rawseti(L, 5, ++j); @@ -153,7 +165,11 @@ lua_call(L, 0, 0); // stack is now at position 7, but we don't care // we assume that the active slot hasn't been exchanged or resetted +#ifdef LUA_VERSION_NUM >= 502 + j = lua_rawlen(L, 5); // but it may include more elements now +#else j = lua_objlen(L, 5); // but it may include more elements now +#endif } else { lua_pushcfunction(L, webmcp_encode_html); // 9 lua_pushvalue(L, 8); // 10 diff -r 4f38db8354b0 -r 3d43a5cf17c1 framework/bin/autodoc.lua --- a/framework/bin/autodoc.lua Tue Apr 03 00:56:02 2012 +0200 +++ b/framework/bin/autodoc.lua Sun Apr 15 16:04:33 2012 +0200 @@ -213,4 +213,4 @@ output(' \n') output(' \n') output('\n') -end \ No newline at end of file +end diff -r 4f38db8354b0 -r 3d43a5cf17c1 framework/bin/langtool.lua --- a/framework/bin/langtool.lua Tue Apr 03 00:56:02 2012 +0200 +++ b/framework/bin/langtool.lua Sun Apr 15 16:04:33 2012 +0200 @@ -2,7 +2,7 @@ if not pcall( function() - require "extos" + extos = require "extos" end ) then io.stderr:write('Could not load library "extos".\n') @@ -151,8 +151,13 @@ end elseif in_filetype == "lua" then io.stderr:write('Reading translations from lua file "', in_filename, '".\n') - local func = assert(loadfile(in_filename)) - setfenv(func, {}) + local func + if _ENV then + func = assert(loadfile(in_filename, "t", {})) + else + func = assert(loadfile(in_filename)) + setfenv(func, {}) + end local updates = func() for key, value in pairs(updates) do update_translation(key, value) diff -r 4f38db8354b0 -r 3d43a5cf17c1 framework/cgi-bin/webmcp.lua --- a/framework/cgi-bin/webmcp.lua Tue Apr 03 00:56:02 2012 +0200 +++ b/framework/cgi-bin/webmcp.lua Sun Apr 15 16:04:33 2012 +0200 @@ -1,6 +1,11 @@ #!/usr/bin/env lua -_WEBMCP_VERSION = "1.1.3" +_WEBMCP_VERSION = "1.1.4" + +-- Lua 5.1 compatibility +if not table.unpack then + table.unpack = unpack +end -- include "../lib/" in search path for libraries if not WEBMCP_PATH then @@ -27,13 +32,13 @@ -- load os extensions for lua -- (should happen as soon as possible due to run time measurement) -require 'extos' +extos = require 'extos' -- load nihil library -require 'nihil' +nihil = require 'nihil' -- load random generator library -require 'multirand' +multirand = require 'multirand' -- load rocketcgi library and map it to cgi do @@ -41,17 +46,17 @@ if option and option ~= "" and option ~= "0" then cgi = nil else - require 'rocketcgi' + rocketcgi = require 'rocketcgi' cgi = rocketcgi end end -- load database access library with object relational mapper -require 'mondelefant' +mondelefant = require 'mondelefant' mondelefant.connection_prototype.error_objects = true -- load type system "atom" -require 'atom' +atom = require 'atom' -- load mondelefant atom connector require 'mondelefant_atom_connector' diff -r 4f38db8354b0 -r 3d43a5cf17c1 framework/env/auth/openid/_curl.lua --- a/framework/env/auth/openid/_curl.lua Tue Apr 03 00:56:02 2012 +0200 +++ b/framework/env/auth/openid/_curl.lua Sun Apr 15 16:04:33 2012 +0200 @@ -6,7 +6,7 @@ local options = table.new(curl_options) options[#options+1] = "-i" options[#options+1] = url - local stdout, errmsg, status = os.pfilter(nil, "curl", unpack(options)) + local stdout, errmsg, status = os.pfilter(nil, "curl", table.unpack(options)) if not stdout then error("Error while executing curl: " .. errmsg) end diff -r 4f38db8354b0 -r 3d43a5cf17c1 framework/env/encode/file_path.lua --- a/framework/env/encode/file_path.lua Tue Apr 03 00:56:02 2012 +0200 +++ b/framework/env/encode/file_path.lua Sun Apr 15 16:04:33 2012 +0200 @@ -17,5 +17,5 @@ for i = 1, #raw_elements do encoded_elements[i] = encode.file_path_element(raw_elements[i]) end - return encode.concat_file_path(base, unpack(encoded_elements)) + return encode.concat_file_path(base, table.unpack(encoded_elements)) end diff -r 4f38db8354b0 -r 3d43a5cf17c1 framework/env/execute/chunk.lua --- a/framework/env/execute/chunk.lua Tue Apr 03 00:56:02 2012 +0200 +++ b/framework/env/execute/chunk.lua Sun Apr 15 16:04:33 2012 +0200 @@ -44,5 +44,5 @@ param.restore() end - return unpack(result) + return table.unpack(result) end diff -r 4f38db8354b0 -r 3d43a5cf17c1 framework/env/locale/_get_translation_table.lua --- a/framework/env/locale/_get_translation_table.lua Tue Apr 03 00:56:02 2012 +0200 +++ b/framework/env/locale/_get_translation_table.lua Sun Apr 15 16:04:33 2012 +0200 @@ -9,8 +9,13 @@ return translation_table end local filename = encode.file_path(request.get_app_basepath(), "locale", "translations." .. language_code .. ".lua") - local func = assert(loadfile(filename)) - setfenv(func, {}) + local func + if _ENV then + func = assert(loadfile(filename), nil, {}) + else + func = assert(loadfile(filename)) + setfenv(func, {}) + end translation_table = func() if type(translation_table) ~= "table" then error("Translation file did not return a table.") diff -r 4f38db8354b0 -r 3d43a5cf17c1 framework/env/net/send_mail.lua --- a/framework/env/net/send_mail.lua Tue Apr 03 00:56:02 2012 +0200 +++ b/framework/env/net/send_mail.lua Sun Apr 15 16:04:33 2012 +0200 @@ -46,7 +46,7 @@ command[#command+1] = "-f" command[#command+1] = envelope_from end - local stdout, errmsg, status = os.pfilter(mail, unpack(command)) + local stdout, errmsg, status = os.pfilter(mail, table.unpack(command)) if not status then error("Error while calling sendmail: " .. errmsg) end diff -r 4f38db8354b0 -r 3d43a5cf17c1 libraries/atom/atom.lua --- a/libraries/atom/atom.lua Tue Apr 03 00:56:02 2012 +0200 +++ b/libraries/atom/atom.lua Sun Apr 15 16:04:33 2012 +0200 @@ -4,33 +4,32 @@ local _VERSION = _VERSION local assert = assert local error = error -local getfenv = getfenv local getmetatable = getmetatable local ipairs = ipairs -local module = module local next = next local pairs = pairs local print = print local rawequal = rawequal local rawget = rawget +local rawlen = rawlen local rawset = rawset -local require = require local select = select -local setfenv = setfenv local setmetatable = setmetatable local tonumber = tonumber local tostring = tostring local type = type -local unpack = unpack -local coroutine = coroutine -local io = io local math = math -local os = os local string = string local table = table -module(...) +local _M = {} +if _ENV then + _ENV = _M +else + _G[...] = _M + setfenv(1, _M) +end @@ -1537,3 +1536,6 @@ end end + + +return _M diff -r 4f38db8354b0 -r 3d43a5cf17c1 libraries/extos/extos.c --- a/libraries/extos/extos.c Tue Apr 03 00:56:02 2012 +0200 +++ b/libraries/extos/extos.c Sun Apr 15 16:04:33 2012 +0200 @@ -328,6 +328,15 @@ return 1; } +static const struct luaL_Reg extos_module_functions[] = { + {"pfilter", extos_pfilter}, + {"listdir", extos_listdir}, + {"crypt", extos_crypt}, + {"hires_time", extos_hires_time}, + {"monotonic_hires_time", extos_monotonic_hires_time}, + {NULL, NULL} +}; + int luaopen_extos(lua_State *L) { { struct timespec tp; @@ -336,16 +345,11 @@ } extos_monotonic_start_time = tp.tv_sec + 0.000000001 * tp.tv_nsec; } - lua_getglobal(L, "os"); - lua_pushcfunction(L, extos_pfilter); - lua_setfield(L, -2, "pfilter"); - lua_pushcfunction(L, extos_listdir); - lua_setfield(L, -2, "listdir"); - lua_pushcfunction(L, extos_crypt); - lua_setfield(L, -2, "crypt"); - lua_pushcfunction(L, extos_hires_time); - lua_setfield(L, -2, "hires_time"); - lua_pushcfunction(L, extos_monotonic_hires_time); - lua_setfield(L, -2, "monotonic_hires_time"); - return 0; +#if LUA_VERSION_NUM >= 502 + lua_newtable(L); + luaL_setfuncs(L, extos_module_functions, 0); +#else + luaL_register(L, lua_tostring(L, 1) || "extos", extos_module_functions); +#endif + return 1; } diff -r 4f38db8354b0 -r 3d43a5cf17c1 libraries/luatex/luatex.lua --- a/libraries/luatex/luatex.lua Tue Apr 03 00:56:02 2012 +0200 +++ b/libraries/luatex/luatex.lua Sun Apr 15 16:04:33 2012 +0200 @@ -3,48 +3,42 @@ local _G = _G local _VERSION = _VERSION local assert = assert -local collectgarbage = collectgarbage -local dofile = dofile local error = error -local getfenv = getfenv local getmetatable = getmetatable local ipairs = ipairs -local load = load -local loadfile = loadfile -local loadstring = loadstring -local module = module local next = next local pairs = pairs -local pcall = pcall local print = print local rawequal = rawequal local rawget = rawget +local rawlen = rawlen local rawset = rawset -local require = require local select = select -local setfenv = setfenv local setmetatable = setmetatable local tonumber = tonumber local tostring = tostring local type = type -local unpack = unpack -local xpcall = xpcall -local coroutine = coroutine -local debug = debug local io = io local math = math local os = os -local package = package local string = string local table = table -require("multirand") -local multirand = multirand +local multirand = require("multirand") -module(...) +local _M = {} +if _ENV then + _ENV = _M +else + _G[...] = _M + setfenv(1, _M) +end -temp_dir = false -- has to be set to a private directory (/tmp can be unsafe) +-- NOTE: +-- temp_dir MUST NOT contain any charactes interpreted by system shell +-- and has to be set to a private directory (/tmp may be unsafe) +temp_dir = false function escape(str) return ( @@ -101,7 +95,8 @@ end function document_methods:get_pdf() - -- TODO: proper escaping of shell commands (should not be a real risk) + -- TODO: proper escaping of shell commands + -- (not a security risk, as args are safe) if not temp_dir then error("luatex.temp_dir not set") end @@ -109,11 +104,12 @@ local latex_file = assert(io.open(basename .. ".tex", "w")) latex_file:write(self:get_latex()) latex_file:close() - local result = os.execute( + local result1, result2, result3 = os.execute( 'latex -output-format=pdf "-output-directory=' .. temp_dir .. '" ' .. basename .. '< /dev/null > /dev/null 2> /dev/null' ) - if result ~= 0 then + -- NOTE: use result1 and result3 for lua5.1 and lua5.2 compatibility + if not (result1 == 0 or (result2 == "exit" and result3 == 0)) then error('LaTeX failed, see "' .. basename .. '.log" for details.') end local pdf_file = assert(io.open(basename .. ".pdf", "r")) @@ -123,9 +119,11 @@ return pdf_data end +return _M + --[[ -require("luatex") +luatex = require("luatex") luatex.temp_dir = "." local tex = luatex.new_document() diff -r 4f38db8354b0 -r 3d43a5cf17c1 libraries/mondelefant/example.lua --- a/libraries/mondelefant/example.lua Tue Apr 03 00:56:02 2012 +0200 +++ b/libraries/mondelefant/example.lua Sun Apr 15 16:04:33 2012 +0200 @@ -1,5 +1,5 @@ #!/usr/bin/env lua -require("mondelefant") +mondelefant = require("mondelefant") -- Standarddatenbankverbindung ist globale Variable 'db' function mondelefant.class_prototype:get_db_conn() return db end @@ -83,4 +83,4 @@ sel:add_field("*") sel:attach("m1", products, "product_id", "id", "product", "product_variants") product_variants = sel:exec() ---]] \ No newline at end of file +--]] diff -r 4f38db8354b0 -r 3d43a5cf17c1 libraries/mondelefant/mondelefant.lua --- a/libraries/mondelefant/mondelefant.lua Tue Apr 03 00:56:02 2012 +0200 +++ b/libraries/mondelefant/mondelefant.lua Sun Apr 15 16:04:33 2012 +0200 @@ -8,42 +8,35 @@ local _G = _G local _VERSION = _VERSION local assert = assert -local collectgarbage = collectgarbage -local dofile = dofile local error = error -local getfenv = getfenv local getmetatable = getmetatable local ipairs = ipairs -local load = load -local loadfile = loadfile -local loadstring = loadstring local next = next local pairs = pairs -local pcall = pcall local print = print local rawequal = rawequal local rawget = rawget +local rawlen = rawlen local rawset = rawset local select = select -local setfenv = setfenv local setmetatable = setmetatable local tonumber = tonumber local tostring = tostring local type = type -local unpack = unpack -local xpcall = xpcall -local coroutine = coroutine -local io = io local math = math -local os = os local string = string local table = table local add = table.insert -_G[...] = require("mondelefant_native") -module(...) +local _M = require("mondelefant_native") +if _ENV then + _ENV = _M +else + _G[...] = _M + setfenv(1, _M) +end diff -r 4f38db8354b0 -r 3d43a5cf17c1 libraries/mondelefant/mondelefant_atom_connector.lua --- a/libraries/mondelefant/mondelefant_atom_connector.lua Tue Apr 03 00:56:02 2012 +0200 +++ b/libraries/mondelefant/mondelefant_atom_connector.lua Sun Apr 15 16:04:33 2012 +0200 @@ -3,45 +3,36 @@ local _G = _G local _VERSION = _VERSION local assert = assert -local collectgarbage = collectgarbage -local dofile = dofile local error = error -local getfenv = getfenv local getmetatable = getmetatable local ipairs = ipairs -local load = load -local loadfile = loadfile -local loadstring = loadstring -local module = module local next = next local pairs = pairs -local pcall = pcall local print = print local rawequal = rawequal local rawget = rawget +local rawlen = rawlen local rawset = rawset -local require = require local select = select -local setfenv = setfenv local setmetatable = setmetatable local tonumber = tonumber local tostring = tostring local type = type -local unpack = unpack -local xpcall = xpcall -local coroutine = coroutine -local debug = debug -local io = io local math = math -local os = os -local package = package local string = string +local table = table local mondelefant = require("mondelefant") local atom = require("atom") -module(...) +local _M = {} +if _ENV then + _ENV = _M +else + _G[...] = _M + setfenv(1, _M) +end input_converters = setmetatable({}, { __mode = "k" }) @@ -179,6 +170,8 @@ end end +return _M + --[[ diff -r 4f38db8354b0 -r 3d43a5cf17c1 libraries/mondelefant/mondelefant_native.c --- a/libraries/mondelefant/mondelefant_native.c Tue Apr 03 00:56:02 2012 +0200 +++ b/libraries/mondelefant/mondelefant_native.c Sun Apr 15 16:04:33 2012 +0200 @@ -632,7 +632,11 @@ } luaL_pushresult(&keybuf); // check, if any characters matched: +#if LUA_VERSION_NUM >= 502 + if (lua_rawlen(L, -1)) { +#else if (lua_objlen(L, -1)) { +#endif // if any alpha numeric chars or underscores were found, // push them on stack as a Lua string and use them to lookup // value from second argument: @@ -683,7 +687,11 @@ ); } // iterate over items of sub-structure: +#if LUA_VERSION_NUM >= 502 + count = lua_rawlen(L, 5); +#else count = lua_objlen(L, 5); +#endif for (i = 0; i < count; i++) { // add seperator, unless this is the first run: if (i) { @@ -1137,9 +1145,17 @@ lua_rawgeti(L, 3, command_idx+1); // raw result at stack position 5 if (lua_toboolean(L, 5)) { lua_getfield(L, 5, "_column_info"); // column_info list at position 6 +#if LUA_VERSION_NUM >= 502 + cols = lua_rawlen(L, 6); +#else cols = lua_objlen(L, 6); +#endif if (mode == MONDELEFANT_QUERY_MODE_LIST) { +#if LUA_VERSION_NUM >= 502 + rows = lua_rawlen(L, 5); +#else rows = lua_objlen(L, 5); +#endif for (row = 0; row < rows; row++) { lua_rawgeti(L, 5, row+1); // row at stack position 7 lua_getfield(L, 7, "_data"); // _data table at stack position 8 @@ -1260,12 +1276,20 @@ lua_settop(L, 2); lua_getmetatable(L, 1); // 3 lua_getfield(L, LUA_REGISTRYINDEX, MONDELEFANT_RESULT_MT_REGKEY); // 4 +#if LUA_VERSION_NUM >= 502 + luaL_argcheck(L, lua_compare(L, 3, 4, LUA_OPEQ), 1, "not a database result"); +#else luaL_argcheck(L, lua_equal(L, 3, 4), 1, "not a database result"); +#endif // ensure that second argument is a database class (model): lua_settop(L, 2); lua_getmetatable(L, 2); // 3 lua_getfield(L, LUA_REGISTRYINDEX, MONDELEFANT_CLASS_MT_REGKEY); // 4 +#if LUA_VERSION_NUM >= 502 + luaL_argcheck(L, lua_compare(L, 3, 4, LUA_OPEQ), 2, "not a database class"); +#else luaL_argcheck(L, lua_equal(L, 3, 4), 2, "not a database class"); +#endif // set attribute "_class" of result list/object to given class: lua_settop(L, 2); lua_pushvalue(L, 2); // 3 @@ -1276,7 +1300,11 @@ if (lua_rawequal(L, 3, 4)) { int i; // set attribute "_class" of all elements to given class: +#if LUA_VERSION_NUM >= 502 + for (i=0; i < lua_rawlen(L, 1); i++) { +#else for (i=0; i < lua_objlen(L, 1); i++) { +#endif lua_settop(L, 2); lua_rawgeti(L, 1, i+1); // 3 lua_pushvalue(L, 2); // 4 @@ -1740,38 +1768,66 @@ int luaopen_mondelefant_native(lua_State *L) { lua_settop(L, 0); lua_newtable(L); // module at stack position 1 +#if LUA_VERSION_NUM >= 502 + luaL_setfuncs(L, mondelefant_module_functions, 0); +#else luaL_register(L, NULL, mondelefant_module_functions); +#endif lua_pushvalue(L, 1); // 2 lua_setfield(L, LUA_REGISTRYINDEX, MONDELEFANT_MODULE_REGKEY); lua_newtable(L); // 2 // NOTE: only PostgreSQL is supported yet: +#if LUA_VERSION_NUM >= 502 + luaL_setfuncs(L, mondelefant_conn_methods, 0); +#else luaL_register(L, NULL, mondelefant_conn_methods); +#endif lua_setfield(L, 1, "postgresql_connection_prototype"); lua_newtable(L); // 2 lua_setfield(L, 1, "connection_prototype"); luaL_newmetatable(L, MONDELEFANT_CONN_MT_REGKEY); // 2 +#if LUA_VERSION_NUM >= 502 + luaL_setfuncs(L, mondelefant_conn_mt_functions, 0); +#else luaL_register(L, NULL, mondelefant_conn_mt_functions); +#endif lua_settop(L, 1); luaL_newmetatable(L, MONDELEFANT_RESULT_MT_REGKEY); // 2 +#if LUA_VERSION_NUM >= 502 + luaL_setfuncs(L, mondelefant_result_mt_functions, 0); +#else luaL_register(L, NULL, mondelefant_result_mt_functions); +#endif lua_setfield(L, 1, "result_metatable"); luaL_newmetatable(L, MONDELEFANT_CLASS_MT_REGKEY); // 2 +#if LUA_VERSION_NUM >= 502 + luaL_setfuncs(L, mondelefant_class_mt_functions, 0); +#else luaL_register(L, NULL, mondelefant_class_mt_functions); +#endif lua_setfield(L, 1, "class_metatable"); lua_newtable(L); // 2 lua_newtable(L); // 3 +#if LUA_VERSION_NUM >= 502 + luaL_setfuncs(L, mondelefant_object_methods, 0); +#else luaL_register(L, NULL, mondelefant_object_methods); +#endif lua_setfield(L, 2, "object"); lua_newtable(L); // 3 lua_setfield(L, 2, "object_get"); lua_newtable(L); // 3 lua_setfield(L, 2, "object_set"); lua_newtable(L); // 3 +#if LUA_VERSION_NUM >= 502 + luaL_setfuncs(L, mondelefant_list_methods, 0); +#else luaL_register(L, NULL, mondelefant_list_methods); +#endif lua_setfield(L, 2, "list"); lua_newtable(L); // 3 lua_setfield(L, 2, "references"); @@ -1791,9 +1847,17 @@ lua_settop(L, 1); luaL_newmetatable(L, MONDELEFANT_ERROROBJECT_MT_REGKEY); // 2 +#if LUA_VERSION_NUM >= 502 + luaL_setfuncs(L, mondelefant_errorobject_mt_functions, 0); +#else luaL_register(L, NULL, mondelefant_errorobject_mt_functions); +#endif lua_newtable(L); // 3 +#if LUA_VERSION_NUM >= 502 + luaL_setfuncs(L, mondelefant_errorobject_methods, 0); +#else luaL_register(L, NULL, mondelefant_errorobject_methods); +#endif lua_setfield(L, 2, "__index"); lua_setfield(L, 1, "errorobject_metatable"); diff -r 4f38db8354b0 -r 3d43a5cf17c1 libraries/multirand/multirand.c --- a/libraries/multirand/multirand.c Tue Apr 03 00:56:02 2012 +0200 +++ b/libraries/multirand/multirand.c Sun Apr 15 16:04:33 2012 +0200 @@ -1,6 +1,5 @@ #include #include -#include static FILE *multirand_dev; @@ -43,7 +42,7 @@ lua_settop(L, 2); arg1 = luaL_checkinteger(L, 1); if (lua_toboolean(L, 2)) { - arg2 = luaL_optinteger(L, 2, 0); + arg2 = luaL_checkinteger(L, 2); if (arg1 > arg2) { return luaL_error(L, "Upper boundary is smaller than lower boundary." @@ -109,16 +108,13 @@ }; int luaopen_multirand(lua_State *L) { - const char *module_name; - lua_settop(L, 1); - module_name = lua_tostring(L, 1); - if (module_name) { - luaL_register(L, module_name, multirand_module_functions); - } else { - luaL_register(L, "multirand", multirand_module_functions); - } - lua_replace(L, 1); multirand_dev = fopen("/dev/urandom", "r"); if (!multirand_dev) return luaL_error(L, "Could not open /dev/urandom."); +#if LUA_VERSION_NUM >= 502 + lua_newtable(L); + luaL_setfuncs(L, multirand_module_functions, 0); +#else + luaL_register(L, lua_tostring(L, 1) || "multirand", multirand_module_functions); +#endif return 1; } diff -r 4f38db8354b0 -r 3d43a5cf17c1 libraries/nihil/nihil.lua --- a/libraries/nihil/nihil.lua Tue Apr 03 00:56:02 2012 +0200 +++ b/libraries/nihil/nihil.lua Sun Apr 15 16:04:33 2012 +0200 @@ -2,11 +2,16 @@ local error = error local getmetatable = getmetatable -local module = module local rawset = rawset local setmetatable = setmetatable -module(...) +local _M = {} +if _ENV then + _ENV = _M +else + _G[...] = _M + setfenv(1, _M) +end metatable = { __tostring = function(self) @@ -50,3 +55,5 @@ return value end end + +return _M diff -r 4f38db8354b0 -r 3d43a5cf17c1 libraries/rocketcgi/rocketcgi.lua --- a/libraries/rocketcgi/rocketcgi.lua Tue Apr 03 00:56:02 2012 +0200 +++ b/libraries/rocketcgi/rocketcgi.lua Sun Apr 15 16:04:33 2012 +0200 @@ -3,24 +3,20 @@ local assert = assert local collectgarbage = collectgarbage local error = error -local getfenv = getfenv local getmetatable = getmetatable local ipairs = ipairs local next = next local pairs = pairs -local pcall = pcall local print = print local rawequal = rawequal local rawget = rawget +local rawlen = rawlen local rawset = rawset local select = select -local setfenv = setfenv local setmetatable = setmetatable local tonumber = tonumber local tostring = tostring local type = type -local unpack = unpack -local xpcall = xpcall local io = io local math = math @@ -28,7 +24,13 @@ local string = string local table = table -module(...) +local _M = {} +if _ENV then + _ENV = _M +else + _G[...] = _M + setfenv(1, _M) +end data_sent = false @@ -307,3 +309,5 @@ else post_data = nil end + +return _M