Portable way to use loadstring

Signed-off-by: Arvydas Sidorenko <asido4@gmail.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Arvydas Sidorenko 2012-06-16 14:22:35 +02:00 committed by Uli Schlachter
parent ce19cabae3
commit 650bde830c
2 changed files with 4 additions and 4 deletions

View File

@ -6,7 +6,7 @@
-- Grab environment we need
require("awful.dbus")
local loadstring = loadstring
local load = loadstring or load -- v5.1 - loadstring, v5.2 - load
local tostring = tostring
local ipairs = ipairs
local table = table
@ -20,7 +20,7 @@ local type = type
if dbus then
dbus.connect_signal("org.naquadah.awesome.awful.Remote", function(data, code)
if data.member == "Eval" then
local f, e = loadstring(code)
local f, e = load(code)
if f then
results = { f() }
retvals = {}

View File

@ -8,7 +8,7 @@
local os = os
local io = io
local assert = assert
local loadstring = loadstring
local load = loadstring or load -- v5.1 - loadstring, v5.2 - load
local loadfile = loadfile
local debug = debug
local pairs = pairs
@ -108,7 +108,7 @@ end
--- Eval Lua code.
-- @return The return value of Lua code.
function util.eval(s)
return assert(loadstring(s))()
return assert(load(s))()
end
local xml_entity_names = { ["'"] = "&apos;", ["\""] = "&quot;", ["<"] = "&lt;", [">"] = "&gt;", ["&"] = "&amp;" };