Commit a22cb202 authored by Kenton Varda's avatar Kenton Varda

Fix bug handling absolute source paths with no --src-prefix -- just output to…

Fix bug handling absolute source paths with no --src-prefix -- just output to the same directory in this case.
parent 9bcbd1cd
...@@ -268,6 +268,11 @@ public: ...@@ -268,6 +268,11 @@ public:
// Strip redundant "./" prefixes to make src-prefix matching more lenient. // Strip redundant "./" prefixes to make src-prefix matching more lenient.
while (file.startsWith("./")) { while (file.startsWith("./")) {
file = file.slice(2); file = file.slice(2);
// Remove redundant slashes as well (e.g. ".////foo" -> "foo").
while (file.startsWith("/")) {
file = file.slice(1);
}
} }
if (!compilerConstructed) { if (!compilerConstructed) {
......
...@@ -1967,10 +1967,12 @@ private: ...@@ -1967,10 +1967,12 @@ private:
} }
void writeFile(kj::StringPtr filename, const kj::StringTree& text) { void writeFile(kj::StringPtr filename, const kj::StringTree& text) {
if (!filename.startsWith("/")) {
KJ_IF_MAYBE(slashpos, filename.findLast('/')) { KJ_IF_MAYBE(slashpos, filename.findLast('/')) {
// Make the parent dir. // Make the parent dir.
makeDirectory(kj::str(filename.slice(0, *slashpos))); makeDirectory(kj::str(filename.slice(0, *slashpos)));
} }
}
int fd; int fd;
KJ_SYSCALL(fd = open(filename.cStr(), O_CREAT | O_WRONLY | O_TRUNC, 0666), filename); KJ_SYSCALL(fd = open(filename.cStr(), O_CREAT | O_WRONLY | O_TRUNC, 0666), filename);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment