| 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> // For offsetof(). | 7 #include <stddef.h> // For offsetof(). |
| 8 | 8 |
| 9 #include "../../include/fxcrt/fx_basic.h" | 9 #include "../../include/fxcrt/fx_basic.h" |
| 10 #include "../../../third_party/base/numerics/safe_math.h" | 10 #include "../../../third_party/base/numerics/safe_math.h" |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 return *this; | 198 return *this; |
| 199 } | 199 } |
| 200 const CFX_WideString& CFX_WideString::operator+=(const CFX_WideStringC& string) | 200 const CFX_WideString& CFX_WideString::operator+=(const CFX_WideStringC& string) |
| 201 { | 201 { |
| 202 if (string.IsEmpty()) { | 202 if (string.IsEmpty()) { |
| 203 return *this; | 203 return *this; |
| 204 } | 204 } |
| 205 ConcatInPlace(string.GetLength(), string.GetPtr()); | 205 ConcatInPlace(string.GetLength(), string.GetPtr()); |
| 206 return *this; | 206 return *this; |
| 207 } | 207 } |
| 208 bool operator==(const CFX_WideString& s1, FX_LPCWSTR s2) | 208 bool CFX_WideString::Equal(const wchar_t* ptr) const |
| 209 { | 209 { |
| 210 return s1.Equal(s2); | 210 if (!m_pData) { |
| 211 } | 211 return !ptr; |
| 212 bool operator==(FX_LPCWSTR s1, const CFX_WideString& s2) | 212 } |
| 213 { | 213 if (!ptr) { |
| 214 return s2.Equal(s1); | 214 return false; |
| 215 } | 215 } |
| 216 bool operator==(const CFX_WideString& s1, const CFX_WideString& s2) | 216 return wcslen(ptr) == m_pData->m_nDataLength && |
| 217 { | 217 wmemcmp(ptr, m_pData->m_String, m_pData->m_nDataLength) == 0; |
| 218 return s1.Equal(s2); | |
| 219 } | |
| 220 bool operator==(const CFX_WideString& s1, const CFX_WideStringC& s2) | |
| 221 { | |
| 222 return s1.Equal(s2); | |
| 223 } | |
| 224 bool operator==(const CFX_WideStringC& s1, const CFX_WideString& s2) | |
| 225 { | |
| 226 return s2.Equal(s1); | |
| 227 } | |
| 228 bool operator != (const CFX_WideString& s1, FX_LPCWSTR s2) | |
| 229 { | |
| 230 return !s1.Equal(s2); | |
| 231 } | |
| 232 bool operator!=(const CFX_WideString& s1, const CFX_WideString& s2) | |
| 233 { | |
| 234 return !s1.Equal(s2); | |
| 235 } | |
| 236 bool operator!=(const CFX_WideString& s1, const CFX_WideStringC& s2) | |
| 237 { | |
| 238 return !s1.Equal(s2); | |
| 239 } | |
| 240 bool operator!=(const CFX_WideStringC& s1, const CFX_WideString& s2) | |
| 241 { | |
| 242 return !s2.Equal(s1); | |
| 243 } | 218 } |
| 244 bool CFX_WideString::Equal(const CFX_WideStringC& str) const | 219 bool CFX_WideString::Equal(const CFX_WideStringC& str) const |
| 245 { | 220 { |
| 246 if (m_pData == NULL) { | 221 if (m_pData == NULL) { |
| 247 return str.IsEmpty(); | 222 return str.IsEmpty(); |
| 248 } | 223 } |
| 249 return str.GetLength() == m_pData->m_nDataLength && | 224 return str.GetLength() == m_pData->m_nDataLength && |
| 250 FXSYS_memcmp32(str.GetPtr(), m_pData->m_String, m_pData->m_nDataLengt
h * sizeof(FX_WCHAR)) == 0; | 225 wmemcmp(str.GetPtr(), m_pData->m_String, m_pData->m_nDataLength) == 0; |
| 226 } |
| 227 bool CFX_WideString::Equal(const CFX_WideString& other) const |
| 228 { |
| 229 if (!m_pData) { |
| 230 return other.IsEmpty(); |
| 231 } |
| 232 if (!other.m_pData) { |
| 233 return false; |
| 234 } |
| 235 return other.m_pData->m_nDataLength == m_pData->m_nDataLength && |
| 236 wmemcmp(other.m_pData->m_String, |
| 237 m_pData->m_String, |
| 238 m_pData->m_nDataLength) == 0; |
| 251 } | 239 } |
| 252 void CFX_WideString::Empty() | 240 void CFX_WideString::Empty() |
| 253 { | 241 { |
| 254 if (m_pData == NULL) { | 242 if (m_pData == NULL) { |
| 255 return; | 243 return; |
| 256 } | 244 } |
| 257 if (m_pData->m_nRefs > 1) { | 245 if (m_pData->m_nRefs > 1) { |
| 258 m_pData->m_nRefs --; | 246 m_pData->m_nRefs --; |
| 259 } else { | 247 } else { |
| 260 FX_Free(m_pData); | 248 FX_Free(m_pData); |
| (...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1119 return (CFX_CharMap*)&g_DefaultJISMapper; | 1107 return (CFX_CharMap*)&g_DefaultJISMapper; |
| 1120 case 936: | 1108 case 936: |
| 1121 return (CFX_CharMap*)&g_DefaultGBKMapper; | 1109 return (CFX_CharMap*)&g_DefaultGBKMapper; |
| 1122 case 949: | 1110 case 949: |
| 1123 return (CFX_CharMap*)&g_DefaultUHCMapper; | 1111 return (CFX_CharMap*)&g_DefaultUHCMapper; |
| 1124 case 950: | 1112 case 950: |
| 1125 return (CFX_CharMap*)&g_DefaultBig5Mapper; | 1113 return (CFX_CharMap*)&g_DefaultBig5Mapper; |
| 1126 } | 1114 } |
| 1127 return NULL; | 1115 return NULL; |
| 1128 } | 1116 } |
| OLD | NEW |