mirror of
https://github.com/mpv-player/mpv
synced 2025-01-24 08:33:34 +00:00
auto_profiles: fix compile_cond on lua 5.1
5.1's load() doesn't accept strings; loadstring must be used instead. In 5.2, loadstring is deprecated and setfenv is gone.
This commit is contained in:
parent
36e569b242
commit
df805cfc84
@ -136,16 +136,20 @@ setmetatable(p, {
|
||||
})
|
||||
|
||||
local function compile_cond(name, s)
|
||||
-- (pre 5.2 ignores the extra arguments)
|
||||
local chunk, err = load("return " .. s, "profile " .. name .. " condition",
|
||||
"t", evil_magic)
|
||||
local code, chunkname = "return " .. s, "profile " .. name .. " condition"
|
||||
local chunk, err
|
||||
if setfenv then -- lua 5.1
|
||||
chunk, err = loadstring(code, chunkname)
|
||||
if chunk then
|
||||
setfenv(chunk, evil_magic)
|
||||
end
|
||||
else -- lua 5.2
|
||||
chunk, err = load(code, chunkname, "t", evil_magic)
|
||||
end
|
||||
if not chunk then
|
||||
msg.error("Profile '" .. name .. "' condition: " .. err)
|
||||
chunk = function() return false end
|
||||
end
|
||||
if setfenv then
|
||||
setfenv(chunk, evil_magic)
|
||||
end
|
||||
return chunk
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user