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

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

Issue 1125703004: Fix issuse with != and == shown by fx_basic_bstring unit tests. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Tidy, avoid typedefs to improve transparency. 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
« no previous file with comments | « core/include/fxcrt/fx_string.h ('k') | core/src/fxcrt/fx_basic_bstring_unittest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 return *this; 244 return *this;
245 } 245 }
246 const CFX_ByteString& CFX_ByteString::operator+=(FX_BSTR string) 246 const CFX_ByteString& CFX_ByteString::operator+=(FX_BSTR string)
247 { 247 {
248 if (string.IsEmpty()) { 248 if (string.IsEmpty()) {
249 return *this; 249 return *this;
250 } 250 }
251 ConcatInPlace(string.GetLength(), string.GetCStr()); 251 ConcatInPlace(string.GetLength(), string.GetCStr());
252 return *this; 252 return *this;
253 } 253 }
254 bool CFX_ByteString::Equal(FX_BSTR str) const 254 bool CFX_ByteString::Equal(const char* ptr) const
255 {
256 if (!m_pData) {
257 return !ptr;
258 }
259 if (!ptr) {
260 return false;
261 }
262 return strlen(ptr) == m_pData->m_nDataLength &&
263 FXSYS_memcmp32(ptr, m_pData->m_String, m_pData->m_nDataLength) == 0;
264 }
265 bool CFX_ByteString::Equal(const CFX_ByteStringC& str) const
255 { 266 {
256 if (m_pData == NULL) { 267 if (m_pData == NULL) {
257 return str.IsEmpty(); 268 return str.IsEmpty();
258 } 269 }
259 return m_pData->m_nDataLength == str.GetLength() && 270 return m_pData->m_nDataLength == str.GetLength() &&
260 FXSYS_memcmp32(m_pData->m_String, str.GetCStr(), str.GetLength()) == 0; 271 FXSYS_memcmp32(m_pData->m_String, str.GetCStr(), str.GetLength()) == 0;
261 } 272 }
262 bool CFX_ByteString::operator ==(const CFX_ByteString& s2) const 273 bool CFX_ByteString::Equal(const CFX_ByteString& other) const
263 { 274 {
264 if (m_pData == NULL) { 275 if (!m_pData) {
265 return s2.IsEmpty(); 276 return other.IsEmpty();
266 } 277 }
267 if (s2.m_pData == NULL) { 278 if (!other.m_pData) {
268 return false; 279 return false;
269 } 280 }
270 return m_pData->m_nDataLength == s2.m_pData->m_nDataLength && 281 return other.m_pData->m_nDataLength == m_pData->m_nDataLength &&
271 FXSYS_memcmp32(m_pData->m_String, s2.m_pData->m_String, m_pData->m_nD ataLength) == 0; 282 FXSYS_memcmp32(other.m_pData->m_String,
283 m_pData->m_String,
284 m_pData->m_nDataLength) == 0;
272 } 285 }
273 void CFX_ByteString::Empty() 286 void CFX_ByteString::Empty()
274 { 287 {
275 if (m_pData == NULL) { 288 if (m_pData == NULL) {
276 return; 289 return;
277 } 290 }
278 if (m_pData->m_nRefs > 1) { 291 if (m_pData->m_nRefs > 1) {
279 m_pData->m_nRefs --; 292 m_pData->m_nRefs --;
280 } else { 293 } else {
281 FX_Free(m_pData); 294 FX_Free(m_pData);
(...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after
1137 scale /= 10; 1150 scale /= 10;
1138 } 1151 }
1139 return buf_size; 1152 return buf_size;
1140 } 1153 }
1141 CFX_ByteString CFX_ByteString::FormatFloat(FX_FLOAT d, int precision) 1154 CFX_ByteString CFX_ByteString::FormatFloat(FX_FLOAT d, int precision)
1142 { 1155 {
1143 FX_CHAR buf[32]; 1156 FX_CHAR buf[32];
1144 FX_STRSIZE len = FX_ftoa(d, buf); 1157 FX_STRSIZE len = FX_ftoa(d, buf);
1145 return CFX_ByteString(buf, len); 1158 return CFX_ByteString(buf, len);
1146 } 1159 }
OLDNEW
« no previous file with comments | « core/include/fxcrt/fx_string.h ('k') | core/src/fxcrt/fx_basic_bstring_unittest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698