From 6da7e32d62311d166a3be08ce0bbfeab2b544681 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Thu, 29 Nov 2018 09:52:15 -0500 Subject: Fixed bug in new filter regarding extensions. If any extensions are specified as inclusive, exclude all others not specified. --- core/lfs_ext.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'core/lfs_ext.lua') 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 -- cgit v1.2.3