aboutsummaryrefslogtreecommitdiffhomepage
path: root/core/lfs_ext.lua
diff options
context:
space:
mode:
authorGravatar mitchell <70453897+667e-11@users.noreply.github.com>2018-11-29 09:52:15 -0500
committerGravatar mitchell <70453897+667e-11@users.noreply.github.com>2018-11-29 09:52:15 -0500
commit6da7e32d62311d166a3be08ce0bbfeab2b544681 (patch)
tree1acb17e17d1d47f61c9b16aab2b29dedfa2c6019 /core/lfs_ext.lua
parent59d57ba47bdda8e7908892f806e70caaea1abafa (diff)
Fixed bug in new filter regarding extensions.
If any extensions are specified as inclusive, exclude all others not specified.
Diffstat (limited to 'core/lfs_ext.lua')
-rw-r--r--core/lfs_ext.lua10
1 files changed, 8 insertions, 2 deletions
diff --git a/core/lfs_ext.lua b/core/lfs_ext.lua
index d36753eb..d69071ef 100644
--- a/core/lfs_ext.lua
+++ b/core/lfs_ext.lua
@@ -63,10 +63,16 @@ function lfs.dir_foreach(dir, f, filter, n, include_dirs, level)
local patt = filter[i]
patt = patt:gsub('^(!?)%%?%.([^.]+)$', '%1%%.%2$') -- '.lua' to '%.lua$'
patt = patt:gsub('/([^\\])', '[/\\]%1') -- '/' to '[/\\]'
- if not patt:find('^!') then processed_filter.consider_any = false end
+ local include = not patt:find('^!')
+ if include then processed_filter.consider_any = false end
local ext = patt:match('^!?%%.([^.]+)%$$')
if ext then
- processed_filter.exts[ext] = patt:find('^!') and 'exclude' or 'include'
+ processed_filter.exts[ext] = include and 'include' or 'exclude'
+ if include and not getmetatable(processed_filter.exts) then
+ -- Exclude any extensions not manually specified.
+ setmetatable(processed_filter.exts,
+ {__index = function() return 'exclude' end})
+ end
else
processed_filter[#processed_filter + 1] = patt
end