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

Unified Diff: tools/gn/label_pattern.cc

Issue 1742303002: Accept absolute Windows paths without leading slash in GN commands (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Format files with 'git cl format' to make presubmit script happy Created 4 years, 8 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_pattern_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 e107ba41f2decfdc7f70f1852566033c7af27661..a330b3b66649c032c306dc06a5a3551149d75f88 100644
--- a/tools/gn/label_pattern.cc
+++ b/tools/gn/label_pattern.cc
@@ -130,16 +130,12 @@ LabelPattern LabelPattern::GetPattern(const SourceDir& current_dir,
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]) &&
- base::IsAsciiAlpha(str[1])) {
+ size_t drive_letter_pos = str[0] == '/' ? 1 : 0;
+ if (str.size() > drive_letter_pos + 2 && str[drive_letter_pos + 1] == ':' &&
+ IsSlash(str[drive_letter_pos + 2]) &&
+ base::IsAsciiAlpha(str[drive_letter_pos])) {
// Skip over the drive letter colon.
- offset = 3;
+ offset = drive_letter_pos + 2;
}
}
#endif
« no previous file with comments | « tools/gn/label.cc ('k') | tools/gn/label_pattern_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698