summaryrefslogtreecommitdiff
path: root/lualibs-util-lua.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2013-07-14 10:01:25 +0200
committerPhilipp Gesang <phg42.2a@gmail.com>2013-07-14 10:01:25 +0200
commite00d066f7a7cb1ffd8df94d90e16565c3dedeec7 (patch)
treec9893c780ccc05c8f5402b8bf09caf361cbeea86 /lualibs-util-lua.lua
parentf2f35fe3d8a1c5ce74ddbb8eef3cad2b18a379dc (diff)
downloadlualibs-e00d066f7a7cb1ffd8df94d90e16565c3dedeec7.tar.gz
sync with Context as of 2013-07-14
Diffstat (limited to 'lualibs-util-lua.lua')
-rw-r--r--lualibs-util-lua.lua22
1 files changed, 15 insertions, 7 deletions
diff --git a/lualibs-util-lua.lua b/lualibs-util-lua.lua
index 61d1190..e1dcdc9 100644
--- a/lualibs-util-lua.lua
+++ b/lualibs-util-lua.lua
@@ -74,9 +74,16 @@ end
function luautilities.loadedluacode(fullname,forcestrip,name)
-- quite subtle ... doing this wrong incidentally can give more bytes
name = name or fullname
- local code = environment.loadpreprocessedfile and environment.loadpreprocessedfile(fullname) or loadfile(fullname)
+ local code, message
+ if environment.loadpreprocessedfile then
+ code, message = environment.loadpreprocessedfile(fullname)
+ else
+ code, message = loadfile(fullname)
+ end
if code then
code()
+ else
+ report_lua("loading of file %a failed:\n\t%s",fullname,message or "no message")
end
if forcestrip and luautilities.stripcode then
if type(forcestrip) == "function" then
@@ -97,15 +104,16 @@ function luautilities.loadedluacode(fullname,forcestrip,name)
end
function luautilities.strippedloadstring(code,forcestrip,name) -- not executed
+ local code, message = load(code)
+ if not code then
+ report_lua("loading of file %a failed:\n\t%s",name,message or "no message")
+ end
if forcestrip and luautilities.stripcode or luautilities.alwaysstripcode then
- code = load(code)
- if not code then
- report_lua("fatal error %a in file %a",3,name)
- end
register(name)
- code = dump(code,true)
+ return load(dump(code,true)), 0 -- not yet executes
+ else
+ return code, 0
end
- return load(code), 0
end
function luautilities.compile(luafile,lucfile,cleanup,strip,fallback) -- defaults: cleanup=false strip=true