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

Side by Side Diff: tools/gn/input_conversion.cc

Issue 1284833004: Remove remaining legacy SplitString calls. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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/command_refs.cc ('k') | tools/gn/runtime_deps.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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/input_conversion.h" 5 #include "tools/gn/input_conversion.h"
6 6
7 #include "base/strings/string_split.h" 7 #include "base/strings/string_split.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "tools/gn/build_settings.h" 9 #include "tools/gn/build_settings.h"
10 #include "tools/gn/err.h" 10 #include "tools/gn/err.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 // we made, rather than the result of running the block (which will be empty). 80 // we made, rather than the result of running the block (which will be empty).
81 if (what == PARSE_SCOPE) { 81 if (what == PARSE_SCOPE) {
82 DCHECK(result.type() == Value::NONE); 82 DCHECK(result.type() == Value::NONE);
83 result = Value(origin, scope.Pass()); 83 result = Value(origin, scope.Pass());
84 } 84 }
85 return result; 85 return result;
86 } 86 }
87 87
88 Value ParseList(const std::string& input, const ParseNode* origin, Err* err) { 88 Value ParseList(const std::string& input, const ParseNode* origin, Err* err) {
89 Value ret(origin, Value::LIST); 89 Value ret(origin, Value::LIST);
90 std::vector<std::string> as_lines; 90 std::vector<std::string> as_lines = base::SplitString(
91 base::SplitString(input, '\n', &as_lines); 91 input, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
92 92
93 // Trim one empty line from the end since the last line might end in a 93 // Trim one empty line from the end since the last line might end in a
94 // newline. If the user wants more trimming, they'll specify "trim" in the 94 // newline. If the user wants more trimming, they'll specify "trim" in the
95 // input conversion options. 95 // input conversion options.
96 if (!as_lines.empty() && as_lines[as_lines.size() - 1].empty()) 96 if (!as_lines.empty() && as_lines[as_lines.size() - 1].empty())
97 as_lines.resize(as_lines.size() - 1); 97 as_lines.resize(as_lines.size() - 1);
98 98
99 ret.list_value().reserve(as_lines.size()); 99 ret.list_value().reserve(as_lines.size());
100 for (const auto& line : as_lines) 100 for (const auto& line : as_lines)
101 ret.list_value().push_back(Value(origin, line)); 101 ret.list_value().push_back(Value(origin, line));
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 const ParseNode* origin, 201 const ParseNode* origin,
202 const Value& input_conversion_value, 202 const Value& input_conversion_value,
203 Err* err) { 203 Err* err) {
204 if (input_conversion_value.type() == Value::NONE) 204 if (input_conversion_value.type() == Value::NONE)
205 return Value(); // Allow null inputs to mean discard the result. 205 return Value(); // Allow null inputs to mean discard the result.
206 if (!input_conversion_value.VerifyTypeIs(Value::STRING, err)) 206 if (!input_conversion_value.VerifyTypeIs(Value::STRING, err))
207 return Value(); 207 return Value();
208 return DoConvertInputToValue(settings, input, origin, input_conversion_value, 208 return DoConvertInputToValue(settings, input, origin, input_conversion_value,
209 input_conversion_value.string_value(), err); 209 input_conversion_value.string_value(), err);
210 } 210 }
OLDNEW
« no previous file with comments | « tools/gn/command_refs.cc ('k') | tools/gn/runtime_deps.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698