Return absolute path if getrelative() hits the top of a DOS file system (issue #213)
This commit is contained in:
parent
860826c3d8
commit
b3216cbcf8
@ -87,8 +87,9 @@ int path_getrelative(lua_State* L)
|
||||
++i;
|
||||
}
|
||||
|
||||
/* if they have nothing in common return absolute path */
|
||||
if (last <= 0) {
|
||||
/* if I end up with just the root of the filesystem, either a single
|
||||
* slash (/) or a drive letter (c:) then return the absolute path. */
|
||||
if (last <= 0 || (last == 2 && src[1] == ':')) {
|
||||
dst[strlen(dst) - 1] = '\0';
|
||||
lua_pushstring(L, dst);
|
||||
return 1;
|
||||
|
@ -201,18 +201,22 @@
|
||||
test.isequal("/opt/include", path.getrelative("/home/me/src/project", "/opt/include"))
|
||||
end
|
||||
|
||||
function suite.ignoresExtraSlashes2()
|
||||
function suite.getrelative_ignoresExtraSlashes2()
|
||||
test.isequal("..", path.getrelative("/a//b/c","/a/b"))
|
||||
end
|
||||
|
||||
function suite.ignoresExtraSlashes3()
|
||||
function suite.getrelative_ignoresExtraSlashes3()
|
||||
test.isequal("..", path.getrelative("/a///b/c","/a/b"))
|
||||
end
|
||||
|
||||
function suite.ignoresTrailingSlashes()
|
||||
function suite.getrelative_ignoresTrailingSlashes()
|
||||
test.isequal("c", path.getrelative("/a/b/","/a/b/c"))
|
||||
end
|
||||
|
||||
function suite.getrelative_returnsAbsPath_onContactWithFileSysRoot()
|
||||
test.isequal("C:/Boost/Include", path.getrelative("C:/Code/MyApp", "C:/Boost/Include"))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- path.isabsolute() tests
|
||||
|
Loading…
Reference in New Issue
Block a user