Commit e7a2d014 authored by Renato Figueiro Maia's avatar Renato Figueiro Maia

Merge from branch 02_00_00 (r161244)


git-svn-id: https://subversion.tecgraf.puc-rio.br/engdist/openbus/sdk/lua/branches/02_00_01@161245 ae0415b3-e90b-0410-900d-d0be9363c56b
parents 2f26cf6b 7de2ee6c
......@@ -22,7 +22,7 @@ local string = require "string"
local module = {}
function module.create()
function module.create(...)
local preloaded = {}
local packcfg = {
preload = preloaded,
......@@ -155,24 +155,32 @@ function module.create()
env[name] = module
end
local forbiden = {...}
function env.require(name)
local module = allowed[name]
if module == nil then
local isforbiden
for _, pattern in ipairs(forbiden) do
if match(name, pattern) then
isforbiden = true
end
end
if isforbiden then
error("no permission to load module '"..name.."'")
end
local loader = preloaded[name]
if loader ~= nil then
module = loader(name)
if module == nil then
module = true
end
elseif preload[name] == nil and loaded[name] == nil then
else
local path, cpath = package.path, package.cpath
package.path, package.cpath = packcfg.path, packcfg.cpath
local ok, result = xpcall(require, traceback, name)
package.path, package.cpath = path, cpath
if not ok then error(result) end
module = result
else
error("no permission to load module '"..name.."'")
end
allowed[name] = module
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment