From 49a9a1e76a34d67cfa2be24cbb2e2a9db545f969 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 2 Jul 2022 17:31:14 +0200 Subject: util: Remove various Lua 5.1 compatibility hacks Part of #1600 --- util/human/io.lua | 5 +---- util/human/units.lua | 8 -------- 2 files changed, 1 insertion(+), 12 deletions(-) (limited to 'util/human') diff --git a/util/human/io.lua b/util/human/io.lua index 7d7dea97..4fce0e94 100644 --- a/util/human/io.lua +++ b/util/human/io.lua @@ -30,10 +30,7 @@ local function getline() end local function getpass() - local stty_ret, _, status_code = os.execute("stty -echo 2>/dev/null"); - if status_code then -- COMPAT w/ Lua 5.1 - stty_ret = status_code; - end + local stty_ret = os.execute("stty -echo 2>/dev/null"); if stty_ret ~= 0 then io.write("\027[08m"); -- ANSI 'hidden' text attribute end diff --git a/util/human/units.lua b/util/human/units.lua index af233e98..23e3e579 100644 --- a/util/human/units.lua +++ b/util/human/units.lua @@ -6,14 +6,6 @@ local math_max = math.max; local math_min = math.min; local unpack = table.unpack or unpack; --luacheck: ignore 113 -if math_log(10, 10) ~= 1 then - -- Lua 5.1 COMPAT - local log10 = math.log10; - function math_log(n, base) - return log10(n) / log10(base); - end -end - local large = { "k", 1000, "M", 1000000, -- cgit v1.2.3 From 5251c9b686fc7885c1213cc2580d66ebda2dda9b Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 11 Jul 2022 19:07:38 +0200 Subject: compat: Remove handling of Lua 5.1 location of 'unpack' function --- util/human/units.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util/human') diff --git a/util/human/units.lua b/util/human/units.lua index 23e3e579..329c8518 100644 --- a/util/human/units.lua +++ b/util/human/units.lua @@ -4,7 +4,7 @@ local math_floor = math.floor; local math_log = math.log; local math_max = math.max; local math_min = math.min; -local unpack = table.unpack or unpack; --luacheck: ignore 113 +local unpack = table.unpack; local large = { "k", 1000, -- cgit v1.2.3 From 1acd5e0474c00f29fa436eba61c7aceb65ed08dd Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 20 Oct 2022 17:35:01 +0200 Subject: util.human.io: Fix handling of os.execute() return values in Lua 5.2+ Wrong part of Lua 5.1 compat removed in 0f4feaf9ca64 --- util/human/io.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'util/human') diff --git a/util/human/io.lua b/util/human/io.lua index 4fce0e94..b272af71 100644 --- a/util/human/io.lua +++ b/util/human/io.lua @@ -8,7 +8,7 @@ end; local function getchar(n) local stty_ret = os.execute("stty raw -echo 2>/dev/null"); local ok, char; - if stty_ret == true or stty_ret == 0 then + if stty_ret then ok, char = pcall(io.read, n or 1); os.execute("stty sane"); else @@ -31,11 +31,11 @@ end local function getpass() local stty_ret = os.execute("stty -echo 2>/dev/null"); - if stty_ret ~= 0 then + if not stty_ret then io.write("\027[08m"); -- ANSI 'hidden' text attribute end local ok, pass = pcall(io.read, "*l"); - if stty_ret == 0 then + if stty_ret then os.execute("stty sane"); else io.write("\027[00m"); -- cgit v1.2.3