summaryrefslogtreecommitdiffstats
path: root/TOOLS
diff options
context:
space:
mode:
authorKacper Michajłow <kasper93@gmail.com>2024-05-12 02:06:14 +0200
committerKacper Michajłow <kasper93@gmail.com>2024-05-12 20:06:39 +0200
commita1caa001870985f36ae3c0082181e4e708ebdd73 (patch)
tree860495dca2e366121015735d22305ef189c539d4 /TOOLS
parentb4fcf7d2488a8071aec5c570638ce511e604b732 (diff)
downloadmpv-a1caa001870985f36ae3c0082181e4e708ebdd73.tar.bz2
mpv-a1caa001870985f36ae3c0082181e4e708ebdd73.tar.xz
autoload.lua: fix some lint warnings
Fixes: autoload.lua:201:1: setting undefined field filter of global table autoload.lua:209:1: setting undefined field append of global table autoload.lua:322:11: value assigned to variable extensions is unused
Diffstat (limited to 'TOOLS')
-rw-r--r--TOOLS/lua/autoload.lua41
1 files changed, 21 insertions, 20 deletions
diff --git a/TOOLS/lua/autoload.lua b/TOOLS/lua/autoload.lua
index 593d375431..486801e10d 100644
--- a/TOOLS/lua/autoload.lua
+++ b/TOOLS/lua/autoload.lua
@@ -198,21 +198,6 @@ function is_ignored(file)
return false
end
-table.filter = function(t, iter)
- for i = #t, 1, -1 do
- if not iter(t[i]) then
- table.remove(t, i)
- end
- end
-end
-
-table.append = function(t1, t2)
- local t1_size = #t1
- for i = 1, #t2 do
- t1[t1_size + i] = t2[i]
- end
-end
-
-- alphanum sorting for humans in Lua
-- http://notebook.kulchenko.com/algorithms/alphanumeric-natural-sorting-for-humans-in-lua
@@ -245,7 +230,16 @@ function scan_dir(path, current_file, dir_mode, separator, dir_depth, total_file
local files = utils.readdir(path, "files") or {}
local dirs = dir_mode ~= "ignore" and utils.readdir(path, "dirs") or {}
local prefix = path == "." and "" or path
- table.filter(files, function (v)
+
+ local filter = function(t, iter)
+ for i = #t, 1, -1 do
+ if not iter(t[i]) then
+ table.remove(t, i)
+ end
+ end
+ end
+
+ filter(files, function (v)
-- The current file could be a hidden file, ignoring it doesn't load other
-- files from the current directory.
local current = prefix .. v == current_file
@@ -262,7 +256,7 @@ function scan_dir(path, current_file, dir_mode, separator, dir_depth, total_file
end
return extensions[string.lower(ext)]
end)
- table.filter(dirs, function(d)
+ filter(dirs, function(d)
return not ((o.ignore_hidden and string.match(d, "^%.")))
end)
alphanumsort(files)
@@ -272,7 +266,14 @@ function scan_dir(path, current_file, dir_mode, separator, dir_depth, total_file
files[i] = prefix .. file
end
- table.append(total_files, files)
+ local append = function(t1, t2)
+ local t1_size = #t1
+ for i = 1, #t2 do
+ t1[t1_size + i] = t2[i]
+ end
+ end
+
+ append(total_files, files)
if dir_mode == "recursive" then
for _, dir in ipairs(dirs) do
scan_dir(prefix .. dir .. separator, current_file, dir_mode,
@@ -282,7 +283,7 @@ function scan_dir(path, current_file, dir_mode, separator, dir_depth, total_file
for i, dir in ipairs(dirs) do
dirs[i] = prefix .. dir
end
- table.append(total_files, dirs)
+ append(total_files, dirs)
end
end
@@ -319,7 +320,7 @@ function find_and_add_entries()
end
end
- local extensions = {}
+ local extensions
if o.same_type then
if EXTENSIONS_VIDEO[string.lower(this_ext)] ~= nil then
extensions = EXTENSIONS_VIDEO