aboutsummaryrefslogtreecommitdiff
path: root/core/lfs_ext.lua
diff options
context:
space:
mode:
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