Clean up CFX_TxtBreak
Removed some unused assignments and now unused variables.
Also rewrote a for loop so that its secondary condition is now in the
control block. The static analyzer was claiming it was possible for a
division by 0, though following the control path it was claiming, I am
pretty sure it should have exited early. This reorganizing of the code
makes it a bit more readable and eliminates the div by 0 warning from
the static analyzer.
Issues found with Clang Static Analyzer.
Change-Id: I91f1b42374734665b06724e9fafa6490e06bd3da
Reviewed-on: https://pdfium-review.googlesource.com/33910
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
diff --git a/xfa/fgas/layout/cfx_txtbreak.cpp b/xfa/fgas/layout/cfx_txtbreak.cpp
index 76a36c9..7633c4c 100644
--- a/xfa/fgas/layout/cfx_txtbreak.cpp
+++ b/xfa/fgas/layout/cfx_txtbreak.cpp
@@ -456,7 +456,7 @@
else
ttp.m_iStartPos = iStart;
- for (int32_t j = 0; j < ttp.m_iChars; j++) {
+ for (int32_t j = 0; j < ttp.m_iChars && iGapChars > 0; j++, iGapChars--) {
CFX_Char* pTC = ttp.GetChar(j);
if (pTC->m_nBreakType != FX_LBT_DIRECT_BRK || pTC->m_iCharWidth < 0)
continue;
@@ -465,9 +465,6 @@
pTC->m_iCharWidth += k;
ttp.m_iWidth += k;
iOffset -= k;
- iGapChars--;
- if (iGapChars < 1)
- break;
}
iStart += ttp.m_iWidth;
}
@@ -804,7 +801,6 @@
if (chartype < FX_CHARTYPE_ArabicAlef)
bLam = false;
- dwProps = FX_GetUnicodeProperties(wForm);
bool bEmptyChar =
(chartype >= FX_CHARTYPE_Tab && chartype <= FX_CHARTYPE_Control);
if (wForm == 0xFEFF)
@@ -928,7 +924,6 @@
int32_t iLength = pTxtRun->iLength;
CFX_RectF rect(*pTxtRun->pRect);
float fFontSize = pTxtRun->fFontSize;
- int32_t iFontSize = FXSYS_round(fFontSize * 20.0f);
float fScale = fFontSize / 1000.0f;
RetainPtr<CFGAS_GEFont> pFont = pTxtRun->pFont;
if (!pFont)
@@ -964,10 +959,8 @@
wch == L'\n')) {
bRet = false;
}
- if (bRet) {
- iCharSize = iFontSize * 500;
+ if (bRet)
fCharSize = fFontSize / 2.0f;
- }
rect.left = fStart;
if (bRTLPiece) {
rect.left -= fCharSize;