summaryrefslogtreecommitdiff
path: root/lualibs-util-lua.lua
diff options
context:
space:
mode:
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