From e00d066f7a7cb1ffd8df94d90e16565c3dedeec7 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 14 Jul 2013 10:01:25 +0200 Subject: sync with Context as of 2013-07-14 --- lualibs-util-lua.lua | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'lualibs-util-lua.lua') 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 -- cgit v1.2.3