Index: tools/gn/source_file.cc |
diff --git a/tools/gn/source_file.cc b/tools/gn/source_file.cc |
index b3eb560bac5b93d8a8f411c60aab7d99174ba8a7..71d8592c1aac614b26b7c919283f369c83217624 100644 |
--- a/tools/gn/source_file.cc |
+++ b/tools/gn/source_file.cc |
@@ -9,21 +9,33 @@ |
#include "tools/gn/filesystem_utils.h" |
#include "tools/gn/source_dir.h" |
+namespace { |
+ |
+void AssertValueSourceFileString(const std::string& s) { |
+#if defined(OS_WIN) |
+ DCHECK(s[0] == '/' || |
+ (s.size() > 2 && s[0] != '/' && s[1] == ':' && IsSlash(s[2]))); |
+#else |
+ DCHECK(s[0] == '/'); |
+#endif |
+ DCHECK(!EndsWithSlash(s)); |
+} |
+ |
+} // namespace |
+ |
SourceFile::SourceFile() { |
} |
SourceFile::SourceFile(const base::StringPiece& p) |
: value_(p.data(), p.size()) { |
DCHECK(!value_.empty()); |
- DCHECK(value_[0] == '/'); |
- DCHECK(!EndsWithSlash(value_)); |
+ AssertValueSourceFileString(value_); |
} |
SourceFile::SourceFile(SwapIn, std::string* value) { |
value_.swap(*value); |
DCHECK(!value_.empty()); |
- DCHECK(value_[0] == '/'); |
- DCHECK(!EndsWithSlash(value_)); |
+ AssertValueSourceFileString(value_); |
} |
SourceFile::~SourceFile() { |