OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |