OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "base/strings/string_util.h" | 5 #include "base/strings/string_util.h" |
6 | 6 |
7 #include <ctype.h> | 7 #include <ctype.h> |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <math.h> | 9 #include <math.h> |
10 #include <stdarg.h> | 10 #include <stdarg.h> |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 TrimPositions TrimWhitespaceASCII(const std::string& input, | 396 TrimPositions TrimWhitespaceASCII(const std::string& input, |
397 TrimPositions positions, | 397 TrimPositions positions, |
398 std::string* output) { | 398 std::string* output) { |
399 return TrimStringT(input, StringPiece(kWhitespaceASCII), positions, output); | 399 return TrimStringT(input, StringPiece(kWhitespaceASCII), positions, output); |
400 } | 400 } |
401 | 401 |
402 StringPiece TrimWhitespaceASCII(StringPiece input, TrimPositions positions) { | 402 StringPiece TrimWhitespaceASCII(StringPiece input, TrimPositions positions) { |
403 return TrimStringPieceT(input, StringPiece(kWhitespaceASCII), positions); | 403 return TrimStringPieceT(input, StringPiece(kWhitespaceASCII), positions); |
404 } | 404 } |
405 | 405 |
406 // This function is only for backward-compatibility. | |
407 // To be removed when all callers are updated. | |
408 TrimPositions TrimWhitespace(const std::string& input, | |
409 TrimPositions positions, | |
410 std::string* output) { | |
411 return TrimWhitespaceASCII(input, positions, output); | |
412 } | |
413 | |
414 template<typename STR> | 406 template<typename STR> |
415 STR CollapseWhitespaceT(const STR& text, | 407 STR CollapseWhitespaceT(const STR& text, |
416 bool trim_sequences_with_line_breaks) { | 408 bool trim_sequences_with_line_breaks) { |
417 STR result; | 409 STR result; |
418 result.resize(text.size()); | 410 result.resize(text.size()); |
419 | 411 |
420 // Set flags to pretend we're already in a trimmed whitespace sequence, so we | 412 // Set flags to pretend we're already in a trimmed whitespace sequence, so we |
421 // will trim any leading whitespace. | 413 // will trim any leading whitespace. |
422 bool in_whitespace = true; | 414 bool in_whitespace = true; |
423 bool already_trimmed = true; | 415 bool already_trimmed = true; |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 } // namespace | 989 } // namespace |
998 | 990 |
999 size_t strlcpy(char* dst, const char* src, size_t dst_size) { | 991 size_t strlcpy(char* dst, const char* src, size_t dst_size) { |
1000 return lcpyT<char>(dst, src, dst_size); | 992 return lcpyT<char>(dst, src, dst_size); |
1001 } | 993 } |
1002 size_t wcslcpy(wchar_t* dst, const wchar_t* src, size_t dst_size) { | 994 size_t wcslcpy(wchar_t* dst, const wchar_t* src, size_t dst_size) { |
1003 return lcpyT<wchar_t>(dst, src, dst_size); | 995 return lcpyT<wchar_t>(dst, src, dst_size); |
1004 } | 996 } |
1005 | 997 |
1006 } // namespace base | 998 } // namespace base |
OLD | NEW |