Fix handling of "files:not Pattern*" for non-file contexts
This commit is contained in:
parent
0f713d5c39
commit
7dd9f4b041
@ -101,9 +101,14 @@ static int testContext(lua_State* L, const char* prefix, const char* part,
|
||||
/*
|
||||
if prefix then
|
||||
local result = testValue(context[prefix], part, wildcard)
|
||||
if result == assertion and prefix == "files" then
|
||||
if prefix == "files" then
|
||||
if not filename then
|
||||
return false
|
||||
end
|
||||
if result == assertion then
|
||||
filematched = true
|
||||
end
|
||||
end
|
||||
if result then
|
||||
return assertion
|
||||
end
|
||||
@ -126,9 +131,14 @@ static int testContext(lua_State* L, const char* prefix, const char* part,
|
||||
lua_getfield(L, 2, prefix);
|
||||
result = testValue(L, part, wildcard);
|
||||
lua_pop(L, 1);
|
||||
if (result == assertion && strcmp(prefix, "files") == 0) {
|
||||
if (strcmp(prefix, "files") == 0) {
|
||||
if (filename == NULL) {
|
||||
return 0;
|
||||
}
|
||||
if (result == assertion) {
|
||||
(*fileMatched) = 1;
|
||||
}
|
||||
}
|
||||
if (result) {
|
||||
return assertion;
|
||||
}
|
||||
@ -229,9 +239,9 @@ int criteria_matches(lua_State* L)
|
||||
/* stack [2] = context */
|
||||
|
||||
const char* filename;
|
||||
int fileMatched;
|
||||
int top = lua_gettop(L);
|
||||
int matched = 1;
|
||||
int fileMatched = 0;
|
||||
|
||||
/*
|
||||
Cache string.match for a quicker lookup in match() above
|
||||
@ -246,6 +256,7 @@ int criteria_matches(lua_State* L)
|
||||
|
||||
lua_getfield(L, 2, "files");
|
||||
filename = lua_tostring(L, -1);
|
||||
fileMatched = (filename == NULL);
|
||||
|
||||
/*
|
||||
for i, pattern in pairs(criteria.patterns) do
|
||||
@ -273,7 +284,7 @@ int criteria_matches(lua_State* L)
|
||||
return matched
|
||||
*/
|
||||
|
||||
if (matched && filename && !fileMatched) {
|
||||
if (filename != NULL && !fileMatched) {
|
||||
matched = 0;
|
||||
}
|
||||
|
||||
|
@ -214,3 +214,13 @@
|
||||
crit = criteria.new { "files:not **.h" }
|
||||
test.istrue(criteria.matches(crit, { files = "hello.cpp" }))
|
||||
end
|
||||
|
||||
function suite.filesTermFails_onNoValue()
|
||||
crit = criteria.new { "files:Debug**" }
|
||||
test.isfalse(criteria.matches(crit, { configurations = "Debug32" }))
|
||||
end
|
||||
|
||||
function suite.filesTermFails_onNotModifierAndNoMatch()
|
||||
crit = criteria.new { "files:not Debug**" }
|
||||
test.isfalse(criteria.matches(crit, { configurations = "Debug32" }))
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user