OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium 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 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cctype> | 10 #include <cctype> |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 return haystack; | 52 return haystack; |
53 } | 53 } |
54 } | 54 } |
55 haystack++; | 55 haystack++; |
56 } | 56 } |
57 return nullptr; | 57 return nullptr; |
58 } | 58 } |
59 | 59 |
60 } // namespace | 60 } // namespace |
61 | 61 |
| 62 static_assert(sizeof(CFX_WideString) <= sizeof(FX_WCHAR*), |
| 63 "Strings must not require more space than pointers"); |
| 64 |
62 CFX_WideString::CFX_WideString(const FX_WCHAR* pStr, FX_STRSIZE nLen) { | 65 CFX_WideString::CFX_WideString(const FX_WCHAR* pStr, FX_STRSIZE nLen) { |
63 if (nLen < 0) | 66 if (nLen < 0) |
64 nLen = pStr ? FXSYS_wcslen(pStr) : 0; | 67 nLen = pStr ? FXSYS_wcslen(pStr) : 0; |
65 | 68 |
66 if (nLen) | 69 if (nLen) |
67 m_pData.Reset(StringData::Create(pStr, nLen)); | 70 m_pData.Reset(StringData::Create(pStr, nLen)); |
68 } | 71 } |
69 | 72 |
70 CFX_WideString::CFX_WideString(FX_WCHAR ch) { | 73 CFX_WideString::CFX_WideString(FX_WCHAR ch) { |
71 m_pData.Reset(StringData::Create(1)); | 74 m_pData.Reset(StringData::Create(1)); |
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
983 FXSYS_MultiByteToWideChar(codepage, 0, bstr.c_str(), src_len, nullptr, 0); | 986 FXSYS_MultiByteToWideChar(codepage, 0, bstr.c_str(), src_len, nullptr, 0); |
984 CFX_WideString wstr; | 987 CFX_WideString wstr; |
985 if (dest_len) { | 988 if (dest_len) { |
986 FX_WCHAR* dest_buf = wstr.GetBuffer(dest_len); | 989 FX_WCHAR* dest_buf = wstr.GetBuffer(dest_len); |
987 FXSYS_MultiByteToWideChar(codepage, 0, bstr.c_str(), src_len, dest_buf, | 990 FXSYS_MultiByteToWideChar(codepage, 0, bstr.c_str(), src_len, dest_buf, |
988 dest_len); | 991 dest_len); |
989 wstr.ReleaseBuffer(dest_len); | 992 wstr.ReleaseBuffer(dest_len); |
990 } | 993 } |
991 return wstr; | 994 return wstr; |
992 } | 995 } |
OLD | NEW |