webmcp
changeset 68:ebdc20b7048b
Lua 5.2 compatibility:
Make function load accepting strings as first argument
Make function load accepting strings as first argument
author | jbe |
---|---|
date | Tue Apr 17 16:26:32 2012 +0200 (2012-04-17) |
parents | 937bbe05098c |
children | 343e121178d1 |
files | framework/cgi-bin/webmcp.lua |
line diff
1.1 --- a/framework/cgi-bin/webmcp.lua Tue Apr 17 15:39:27 2012 +0200 1.2 +++ b/framework/cgi-bin/webmcp.lua Tue Apr 17 16:26:32 2012 +0200 1.3 @@ -6,6 +6,23 @@ 1.4 if not table.unpack then 1.5 table.unpack = unpack 1.6 end 1.7 +do 1.8 + local old_load = load 1.9 + function load(ld, ...) 1.10 + if type(ld) == string then 1.11 + local done = false 1.12 + local func = function() 1.13 + if not done then 1.14 + done = true 1.15 + return ld 1.16 + end 1.17 + end 1.18 + return old_load(func, ...) 1.19 + else 1.20 + return old_load(ld, ...) 1.21 + end 1.22 + end 1.23 +end 1.24 1.25 -- include "../lib/" in search path for libraries 1.26 if not WEBMCP_PATH then 1.27 @@ -144,7 +161,7 @@ 1.28 if file then 1.29 local filedata = file:read("*a") 1.30 io.close(file) 1.31 - local func, errmsg = loadstring(filedata, "=" .. filename) 1.32 + local func, errmsg = load(filedata, "=" .. filename) 1.33 if func then 1.34 func() 1.35 return true