summaryrefslogtreecommitdiff
path: root/core/src/fxcrt/fx_basic_bstring.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-05-04 14:03:25 -0700
committerTom Sepez <tsepez@chromium.org>2015-05-04 14:03:25 -0700
commit447e2beb38d5bd8b71b1ddc3df448559dbd588af (patch)
tree77f07888919dedcb9c4a9e4709bb88746ba61768 /core/src/fxcrt/fx_basic_bstring.cpp
parente09556b4e9049a6e46789d31da5eb0c203dd8580 (diff)
downloadpdfium-447e2beb38d5bd8b71b1ddc3df448559dbd588af.tar.xz
Fix issuse with != and == shown by fx_basic_bstring unit tests.
R=thestig@chromium.org Review URL: https://codereview.chromium.org/1125703004
Diffstat (limited to 'core/src/fxcrt/fx_basic_bstring.cpp')
-rw-r--r--core/src/fxcrt/fx_basic_bstring.cpp29
1 files changed, 21 insertions, 8 deletions
diff --git a/core/src/fxcrt/fx_basic_bstring.cpp b/core/src/fxcrt/fx_basic_bstring.cpp
index 9cf084c2fb..f18ae0825c 100644
--- a/core/src/fxcrt/fx_basic_bstring.cpp
+++ b/core/src/fxcrt/fx_basic_bstring.cpp
@@ -251,24 +251,37 @@ const CFX_ByteString& CFX_ByteString::operator+=(FX_BSTR string)
ConcatInPlace(string.GetLength(), string.GetCStr());
return *this;
}
-bool CFX_ByteString::Equal(FX_BSTR str) const
+bool CFX_ByteString::Equal(const char* ptr) const
+{
+ if (!m_pData) {
+ return !ptr;
+ }
+ if (!ptr) {
+ return false;
+ }
+ return strlen(ptr) == m_pData->m_nDataLength &&
+ FXSYS_memcmp32(ptr, m_pData->m_String, m_pData->m_nDataLength) == 0;
+}
+bool CFX_ByteString::Equal(const CFX_ByteStringC& str) const
{
if (m_pData == NULL) {
return str.IsEmpty();
}
return m_pData->m_nDataLength == str.GetLength() &&
- FXSYS_memcmp32(m_pData->m_String, str.GetCStr(), str.GetLength()) == 0;
+ FXSYS_memcmp32(m_pData->m_String, str.GetCStr(), str.GetLength()) == 0;
}
-bool CFX_ByteString::operator ==(const CFX_ByteString& s2) const
+bool CFX_ByteString::Equal(const CFX_ByteString& other) const
{
- if (m_pData == NULL) {
- return s2.IsEmpty();
+ if (!m_pData) {
+ return other.IsEmpty();
}
- if (s2.m_pData == NULL) {
+ if (!other.m_pData) {
return false;
}
- return m_pData->m_nDataLength == s2.m_pData->m_nDataLength &&
- FXSYS_memcmp32(m_pData->m_String, s2.m_pData->m_String, m_pData->m_nDataLength) == 0;
+ return other.m_pData->m_nDataLength == m_pData->m_nDataLength &&
+ FXSYS_memcmp32(other.m_pData->m_String,
+ m_pData->m_String,
+ m_pData->m_nDataLength) == 0;
}
void CFX_ByteString::Empty()
{