diff options
author | Scott Graham <scottmg@chromium.org> | 2014-11-08 19:25:03 (GMT) |
---|---|---|
committer | Scott Graham <scottmg@chromium.org> | 2014-11-08 19:25:03 (GMT) |
commit | 3fb18496c4c2642742df152974d78756d1c9df8a (patch) | |
tree | 6cbce5b10eea5543e43d967b67b4ca79e190ff8c | |
parent | aacfd606f463bc3a7c2cc92d961dbded7979051c (diff) | |
download | Ninja-3fb18496c4c2642742df152974d78756d1c9df8a.zip Ninja-3fb18496c4c2642742df152974d78756d1c9df8a.tar.gz Ninja-3fb18496c4c2642742df152974d78756d1c9df8a.tar.bz2 |
fix multiple sequential slashes
-rw-r--r-- | src/manifest_parser_test.cc | 4 | ||||
-rw-r--r-- | src/util.cc | 2 | ||||
-rw-r--r-- | src/util_test.cc | 15 |
3 files changed, 18 insertions, 3 deletions
diff --git a/src/manifest_parser_test.cc b/src/manifest_parser_test.cc index 1998a77..0668668 100644 --- a/src/manifest_parser_test.cc +++ b/src/manifest_parser_test.cc @@ -319,7 +319,7 @@ TEST_F(ParserTest, CanonicalizePathsBackslashes) { " command = cat $in > $out\n" "build ./out.o: cat ./bar/baz/../foo.cc\n" "build .\\out2.o: cat .\\bar/baz\\..\\foo.cc\n" -"build .\\out3.o: cat .\\bar/baz\\..\\foo3.cc\n" +"build .\\out3.o: cat .\\bar\\baz\\..\\foo3.cc\n" )); EXPECT_FALSE(state.LookupNode("./out.o")); @@ -336,7 +336,7 @@ TEST_F(ParserTest, CanonicalizePathsBackslashes) { EXPECT_EQ(0, node->slash_bits()); node = state.LookupNode("bar/foo3.cc"); EXPECT_TRUE(node); - EXPECT_EQ(1, node->slash_bits()); // First seen determines slashes. + EXPECT_EQ(1, node->slash_bits()); } #endif diff --git a/src/util.cc b/src/util.cc index 6a9079e..9cf736e 100644 --- a/src/util.cc +++ b/src/util.cc @@ -194,7 +194,7 @@ bool CanonicalizePath(char* path, size_t* len, string* err, if (*src == '/') { src++; - bits_offset++; + bits = ShiftOverBit(bits_offset, bits); continue; } diff --git a/src/util_test.cc b/src/util_test.cc index 36f212e..d047d9c 100644 --- a/src/util_test.cc +++ b/src/util_test.cc @@ -218,6 +218,21 @@ TEST(CanonicalizePath, SlashTracking) { EXPECT_TRUE(CanonicalizePath(&path, &err, &slash_bits)); EXPECT_EQ("a/g/foo.h", path); EXPECT_EQ(1, slash_bits); + + path = "a\\\\\\foo.h"; + EXPECT_TRUE(CanonicalizePath(&path, &err, &slash_bits)); + EXPECT_EQ("a/foo.h", path); + EXPECT_EQ(1, slash_bits); + + path = "a/\\\\foo.h"; + EXPECT_TRUE(CanonicalizePath(&path, &err, &slash_bits)); + EXPECT_EQ("a/foo.h", path); + EXPECT_EQ(0, slash_bits); + + path = "a\\//foo.h"; + EXPECT_TRUE(CanonicalizePath(&path, &err, &slash_bits)); + EXPECT_EQ("a/foo.h", path); + EXPECT_EQ(1, slash_bits); } #endif |