Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1654)

Side by Side Diff: core/src/fxcrt/fx_basic_wstring.cpp

Issue 1140093003: Merge to XFA: Fix comparison of CFX_ByteString and CFX_WideString. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 { 199 {
200 if (string.IsEmpty()) { 200 if (string.IsEmpty()) {
201 return *this; 201 return *this;
202 } 202 }
203 ConcatInPlace(string.GetLength(), string.GetPtr()); 203 ConcatInPlace(string.GetLength(), string.GetPtr());
204 return *this; 204 return *this;
205 } 205 }
206 bool CFX_WideString::Equal(const wchar_t* ptr) const 206 bool CFX_WideString::Equal(const wchar_t* ptr) const
207 { 207 {
208 if (!m_pData) { 208 if (!m_pData) {
209 return !ptr; 209 return !ptr || ptr[0] == L'\0';
210 } 210 }
211 if (!ptr) { 211 if (!ptr) {
212 return false; 212 return m_pData->m_nDataLength == 0;
213 } 213 }
214 return wcslen(ptr) == m_pData->m_nDataLength && 214 return wcslen(ptr) == m_pData->m_nDataLength &&
215 wmemcmp(ptr, m_pData->m_String, m_pData->m_nDataLength) == 0; 215 wmemcmp(ptr, m_pData->m_String, m_pData->m_nDataLength) == 0;
216 } 216 }
217 bool CFX_WideString::Equal(const CFX_WideStringC& str) const 217 bool CFX_WideString::Equal(const CFX_WideStringC& str) const
218 { 218 {
219 if (m_pData == NULL) { 219 if (m_pData == NULL) {
220 return str.IsEmpty(); 220 return str.IsEmpty();
221 } 221 }
222 return str.GetLength() == m_pData->m_nDataLength && 222 return str.GetLength() == m_pData->m_nDataLength &&
223 wmemcmp(str.GetPtr(), m_pData->m_String, m_pData->m_nDataLength) == 0; 223 wmemcmp(str.GetPtr(), m_pData->m_String, m_pData->m_nDataLength) == 0;
224 } 224 }
225 bool CFX_WideString::Equal(const CFX_WideString& other) const 225 bool CFX_WideString::Equal(const CFX_WideString& other) const
226 { 226 {
227 if (!m_pData) { 227 if (IsEmpty()) {
228 return other.IsEmpty(); 228 return other.IsEmpty();
229 } 229 }
230 if (!other.m_pData) { 230 if (other.IsEmpty()) {
231 return false; 231 return false;
232 } 232 }
233 return other.m_pData->m_nDataLength == m_pData->m_nDataLength && 233 return other.m_pData->m_nDataLength == m_pData->m_nDataLength &&
234 wmemcmp(other.m_pData->m_String, 234 wmemcmp(other.m_pData->m_String,
235 m_pData->m_String, 235 m_pData->m_String,
236 m_pData->m_nDataLength) == 0; 236 m_pData->m_nDataLength) == 0;
237 } 237 }
238 void CFX_WideString::Empty() 238 void CFX_WideString::Empty()
239 { 239 {
240 if (m_pData == NULL) { 240 if (m_pData == NULL) {
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 return (CFX_CharMap*)&g_DefaultJISMapper; 1105 return (CFX_CharMap*)&g_DefaultJISMapper;
1106 case 936: 1106 case 936:
1107 return (CFX_CharMap*)&g_DefaultGBKMapper; 1107 return (CFX_CharMap*)&g_DefaultGBKMapper;
1108 case 949: 1108 case 949:
1109 return (CFX_CharMap*)&g_DefaultUHCMapper; 1109 return (CFX_CharMap*)&g_DefaultUHCMapper;
1110 case 950: 1110 case 950:
1111 return (CFX_CharMap*)&g_DefaultBig5Mapper; 1111 return (CFX_CharMap*)&g_DefaultBig5Mapper;
1112 } 1112 }
1113 return NULL; 1113 return NULL;
1114 } 1114 }
OLDNEW
« no previous file with comments | « core/src/fxcrt/fx_basic_bstring_unittest.cpp ('k') | core/src/fxcrt/fx_basic_wstring_unittest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698