summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2012-08-17 07:26:01 (GMT)
committerEvan Martin <martine@danga.com>2012-08-17 07:26:01 (GMT)
commit413103c4c472410c10da179a841b5e3b05e576c0 (patch)
treed259ea30cba734d08bd2d58d75aa82110ae984ef /src
parent5fe8c1308cf1785b1903eb11cf32909df3be113b (diff)
parentee44a510f448d130948380bd26926d3b17f5f11d (diff)
downloadNinja-413103c4c472410c10da179a841b5e3b05e576c0.zip
Ninja-413103c4c472410c10da179a841b5e3b05e576c0.tar.gz
Ninja-413103c4c472410c10da179a841b5e3b05e576c0.tar.bz2
Merge pull request #401 from syntheticpp/win-network-path
on windows a network path starts with two backslashes
Diffstat (limited to 'src')
-rw-r--r--src/util.cc11
-rw-r--r--src/util_test.cc16
2 files changed, 27 insertions, 0 deletions
diff --git a/src/util.cc b/src/util.cc
index 14f6265..580f22a 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -110,8 +110,19 @@ bool CanonicalizePath(char* path, size_t* len, string* err) {
const char* end = start + *len;
if (*src == '/') {
+#ifdef _WIN32
+ // network path starts with //
+ if (*len > 1 && *(src + 1) == '/') {
+ src += 2;
+ dst += 2;
+ } else {
+ ++src;
+ ++dst;
+ }
+#else
++src;
++dst;
+#endif
}
while (src < end) {
diff --git a/src/util_test.cc b/src/util_test.cc
index 7a34671..4776546 100644
--- a/src/util_test.cc
+++ b/src/util_test.cc
@@ -66,6 +66,22 @@ TEST(CanonicalizePath, PathSamples) {
path = "foo/.hidden_bar";
EXPECT_TRUE(CanonicalizePath(&path, &err));
EXPECT_EQ("foo/.hidden_bar", path);
+
+ path = "/foo";
+ EXPECT_TRUE(CanonicalizePath(&path, &err));
+ EXPECT_EQ("/foo", path);
+
+ path = "//foo";
+ EXPECT_TRUE(CanonicalizePath(&path, &err));
+#ifdef _WIN32
+ EXPECT_EQ("//foo", path);
+#else
+ EXPECT_EQ("/foo", path);
+#endif
+
+ path = "/";
+ EXPECT_TRUE(CanonicalizePath(&path, &err));
+ EXPECT_EQ("", path);
}
TEST(CanonicalizePath, EmptyResult) {