From d6a8aa05fedb53ef562feac68209d79113d3f18d Mon Sep 17 00:00:00 2001 From: Jason Perkins Date: Wed, 9 Apr 2014 16:14:59 -0400 Subject: [PATCH] Avoid file filter term tests when matching against non-file configurations --- src/host/criteria_matches.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/host/criteria_matches.c b/src/host/criteria_matches.c index 39cc3cf5..3838f46c 100644 --- a/src/host/criteria_matches.c +++ b/src/host/criteria_matches.c @@ -100,14 +100,13 @@ static int testContext(lua_State* L, const char* prefix, const char* part, { /* if prefix then + local isFiles = (prefix == "files") + if isFiles and not filename then + return false + end local result = testValue(context[prefix], part, wildcard) - if prefix == "files" then - if not filename then - return false - end - if result == assertion then - filematched = true - end + if isFiles and result == assertion then + filematched = true end if result then return assertion @@ -128,16 +127,16 @@ static int testContext(lua_State* L, const char* prefix, const char* part, int result; if (prefix) { + int isFiles = (strcmp(prefix, "files") == 0); + if (isFiles && filename == NULL) { + return 0; + } + lua_getfield(L, 2, prefix); result = testValue(L, part, wildcard); lua_pop(L, 1); - if (strcmp(prefix, "files") == 0) { - if (filename == NULL) { - return 0; - } - if (result == assertion) { - (*fileMatched) = 1; - } + if (isFiles && result == assertion) { + (*fileMatched) = 1; } if (result) { return assertion;