From 971f7b58dc54a6c1729ffbd5f6bb30c00325c5a2 Mon Sep 17 00:00:00 2001 From: Tom van Dijck Date: Tue, 13 Jun 2017 06:53:13 -0700 Subject: [PATCH] Fix os.outputof for lua 5.3.4 --- src/base/os.lua | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/base/os.lua b/src/base/os.lua index 4e0c8e78..7dbaddaa 100644 --- a/src/base/os.lua +++ b/src/base/os.lua @@ -61,7 +61,7 @@ end return dirs end - + local function get_library_search_path() local path if os.istarget("windows") then @@ -151,14 +151,14 @@ function os.findheader(headerpath, headerdirs) -- headerpath: a partial header file path -- headerdirs: additional header search paths - + local path = get_library_search_path() - + -- replace all /lib by /include path = path .. ':' - path = path:gsub ('/lib[0-9]*([:/])', '/include%1') + path = path:gsub ('/lib[0-9]*([:/])', '/include%1') path = path:sub (1, #path - 1) - + local userpath = "" if type(headerdirs) == "string" then @@ -174,7 +174,7 @@ path = userpath end end - + local result = os.pathsearch (headerpath, path) return result end @@ -460,17 +460,17 @@ local pipe = io.popen(cmd .. " 2>&1") local result = pipe:read('*a') - local b, exitcode = pipe:close() - if not b then - exitcode = -1 - end + local success, what, code = pipe:close() + if success then + -- chomp trailing newlines + if result then + result = string.gsub(result, "[\r\n]+$", "") + end - -- chomp trailing newlines - if result then - result = string.gsub(result, "[\r\n]+$", "") + return result, code, what + else + return nil, code, what end - - return result, exitcode end