Skip to content

Commit

Permalink
fix: return third result in file-opening functions
Browse files Browse the repository at this point in the history
  • Loading branch information
hishamhm committed Aug 30, 2024
1 parent 1847fe0 commit 13e1404
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions compat53/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ if lua_version < "5.3" then
end

function M.io.open(...)
local fd, err = io_open(...)
local fd, err, code = io_open(...)
if fd and debug_setmetatable then
if not compat_file_meta_loaded then
local file_meta = gmt(fd)
Expand All @@ -857,11 +857,15 @@ if lua_version < "5.3" then
debug_setmetatable(fd, compat_file_meta)
end

return fd, err
if fd then
return fd
else
return fd, err, code
end
end

function M.io.popen(...)
local fd, err = io_popen(...)
local fd, err, code = io_popen(...)
if fd and debug_setmetatable then
if not compat_file_meta_loaded then
local file_meta = gmt(fd)
Expand All @@ -870,11 +874,15 @@ if lua_version < "5.3" then
debug_setmetatable(fd, compat_file_meta)
end

return fd, err
if fd then
return fd
else
return fd, err, code
end
end

function M.io.tmpfile(...)
local fd, err = io_tmpfile(...)
local fd, err, code = io_tmpfile(...)
if fd and debug_setmetatable then
if not compat_file_meta_loaded then
local file_meta = gmt(fd)
Expand All @@ -883,7 +891,11 @@ if lua_version < "5.3" then
debug_setmetatable(fd, compat_file_meta)
end

return fd, err
if fd then
return fd
else
return fd, err, code
end
end
end

Expand Down

0 comments on commit 13e1404

Please sign in to comment.