| Index: base/strings/string_util.cc
|
| diff --git a/base/strings/string_util.cc b/base/strings/string_util.cc
|
| index 72b8500633fe4fc2593f0cfa01790eb8a4760d4a..39cc6f5f063efcb4ba5792e2e79e193b7ba482c2 100644
|
| --- a/base/strings/string_util.cc
|
| +++ b/base/strings/string_util.cc
|
| @@ -8,6 +8,7 @@
|
| #include <errno.h>
|
| #include <math.h>
|
| #include <stdarg.h>
|
| +#include <stdint.h>
|
| #include <stdio.h>
|
| #include <stdlib.h>
|
| #include <string.h>
|
| @@ -16,9 +17,9 @@
|
| #include <wctype.h>
|
|
|
| #include <algorithm>
|
| +#include <limits>
|
| #include <vector>
|
|
|
| -#include "base/basictypes.h"
|
| #include "base/logging.h"
|
| #include "base/memory/singleton.h"
|
| #include "base/strings/string_split.h"
|
| @@ -354,10 +355,11 @@ void TruncateUTF8ToByteSize(const std::string& input,
|
| *output = input;
|
| return;
|
| }
|
| - DCHECK_LE(byte_size, static_cast<uint32>(kint32max));
|
| - // Note: This cast is necessary because CBU8_NEXT uses int32s.
|
| - int32 truncation_length = static_cast<int32>(byte_size);
|
| - int32 char_index = truncation_length - 1;
|
| + DCHECK_LE(byte_size,
|
| + static_cast<uint32_t>(std::numeric_limits<int32_t>::max()));
|
| + // Note: This cast is necessary because CBU8_NEXT uses int32_ts.
|
| + int32_t truncation_length = static_cast<int32_t>(byte_size);
|
| + int32_t char_index = truncation_length - 1;
|
| const char* data = input.data();
|
|
|
| // Using CBU8, we will move backwards from the truncation point
|
| @@ -365,7 +367,7 @@ void TruncateUTF8ToByteSize(const std::string& input,
|
| // character. Once a full UTF8 character is found, we will
|
| // truncate the string to the end of that character.
|
| while (char_index >= 0) {
|
| - int32 prev = char_index;
|
| + int32_t prev = char_index;
|
| base_icu::UChar32 code_point = 0;
|
| CBU8_NEXT(data, char_index, truncation_length, code_point);
|
| if (!IsValidCharacter(code_point) ||
|
| @@ -515,11 +517,11 @@ bool IsStringASCII(const std::wstring& str) {
|
|
|
| bool IsStringUTF8(const StringPiece& str) {
|
| const char *src = str.data();
|
| - int32 src_len = static_cast<int32>(str.length());
|
| - int32 char_index = 0;
|
| + int32_t src_len = static_cast<int32_t>(str.length());
|
| + int32_t char_index = 0;
|
|
|
| while (char_index < src_len) {
|
| - int32 code_point;
|
| + int32_t code_point;
|
| CBU8_NEXT(src, char_index, src_len, code_point);
|
| if (!IsValidCharacter(code_point))
|
| return false;
|
| @@ -672,7 +674,7 @@ static const char* const kByteStringsUnlocalized[] = {
|
| " PB"
|
| };
|
|
|
| -string16 FormatBytesUnlocalized(int64 bytes) {
|
| +string16 FormatBytesUnlocalized(int64_t bytes) {
|
| double unit_amount = static_cast<double>(bytes);
|
| size_t dimension = 0;
|
| const int kKilo = 1024;
|
|
|