From 2c264728d9ea490f9880c34928f815033745e314 Mon Sep 17 00:00:00 2001 From: "Wilma456 (Jakob0815)" Date: Thu, 10 Aug 2017 13:40:35 +0200 Subject: [PATCH 1/2] Add Check to textutils.tabulate/pagedTabulate --- .../resources/assets/computercraft/lua/rom/apis/textutils.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/resources/assets/computercraft/lua/rom/apis/textutils.lua b/src/main/resources/assets/computercraft/lua/rom/apis/textutils.lua index 35ffe8087..9f51b771e 100644 --- a/src/main/resources/assets/computercraft/lua/rom/apis/textutils.lua +++ b/src/main/resources/assets/computercraft/lua/rom/apis/textutils.lua @@ -122,6 +122,9 @@ local function tabulateCommon( bPaged, ... ) for n, t in ipairs( tAll ) do if type(t) == "table" then for n, sItem in pairs(t) do + if type( sItem ) ~= "number" and type( sItem ) ~= "string" then + error( "textutils.tabulate/pagedTabulate only allow strings and numbers in the table", 3 ) + end nMaxLen = math.max( string.len( sItem ) + 1, nMaxLen ) end end From 282aa804f89f7adfafa16501ff39884a28b92bc5 Mon Sep 17 00:00:00 2001 From: "Wilma456 (Jakob0815)" Date: Tue, 12 Sep 2017 19:42:08 +0200 Subject: [PATCH 2/2] Changes sugested by dan200 --- .../assets/computercraft/lua/rom/apis/textutils.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/resources/assets/computercraft/lua/rom/apis/textutils.lua b/src/main/resources/assets/computercraft/lua/rom/apis/textutils.lua index 9f51b771e..088bf82a2 100644 --- a/src/main/resources/assets/computercraft/lua/rom/apis/textutils.lua +++ b/src/main/resources/assets/computercraft/lua/rom/apis/textutils.lua @@ -113,7 +113,7 @@ local function tabulateCommon( bPaged, ... ) local tAll = { ... } for k,v in ipairs( tAll ) do if type( v ) ~= "number" and type( v ) ~= "table" then - error( "bad argument #"..k.." (expected number/table, got " .. type( v ) .. ")", 3 ) + error( "bad argument #"..k.." (expected number or table, got " .. type( v ) .. ")", 3 ) end end @@ -121,9 +121,9 @@ local function tabulateCommon( bPaged, ... ) local nMaxLen = w / 8 for n, t in ipairs( tAll ) do if type(t) == "table" then - for n, sItem in pairs(t) do - if type( sItem ) ~= "number" and type( sItem ) ~= "string" then - error( "textutils.tabulate/pagedTabulate only allow strings and numbers in the table", 3 ) + for nu, sItem in pairs(t) do + if type( sItem ) ~= "string" then + error( "bad argument #"..n.."."..nu.." (expected string, got " .. type( sItem ) .. ")", 3 ) end nMaxLen = math.max( string.len( sItem ) + 1, nMaxLen ) end