From aeffe1056f9ff6526d87a16ef55222899f5528f7 Mon Sep 17 00:00:00 2001 From: "ted.mielczarek@gmail.com" Date: Wed, 6 Mar 2013 14:04:42 +0000 Subject: Use stdint types everywhere R=mark at https://breakpad.appspot.com/535002/ git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1121 4c0a9323-5329-0410-9bdc-e9ce6186880e --- src/common/string_conversion.cc | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'src/common/string_conversion.cc') diff --git a/src/common/string_conversion.cc b/src/common/string_conversion.cc index 444ac817..c4107faf 100644 --- a/src/common/string_conversion.cc +++ b/src/common/string_conversion.cc @@ -38,15 +38,15 @@ namespace google_breakpad { using std::vector; -void UTF8ToUTF16(const char *in, vector *out) { +void UTF8ToUTF16(const char *in, vector *out) { size_t source_length = strlen(in); const UTF8 *source_ptr = reinterpret_cast(in); const UTF8 *source_end_ptr = source_ptr + source_length; // Erase the contents and zero fill to the expected size out->clear(); out->insert(out->begin(), source_length, 0); - u_int16_t *target_ptr = &(*out)[0]; - u_int16_t *target_end_ptr = target_ptr + out->capacity() * sizeof(u_int16_t); + uint16_t *target_ptr = &(*out)[0]; + uint16_t *target_end_ptr = target_ptr + out->capacity() * sizeof(uint16_t); ConversionResult result = ConvertUTF8toUTF16(&source_ptr, source_end_ptr, &target_ptr, target_end_ptr, strictConversion); @@ -55,11 +55,11 @@ void UTF8ToUTF16(const char *in, vector *out) { out->resize(result == conversionOK ? target_ptr - &(*out)[0] + 1: 0); } -int UTF8ToUTF16Char(const char *in, int in_length, u_int16_t out[2]) { +int UTF8ToUTF16Char(const char *in, int in_length, uint16_t out[2]) { const UTF8 *source_ptr = reinterpret_cast(in); const UTF8 *source_end_ptr = source_ptr + sizeof(char); - u_int16_t *target_ptr = out; - u_int16_t *target_end_ptr = target_ptr + 2 * sizeof(u_int16_t); + uint16_t *target_ptr = out; + uint16_t *target_end_ptr = target_ptr + 2 * sizeof(uint16_t); out[0] = out[1] = 0; // Process one character at a time @@ -82,15 +82,15 @@ int UTF8ToUTF16Char(const char *in, int in_length, u_int16_t out[2]) { return 0; } -void UTF32ToUTF16(const wchar_t *in, vector *out) { +void UTF32ToUTF16(const wchar_t *in, vector *out) { size_t source_length = wcslen(in); const UTF32 *source_ptr = reinterpret_cast(in); const UTF32 *source_end_ptr = source_ptr + source_length; // Erase the contents and zero fill to the expected size out->clear(); out->insert(out->begin(), source_length, 0); - u_int16_t *target_ptr = &(*out)[0]; - u_int16_t *target_end_ptr = target_ptr + out->capacity() * sizeof(u_int16_t); + uint16_t *target_ptr = &(*out)[0]; + uint16_t *target_end_ptr = target_ptr + out->capacity() * sizeof(uint16_t); ConversionResult result = ConvertUTF32toUTF16(&source_ptr, source_end_ptr, &target_ptr, target_end_ptr, strictConversion); @@ -99,11 +99,11 @@ void UTF32ToUTF16(const wchar_t *in, vector *out) { out->resize(result == conversionOK ? target_ptr - &(*out)[0] + 1: 0); } -void UTF32ToUTF16Char(wchar_t in, u_int16_t out[2]) { +void UTF32ToUTF16Char(wchar_t in, uint16_t out[2]) { const UTF32 *source_ptr = reinterpret_cast(&in); const UTF32 *source_end_ptr = source_ptr + 1; - u_int16_t *target_ptr = out; - u_int16_t *target_end_ptr = target_ptr + 2 * sizeof(u_int16_t); + uint16_t *target_ptr = out; + uint16_t *target_end_ptr = target_ptr + 2 * sizeof(uint16_t); out[0] = out[1] = 0; ConversionResult result = ConvertUTF32toUTF16(&source_ptr, source_end_ptr, &target_ptr, target_end_ptr, @@ -114,20 +114,20 @@ void UTF32ToUTF16Char(wchar_t in, u_int16_t out[2]) { } } -static inline u_int16_t Swap(u_int16_t value) { - return (value >> 8) | static_cast(value << 8); +static inline uint16_t Swap(uint16_t value) { + return (value >> 8) | static_cast(value << 8); } -string UTF16ToUTF8(const vector &in, bool swap) { +string UTF16ToUTF8(const vector &in, bool swap) { const UTF16 *source_ptr = &in[0]; - scoped_ptr source_buffer; + scoped_ptr source_buffer; // If we're to swap, we need to make a local copy and swap each byte pair if (swap) { int idx = 0; - source_buffer.reset(new u_int16_t[in.size()]); + source_buffer.reset(new uint16_t[in.size()]); UTF16 *source_buffer_ptr = source_buffer.get(); - for (vector::const_iterator it = in.begin(); + for (vector::const_iterator it = in.begin(); it != in.end(); ++it, ++idx) source_buffer_ptr[idx] = Swap(*it); -- cgit v1.2.1