Chromium Code Reviews| 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 "base/strings/string_util.h" | |
| 7 #include "tools/gn/err.h" | 8 #include "tools/gn/err.h" |
| 8 #include "tools/gn/filesystem_utils.h" | 9 #include "tools/gn/filesystem_utils.h" |
| 9 #include "tools/gn/value.h" | 10 #include "tools/gn/value.h" |
| 10 | 11 |
| 11 const char kLabelPattern_Help[] = | 12 const char kLabelPattern_Help[] = |
| 12 "Label patterns\n" | 13 "Label patterns\n" |
| 13 "\n" | 14 "\n" |
| 14 " A label pattern is a way of expressing one or more labels in a portion\n" | 15 " A label pattern is a way of expressing one or more labels in a portion\n" |
| 15 " of the source tree. They are not general regular expressions.\n" | 16 " of the source tree. They are not general regular expressions.\n" |
| 16 "\n" | 17 "\n" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 if (err->has_error()) | 115 if (err->has_error()) |
| 115 return LabelPattern(); | 116 return LabelPattern(); |
| 116 | 117 |
| 117 // Trim off the toolchain for the processing below. | 118 // Trim off the toolchain for the processing below. |
| 118 str = str.substr(0, open_paren); | 119 str = str.substr(0, open_paren); |
| 119 } | 120 } |
| 120 | 121 |
| 121 // Extract path and name. | 122 // Extract path and name. |
| 122 base::StringPiece path; | 123 base::StringPiece path; |
| 123 base::StringPiece name; | 124 base::StringPiece name; |
| 124 size_t colon = str.find(':'); | 125 size_t offset = 0; |
| 126 #if defined(OS_WIN) | |
| 127 if (IsPathAbsolute(str)) { | |
| 128 if (str[0] != '/') { | |
| 129 *err = Err(value, "Bad absolute path.", | |
| 130 "Absolute paths must be on the form /C:\\"); | |
|
brettw
2015/02/06 23:08:38
Ditto from previous file.
| |
| 131 return LabelPattern(); | |
| 132 } | |
| 133 if (str.size() > 3 && str[2] == ':' && IsSlash(str[3]) && | |
| 134 IsAsciiAlpha(str[1])) { | |
| 135 // Skip over the drive letter colon. | |
| 136 offset = 3; | |
| 137 } | |
| 138 } | |
| 139 #endif | |
| 140 size_t colon = str.find(':', offset); | |
| 125 if (colon == std::string::npos) { | 141 if (colon == std::string::npos) { |
| 126 path = base::StringPiece(str); | 142 path = base::StringPiece(str); |
| 127 } else { | 143 } else { |
| 128 path = str.substr(0, colon); | 144 path = str.substr(0, colon); |
| 129 name = str.substr(colon + 1); | 145 name = str.substr(colon + 1); |
| 130 } | 146 } |
| 131 | 147 |
| 132 // The path can have these forms: | 148 // The path can have these forms: |
| 133 // 1. <empty> (use current dir) | 149 // 1. <empty> (use current dir) |
| 134 // 2. <non wildcard stuff> (send through directory resolution) | 150 // 2. <non wildcard stuff> (send through directory resolution) |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 238 break; | 254 break; |
| 239 } | 255 } |
| 240 | 256 |
| 241 if (!toolchain_.is_null()) { | 257 if (!toolchain_.is_null()) { |
| 242 result.push_back('('); | 258 result.push_back('('); |
| 243 result.append(toolchain_.GetUserVisibleName(false)); | 259 result.append(toolchain_.GetUserVisibleName(false)); |
| 244 result.push_back(')'); | 260 result.push_back(')'); |
| 245 } | 261 } |
| 246 return result; | 262 return result; |
| 247 } | 263 } |
| OLD | NEW |