Cleanup global namespace pollution in builtin (#9451)
authorWuzzy <wuzzy2@mail.ru>
Fri, 6 Mar 2020 20:19:14 +0000 (20:19 +0000)
committerGitHub <noreply@github.com>
Fri, 6 Mar 2020 20:19:14 +0000 (20:19 +0000)
builtin/common/misc_helpers.lua
builtin/mainmenu/pkgmgr.lua

index 1e9a08851fe9a2a653a125f68e760365549eced1..715f89bc4b9424284be547ed3df31351d5a05f44 100644 (file)
@@ -5,7 +5,7 @@
 local string_sub, string_find = string.sub, string.find
 
 --------------------------------------------------------------------------------
-function basic_dump(o)
+local function basic_dump(o)
        local tp = type(o)
        if tp == "number" then
                return tostring(o)
@@ -200,18 +200,6 @@ function table.indexof(list, val)
        return -1
 end
 
---------------------------------------------------------------------------------
-if INIT ~= "client" then
-       function file_exists(filename)
-               local f = io.open(filename, "r")
-               if f == nil then
-                       return false
-               else
-                       f:close()
-                       return true
-               end
-       end
-end
 --------------------------------------------------------------------------------
 function string:trim()
        return (self:gsub("^%s*(.-)%s*$", "%1"))
@@ -254,64 +242,6 @@ function math.factorial(x)
        return v
 end
 
---------------------------------------------------------------------------------
-function get_last_folder(text,count)
-       local parts = text:split(DIR_DELIM)
-
-       if count == nil then
-               return parts[#parts]
-       end
-
-       local retval = ""
-       for i=1,count,1 do
-               retval = retval .. parts[#parts - (count-i)] .. DIR_DELIM
-       end
-
-       return retval
-end
-
---------------------------------------------------------------------------------
-function cleanup_path(temppath)
-
-       local parts = temppath:split("-")
-       temppath = ""
-       for i=1,#parts,1 do
-               if temppath ~= "" then
-                       temppath = temppath .. "_"
-               end
-               temppath = temppath .. parts[i]
-       end
-
-       parts = temppath:split(".")
-       temppath = ""
-       for i=1,#parts,1 do
-               if temppath ~= "" then
-                       temppath = temppath .. "_"
-               end
-               temppath = temppath .. parts[i]
-       end
-
-       parts = temppath:split("'")
-       temppath = ""
-       for i=1,#parts,1 do
-               if temppath ~= "" then
-                       temppath = temppath .. ""
-               end
-               temppath = temppath .. parts[i]
-       end
-
-       parts = temppath:split(" ")
-       temppath = ""
-       for i=1,#parts,1 do
-               if temppath ~= "" then
-                       temppath = temppath
-               end
-               temppath = temppath .. parts[i]
-       end
-
-       return temppath
-end
-
 function core.formspec_escape(text)
        if text ~= nil then
                text = string.gsub(text,"\\","\\\\")
index 0ac697fdb7e24ca68662b8c05d1558771fdd261e..5b880731009af0e151890a961d16653eddf147e1 100644 (file)
 --51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 --------------------------------------------------------------------------------
+local function get_last_folder(text,count)
+       local parts = text:split(DIR_DELIM)
+
+       if count == nil then
+               return parts[#parts]
+       end
+
+       local retval = ""
+       for i=1,count,1 do
+               retval = retval .. parts[#parts - (count-i)] .. DIR_DELIM
+       end
+
+       return retval
+end
+
+local function cleanup_path(temppath)
+
+       local parts = temppath:split("-")
+       temppath = ""
+       for i=1,#parts,1 do
+               if temppath ~= "" then
+                       temppath = temppath .. "_"
+               end
+               temppath = temppath .. parts[i]
+       end
+
+       parts = temppath:split(".")
+       temppath = ""
+       for i=1,#parts,1 do
+               if temppath ~= "" then
+                       temppath = temppath .. "_"
+               end
+               temppath = temppath .. parts[i]
+       end
+
+       parts = temppath:split("'")
+       temppath = ""
+       for i=1,#parts,1 do
+               if temppath ~= "" then
+                       temppath = temppath .. ""
+               end
+               temppath = temppath .. parts[i]
+       end
+
+       parts = temppath:split(" ")
+       temppath = ""
+       for i=1,#parts,1 do
+               if temppath ~= "" then
+                       temppath = temppath
+               end
+               temppath = temppath .. parts[i]
+       end
+
+       return temppath
+end
+
 function get_mods(path,retval,modpack)
        local mods = core.get_dir_list(path, true)