diff options
author | Ryan Harrison <rharrison@chromium.org> | 2017-08-29 16:39:44 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-08-30 14:35:33 +0000 |
commit | aa3a9cd82df9dff1ef136797259e606a39c18b75 (patch) | |
tree | 5ca71f96fa289c5f13d22b371341882b77c7331f /xfa/fxfa | |
parent | 980a3ea30872cef9ada360aa85e7c3573d7668b5 (diff) | |
download | pdfium-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>
Diffstat (limited to 'xfa/fxfa')
-rw-r--r-- | xfa/fxfa/cxfa_pdffontmgr.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp | 28 | ||||
-rw-r--r-- | xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_widgetdata.cpp | 9 |
4 files changed, 20 insertions, 21 deletions
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); } |