summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/fpdfapi/font/cpdf_cmap.cpp38
-rw-r--r--core/fxcrt/cfx_binarybuf.cpp3
-rw-r--r--core/fxcrt/cfx_seekablestreamproxy.cpp6
-rw-r--r--core/fxcrt/cfx_seekablestreamproxy.h2
4 files changed, 25 insertions, 24 deletions
diff --git a/core/fpdfapi/font/cpdf_cmap.cpp b/core/fpdfapi/font/cpdf_cmap.cpp
index 9e8c48bb27..659139f687 100644
--- a/core/fpdfapi/font/cpdf_cmap.cpp
+++ b/core/fpdfapi/font/cpdf_cmap.cpp
@@ -434,46 +434,46 @@ int CPDF_CMap::CountChar(const char* pString, int size) const {
int CPDF_CMap::AppendChar(char* str, uint32_t charcode) const {
switch (m_CodingScheme) {
case OneByte:
- str[0] = (uint8_t)charcode;
+ str[0] = static_cast<char>(charcode);
return 1;
case TwoBytes:
- str[0] = (uint8_t)(charcode / 256);
- str[1] = (uint8_t)(charcode % 256);
+ str[0] = static_cast<char>(charcode / 256);
+ str[1] = static_cast<char>(charcode % 256);
return 2;
case MixedTwoBytes:
- if (charcode < 0x100 && !m_MixedTwoByteLeadingBytes[(uint8_t)charcode]) {
- str[0] = (uint8_t)charcode;
+ if (charcode < 0x100 && !m_MixedTwoByteLeadingBytes[charcode]) {
+ str[0] = static_cast<char>(charcode);
return 1;
}
- str[0] = (uint8_t)(charcode >> 8);
- str[1] = (uint8_t)charcode;
+ str[0] = static_cast<char>(charcode >> 8);
+ str[1] = static_cast<char>(charcode);
return 2;
case MixedFourBytes:
if (charcode < 0x100) {
- int iSize =
- GetFourByteCharSizeImpl(charcode, m_MixedFourByteLeadingRanges);
+ int iSize = static_cast<int>(
+ GetFourByteCharSizeImpl(charcode, m_MixedFourByteLeadingRanges));
if (iSize == 0)
iSize = 1;
- str[iSize - 1] = (uint8_t)charcode;
+ str[iSize - 1] = static_cast<char>(charcode);
if (iSize > 1)
memset(str, 0, iSize - 1);
return iSize;
}
if (charcode < 0x10000) {
- str[0] = (uint8_t)(charcode >> 8);
- str[1] = (uint8_t)charcode;
+ str[0] = static_cast<char>(charcode >> 8);
+ str[1] = static_cast<char>(charcode);
return 2;
}
if (charcode < 0x1000000) {
- str[0] = (uint8_t)(charcode >> 16);
- str[1] = (uint8_t)(charcode >> 8);
- str[2] = (uint8_t)charcode;
+ str[0] = static_cast<char>(charcode >> 16);
+ str[1] = static_cast<char>(charcode >> 8);
+ str[2] = static_cast<char>(charcode);
return 3;
}
- str[0] = (uint8_t)(charcode >> 24);
- str[1] = (uint8_t)(charcode >> 16);
- str[2] = (uint8_t)(charcode >> 8);
- str[3] = (uint8_t)charcode;
+ str[0] = static_cast<char>(charcode >> 24);
+ str[1] = static_cast<char>(charcode >> 16);
+ str[2] = static_cast<char>(charcode >> 8);
+ str[3] = static_cast<char>(charcode);
return 4;
}
return 0;
diff --git a/core/fxcrt/cfx_binarybuf.cpp b/core/fxcrt/cfx_binarybuf.cpp
index a1388b8d32..6c67912d3b 100644
--- a/core/fxcrt/cfx_binarybuf.cpp
+++ b/core/fxcrt/cfx_binarybuf.cpp
@@ -51,7 +51,8 @@ void CFX_BinaryBuf::ExpandBuf(FX_STRSIZE add_size) {
if (m_AllocSize >= new_size.ValueOrDie())
return;
- int alloc_step = std::max(128, m_AllocStep ? m_AllocStep : m_AllocSize / 4);
+ FX_STRSIZE alloc_step = std::max(static_cast<FX_STRSIZE>(128),
+ m_AllocStep ? m_AllocStep : m_AllocSize / 4);
new_size += alloc_step - 1; // Quantize, don't combine these lines.
new_size /= alloc_step;
new_size *= alloc_step;
diff --git a/core/fxcrt/cfx_seekablestreamproxy.cpp b/core/fxcrt/cfx_seekablestreamproxy.cpp
index da1170717a..a67ec52c85 100644
--- a/core/fxcrt/cfx_seekablestreamproxy.cpp
+++ b/core/fxcrt/cfx_seekablestreamproxy.cpp
@@ -230,15 +230,15 @@ FX_STRSIZE CFX_SeekableStreamProxy::ReadData(uint8_t* pBuffer,
FX_STRSIZE CFX_SeekableStreamProxy::ReadString(wchar_t* pStr,
FX_STRSIZE iMaxLength,
bool* bEOS) {
- ASSERT(pStr);
- ASSERT(iMaxLength > 0);
+ if (!pStr || iMaxLength <= 0)
+ return 0;
if (m_IsWriteStream)
return 0;
if (m_wCodePage == FX_CODEPAGE_UTF16LE ||
m_wCodePage == FX_CODEPAGE_UTF16BE) {
- FX_FILESIZE iBytes = iMaxLength * 2;
+ FX_STRSIZE iBytes = iMaxLength * 2;
FX_STRSIZE iLen = ReadData(reinterpret_cast<uint8_t*>(pStr), iBytes);
iMaxLength = iLen / 2;
if (sizeof(wchar_t) > 2 && iMaxLength > 0)
diff --git a/core/fxcrt/cfx_seekablestreamproxy.h b/core/fxcrt/cfx_seekablestreamproxy.h
index 1a8e6f2f3b..0e427fc79b 100644
--- a/core/fxcrt/cfx_seekablestreamproxy.h
+++ b/core/fxcrt/cfx_seekablestreamproxy.h
@@ -25,7 +25,7 @@ class CFX_SeekableStreamProxy : public CFX_Retainable {
FX_FILESIZE GetLength() const { return m_pStream->GetSize(); }
FX_FILESIZE GetPosition() { return m_iPosition; }
- FX_STRSIZE GetBOMLength() const { return std::max(0, m_wBOMLength); }
+ FX_STRSIZE GetBOMLength() const { return m_wBOMLength; }
bool IsEOF() const { return m_iPosition >= GetLength(); }
void Seek(From eSeek, FX_FILESIZE iOffset);