Skip to content

Commit

Permalink
A fix in file masks processor
Browse files Browse the repository at this point in the history
  • Loading branch information
shmuz committed Nov 13, 2023
1 parent 5a80849 commit 6dacca7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
23 changes: 9 additions & 14 deletions far/src/filemask/FileMasksProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// This method was chosen due to its simplicity.
#define MAXCALLDEPTH 64

static const wchar_t *FindExcludeChar(const wchar_t *masks)
static wchar_t *FindExcludeChar(wchar_t *masks)
{
for (bool regexp=false; *masks; masks++)
{
Expand All @@ -72,11 +72,6 @@ static const wchar_t *FindExcludeChar(const wchar_t *masks)
return nullptr;
}

static bool IsExcludeMask(const wchar_t *masks)
{
return FindExcludeChar(masks)!=nullptr;
}

bool SingleFileMask::Set(const wchar_t *Masks, DWORD Flags)
{
Mask=Masks;
Expand Down Expand Up @@ -204,28 +199,28 @@ bool FileMasksProcessor::Set(const wchar_t *masks, DWORD Flags)
bool rc = false;
wchar_t *MasksStr = wcsdup(masks);

if (MasksStr)
{
if (MasksStr) {
rc = true;

wchar_t *pInclude = MasksStr;
while (iswspace(*pInclude))
pInclude++;

wchar_t *pExclude = (wchar_t*) FindExcludeChar(pInclude);
wchar_t *pExclude = FindExcludeChar(pInclude);

if (pExclude)
{
if (pExclude) {
*pExclude++ = 0;
while (iswspace(*pExclude))
pExclude++;

if (*pInclude == 0 && *pExclude == 0)
rc = false;
else if (*pExclude == 0)
else if (*pExclude == 0) // treat empty exclude mask as no exclude mask
pExclude = nullptr;
else if (*pExclude != L'/' && wcschr(pExclude, EXCLUDEMASKSEPARATOR)) // FIXME
rc = false;
else {
wchar_t *ptr = FindExcludeChar(pExclude);
if (ptr) *ptr = 0; // ignore all starting from the 2-nd exclude char
}
}

if (rc)
Expand Down
1 change: 1 addition & 0 deletions luamacro/src/macrotest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1540,6 +1540,7 @@ local function test_ProcessName()
assert_true (far.CmpNameList("*|*.cpp", "foo.abc" )) -- exclude mask IS supported
assert_true (far.CmpNameList("|*.cpp", "foo.abc" ))
assert_true (far.CmpNameList("*|", "foo.abc" ))
assert_true (far.CmpNameList("*|bar|*", "foo.abc" ))
assert_false(far.CmpNameList("*|*.abc", "foo.abc" ))
assert_false(far.CmpNameList("|", "foo.abc" ))

Expand Down

0 comments on commit 6dacca7

Please sign in to comment.