summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2017-08-29 16:39:44 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-08-30 14:35:33 +0000
commitaa3a9cd82df9dff1ef136797259e606a39c18b75 (patch)
tree5ca71f96fa289c5f13d22b371341882b77c7331f
parent980a3ea30872cef9ada360aa85e7c3573d7668b5 (diff)
downloadpdfium-aa3a9cd82df9dff1ef136797259e606a39c18b75.tar.xz
Convert int* references to FX_STRSIZE
Through out the code base there are numerous places where variables are declared using a signed integer type when interacting with the string classes, since they assume that FX_STRSIZE is 'int'. As part of changing the underling type of FX_STRSIZE to be unsigned, these locations are being changed to use FX_STRSIZE. This is necessary as part of converting the type, but has been broken off into a separate CL, since it should be low risk. Some related cleanups that are low risk are included as part of this CL. BUG=pdfium:828 Change-Id: Ifaae54ad195ccde0fe8672f71271d29a6ebd65fd Reviewed-on: https://pdfium-review.googlesource.com/12210 Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
-rw-r--r--core/fpdfapi/font/cpdf_cmap.cpp4
-rw-r--r--core/fpdfapi/font/cpdf_cmap.h2
-rw-r--r--core/fpdfapi/font/cpdf_cmapparser.cpp17
-rw-r--r--core/fpdfapi/page/cpdf_image.cpp2
-rw-r--r--core/fpdfapi/page/cpdf_streamparser.cpp10
-rw-r--r--core/fpdfdoc/cpdf_interform.cpp2
-rw-r--r--core/fpdftext/cpdf_linkextract.cpp12
-rw-r--r--core/fpdftext/cpdf_textpage.cpp8
-rw-r--r--core/fxcrt/cfx_bytestring.cpp2
-rw-r--r--core/fxcrt/cfx_chariter.cpp7
-rw-r--r--core/fxcrt/cfx_seekablestreamproxy.cpp4
-rw-r--r--core/fxcrt/cfx_string_data_template.h6
-rw-r--r--core/fxcrt/fx_basic.h2
-rw-r--r--core/fxcrt/fx_basic_buffer.cpp2
-rw-r--r--core/fxcrt/fx_basic_util.cpp2
-rw-r--r--fpdfsdk/fpdfppo.cpp21
-rw-r--r--fpdfsdk/javascript/Document.cpp2
-rw-r--r--fpdfsdk/javascript/PublicMethods.cpp8
-rw-r--r--fxbarcode/oned/BC_OneDimWriter.cpp6
-rw-r--r--fxbarcode/oned/BC_OneDimWriter.h2
-rw-r--r--fxbarcode/oned/BC_OnedCodaBarWriter.cpp4
-rw-r--r--fxbarcode/oned/BC_OnedCode128Writer.cpp11
-rw-r--r--fxbarcode/oned/BC_OnedCode39Writer.cpp39
-rw-r--r--fxbarcode/oned/BC_OnedEAN13Writer.cpp11
-rw-r--r--fxbarcode/oned/BC_OnedEAN8Writer.cpp14
-rw-r--r--fxbarcode/oned/BC_OnedUPCAWriter.cpp6
-rw-r--r--fxbarcode/qrcode/BC_QRCoderEncoder.cpp8
-rw-r--r--xfa/fde/cfde_textout.cpp2
-rw-r--r--xfa/fxfa/cxfa_pdffontmgr.cpp2
-rw-r--r--xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp28
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp2
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.cpp9
32 files changed, 125 insertions, 132 deletions
diff --git a/core/fpdfapi/font/cpdf_cmap.cpp b/core/fpdfapi/font/cpdf_cmap.cpp
index 55f5ccc5c5..7b88346d64 100644
--- a/core/fpdfapi/font/cpdf_cmap.cpp
+++ b/core/fpdfapi/font/cpdf_cmap.cpp
@@ -182,7 +182,7 @@ const PredefinedCMap g_PredefinedCMaps[] = {
};
int CheckFourByteCodeRange(uint8_t* codes,
- int size,
+ FX_STRSIZE size,
const std::vector<CPDF_CMap::CodeRange>& ranges) {
int iSeg = pdfium::CollectionSize<int>(ranges) - 1;
while (iSeg >= 0) {
@@ -216,7 +216,7 @@ int GetFourByteCharSizeImpl(uint32_t charcode,
codes[0] = codes[1] = 0x00;
codes[2] = (uint8_t)(charcode >> 8 & 0xFF);
codes[3] = (uint8_t)charcode;
- int offset = 0;
+ FX_STRSIZE offset = 0;
int size = 4;
for (int i = 0; i < 4; ++i) {
int iSeg = pdfium::CollectionSize<int>(ranges) - 1;
diff --git a/core/fpdfapi/font/cpdf_cmap.h b/core/fpdfapi/font/cpdf_cmap.h
index ab495efbfc..b47b12d531 100644
--- a/core/fpdfapi/font/cpdf_cmap.h
+++ b/core/fpdfapi/font/cpdf_cmap.h
@@ -37,7 +37,7 @@ class CPDF_CMap : public CFX_Retainable {
};
struct CodeRange {
- int m_CharSize;
+ FX_STRSIZE m_CharSize;
uint8_t m_Lower[4];
uint8_t m_Upper[4];
};
diff --git a/core/fpdfapi/font/cpdf_cmapparser.cpp b/core/fpdfapi/font/cpdf_cmapparser.cpp
index 272f8deb34..101ae5f0c8 100644
--- a/core/fpdfapi/font/cpdf_cmapparser.cpp
+++ b/core/fpdfapi/font/cpdf_cmapparser.cpp
@@ -141,7 +141,8 @@ uint32_t CPDF_CMapParser::CMap_GetCode(const CFX_ByteStringC& word) {
return 0;
pdfium::base::CheckedNumeric<uint32_t> num = 0;
if (word[0] == '<') {
- for (int i = 1; i < word.GetLength() && std::isxdigit(word[i]); ++i) {
+ for (FX_STRSIZE i = 1; i < word.GetLength() && std::isxdigit(word[i]);
+ ++i) {
num = num * 16 + FXSYS_HexCharToInt(word[i]);
if (!num.IsValid())
return 0;
@@ -149,7 +150,7 @@ uint32_t CPDF_CMapParser::CMap_GetCode(const CFX_ByteStringC& word) {
return num.ValueOrDie();
}
- for (int i = 0; i < word.GetLength() && std::isdigit(word[i]); ++i) {
+ for (FX_STRSIZE i = 0; i < word.GetLength() && std::isdigit(word[i]); ++i) {
num = num * 10 + FXSYS_DecimalCharToInt(static_cast<wchar_t>(word[i]));
if (!num.IsValid())
return 0;
@@ -164,7 +165,7 @@ bool CPDF_CMapParser::CMap_GetCodeRange(CPDF_CMap::CodeRange& range,
if (first.GetLength() == 0 || first[0] != '<')
return false;
- int i;
+ FX_STRSIZE i;
for (i = 1; i < first.GetLength(); ++i) {
if (first[i] == '>') {
break;
@@ -181,14 +182,10 @@ bool CPDF_CMapParser::CMap_GetCodeRange(CPDF_CMap::CodeRange& range,
FXSYS_HexCharToInt(digit1) * 16 + FXSYS_HexCharToInt(digit2);
}
- uint32_t size = second.GetLength();
+ FX_STRSIZE size = second.GetLength();
for (i = 0; i < range.m_CharSize; ++i) {
- uint8_t digit1 = ((uint32_t)i * 2 + 1 < size)
- ? second[static_cast<FX_STRSIZE>(i * 2 + 1)]
- : '0';
- uint8_t digit2 = ((uint32_t)i * 2 + 2 < size)
- ? second[static_cast<FX_STRSIZE>(i * 2 + 2)]
- : '0';
+ uint8_t digit1 = (i * 2 + 1 < size) ? second[i * 2 + 1] : '0';
+ uint8_t digit2 = (i * 2 + 2 < size) ? second[i * 2 + 2] : '0';
range.m_Upper[i] =
FXSYS_HexCharToInt(digit1) * 16 + FXSYS_HexCharToInt(digit2);
}
diff --git a/core/fpdfapi/page/cpdf_image.cpp b/core/fpdfapi/page/cpdf_image.cpp
index efdd66b442..2c3f13e9c2 100644
--- a/core/fpdfapi/page/cpdf_image.cpp
+++ b/core/fpdfapi/page/cpdf_image.cpp
@@ -257,7 +257,7 @@ void CPDF_Image::SetImage(const CFX_RetainPtr<CFX_DIBitmap>& pBitmap) {
int32_t maskWidth = pMaskBitmap->GetWidth();
int32_t maskHeight = pMaskBitmap->GetHeight();
std::unique_ptr<uint8_t, FxFreeDeleter> mask_buf;
- FX_STRSIZE mask_size = 0;
+ int32_t mask_size = 0;
auto pMaskDict =
pdfium::MakeUnique<CPDF_Dictionary>(m_pDocument->GetByteStringPool());
pMaskDict->SetNewFor<CPDF_Name>("Type", "XObject");
diff --git a/core/fpdfapi/page/cpdf_streamparser.cpp b/core/fpdfapi/page/cpdf_streamparser.cpp
index 9d7dd1ed55..f745331818 100644
--- a/core/fpdfapi/page/cpdf_streamparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamparser.cpp
@@ -478,9 +478,9 @@ CFX_ByteString CPDF_StreamParser::ReadString() {
case 0:
if (ch == ')') {
if (parlevel == 0) {
- return CFX_ByteString(
- buf.str().c_str(),
- std::min(static_cast<int>(buf.tellp()), kMaxStringLength));
+ return CFX_ByteString(buf.str().c_str(),
+ std::min(static_cast<FX_STRSIZE>(buf.tellp()),
+ kMaxStringLength));
}
parlevel--;
buf << ')';
@@ -557,7 +557,7 @@ CFX_ByteString CPDF_StreamParser::ReadString() {
return CFX_ByteString(
buf.str().c_str(),
- std::min(static_cast<int>(buf.tellp()), kMaxStringLength));
+ std::min(static_cast<FX_STRSIZE>(buf.tellp()), kMaxStringLength));
}
CFX_ByteString CPDF_StreamParser::ReadHexString() {
@@ -590,7 +590,7 @@ CFX_ByteString CPDF_StreamParser::ReadHexString() {
return CFX_ByteString(
buf.str().c_str(),
- std::min(static_cast<int>(buf.tellp()), kMaxStringLength));
+ std::min(static_cast<FX_STRSIZE>(buf.tellp()), kMaxStringLength));
}
bool CPDF_StreamParser::PositionIsInBounds() const {
diff --git a/core/fpdfdoc/cpdf_interform.cpp b/core/fpdfdoc/cpdf_interform.cpp
index 9c3730ad70..7e73f7e5a5 100644
--- a/core/fpdfdoc/cpdf_interform.cpp
+++ b/core/fpdfdoc/cpdf_interform.cpp
@@ -377,7 +377,7 @@ int CompareFieldName(const CFX_WideString& name1, const CFX_WideString& name2) {
if (name1.GetLength() == name2.GetLength())
return name1 == name2 ? 1 : 0;
- int i = 0;
+ FX_STRSIZE i = 0;
while (ptr1[i] == ptr2[i])
i++;
if (i == name1.GetLength())
diff --git a/core/fpdftext/cpdf_linkextract.cpp b/core/fpdftext/cpdf_linkextract.cpp
index cfa9dbba7f..880a4ceb92 100644
--- a/core/fpdftext/cpdf_linkextract.cpp
+++ b/core/fpdftext/cpdf_linkextract.cpp
@@ -244,8 +244,8 @@ bool CPDF_LinkExtract::CheckMailLink(CFX_WideString* str) {
return false;
// Check the local part.
- int pPos = aPos.value(); // Used to track the position of '@' or '.'.
- for (int i = aPos.value() - 1; i >= 0; i--) {
+ FX_STRSIZE pPos = aPos.value(); // Used to track the position of '@' or '.'.
+ for (FX_STRSIZE i = aPos.value() - 1; i >= 0; i--) {
wchar_t ch = (*str)[i];
if (ch == L'_' || ch == L'-' || FXSYS_iswalnum(ch))
continue;
@@ -257,7 +257,7 @@ bool CPDF_LinkExtract::CheckMailLink(CFX_WideString* str) {
}
// End extracting for other invalid chars, '.' at the beginning, or
// consecutive '.'.
- int removed_len = i == pPos - 1 ? i + 2 : i + 1;
+ FX_STRSIZE removed_len = i == pPos - 1 ? i + 2 : i + 1;
*str = str->Right(str->GetLength() - removed_len);
break;
}
@@ -279,16 +279,16 @@ bool CPDF_LinkExtract::CheckMailLink(CFX_WideString* str) {
return false;
// Validate all other chars in domain name.
- int nLen = str->GetLength();
+ FX_STRSIZE nLen = str->GetLength();
pPos = 0; // Used to track the position of '.'.
- for (int i = aPos.value() + 1; i < nLen; i++) {
+ for (FX_STRSIZE i = aPos.value() + 1; i < nLen; i++) {
wchar_t wch = (*str)[i];
if (wch == L'-' || FXSYS_iswalnum(wch))
continue;
if (wch != L'.' || i == pPos + 1) {
// Domain name should end before invalid char.
- int host_end = i == pPos + 1 ? i - 2 : i - 1;
+ FX_STRSIZE host_end = i == pPos + 1 ? i - 2 : i - 1;
if (pPos > 0 && host_end - aPos.value() >= 3) {
// Trim the ending invalid chars if there is at least one '.' and name.
*str = str->Left(host_end + 1);
diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp
index 223b59f4e8..ffc3729af4 100644
--- a/core/fpdftext/cpdf_textpage.cpp
+++ b/core/fpdftext/cpdf_textpage.cpp
@@ -649,7 +649,7 @@ void CPDF_TextPage::AddCharInfoByLRDirection(wchar_t wChar,
if (nCount >= 1) {
pDst = FX_Alloc(wchar_t, nCount);
Unicode_GetNormalization(wChar, pDst);
- for (int nIndex = 0; nIndex < nCount; nIndex++) {
+ for (FX_STRSIZE nIndex = 0; nIndex < nCount; nIndex++) {
PAGECHAR_INFO info2 = info;
info2.m_Unicode = pDst[nIndex];
info2.m_Flag = FPDFTEXT_CHAR_PIECE;
@@ -679,7 +679,7 @@ void CPDF_TextPage::AddCharInfoByRLDirection(wchar_t wChar,
if (nCount >= 1) {
pDst = FX_Alloc(wchar_t, nCount);
Unicode_GetNormalization(wChar, pDst);
- for (int nIndex = 0; nIndex < nCount; nIndex++) {
+ for (FX_STRSIZE nIndex = 0; nIndex < nCount; nIndex++) {
PAGECHAR_INFO info2 = info;
info2.m_Unicode = pDst[nIndex];
info2.m_Flag = FPDFTEXT_CHAR_PIECE;
@@ -700,7 +700,7 @@ void CPDF_TextPage::CloseTempLine() {
CFX_WideString str = m_TempTextBuf.MakeString();
bool bPrevSpace = false;
- for (int i = 0; i < str.GetLength(); i++) {
+ for (FX_STRSIZE i = 0; i < str.GetLength(); i++) {
if (str[i] != ' ') {
bPrevSpace = false;
continue;
@@ -1222,7 +1222,7 @@ bool CPDF_TextPage::IsHyphen(wchar_t curChar) {
FX_STRSIZE nCount = strCurText.GetLength();
if (nCount < 1)
return false;
- int nIndex = nCount - 1;
+ FX_STRSIZE nIndex = nCount - 1;
wchar_t wcTmp = strCurText[nIndex];
while (wcTmp == 0x20 && nIndex > 0 && nIndex <= nCount - 1)
wcTmp = strCurText[--nIndex];
diff --git a/core/fxcrt/cfx_bytestring.cpp b/core/fxcrt/cfx_bytestring.cpp
index ac390949ee..13b6673c70 100644
--- a/core/fxcrt/cfx_bytestring.cpp
+++ b/core/fxcrt/cfx_bytestring.cpp
@@ -427,7 +427,7 @@ FX_STRSIZE CFX_ByteString::Delete(FX_STRSIZE index, FX_STRSIZE count) {
return old_length;
ReallocBeforeWrite(old_length);
- int chars_to_copy = old_length - removal_length + 1;
+ FX_STRSIZE chars_to_copy = old_length - removal_length + 1;
memmove(m_pData->m_String + index, m_pData->m_String + removal_length,
chars_to_copy);
m_pData->m_nDataLength = old_length - count;
diff --git a/core/fxcrt/cfx_chariter.cpp b/core/fxcrt/cfx_chariter.cpp
index db94fb09f4..827e86967d 100644
--- a/core/fxcrt/cfx_chariter.cpp
+++ b/core/fxcrt/cfx_chariter.cpp
@@ -21,7 +21,7 @@ bool CFX_CharIter::Next(bool bPrev) {
return false;
m_nIndex--;
} else {
- if (m_nIndex + 1 >= m_wsText.GetLength())
+ if (static_cast<FX_STRSIZE>(m_nIndex + 1) >= m_wsText.GetLength())
return false;
m_nIndex++;
}
@@ -33,7 +33,7 @@ wchar_t CFX_CharIter::GetChar() const {
}
void CFX_CharIter::SetAt(int32_t nIndex) {
- if (nIndex < 0 || nIndex >= m_wsText.GetLength())
+ if (nIndex < 0 || static_cast<FX_STRSIZE>(nIndex) >= m_wsText.GetLength())
return;
m_nIndex = nIndex;
}
@@ -43,7 +43,8 @@ int32_t CFX_CharIter::GetAt() const {
}
bool CFX_CharIter::IsEOF(bool bTail) const {
- return bTail ? (m_nIndex + 1 == m_wsText.GetLength()) : (m_nIndex == 0);
+ return bTail ? (static_cast<FX_STRSIZE>(m_nIndex + 1) == m_wsText.GetLength())
+ : (m_nIndex == 0);
}
std::unique_ptr<IFX_CharIter> CFX_CharIter::Clone() const {
diff --git a/core/fxcrt/cfx_seekablestreamproxy.cpp b/core/fxcrt/cfx_seekablestreamproxy.cpp
index e610e0a9c3..da1170717a 100644
--- a/core/fxcrt/cfx_seekablestreamproxy.cpp
+++ b/core/fxcrt/cfx_seekablestreamproxy.cpp
@@ -98,8 +98,8 @@ void UTF16ToWChar(void* pBuffer, FX_STRSIZE iLength) {
uint16_t* pSrc = static_cast<uint16_t*>(pBuffer);
wchar_t* pDst = static_cast<wchar_t*>(pBuffer);
- while (--iLength >= 0)
- pDst[iLength] = static_cast<wchar_t>(pSrc[iLength]);
+ for (FX_STRSIZE i = 0; i < iLength; i++)
+ pDst[i] = static_cast<wchar_t>(pSrc[i]);
}
void SwapByteOrder(wchar_t* pStr, FX_STRSIZE iLength) {
diff --git a/core/fxcrt/cfx_string_data_template.h b/core/fxcrt/cfx_string_data_template.h
index e39f6a5dfd..eabb608818 100644
--- a/core/fxcrt/cfx_string_data_template.h
+++ b/core/fxcrt/cfx_string_data_template.h
@@ -21,7 +21,7 @@ class CFX_StringDataTemplate {
// NUL char that is not included in |m_nAllocLength|.
int overhead =
offsetof(CFX_StringDataTemplate, m_String) + sizeof(CharType);
- pdfium::base::CheckedNumeric<int> nSize = nLen;
+ pdfium::base::CheckedNumeric<FX_STRSIZE> nSize = nLen;
nSize *= sizeof(CharType);
nSize += overhead;
@@ -31,8 +31,8 @@ class CFX_StringDataTemplate {
// by using this otherwise wasted space.
nSize += 7;
nSize &= ~7;
- int totalSize = nSize.ValueOrDie();
- int usableLen = (totalSize - overhead) / sizeof(CharType);
+ FX_STRSIZE totalSize = nSize.ValueOrDie();
+ FX_STRSIZE usableLen = (totalSize - overhead) / sizeof(CharType);
ASSERT(usableLen >= nLen);
void* pData = pdfium::base::PartitionAllocGeneric(
diff --git a/core/fxcrt/fx_basic.h b/core/fxcrt/fx_basic.h
index 47cce9a60f..1f05dfb627 100644
--- a/core/fxcrt/fx_basic.h
+++ b/core/fxcrt/fx_basic.h
@@ -43,7 +43,7 @@ class CFX_BinaryBuf {
}
void InsertBlock(FX_STRSIZE pos, const void* pBuf, FX_STRSIZE size);
- void Delete(int start_index, int count);
+ void Delete(FX_STRSIZE start_index, FX_STRSIZE count);
// Releases ownership of |m_pBuffer| and returns it.
std::unique_ptr<uint8_t, FxFreeDeleter> DetachBuffer();
diff --git a/core/fxcrt/fx_basic_buffer.cpp b/core/fxcrt/fx_basic_buffer.cpp
index a359bdd5d0..310aec7faf 100644
--- a/core/fxcrt/fx_basic_buffer.cpp
+++ b/core/fxcrt/fx_basic_buffer.cpp
@@ -23,7 +23,7 @@ CFX_BinaryBuf::CFX_BinaryBuf(FX_STRSIZE size)
CFX_BinaryBuf::~CFX_BinaryBuf() {}
-void CFX_BinaryBuf::Delete(int start_index, int count) {
+void CFX_BinaryBuf::Delete(FX_STRSIZE start_index, FX_STRSIZE count) {
if (!m_pBuffer || start_index < 0 || count < 0 || count > m_DataSize ||
start_index > m_DataSize - count) {
return;
diff --git a/core/fxcrt/fx_basic_util.cpp b/core/fxcrt/fx_basic_util.cpp
index 05ab20472c..6f59f32fff 100644
--- a/core/fxcrt/fx_basic_util.cpp
+++ b/core/fxcrt/fx_basic_util.cpp
@@ -28,7 +28,7 @@ bool FX_atonum(const CFX_ByteStringC& strc, void* pData) {
pdfium::base::CheckedNumeric<uint32_t> integer = 0;
bool bNegative = false;
bool bSigned = false;
- int cc = 0;
+ FX_STRSIZE cc = 0;
if (strc[0] == '+') {
cc++;
bSigned = true;
diff --git a/fpdfsdk/fpdfppo.cpp b/fpdfsdk/fpdfppo.cpp
index 861b15c259..d08de020bb 100644
--- a/fpdfsdk/fpdfppo.cpp
+++ b/fpdfsdk/fpdfppo.cpp
@@ -77,9 +77,9 @@ bool ParserPageRangeString(CFX_ByteString rangstring,
return true;
rangstring.Remove(' ');
- int nLength = rangstring.GetLength();
+ FX_STRSIZE nLength = rangstring.GetLength();
CFX_ByteString cbCompareString("0123456789-,");
- for (int i = 0; i < nLength; ++i) {
+ for (FX_STRSIZE i = 0; i < nLength; ++i) {
if (!cbCompareString.Contains(rangstring[i]))
return false;
}
@@ -94,26 +94,29 @@ bool ParserPageRangeString(CFX_ByteString rangstring,
cbMidRange = rangstring.Mid(nStringFrom, nStringTo.value() - nStringFrom);
auto nMid = cbMidRange.Find('-');
if (!nMid.has_value()) {
- long lPageNum = atol(cbMidRange.c_str());
- if (lPageNum <= 0 || lPageNum > nCount)
+ uint16_t pageNum =
+ pdfium::base::checked_cast<uint16_t>(atoi(cbMidRange.c_str()));
+ if (pageNum <= 0 || pageNum > nCount)
return false;
- pageArray->push_back((uint16_t)lPageNum);
+ pageArray->push_back(pageNum);
} else {
- int nStartPageNum = atol(cbMidRange.Left(nMid.value()).c_str());
+ uint16_t nStartPageNum = pdfium::base::checked_cast<uint16_t>(
+ atoi(cbMidRange.Left(nMid.value()).c_str()));
if (nStartPageNum == 0)
return false;
nMid = nMid.value() + 1;
- int nEnd = cbMidRange.GetLength() - nMid.value();
+ FX_STRSIZE nEnd = cbMidRange.GetLength() - nMid.value();
if (nEnd == 0)
return false;
- int nEndPageNum = atol(cbMidRange.Mid(nMid.value(), nEnd).c_str());
+ uint16_t nEndPageNum = pdfium::base::checked_cast<uint16_t>(
+ atoi(cbMidRange.Mid(nMid.value(), nEnd).c_str()));
if (nStartPageNum < 0 || nStartPageNum > nEndPageNum ||
nEndPageNum > nCount) {
return false;
}
- for (int i = nStartPageNum; i <= nEndPageNum; ++i) {
+ for (uint16_t i = nStartPageNum; i <= nEndPageNum; ++i) {
pageArray->push_back(i);
}
}
diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp
index 9b821471c2..d8934a44f6 100644
--- a/fpdfsdk/javascript/Document.cpp
+++ b/fpdfsdk/javascript/Document.cpp
@@ -1016,7 +1016,7 @@ bool Document::documentFileName(CJS_Runtime* pRuntime,
return false;
}
CFX_WideString wsFilePath = m_pFormFillEnv->JS_docGetFilePath();
- int32_t i = wsFilePath.GetLength() - 1;
+ FX_STRSIZE i = wsFilePath.GetLength() - 1;
for (; i >= 0; i--) {
if (wsFilePath[i] == L'\\' || wsFilePath[i] == L'/')
break;
diff --git a/fpdfsdk/javascript/PublicMethods.cpp b/fpdfsdk/javascript/PublicMethods.cpp
index ff1d4fb7b7..ee5bbbacb8 100644
--- a/fpdfsdk/javascript/PublicMethods.cpp
+++ b/fpdfsdk/javascript/PublicMethods.cpp
@@ -366,7 +366,7 @@ double CJS_PublicMethods::MakeRegularDate(const CFX_WideString& value,
bool bExit = false;
bool bBadFormat = false;
- int i = 0;
+ FX_STRSIZE i = 0;
int j = 0;
while (i < format.GetLength()) {
@@ -394,7 +394,7 @@ double CJS_PublicMethods::MakeRegularDate(const CFX_WideString& value,
case 't': {
int oldj = j;
int nSkip = 0;
- int remaining = format.GetLength() - i - 1;
+ FX_STRSIZE remaining = format.GetLength() - i - 1;
if (remaining == 0 || format[i + 1] != c) {
switch (c) {
@@ -628,10 +628,10 @@ CFX_WideString CJS_PublicMethods::MakeFormatDate(double dDate,
int nMin = JS_GetMinFromTime(dDate);
int nSec = JS_GetSecFromTime(dDate);
- int i = 0;
+ FX_STRSIZE i = 0;
while (i < format.GetLength()) {
wchar_t c = format[i];
- int remaining = format.GetLength() - i - 1;
+ FX_STRSIZE remaining = format.GetLength() - i - 1;
sPart = L"";
switch (c) {
case 'y':
diff --git a/fxbarcode/oned/BC_OneDimWriter.cpp b/fxbarcode/oned/BC_OneDimWriter.cpp
index 69c031608c..2927dda3af 100644
--- a/fxbarcode/oned/BC_OneDimWriter.cpp
+++ b/fxbarcode/oned/BC_OneDimWriter.cpp
@@ -136,10 +136,10 @@ void CBC_OneDimWriter::CalcTextInfo(const CFX_ByteString& text,
std::unique_ptr<CFX_UnicodeEncodingEx> encoding =
FX_CreateFontEncodingEx(cFont, FXFM_ENCODING_NONE);
- int32_t length = text.GetLength();
+ FX_STRSIZE length = text.GetLength();
uint32_t* pCharCode = FX_Alloc(uint32_t, text.GetLength());
float charWidth = 0;
- for (int32_t j = 0; j < text.GetLength(); j++) {
+ for (FX_STRSIZE j = 0; j < length; j++) {
pCharCode[j] = encoding->CharCodeFromUnicode(text[j]);
int32_t glyp_code = encoding->GlyphFromCharCode(pCharCode[j]);
int32_t glyp_value = cFont->GetGlyphWidth(glyp_code);
@@ -162,7 +162,7 @@ void CBC_OneDimWriter::CalcTextInfo(const CFX_ByteString& text,
charPos[0].m_ExtGID = charPos[0].m_GlyphIndex;
#endif
penX += (float)(charPos[0].m_FontCharWidth) * (float)fontSize / 1000.0f;
- for (int32_t i = 1; i < length; i++) {
+ for (FX_STRSIZE i = 1; i < length; i++) {
charPos[i].m_Origin = CFX_PointF(penX + left, penY + top);
charPos[i].m_GlyphIndex = encoding->GlyphFromCharCode(pCharCode[i]);
charPos[i].m_FontCharWidth = cFont->GetGlyphWidth(charPos[i].m_GlyphIndex);
diff --git a/fxbarcode/oned/BC_OneDimWriter.h b/fxbarcode/oned/BC_OneDimWriter.h
index d81a3e0a0a..c220f382ee 100644
--- a/fxbarcode/oned/BC_OneDimWriter.h
+++ b/fxbarcode/oned/BC_OneDimWriter.h
@@ -92,7 +92,7 @@ class CBC_OneDimWriter : public CBC_Writer {
int32_t m_iFontStyle;
uint32_t m_fontColor;
BC_TEXT_LOC m_locTextLoc;
- int32_t m_iContentLen;
+ FX_STRSIZE m_iContentLen;
bool m_bLeftPadding;
bool m_bRightPadding;
std::vector<CFX_PathData> m_output;
diff --git a/fxbarcode/oned/BC_OnedCodaBarWriter.cpp b/fxbarcode/oned/BC_OnedCodaBarWriter.cpp
index ecaeb8d656..5a56acb37c 100644
--- a/fxbarcode/oned/BC_OnedCodaBarWriter.cpp
+++ b/fxbarcode/oned/BC_OnedCodaBarWriter.cpp
@@ -105,7 +105,7 @@ CFX_WideString CBC_OnedCodaBarWriter::FilterContents(
const CFX_WideStringC& contents) {
CFX_WideString filtercontents;
wchar_t ch;
- for (int32_t index = 0; index < contents.GetLength(); index++) {
+ for (FX_STRSIZE index = 0; index < contents.GetLength(); index++) {
ch = contents[index];
if (ch > 175) {
index++;
@@ -136,7 +136,7 @@ uint8_t* CBC_OnedCodaBarWriter::EncodeImpl(const CFX_ByteString& contents,
uint8_t* result = FX_Alloc2D(uint8_t, m_iWideNarrRatio * 7, data.GetLength());
char ch;
int32_t position = 0;
- for (int32_t index = 0; index < data.GetLength(); index++) {
+ for (FX_STRSIZE index = 0; index < data.GetLength(); index++) {
ch = data[index];
if (((ch >= 'a') && (ch <= 'z'))) {
ch = ch - 32;
diff --git a/fxbarcode/oned/BC_OnedCode128Writer.cpp b/fxbarcode/oned/BC_OnedCode128Writer.cpp
index a6dc749a76..1e9f98b9e7 100644
--- a/fxbarcode/oned/BC_OnedCode128Writer.cpp
+++ b/fxbarcode/oned/BC_OnedCode128Writer.cpp
@@ -96,7 +96,7 @@ bool CBC_OnedCode128Writer::CheckContentValidity(
CFX_WideString CBC_OnedCode128Writer::FilterContents(
const CFX_WideStringC& contents) {
CFX_WideString filterChineseChar;
- for (int32_t i = 0; i < contents.GetLength(); i++) {
+ for (FX_STRSIZE i = 0; i < contents.GetLength(); i++) {
wchar_t ch = contents[i];
if (ch > 175) {
i++;
@@ -173,9 +173,8 @@ int32_t CBC_OnedCode128Writer::Encode128B(const CFX_ByteString& contents,
int32_t checkWeight = 1;
patterns->push_back(CODE_START_B);
int32_t checkSum = CODE_START_B * checkWeight;
- int32_t position = 0;
- while (position < contents.GetLength()) {
- int32_t patternIndex = contents[position++] - ' ';
+ for (FX_STRSIZE position = 0; position < contents.GetLength(); position++) {
+ int32_t patternIndex = contents[position] - ' ';
patterns->push_back(patternIndex);
checkSum += patternIndex * checkWeight++;
}
@@ -188,13 +187,13 @@ int32_t CBC_OnedCode128Writer::Encode128C(const CFX_ByteString& contents,
int32_t checkWeight = 1;
patterns->push_back(CODE_START_C);
int32_t checkSum = CODE_START_C * checkWeight;
- int32_t position = 0;
+ FX_STRSIZE position = 0;
while (position < contents.GetLength()) {
int32_t patternIndex;
char ch = contents[position];
if (std::isdigit(ch)) {
patternIndex = FXSYS_atoi(
- contents.Mid(position, position + 1 < contents.GetLength() ? 2 : 1)
+ contents.Mid(position, contents.IsValidIndex(position + 1) ? 2 : 1)
.c_str());
++position;
if (position < contents.GetLength() && std::isdigit(contents[position]))
diff --git a/fxbarcode/oned/BC_OnedCode39Writer.cpp b/fxbarcode/oned/BC_OnedCode39Writer.cpp
index cd87231fdf..ba8769ed95 100644
--- a/fxbarcode/oned/BC_OnedCode39Writer.cpp
+++ b/fxbarcode/oned/BC_OnedCode39Writer.cpp
@@ -49,13 +49,11 @@ CBC_OnedCode39Writer::~CBC_OnedCode39Writer() {}
bool CBC_OnedCode39Writer::CheckContentValidity(
const CFX_WideStringC& contents) {
- for (int32_t i = 0; i < contents.GetLength(); i++) {
+ for (FX_STRSIZE i = 0; i < contents.GetLength(); i++) {
wchar_t ch = contents[i];
- if ((ch >= (wchar_t)'0' && ch <= (wchar_t)'9') ||
- (ch >= (wchar_t)'A' && ch <= (wchar_t)'Z') || ch == (wchar_t)'-' ||
- ch == (wchar_t)'.' || ch == (wchar_t)' ' || ch == (wchar_t)'*' ||
- ch == (wchar_t)'$' || ch == (wchar_t)'/' || ch == (wchar_t)'+' ||
- ch == (wchar_t)'%') {
+ if ((ch >= L'0' && ch <= L'9') || (ch >= L'A' && ch <= L'Z') ||
+ ch == L'-' || ch == L'.' || ch == L' ' || ch == L'*' || ch == L'$' ||
+ ch == L'/' || ch == L'+' || ch == L'%') {
continue;
}
return false;
@@ -66,9 +64,9 @@ bool CBC_OnedCode39Writer::CheckContentValidity(
CFX_WideString CBC_OnedCode39Writer::FilterContents(
const CFX_WideStringC& contents) {
CFX_WideString filtercontents;
- for (int32_t i = 0; i < contents.GetLength(); i++) {
+ for (FX_STRSIZE i = 0; i < contents.GetLength(); i++) {
wchar_t ch = contents[i];
- if (ch == (wchar_t)'*' && (i == 0 || i == contents.GetLength() - 1)) {
+ if (ch == L'*' && (i == 0 || i == contents.GetLength() - 1)) {
continue;
}
if (ch > 175) {
@@ -77,11 +75,9 @@ CFX_WideString CBC_OnedCode39Writer::FilterContents(
} else {
ch = Upper(ch);
}
- if ((ch >= (wchar_t)'0' && ch <= (wchar_t)'9') ||
- (ch >= (wchar_t)'A' && ch <= (wchar_t)'Z') || ch == (wchar_t)'-' ||
- ch == (wchar_t)'.' || ch == (wchar_t)' ' || ch == (wchar_t)'*' ||
- ch == (wchar_t)'$' || ch == (wchar_t)'/' || ch == (wchar_t)'+' ||
- ch == (wchar_t)'%') {
+ if ((ch >= L'0' && ch <= L'9') || (ch >= L'A' && ch <= L'Z') ||
+ ch == L'-' || ch == L'.' || ch == L' ' || ch == L'*' || ch == L'$' ||
+ ch == L'/' || ch == L'+' || ch == L'%') {
filtercontents += ch;
}
}
@@ -91,21 +87,18 @@ CFX_WideString CBC_OnedCode39Writer::FilterContents(
CFX_WideString CBC_OnedCode39Writer::RenderTextContents(
const CFX_WideStringC& contents) {
CFX_WideString renderContents;
- for (int32_t i = 0; i < contents.GetLength(); i++) {
+ for (FX_STRSIZE i = 0; i < contents.GetLength(); i++) {
wchar_t ch = contents[i];
- if (ch == (wchar_t)'*' && (i == 0 || i == contents.GetLength() - 1)) {
+ if (ch == L'*' && (i == 0 || i == contents.GetLength() - 1)) {
continue;
}
if (ch > 175) {
i++;
continue;
}
- if ((ch >= (wchar_t)'0' && ch <= (wchar_t)'9') ||
- (ch >= (wchar_t)'A' && ch <= (wchar_t)'Z') ||
- (ch >= (wchar_t)'a' && ch <= (wchar_t)'z') || ch == (wchar_t)'-' ||
- ch == (wchar_t)'.' || ch == (wchar_t)' ' || ch == (wchar_t)'*' ||
- ch == (wchar_t)'$' || ch == (wchar_t)'/' || ch == (wchar_t)'+' ||
- ch == (wchar_t)'%') {
+ if ((ch >= L'0' && ch <= L'9') || (ch >= L'A' && ch <= L'Z') ||
+ (ch >= L'a' && ch <= L'z') || ch == L'-' || ch == L'.' || ch == L' ' ||
+ ch == L'*' || ch == L'$' || ch == L'/' || ch == L'+' || ch == L'%') {
renderContents += ch;
}
}
@@ -145,7 +138,7 @@ void CBC_OnedCode39Writer::ToIntArray(int32_t a, int8_t* toReturn) {
}
char CBC_OnedCode39Writer::CalcCheckSum(const CFX_ByteString& contents) {
- int32_t length = contents.GetLength();
+ FX_STRSIZE length = contents.GetLength();
if (length > 80)
return '*';
@@ -183,7 +176,7 @@ uint8_t* CBC_OnedCode39Writer::EncodeImpl(const CFX_ByteString& contents,
int32_t codeWidth = (wideStrideNum * m_iWideNarrRatio + narrStrideNum) * 2 +
1 + m_iContentLen;
size_t len = strlen(ALPHABET_STRING);
- for (int32_t j = 0; j < m_iContentLen; j++) {
+ for (FX_STRSIZE j = 0; j < m_iContentLen; j++) {
for (size_t i = 0; i < len; i++) {
if (ALPHABET_STRING[i] != encodedContents[j])
continue;
diff --git a/fxbarcode/oned/BC_OnedEAN13Writer.cpp b/fxbarcode/oned/BC_OnedEAN13Writer.cpp
index 9149982ebe..5dd10ab4fc 100644
--- a/fxbarcode/oned/BC_OnedEAN13Writer.cpp
+++ b/fxbarcode/oned/BC_OnedEAN13Writer.cpp
@@ -63,7 +63,7 @@ CFX_WideString CBC_OnedEAN13Writer::FilterContents(
const CFX_WideStringC& contents) {
CFX_WideString filtercontents;
wchar_t ch;
- for (int32_t i = 0; i < contents.GetLength(); i++) {
+ for (FX_STRSIZE i = 0; i < contents.GetLength(); i++) {
ch = contents[i];
if (ch > 175) {
i++;
@@ -78,12 +78,13 @@ CFX_WideString CBC_OnedEAN13Writer::FilterContents(
int32_t CBC_OnedEAN13Writer::CalcChecksum(const CFX_ByteString& contents) {
int32_t odd = 0;
int32_t even = 0;
- int32_t j = 1;
- for (int32_t i = contents.GetLength() - 1; i >= 0; i--) {
+ FX_STRSIZE j = 1;
+ for (FX_STRSIZE i = 0; i < contents.GetLength(); i++) {
+ FX_STRSIZE rev_i = (contents.GetLength() - 1) - 1;
if (j % 2) {
- odd += FXSYS_atoi(contents.Mid(i, 1).c_str());
+ odd += FXSYS_atoi(contents.Mid(i, rev_i).c_str());
} else {
- even += FXSYS_atoi(contents.Mid(i, 1).c_str());
+ even += FXSYS_atoi(contents.Mid(i, rev_i).c_str());
}
j++;
}
diff --git a/fxbarcode/oned/BC_OnedEAN8Writer.cpp b/fxbarcode/oned/BC_OnedEAN8Writer.cpp
index 0ddafd6f17..5ca53e0568 100644
--- a/fxbarcode/oned/BC_OnedEAN8Writer.cpp
+++ b/fxbarcode/oned/BC_OnedEAN8Writer.cpp
@@ -69,7 +69,7 @@ CFX_WideString CBC_OnedEAN8Writer::FilterContents(
const CFX_WideStringC& contents) {
CFX_WideString filtercontents;
wchar_t ch;
- for (int32_t i = 0; i < contents.GetLength(); i++) {
+ for (FX_STRSIZE i = 0; i < contents.GetLength(); i++) {
ch = contents[i];
if (ch > 175) {
i++;
@@ -83,10 +83,10 @@ CFX_WideString CBC_OnedEAN8Writer::FilterContents(
}
int32_t CBC_OnedEAN8Writer::CalcChecksum(const CFX_ByteString& contents) {
- int32_t odd = 0;
- int32_t even = 0;
- int32_t j = 1;
- for (int32_t i = contents.GetLength() - 1; i >= 0; i--) {
+ FX_STRSIZE odd = 0;
+ FX_STRSIZE even = 0;
+ FX_STRSIZE j = 1;
+ for (FX_STRSIZE i = contents.GetLength() - 1; i >= 0; i--) {
if (j % 2) {
odd += FXSYS_atoi(contents.Mid(i, 1).c_str());
} else {
@@ -157,10 +157,10 @@ bool CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents,
int32_t leftPosition = 3 * multiple;
CFX_ByteString str = FX_UTF8Encode(contents);
- int32_t iLength = str.GetLength();
+ FX_STRSIZE iLength = str.GetLength();
std::vector<FXTEXT_CHARPOS> charpos(iLength);
CFX_ByteString tempStr = str.Left(4);
- int32_t iLen = tempStr.GetLength();
+ FX_STRSIZE iLen = tempStr.GetLength();
int32_t strWidth = 7 * multiple * 4;
float blank = 0.0;
diff --git a/fxbarcode/oned/BC_OnedUPCAWriter.cpp b/fxbarcode/oned/BC_OnedUPCAWriter.cpp
index 07c3e7f174..87b68d364f 100644
--- a/fxbarcode/oned/BC_OnedUPCAWriter.cpp
+++ b/fxbarcode/oned/BC_OnedUPCAWriter.cpp
@@ -53,7 +53,7 @@ CFX_WideString CBC_OnedUPCAWriter::FilterContents(
const CFX_WideStringC& contents) {
CFX_WideString filtercontents;
wchar_t ch;
- for (int32_t i = 0; i < contents.GetLength(); i++) {
+ for (FX_STRSIZE i = 0; i < contents.GetLength(); i++) {
ch = contents[i];
if (ch > 175) {
i++;
@@ -69,8 +69,8 @@ CFX_WideString CBC_OnedUPCAWriter::FilterContents(
int32_t CBC_OnedUPCAWriter::CalcChecksum(const CFX_ByteString& contents) {
int32_t odd = 0;
int32_t even = 0;
- int32_t j = 1;
- for (int32_t i = contents.GetLength() - 1; i >= 0; i--) {
+ FX_STRSIZE j = 1;
+ for (FX_STRSIZE i = contents.GetLength() - 1; i >= 0; i--) {
if (j % 2) {
odd += FXSYS_atoi(contents.Mid(i, 1).c_str());
} else {
diff --git a/fxbarcode/qrcode/BC_QRCoderEncoder.cpp b/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
index f779ed4b95..911730fbe5 100644
--- a/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
+++ b/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
@@ -134,7 +134,7 @@ void Append8BitBytes(const CFX_ByteString& content,
CBC_QRCoderBitVector* bits,
CFX_ByteString encoding,
int32_t& e) {
- for (int32_t i = 0; i < content.GetLength(); i++)
+ for (FX_STRSIZE i = 0; i < content.GetLength(); i++)
bits->AppendBits(content[i], 8);
}
@@ -425,7 +425,7 @@ void MergeString(std::vector<ModeStringPair>* result,
void SplitString(const CFX_ByteString& content,
std::vector<ModeStringPair>* result) {
- int32_t index = 0;
+ FX_STRSIZE index = 0;
while (index < content.GetLength()) {
uint8_t c = static_cast<uint8_t>(content[index]);
if (!((c >= 0xA1 && c <= 0xAA) || (c >= 0xB0 && c <= 0xFA)))
@@ -437,7 +437,7 @@ void SplitString(const CFX_ByteString& content,
if (index >= content.GetLength())
return;
- int32_t flag = index;
+ FX_STRSIZE flag = index;
while (GetAlphaNumericCode(content[index]) == -1 &&
index < content.GetLength()) {
uint8_t c = static_cast<uint8_t>(content[index]);
@@ -491,7 +491,7 @@ CBC_QRCoderMode* ChooseMode(const CFX_ByteString& content,
bool hasNumeric = false;
bool hasAlphaNumeric = false;
- for (int32_t i = 0; i < content.GetLength(); i++) {
+ for (FX_STRSIZE i = 0; i < content.GetLength(); i++) {
if (isdigit(content[i])) {
hasNumeric = true;
} else if (GetAlphaNumericCode(content[i]) != -1) {
diff --git a/xfa/fde/cfde_textout.cpp b/xfa/fde/cfde_textout.cpp
index 76ffcf9517..7ccc9688da 100644
--- a/xfa/fde/cfde_textout.cpp
+++ b/xfa/fde/cfde_textout.cpp
@@ -326,7 +326,7 @@ void CFDE_TextOut::LoadText(const CFX_WideString& str, const CFX_RectF& rect) {
m_wsText = str;
- if (pdfium::CollectionSize<int32_t>(m_CharWidths) < str.GetLength())
+ if (pdfium::CollectionSize<FX_STRSIZE>(m_CharWidths) < str.GetLength())
m_CharWidths.resize(str.GetLength(), 0);
float fLineStep = (m_fLineSpace > m_fFontSize) ? m_fLineSpace : m_fFontSize;
diff --git a/xfa/fxfa/cxfa_pdffontmgr.cpp b/xfa/fxfa/cxfa_pdffontmgr.cpp
index 5872078fdf..30af697e26 100644
--- a/xfa/fxfa/cxfa_pdffontmgr.cpp
+++ b/xfa/fxfa/cxfa_pdffontmgr.cpp
@@ -128,7 +128,7 @@ bool CXFA_PDFFontMgr::PsNameMatchDRFontName(const CFX_ByteStringC& bsPsName,
if (!nIndex.has_value() || nIndex.value() != 0)
return false;
- int32_t iDifferLength = bsDRName.GetLength() - iPsLen;
+ FX_STRSIZE iDifferLength = bsDRName.GetLength() - iPsLen;
if (iDifferLength > 1 || (bBold || bItalic)) {
auto iBoldIndex = bsDRName.Find("Bold");
if (bBold != iBoldIndex.has_value())
diff --git a/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
index a028538198..944dfea7d0 100644
--- a/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
@@ -2939,7 +2939,7 @@ void CXFA_FM2JSContext::UnitValue(CFXJSE_Value* pThis,
return;
}
- int32_t u = 0;
+ FX_STRSIZE u = 0;
while (IsWhitespace(pData[u]))
++u;
@@ -2954,7 +2954,7 @@ void CXFA_FM2JSContext::UnitValue(CFXJSE_Value* pThis,
while (IsWhitespace(pData[u]))
++u;
- int32_t uLen = unitspanString.GetLength();
+ FX_STRSIZE uLen = unitspanString.GetLength();
CFX_ByteString strFirstUnit;
while (u < uLen) {
if (pData[u] == ' ')
@@ -2970,7 +2970,7 @@ void CXFA_FM2JSContext::UnitValue(CFXJSE_Value* pThis,
std::unique_ptr<CFXJSE_Value> unitValue = GetSimpleValue(pThis, args, 1);
CFX_ByteString unitTempString = ValueToUTF8String(unitValue.get());
const char* pChar = unitTempString.c_str();
- int32_t uVal = 0;
+ FX_STRSIZE uVal = 0;
while (IsWhitespace(pChar[uVal]))
++uVal;
@@ -2982,7 +2982,7 @@ void CXFA_FM2JSContext::UnitValue(CFXJSE_Value* pThis,
while (IsWhitespace(pChar[uVal]))
++uVal;
- int32_t uValLen = unitTempString.GetLength();
+ FX_STRSIZE uValLen = unitTempString.GetLength();
while (uVal < uValLen) {
if (pChar[uVal] == ' ')
break;
@@ -3164,7 +3164,7 @@ void CXFA_FM2JSContext::Decode(CFXJSE_Value* pThis,
// static
CFX_WideString CXFA_FM2JSContext::DecodeURL(const CFX_WideString& wsURLString) {
const wchar_t* pData = wsURLString.c_str();
- int32_t i = 0;
+ FX_STRSIZE i = 0;
CFX_WideTextBuf wsResultBuf;
while (i < wsURLString.GetLength()) {
wchar_t ch = pData[i];
@@ -3202,9 +3202,9 @@ CFX_WideString CXFA_FM2JSContext::DecodeURL(const CFX_WideString& wsURLString) {
CFX_WideString CXFA_FM2JSContext::DecodeHTML(
const CFX_WideString& wsHTMLString) {
wchar_t strString[9];
- int32_t iStrIndex = 0;
- int32_t iLen = wsHTMLString.GetLength();
- int32_t i = 0;
+ FX_STRSIZE iStrIndex = 0;
+ FX_STRSIZE iLen = wsHTMLString.GetLength();
+ FX_STRSIZE i = 0;
int32_t iCode = 0;
const wchar_t* pData = wsHTMLString.c_str();
CFX_WideTextBuf wsResultBuf;
@@ -3804,7 +3804,7 @@ void CXFA_FM2JSContext::Lower(CFXJSE_Value* pThis,
CFX_ByteString argString = ValueToUTF8String(argOne.get());
CFX_WideString wsArgString = CFX_WideString::FromUTF8(argString.AsStringC());
const wchar_t* pData = wsArgString.c_str();
- int32_t i = 0;
+ FX_STRSIZE i = 0;
while (i < argString.GetLength()) {
int32_t ch = pData[i];
if ((ch >= 0x41 && ch <= 0x5A) || (ch >= 0xC0 && ch <= 0xDE))
@@ -4001,17 +4001,17 @@ void CXFA_FM2JSContext::Replace(CFXJSE_Value* pThis,
threeString = ValueToUTF8String(argThree.get());
}
- int32_t iFindLen = twoString.GetLength();
+ FX_STRSIZE iFindLen = twoString.GetLength();
std::ostringstream resultString;
- int32_t iFindIndex = 0;
- for (int32_t u = 0; u < oneString.GetLength(); ++u) {
+ FX_STRSIZE iFindIndex = 0;
+ for (FX_STRSIZE u = 0; u < oneString.GetLength(); ++u) {
char ch = static_cast<char>(oneString[u]);
if (ch != static_cast<char>(twoString[iFindIndex])) {
resultString << ch;
continue;
}
- int32_t iTemp = u + 1;
+ FX_STRSIZE iTemp = u + 1;
++iFindIndex;
while (iFindIndex < iFindLen) {
uint8_t chTemp = oneString[iTemp];
@@ -4349,7 +4349,7 @@ void CXFA_FM2JSContext::Upper(CFXJSE_Value* pThis,
CFX_ByteString argString = ValueToUTF8String(argOne.get());
CFX_WideString wsArgString = CFX_WideString::FromUTF8(argString.AsStringC());
const wchar_t* pData = wsArgString.c_str();
- int32_t i = 0;
+ FX_STRSIZE i = 0;
while (i < wsArgString.GetLength()) {
int32_t ch = pData[i];
if ((ch >= 0x61 && ch <= 0x7A) || (ch >= 0xE0 && ch <= 0xFE))
diff --git a/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp b/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp
index 32876e3b65..c30c44aa64 100644
--- a/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp
@@ -132,7 +132,7 @@ bool CXFA_FMStringExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
return true;
}
javascript.AppendChar(L'\"');
- for (int32_t i = 1; i < tempStr.GetLength() - 1; i++) {
+ for (FX_STRSIZE i = 1; i < tempStr.GetLength() - 1; i++) {
wchar_t oneChar = tempStr[i];
switch (oneChar) {
case L'\"':
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp
index 2da8820b67..fd1b2ff9bc 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.cpp
+++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp
@@ -1767,21 +1767,20 @@ void CXFA_WidgetData::FormatNumStr(const CFX_WideString& wsValue,
bNeg = true;
wsSrcNum.Delete(0, 1);
}
- int32_t len = wsSrcNum.GetLength();
+ FX_STRSIZE len = wsSrcNum.GetLength();
auto dot_index = wsSrcNum.Find('.');
dot_index = !dot_index.has_value() ? len : dot_index;
- int32_t cc = dot_index.value() - 1;
- if (cc >= 0) {
+ if (dot_index.value() >= 1) {
int nPos = dot_index.value() % 3;
wsOutput.clear();
- for (int32_t i = 0; i < dot_index; i++) {
+ for (FX_STRSIZE i = 0; i < dot_index.value(); i++) {
if (i % 3 == nPos && i != 0)
wsOutput += wsGroupSymbol;
wsOutput += wsSrcNum[i];
}
- if (dot_index < len) {
+ if (dot_index.value() < len) {
wsOutput += pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal);
wsOutput += wsSrcNum.Right(len - dot_index.value() - 1);
}