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
Showing the changes to TOOLS/lua/autoload.lua (1 of 1 file). Show all
Unified · Split
| @@ -198,21 +198,6 @@ function is_ignored(file) · 197 unmodified lines | |||
| 198 | return false | 198 | return false |
| 199 | end | 199 | end |
| 200 | 200 | ||
| 201 | table.filter = function(t, iter) | ||
| 202 | for i = #t, 1, -1 do | ||
| 203 | if not iter(t[i]) then | ||
| 204 | table.remove(t, i) | ||
| 205 | end | ||
| 206 | end | ||
| 207 | end | ||
| 208 | |||
| 209 | table.append = function(t1, t2) | ||
| 210 | local t1_size = #t1 | ||
| 211 | for i = 1, #t2 do | ||
| 212 | t1[t1_size + i] = t2[i] | ||
| 213 | end | ||
| 214 | end | ||
| 215 | |||
| 216 | -- alphanum sorting for humans in Lua | 201 | -- alphanum sorting for humans in Lua |
| 217 | -- http://notebook.kulchenko.com/algorithms/alphanumeric-natural-sorting-for-humans-in-lua | 202 | -- http://notebook.kulchenko.com/algorithms/alphanumeric-natural-sorting-for-humans-in-lua |
| 218 | 203 | ||
| @@ -245,7 +230,16 @@ function scan_dir(path, current_file, dir_mode, separator, dir_depth, total_file · 26 unmodified lines | |||
| 245 | local files = utils.readdir(path, "files") or {} | 230 | local files = utils.readdir(path, "files") or {} |
| 246 | local dirs = dir_mode ~= "ignore" and utils.readdir(path, "dirs") or {} | 231 | local dirs = dir_mode ~= "ignore" and utils.readdir(path, "dirs") or {} |
| 247 | local prefix = path == "." and "" or path | 232 | local prefix = path == "." and "" or path |
| 248 | table.filter(files, function (v) | 233 | |
| 234 | local filter = function(t, iter) | ||
| 235 | for i = #t, 1, -1 do | ||
| 236 | if not iter(t[i]) then | ||
| 237 | table.remove(t, i) | ||
| 238 | end | ||
| 239 | end | ||
| 240 | end | ||
| 241 | |||
| 242 | filter(files, function (v) | ||
| 249 | -- The current file could be a hidden file, ignoring it doesn't load other | 243 | -- The current file could be a hidden file, ignoring it doesn't load other |
| 250 | -- files from the current directory. | 244 | -- files from the current directory. |
| 251 | local current = prefix .. v == current_file | 245 | local current = prefix .. v == current_file |
| @@ -262,7 +256,7 @@ function scan_dir(path, current_file, dir_mode, separator, dir_depth, total_file · 10 unmodified lines | |||
| 262 | end | 256 | end |
| 263 | return extensions[string.lower(ext)] | 257 | return extensions[string.lower(ext)] |
| 264 | end) | 258 | end) |
| 265 | table.filter(dirs, function(d) | 259 | filter(dirs, function(d) |
| 266 | return not ((o.ignore_hidden and string.match(d, "^%."))) | 260 | return not ((o.ignore_hidden and string.match(d, "^%."))) |
| 267 | end) | 261 | end) |
| 268 | alphanumsort(files) | 262 | alphanumsort(files) |
| @@ -272,7 +266,14 @@ function scan_dir(path, current_file, dir_mode, separator, dir_depth, total_file · 3 unmodified lines | |||
| 272 | files[i] = prefix .. file | 266 | files[i] = prefix .. file |
| 273 | end | 267 | end |
| 274 | 268 | ||
| 275 | table.append(total_files, files) | 269 | local append = function(t1, t2) |
| 270 | local t1_size = #t1 | ||
| 271 | for i = 1, #t2 do | ||
| 272 | t1[t1_size + i] = t2[i] | ||
| 273 | end | ||
| 274 | end | ||
| 275 | |||
| 276 | append(total_files, files) | ||
| 276 | if dir_mode == "recursive" then | 277 | if dir_mode == "recursive" then |
| 277 | for _, dir in ipairs(dirs) do | 278 | for _, dir in ipairs(dirs) do |
| 278 | scan_dir(prefix .. dir .. separator, current_file, dir_mode, | 279 | 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 · 3 unmodified lines | |||
| 282 | for i, dir in ipairs(dirs) do | 283 | for i, dir in ipairs(dirs) do |
| 283 | dirs[i] = prefix .. dir | 284 | dirs[i] = prefix .. dir |
| 284 | end | 285 | end |
| 285 | table.append(total_files, dirs) | 286 | append(total_files, dirs) |
| 286 | end | 287 | end |
| 287 | end | 288 | end |
| 288 | 289 | ||
| @@ -319,7 +320,7 @@ function find_and_add_entries() · 30 unmodified lines | |||
| 319 | end | 320 | end |
| 320 | end | 321 | end |
| 321 | 322 | ||
| 322 | local extensions = {} | 323 | local extensions |
| 323 | if o.same_type then | 324 | if o.same_type then |
| 324 | if EXTENSIONS_VIDEO[string.lower(this_ext)] ~= nil then | 325 | if EXTENSIONS_VIDEO[string.lower(this_ext)] ~= nil then |
| 325 | extensions = EXTENSIONS_VIDEO | 326 | extensions = EXTENSIONS_VIDEO |