We frequently do use absolute paths when depfiles refer to
e.g. /usr/include/stdio.h.
string::size_type end = path->find('/', start);
if (end == string::npos)
end = path->size();
- if (end > start) {
+ if (end == 0 || end > start) {
if (parts_count == kMaxPathComponents) {
*err = "can't canonicalize path '" + *path + "'; too many "
"path components";
EXPECT_EQ("can't canonicalize path './x/../foo/../../bar.h' that reaches "
"above its directory", err);
}
+
+TEST(CanonicalizePath, AbsolutePath) {
+ string path = "/usr/include/stdio.h";
+ string err = "";
+ EXPECT_TRUE(CanonicalizePath(&path, &err));
+ EXPECT_EQ("", err);
+ EXPECT_EQ("/usr/include/stdio.h", path);
+}