Fixed edge case in path.normalize

This commit is contained in:
Sam Surtees 2020-02-02 16:30:44 +10:00
parent 63a1e5ff3b
commit 9128498bf9
2 changed files with 17 additions and 2 deletions

View File

@ -181,8 +181,7 @@ int path_normalize(lua_State* L)
// path is surrounded with quotes
if (readPtr != endPtr &&
IS_QUOTE(*readPtr) && IS_QUOTE(endPtr[-1]) &&
*readPtr == endPtr[-1])
IS_QUOTE(*readPtr))
{
*(writePtr++) = *(readPtr++);
}

View File

@ -740,3 +740,19 @@
-- End
test.isequal("../../test/${MYVAR}", path.normalize("../../test/${MYVAR}"))
end
function suite.normalize_quotedpath_withTokens()
-- Premake tokens
test.isequal("\"%{wks.location}../../test\"", path.normalize("\"%{wks.location}../../test\""))
-- Visual Studio var
test.isequal("\"$(SolutionDir)../../test\"", path.normalize("\"$(SolutionDir)../../test\""))
-- Windows env var
test.isequal("\"%APPDATA%../../test\"", path.normalize("\"%APPDATA%../../test\""))
-- Unix env var
test.isequal("\"${HOME}../../test\"", path.normalize("\"${HOME}../../test\""))
-- Middle
test.isequal("\"../../${MYVAR}/../test\"", path.normalize("\"../../${MYVAR}/../test\""))
-- End
test.isequal("\"../../test/${MYVAR}\"", path.normalize("\"../../test/${MYVAR}\""))
end