Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(336)

Unified Diff: tools/gn/label_pattern.cc

Issue 857163002: Absolute path fixes for gn. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Improve error message Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/label.cc ('k') | tools/gn/label_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/label_pattern.cc
diff --git a/tools/gn/label_pattern.cc b/tools/gn/label_pattern.cc
index 396a9b73a9d4fc1f269d926496b2dda5d0a46e89..4b31174d946dfb2f64f8834f31e00b2b1dc3e1b5 100644
--- a/tools/gn/label_pattern.cc
+++ b/tools/gn/label_pattern.cc
@@ -4,6 +4,7 @@
#include "tools/gn/label_pattern.h"
+#include "base/strings/string_util.h"
#include "tools/gn/err.h"
#include "tools/gn/filesystem_utils.h"
#include "tools/gn/value.h"
@@ -121,7 +122,23 @@ LabelPattern LabelPattern::GetPattern(const SourceDir& current_dir,
// Extract path and name.
base::StringPiece path;
base::StringPiece name;
- size_t colon = str.find(':');
+ size_t offset = 0;
+#if defined(OS_WIN)
+ if (IsPathAbsolute(str)) {
+ if (str[0] != '/') {
+ *err = Err(value, "Bad absolute path.",
+ "Absolute paths must be of the form /C:\\ but this is \"" +
+ str.as_string() + "\".");
+ return LabelPattern();
+ }
+ if (str.size() > 3 && str[2] == ':' && IsSlash(str[3]) &&
+ IsAsciiAlpha(str[1])) {
+ // Skip over the drive letter colon.
+ offset = 3;
+ }
+ }
+#endif
+ size_t colon = str.find(':', offset);
if (colon == std::string::npos) {
path = base::StringPiece(str);
} else {
« no previous file with comments | « tools/gn/label.cc ('k') | tools/gn/label_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698