OLD | NEW |
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/err.h" | 5 #include "tools/gn/err.h" |
6 | 6 |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "tools/gn/filesystem_utils.h" | 9 #include "tools/gn/filesystem_utils.h" |
10 #include "tools/gn/input_file.h" | 10 #include "tools/gn/input_file.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 // Watch out, the char offsets in the location are 1-based, so we have to | 34 // Watch out, the char offsets in the location are 1-based, so we have to |
35 // subtract 1. | 35 // subtract 1. |
36 int begin_char; | 36 int begin_char; |
37 if (range.begin().line_number() < line_number) | 37 if (range.begin().line_number() < line_number) |
38 begin_char = 0; | 38 begin_char = 0; |
39 else | 39 else |
40 begin_char = range.begin().char_offset() - 1; | 40 begin_char = range.begin().char_offset() - 1; |
41 | 41 |
42 int end_char; | 42 int end_char; |
43 if (range.end().line_number() > line_number) | 43 if (range.end().line_number() > line_number) |
44 end_char = line->size(); // Ending is non-inclusive. | 44 end_char = static_cast<int>(line->size()); // Ending is non-inclusive. |
45 else | 45 else |
46 end_char = range.end().char_offset() - 1; | 46 end_char = range.end().char_offset() - 1; |
47 | 47 |
48 CHECK(end_char >= begin_char); | 48 CHECK(end_char >= begin_char); |
49 CHECK(begin_char >= 0 && begin_char <= static_cast<int>(line->size())); | 49 CHECK(begin_char >= 0 && begin_char <= static_cast<int>(line->size())); |
50 CHECK(end_char >= 0 && end_char <= static_cast<int>(line->size())); | 50 CHECK(end_char >= 0 && end_char <= static_cast<int>(line->size())); |
51 for (int i = begin_char; i < end_char; i++) | 51 for (int i = begin_char; i < end_char; i++) |
52 line->at(i) = '-'; | 52 line->at(i) = '-'; |
53 } | 53 } |
54 | 54 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 } | 182 } |
183 | 183 |
184 // Optional help text. | 184 // Optional help text. |
185 if (!help_text_.empty()) | 185 if (!help_text_.empty()) |
186 OutputString(help_text_ + "\n"); | 186 OutputString(help_text_ + "\n"); |
187 | 187 |
188 // Sub errors. | 188 // Sub errors. |
189 for (size_t i = 0; i < sub_errs_.size(); i++) | 189 for (size_t i = 0; i < sub_errs_.size(); i++) |
190 sub_errs_[i].InternalPrintToStdout(true); | 190 sub_errs_[i].InternalPrintToStdout(true); |
191 } | 191 } |
OLD | NEW |