aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Janda <siffiejoe@gmx.net>2015-04-26 14:39:57 +0200
committerPhilipp Janda <siffiejoe@gmx.net>2015-04-26 14:39:57 +0200
commit46b3056a0996d1bbdf4c1d4baa9f841e2d22299f (patch)
tree2070920c99ed7d90a6bea4af13528766928dd3fa
parentc4a98dafd07ed28e8f05d8771de65ce18ba0bee7 (diff)
downloadlua-compat-5.3-46b3056a0996d1bbdf4c1d4baa9f841e2d22299f.tar.gz
lua-compat-5.3-46b3056a0996d1bbdf4c1d4baa9f841e2d22299f.tar.bz2
lua-compat-5.3-46b3056a0996d1bbdf4c1d4baa9f841e2d22299f.zip
Add nonyieldable xpcall that takes extra arguments.
Although the full-featured yieldable xpcall has been moved to the compat53 module, the compat53.module module can at least have a version that takes and passes extra arguments. Also remove some unnecessary local aliases left over from previous refactoring.
-rw-r--r--compat53/init.lua4
-rw-r--r--compat53/module.lua16
2 files changed, 14 insertions, 6 deletions
diff --git a/compat53/init.lua b/compat53/init.lua
index e5f7692..e738091 100644
--- a/compat53/init.lua
+++ b/compat53/init.lua
@@ -9,8 +9,8 @@ local lua_version = _VERSION:sub(-3)
9if lua_version == "5.1" then 9if lua_version == "5.1" then
10 10
11 -- cache globals 11 -- cache globals
12 local error, pcall, rawset, select, setmetatable, tostring, type, unpack, xpcall = 12 local error, pcall, rawset, select, setmetatable, tostring, unpack, xpcall =
13 error, pcall, rawset, select, setmetatable, tostring, type, unpack, xpcall 13 error, pcall, rawset, select, setmetatable, tostring, unpack, xpcall
14 local coroutine, debug, io, package, string = 14 local coroutine, debug, io, package, string =
15 coroutine, debug, io, package, string 15 coroutine, debug, io, package, string
16 local coroutine_create = coroutine.create 16 local coroutine_create = coroutine.create
diff --git a/compat53/module.lua b/compat53/module.lua
index 30b42ee..c69c131 100644
--- a/compat53/module.lua
+++ b/compat53/module.lua
@@ -7,8 +7,8 @@ local M = _G
7if lua_version < "5.3" then 7if lua_version < "5.3" then
8 8
9 -- cache globals in upvalues 9 -- cache globals in upvalues
10 local error, getmetatable, ipairs, pairs, pcall, require, select, setmetatable, type = 10 local error, ipairs, pairs, pcall, require, select, setmetatable, type =
11 error, getmetatable, ipairs, pairs, pcall, require, select, setmetatable, type 11 error, ipairs, pairs, pcall, require, select, setmetatable, type
12 local debug, math, package, string, table = 12 local debug, math, package, string, table =
13 debug, math, package, string, table 13 debug, math, package, string, table
14 14
@@ -352,8 +352,8 @@ if lua_version < "5.3" then
352 #setmetatable({}, { __len = function() return 1 end }) == 1 352 #setmetatable({}, { __len = function() return 1 end }) == 1
353 353
354 -- cache globals in upvalues 354 -- cache globals in upvalues
355 local load, loadfile, loadstring, setfenv, tostring, unpack, xpcall = 355 local load, loadfile, loadstring, setfenv, unpack, xpcall =
356 load, loadfile, loadstring, setfenv, tostring, unpack, xpcall 356 load, loadfile, loadstring, setfenv, unpack, xpcall
357 local coroutine, io, os = coroutine, io, os 357 local coroutine, io, os = coroutine, io, os
358 local coroutine_create = coroutine.create 358 local coroutine_create = coroutine.create
359 local coroutine_resume = coroutine.resume 359 local coroutine_resume = coroutine.resume
@@ -529,6 +529,14 @@ if lua_version < "5.3" then
529 end 529 end
530 530
531 531
532 if not is_luajit then
533 function M.xpall(f, msgh, ...)
534 local args, n = { ... }, select('#', ...)
535 return xpcall(function() return f(unpack(args, 1, n)) end, msgh)
536 end
537 end
538
539
532 if not is_luajit52 then 540 if not is_luajit52 then
533 function M.os.execute(cmd) 541 function M.os.execute(cmd)
534 local code = os_execute(cmd) 542 local code = os_execute(cmd)