From 33805cc811c722a0c5cd439cff419de252cd39c9 Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Thu, 27 Jul 2017 16:28:44 -0400 Subject: Remove single param Mid() method from string classes This support is being removed from CFX_ByteString, CFX_ByteStringC, CFX_WideString, and CFX_WideStringC. This standardizes all of these classes to only have one Mid method that takes in 2 params, offset and count. Count now must be positive. The old behaviour of calculating the length for the user if -1 is passed in for the count has been removed. This work is in preperation for converting these classes to not accept negative lengths anywhere and thus make the underlying size type unsigned. BUG=pdfium:828 Change-Id: I5f15e7b7b00b264231817f143e2da88ee6f69e7b Reviewed-on: https://pdfium-review.googlesource.com/9430 Reviewed-by: (OOO Jul 28 - Aug 8) dsinclair Reviewed-by: Tom Sepez Commit-Queue: Ryan Harrison --- core/fxcrt/cfx_bytestring.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'core/fxcrt/cfx_bytestring.cpp') diff --git a/core/fxcrt/cfx_bytestring.cpp b/core/fxcrt/cfx_bytestring.cpp index c88ad51ab3..e7e55de8e3 100644 --- a/core/fxcrt/cfx_bytestring.cpp +++ b/core/fxcrt/cfx_bytestring.cpp @@ -121,6 +121,7 @@ static_assert(sizeof(CFX_ByteString) <= sizeof(char*), "Strings must not require more space than pointers"); CFX_ByteString::CFX_ByteString(const char* pStr, FX_STRSIZE nLen) { + ASSERT(nLen >= 0); if (nLen < 0) nLen = pStr ? FXSYS_strlen(pStr) : 0; @@ -129,6 +130,7 @@ CFX_ByteString::CFX_ByteString(const char* pStr, FX_STRSIZE nLen) { } CFX_ByteString::CFX_ByteString(const uint8_t* pStr, FX_STRSIZE nLen) { + ASSERT(nLen >= 0); if (nLen > 0) { m_pData.Reset( StringData::Create(reinterpret_cast(pStr), nLen)); @@ -456,14 +458,8 @@ void CFX_ByteString::Concat(const char* pSrcData, FX_STRSIZE nSrcLen) { m_pData.Swap(pNewData); } -CFX_ByteString CFX_ByteString::Mid(FX_STRSIZE nFirst) const { - if (!m_pData) - return CFX_ByteString(); - - return Mid(nFirst, m_pData->m_nDataLength - nFirst); -} - CFX_ByteString CFX_ByteString::Mid(FX_STRSIZE nFirst, FX_STRSIZE nCount) const { + ASSERT(nCount >= 0); if (!m_pData) return CFX_ByteString(); -- cgit v1.2.3