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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « tools/gn/label.cc ('k') | tools/gn/label_pattern_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "tools/gn/label_pattern.h" 5 #include "tools/gn/label_pattern.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 // Trim off the toolchain for the processing below. 123 // Trim off the toolchain for the processing below.
124 str = str.substr(0, open_paren); 124 str = str.substr(0, open_paren);
125 } 125 }
126 126
127 // Extract path and name. 127 // Extract path and name.
128 base::StringPiece path; 128 base::StringPiece path;
129 base::StringPiece name; 129 base::StringPiece name;
130 size_t offset = 0; 130 size_t offset = 0;
131 #if defined(OS_WIN) 131 #if defined(OS_WIN)
132 if (IsPathAbsolute(str)) { 132 if (IsPathAbsolute(str)) {
133 if (str[0] != '/') { 133 size_t drive_letter_pos = str[0] == '/' ? 1 : 0;
134 *err = Err(value, "Bad absolute path.", 134 if (str.size() > drive_letter_pos + 2 && str[drive_letter_pos + 1] == ':' &&
135 "Absolute paths must be of the form /C:\\ but this is \"" + 135 IsSlash(str[drive_letter_pos + 2]) &&
136 str.as_string() + "\"."); 136 base::IsAsciiAlpha(str[drive_letter_pos])) {
137 return LabelPattern();
138 }
139 if (str.size() > 3 && str[2] == ':' && IsSlash(str[3]) &&
140 base::IsAsciiAlpha(str[1])) {
141 // Skip over the drive letter colon. 137 // Skip over the drive letter colon.
142 offset = 3; 138 offset = drive_letter_pos + 2;
143 } 139 }
144 } 140 }
145 #endif 141 #endif
146 size_t colon = str.find(':', offset); 142 size_t colon = str.find(':', offset);
147 if (colon == std::string::npos) { 143 if (colon == std::string::npos) {
148 path = base::StringPiece(str); 144 path = base::StringPiece(str);
149 } else { 145 } else {
150 path = str.substr(0, colon); 146 path = str.substr(0, colon);
151 name = str.substr(colon + 1); 147 name = str.substr(colon + 1);
152 } 148 }
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 break; 258 break;
263 } 259 }
264 260
265 if (!toolchain_.is_null()) { 261 if (!toolchain_.is_null()) {
266 result.push_back('('); 262 result.push_back('(');
267 result.append(toolchain_.GetUserVisibleName(false)); 263 result.append(toolchain_.GetUserVisibleName(false));
268 result.push_back(')'); 264 result.push_back(')');
269 } 265 }
270 return result; 266 return result;
271 } 267 }
OLDNEW
« 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