summaryrefslogtreecommitdiff
path: root/core/fxcrt/cfx_seekablestreamproxy.cpp
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2017-09-27 10:53:11 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-09-27 16:11:38 +0000
commit875e98c581952478f3a3ccef9b2f2e3ed06c5346 (patch)
tree8e0d7e032056bf4c73d6da43c0f3ce4eadb74dfd /core/fxcrt/cfx_seekablestreamproxy.cpp
parentcc3a3ee3ebcc1baabdfa7ffca5876dbbfa3980c1 (diff)
downloadpdfium-875e98c581952478f3a3ccef9b2f2e3ed06c5346.tar.xz
Remove FX_STRSIZE and replace with size_t
BUG=pdfium:828 Change-Id: I5c40237433ebabaeabdb43aec9cdf783e41dfe16 Reviewed-on: https://pdfium-review.googlesource.com/13230 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'core/fxcrt/cfx_seekablestreamproxy.cpp')
-rw-r--r--core/fxcrt/cfx_seekablestreamproxy.cpp45
1 files changed, 22 insertions, 23 deletions
diff --git a/core/fxcrt/cfx_seekablestreamproxy.cpp b/core/fxcrt/cfx_seekablestreamproxy.cpp
index 3c0b5d5aef..f2590ecfd6 100644
--- a/core/fxcrt/cfx_seekablestreamproxy.cpp
+++ b/core/fxcrt/cfx_seekablestreamproxy.cpp
@@ -25,10 +25,10 @@
namespace {
// Returns {src bytes consumed, dst bytes produced}.
-std::pair<FX_STRSIZE, FX_STRSIZE> UTF8Decode(const char* pSrc,
- FX_STRSIZE srcLen,
- wchar_t* pDst,
- FX_STRSIZE dstLen) {
+std::pair<size_t, size_t> UTF8Decode(const char* pSrc,
+ size_t srcLen,
+ wchar_t* pDst,
+ size_t dstLen) {
ASSERT(pDst && dstLen > 0);
if (srcLen < 1)
@@ -36,9 +36,9 @@ std::pair<FX_STRSIZE, FX_STRSIZE> UTF8Decode(const char* pSrc,
uint32_t dwCode = 0;
int32_t iPending = 0;
- FX_STRSIZE iSrcNum = 0;
- FX_STRSIZE iDstNum = 0;
- FX_STRSIZE iIndex = 0;
+ size_t iSrcNum = 0;
+ size_t iDstNum = 0;
+ size_t iIndex = 0;
int32_t k = 1;
while (iIndex < srcLen) {
uint8_t byte = static_cast<uint8_t>(*(pSrc + iIndex));
@@ -91,18 +91,18 @@ std::pair<FX_STRSIZE, FX_STRSIZE> UTF8Decode(const char* pSrc,
return {iSrcNum, iDstNum};
}
-void UTF16ToWChar(void* pBuffer, FX_STRSIZE iLength) {
+void UTF16ToWChar(void* pBuffer, size_t iLength) {
ASSERT(pBuffer);
ASSERT(iLength > 0);
ASSERT(sizeof(wchar_t) > 2);
uint16_t* pSrc = static_cast<uint16_t*>(pBuffer);
wchar_t* pDst = static_cast<wchar_t*>(pBuffer);
- for (FX_STRSIZE i = 0; i < iLength; i++)
+ for (size_t i = 0; i < iLength; i++)
pDst[i] = static_cast<wchar_t>(pSrc[i]);
}
-void SwapByteOrder(wchar_t* pStr, FX_STRSIZE iLength) {
+void SwapByteOrder(wchar_t* pStr, size_t iLength) {
ASSERT(pStr);
uint16_t wch;
@@ -174,7 +174,7 @@ CFX_SeekableStreamProxy::CFX_SeekableStreamProxy(
Seek(From::Begin, static_cast<FX_FILESIZE>(m_wBOMLength));
}
-CFX_SeekableStreamProxy::CFX_SeekableStreamProxy(uint8_t* data, FX_STRSIZE size)
+CFX_SeekableStreamProxy::CFX_SeekableStreamProxy(uint8_t* data, size_t size)
: CFX_SeekableStreamProxy(
pdfium::MakeRetain<CFX_MemoryStream>(data, size, false),
false) {}
@@ -203,15 +203,14 @@ void CFX_SeekableStreamProxy::SetCodePage(uint16_t wCodePage) {
m_wCodePage = wCodePage;
}
-FX_STRSIZE CFX_SeekableStreamProxy::ReadData(uint8_t* pBuffer,
- FX_STRSIZE iBufferSize) {
+size_t CFX_SeekableStreamProxy::ReadData(uint8_t* pBuffer, size_t iBufferSize) {
ASSERT(pBuffer && iBufferSize > 0);
if (m_IsWriteStream)
return 0;
iBufferSize =
- std::min(iBufferSize, static_cast<FX_STRSIZE>(GetLength() - m_iPosition));
+ std::min(iBufferSize, static_cast<size_t>(GetLength() - m_iPosition));
if (iBufferSize <= 0)
return 0;
@@ -224,9 +223,9 @@ FX_STRSIZE CFX_SeekableStreamProxy::ReadData(uint8_t* pBuffer,
return new_pos.IsValid() ? iBufferSize : 0;
}
-FX_STRSIZE CFX_SeekableStreamProxy::ReadString(wchar_t* pStr,
- FX_STRSIZE iMaxLength,
- bool* bEOS) {
+size_t CFX_SeekableStreamProxy::ReadString(wchar_t* pStr,
+ size_t iMaxLength,
+ bool* bEOS) {
if (!pStr || iMaxLength == 0)
return 0;
@@ -235,8 +234,8 @@ FX_STRSIZE CFX_SeekableStreamProxy::ReadString(wchar_t* pStr,
if (m_wCodePage == FX_CODEPAGE_UTF16LE ||
m_wCodePage == FX_CODEPAGE_UTF16BE) {
- FX_STRSIZE iBytes = iMaxLength * 2;
- FX_STRSIZE iLen = ReadData(reinterpret_cast<uint8_t*>(pStr), iBytes);
+ size_t iBytes = iMaxLength * 2;
+ size_t iLen = ReadData(reinterpret_cast<uint8_t*>(pStr), iBytes);
iMaxLength = iLen / 2;
if (sizeof(wchar_t) > 2 && iMaxLength > 0)
UTF16ToWChar(pStr, iMaxLength);
@@ -246,17 +245,17 @@ FX_STRSIZE CFX_SeekableStreamProxy::ReadString(wchar_t* pStr,
} else {
FX_FILESIZE pos = GetPosition();
- FX_STRSIZE iBytes =
- std::min(iMaxLength, static_cast<FX_STRSIZE>(GetLength() - pos));
+ size_t iBytes =
+ std::min(iMaxLength, static_cast<size_t>(GetLength() - pos));
if (iBytes > 0) {
std::vector<uint8_t> buf(iBytes);
- FX_STRSIZE iLen = ReadData(buf.data(), iBytes);
+ size_t iLen = ReadData(buf.data(), iBytes);
if (m_wCodePage != FX_CODEPAGE_UTF8)
return 0;
- FX_STRSIZE iSrc = 0;
+ size_t iSrc = 0;
std::tie(iSrc, iMaxLength) = UTF8Decode(
reinterpret_cast<const char*>(buf.data()), iLen, pStr, iMaxLength);
Seek(From::Current, iSrc - iLen);