path-util: fix path_simplify() with kill_dots and "."

Previously, together with kill_dots true, patch like
".", "./.", ".//.//" would all return an empty string.

That is wrong. There must be one "." left to reference
the current directory.

Also, the comment with examples was wrong.
This commit is contained in:
Thomas Haller
2018-10-05 21:41:33 +02:00
committed by Lennart Poettering
parent c250bf671b
commit afbae3e9f2
2 changed files with 19 additions and 11 deletions
+4 -4
View File
@@ -81,10 +81,10 @@ static void test_path(void) {
test_path_simplify("///.//", "/.", "/");
test_path_simplify("///.//.///", "/./.", "/");
test_path_simplify("////.././///../.", "/.././../.", "/../..");
test_path_simplify(".", ".", "");
test_path_simplify("./", ".", "");
test_path_simplify(".///.//./.", "./././.", "");
test_path_simplify(".///.//././/", "./././.", "");
test_path_simplify(".", ".", ".");
test_path_simplify("./", ".", ".");
test_path_simplify(".///.//./.", "./././.", ".");
test_path_simplify(".///.//././/", "./././.", ".");
test_path_simplify("//./aaa///.//./.bbb/..///c.//d.dd///..eeee/.",
"/./aaa/././.bbb/../c./d.dd/..eeee/.",
"/aaa/.bbb/../c./d.dd/..eeee");