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

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

Issue 1869503004: Convert //tools to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, change iwyu fixes for converted directories to include <memory> Created 4 years, 8 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/setup.cc ('k') | tools/gn/string_utils_unittest.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/string_utils.h" 5 #include "tools/gn/string_utils.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <cctype> 8 #include <cctype>
9 9
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 // The error will point into our temporary buffer, rewrite it to refer 74 // The error will point into our temporary buffer, rewrite it to refer
75 // to the original token. This will make the location information less 75 // to the original token. This will make the location information less
76 // precise, but generally there won't be complicated things in string 76 // precise, but generally there won't be complicated things in string
77 // interpolations. 77 // interpolations.
78 *err = ErrInsideStringToken(token, begin_offset, end_offset - begin_offset, 78 *err = ErrInsideStringToken(token, begin_offset, end_offset - begin_offset,
79 err->message(), err->help_text()); 79 err->message(), err->help_text());
80 return false; 80 return false;
81 } 81 }
82 82
83 // Parse. 83 // Parse.
84 scoped_ptr<ParseNode> node = Parser::ParseExpression(tokens, err); 84 std::unique_ptr<ParseNode> node = Parser::ParseExpression(tokens, err);
85 if (err->has_error()) { 85 if (err->has_error()) {
86 // Rewrite error as above. 86 // Rewrite error as above.
87 *err = ErrInsideStringToken(token, begin_offset, end_offset - begin_offset, 87 *err = ErrInsideStringToken(token, begin_offset, end_offset - begin_offset,
88 err->message(), err->help_text()); 88 err->message(), err->help_text());
89 return false; 89 return false;
90 } 90 }
91 if (!(node->AsIdentifier() || node->AsAccessor())) { 91 if (!(node->AsIdentifier() || node->AsAccessor())) {
92 *err = ErrInsideStringToken(token, begin_offset, end_offset - begin_offset, 92 *err = ErrInsideStringToken(token, begin_offset, end_offset - begin_offset,
93 "Invalid string interpolation.", 93 "Invalid string interpolation.",
94 "The thing inside the ${} must be an identifier ${foo},\n" 94 "The thing inside the ${} must be an identifier ${foo},\n"
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 base::StringPiece result; 336 base::StringPiece result;
337 for (base::StringPiece word : words) { 337 for (base::StringPiece word : words) {
338 size_t distance = EditDistance(word, text, kMaxValidEditDistance); 338 size_t distance = EditDistance(word, text, kMaxValidEditDistance);
339 if (distance < min_distance) { 339 if (distance < min_distance) {
340 min_distance = distance; 340 min_distance = distance;
341 result = word; 341 result = word;
342 } 342 }
343 } 343 }
344 return result; 344 return result;
345 } 345 }
OLDNEW
« no previous file with comments | « tools/gn/setup.cc ('k') | tools/gn/string_utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698