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 | 198 | return false |
| 199 | 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 | 201 | -- alphanum sorting for humans in Lua |
| 217 | 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 | 230 | local files = utils.readdir(path, "files") or {} |
| 246 | 231 | local dirs = dir_mode ~= "ignore" and utils.readdir(path, "dirs") or {} |
| 247 | 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 | 243 | -- The current file could be a hidden file, ignoring it doesn't load other |
| 250 | 244 | -- files from the current directory. |
| 251 | 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 | 256 | end |
| 263 | 257 | return extensions[string.lower(ext)] |
| 264 | 258 | end) |
| 265 | − table.filter(dirs, function(d) | |
| 259 | + filter(dirs, function(d) | |
| 266 | 260 | return not ((o.ignore_hidden and string.match(d, "^%."))) |
| 267 | 261 | end) |
| 268 | 262 | alphanumsort(files) |
| @@ -272,7 +266,14 @@ function scan_dir(path, current_file, dir_mode, separator, dir_depth, total_file · 3 unmodified lines | ||
| 272 | 266 | files[i] = prefix .. file |
| 273 | 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 | 277 | if dir_mode == "recursive" then |
| 277 | 278 | for _, dir in ipairs(dirs) do |
| 278 | 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 | 283 | for i, dir in ipairs(dirs) do |
| 283 | 284 | dirs[i] = prefix .. dir |
| 284 | 285 | end |
| 285 | − table.append(total_files, dirs) | |
| 286 | + append(total_files, dirs) | |
| 286 | 287 | end |
| 287 | 288 | end |
| 288 | 289 | |
| @@ -319,7 +320,7 @@ function find_and_add_entries() · 30 unmodified lines | ||
| 319 | 320 | end |
| 320 | 321 | end |
| 321 | 322 | |
| 322 | − local extensions = {} | |
| 323 | + local extensions | |
| 323 | 324 | if o.same_type then |
| 324 | 325 | if EXTENSIONS_VIDEO[string.lower(this_ext)] ~= nil then |
| 325 | 326 | extensions = EXTENSIONS_VIDEO |