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

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

Issue 986113002: tools/gn: Convert for loops to use the new range-based loops in C++11. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review fixes Created 5 years, 9 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 | « no previous file | tools/gn/command_desc.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "base/files/file_path.h" 5 #include "base/files/file_path.h"
6 #include "base/files/file_util.h" 6 #include "base/files/file_util.h"
7 #include "base/strings/string_split.h" 7 #include "base/strings/string_split.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "tools/gn/commands.h" 9 #include "tools/gn/commands.h"
10 #include "tools/gn/err.h" 10 #include "tools/gn/err.h"
(...skipping 12 matching lines...) Expand all
23 std::string file_contents; 23 std::string file_contents;
24 if (!base::ReadFileToString(build_ninja_file, &file_contents)) { 24 if (!base::ReadFileToString(build_ninja_file, &file_contents)) {
25 return std::string(); 25 return std::string();
26 } 26 }
27 27
28 std::vector<std::string> lines; 28 std::vector<std::string> lines;
29 base::SplitStringDontTrim(file_contents, '\n', &lines); 29 base::SplitStringDontTrim(file_contents, '\n', &lines);
30 30
31 std::string result; 31 std::string result;
32 int num_blank_lines = 0; 32 int num_blank_lines = 0;
33 for (size_t i = 0; i < lines.size(); ++i) { 33 for (const auto& line : lines) {
34 result += lines[i]; 34 result += line;
35 result += "\n"; 35 result += "\n";
36 if (lines[i].empty()) { 36 if (line.empty()) {
37 ++num_blank_lines; 37 ++num_blank_lines;
38 } 38 }
39 if (num_blank_lines == 2) 39 if (num_blank_lines == 2)
40 break; 40 break;
41 } 41 }
42 42
43 return result; 43 return result;
44 } 44 }
45 45
46 const char kDefaultNinjaFile[] = 46 const char kDefaultNinjaFile[] =
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 static_cast<int>(dummy_content.size())) == -1) { 141 static_cast<int>(dummy_content.size())) == -1) {
142 Err(Location(), std::string("Failed to write build.ninja.d.")) 142 Err(Location(), std::string("Failed to write build.ninja.d."))
143 .PrintToStdout(); 143 .PrintToStdout();
144 return 1; 144 return 1;
145 } 145 }
146 146
147 return 0; 147 return 0;
148 } 148 }
149 149
150 } // namespace commands 150 } // namespace commands
OLDNEW
« no previous file with comments | « no previous file | tools/gn/command_desc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698