[code health] Declare one variable per line, part 2
-- rename some variables with trailing underscores.
Change-Id: I92ec5f438144fa4b0e8acaea6356c876c0a1e360
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/80471
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/font/cpdf_simplefont.cpp b/core/fpdfapi/font/cpdf_simplefont.cpp
index 8986705..4fc72ed 100644
--- a/core/fpdfapi/font/cpdf_simplefont.cpp
+++ b/core/fpdfapi/font/cpdf_simplefont.cpp
@@ -250,7 +250,8 @@
void CPDF_SimpleFont::LoadSubstFont() {
if (!m_bUseFontWidth && !FontStyleIsFixedPitch(m_Flags)) {
- int width = 0, i;
+ int width = 0;
+ int i;
for (i = 0; i < 256; i++) {
if (m_CharWidth[i] == 0 || m_CharWidth[i] == 0xffff)
continue;
diff --git a/core/fpdfapi/render/cpdf_rendershading.cpp b/core/fpdfapi/render/cpdf_rendershading.cpp
index a8b541b..4084b30 100644
--- a/core/fpdfapi/render/cpdf_rendershading.cpp
+++ b/core/fpdfapi/render/cpdf_rendershading.cpp
@@ -799,7 +799,9 @@
if (!stream.CanReadFlag())
break;
uint32_t flag = stream.ReadFlag();
- int iStartPoint = 0, iStartColor = 0, i = 0;
+ int iStartPoint = 0;
+ int iStartColor = 0;
+ int i = 0;
if (flag) {
iStartPoint = 4;
iStartColor = 2;
diff --git a/core/fxge/freetype/fx_freetype.cpp b/core/fxge/freetype/fx_freetype.cpp
index fb1c29a..b3de154 100644
--- a/core/fxge/freetype/fx_freetype.cpp
+++ b/core/fxge/freetype/fx_freetype.cpp
@@ -13,8 +13,6 @@
int name_offset,
int table_offset,
wchar_t unicode) {
- int i, count;
-
// copy letters
while (1) {
glyph_name[name_offset] = ft_adobe_glyph_list[table_offset] & 0x7f;
@@ -26,7 +24,7 @@
glyph_name[name_offset] = 0;
// get child count
- count = ft_adobe_glyph_list[table_offset] & 0x7f;
+ int count = ft_adobe_glyph_list[table_offset] & 0x7f;
// check if we have value for this node
if (ft_adobe_glyph_list[table_offset] & 0x80) {
@@ -42,7 +40,8 @@
// now search in sub-nodes
if (count == 0)
return 0;
- for (i = 0; i < count; i++) {
+
+ for (int i = 0; i < count; i++) {
int child_offset = ft_adobe_glyph_list[table_offset + i * 2] * 256 +
ft_adobe_glyph_list[table_offset + i * 2 + 1];
if (xyq_search_node(glyph_name, name_offset, child_offset, unicode))
@@ -156,11 +155,9 @@
}
void FXFT_adobe_name_from_unicode(char* glyph_name, wchar_t unicode) {
- int i, count;
-
// start from top level node
- count = ft_adobe_glyph_list[1];
- for (i = 0; i < count; i++) {
+ int count = ft_adobe_glyph_list[1];
+ for (int i = 0; i < count; i++) {
int child_offset =
ft_adobe_glyph_list[i * 2 + 2] * 256 + ft_adobe_glyph_list[i * 2 + 3];
if (xyq_search_node(glyph_name, 0, child_offset, unicode))
diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp
index db7fd47..15763fa 100644
--- a/core/fxge/skia/fx_skia_device.cpp
+++ b/core/fxge/skia/fx_skia_device.cpp
@@ -2529,7 +2529,8 @@
std::unique_ptr<uint8_t, FxFreeDeleter> dst8Storage;
std::unique_ptr<uint32_t, FxFreeDeleter> dst32Storage;
SkBitmap skBitmap;
- int width, height;
+ int width;
+ int height;
if (!Upsample(pSource, dst8Storage, dst32Storage, &skBitmap, &width, &height,
false, m_bRgbByteOrder)) {
return false;
@@ -2660,8 +2661,12 @@
DebugValidate(m_pBitmap, m_pBackdropBitmap);
std::unique_ptr<uint8_t, FxFreeDeleter> src8Storage, mask8Storage;
std::unique_ptr<uint32_t, FxFreeDeleter> src32Storage, mask32Storage;
- SkBitmap skBitmap, skMask;
- int srcWidth, srcHeight, maskWidth, maskHeight;
+ SkBitmap skBitmap;
+ SkBitmap skMask;
+ int srcWidth;
+ int srcHeight;
+ int maskWidth;
+ int maskHeight;
if (!Upsample(pSource, src8Storage, src32Storage, &skBitmap, &srcWidth,
&srcHeight, false, m_bRgbByteOrder)) {
return false;
diff --git a/core/fxge/win32/cfx_psrenderer.cpp b/core/fxge/win32/cfx_psrenderer.cpp
index f0dd85c..ce8e0e8 100644
--- a/core/fxge/win32/cfx_psrenderer.cpp
+++ b/core/fxge/win32/cfx_psrenderer.cpp
@@ -589,7 +589,8 @@
RetainPtr<CFX_GlyphCache> pGlyphCache = pCache->GetGlyphCache(pFont);
int last_fontnum = -1;
for (int i = 0; i < nChars; i++) {
- int ps_fontnum, ps_glyphindex;
+ int ps_fontnum;
+ int ps_glyphindex;
FindPSFontGlyph(pGlyphCache.Get(), pFont, pCharPos[i], &ps_fontnum,
&ps_glyphindex);
if (last_fontnum != ps_fontnum) {
diff --git a/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp b/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp
index a4879e3..f9b6bc1 100644
--- a/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp
+++ b/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp
@@ -167,7 +167,8 @@
int32_t y) {
DCHECK(CBC_QRCoder::IsValidMaskPattern(maskPattern));
- int32_t intermediate = 0, temp = 0;
+ int32_t intermediate = 0;
+ int32_t temp = 0;
switch (maskPattern) {
case 0:
intermediate = (y + x) & 0x1;
diff --git a/fxjs/xfa/cfxjse_value.cpp b/fxjs/xfa/cfxjse_value.cpp
index 5aa05c1..6a3ae99 100644
--- a/fxjs/xfa/cfxjse_value.cpp
+++ b/fxjs/xfa/cfxjse_value.cpp
@@ -29,15 +29,18 @@
if (nErrExp >= 0)
return fNumber;
- double dwError = pow(2.0, nErrExp), dwErrorHalf = dwError / 2;
- double dNumber = fNumber, dNumberAbs = fabs(fNumber);
- double dNumberAbsMin = dNumberAbs - dwErrorHalf,
- dNumberAbsMax = dNumberAbs + dwErrorHalf;
+ double dwError = pow(2.0, nErrExp);
+ double dwErrorHalf = dwError / 2;
+ double dNumber = fNumber;
+ double dNumberAbs = fabs(fNumber);
+ double dNumberAbsMin = dNumberAbs - dwErrorHalf;
+ double dNumberAbsMax = dNumberAbs + dwErrorHalf;
int32_t iErrPos = 0;
if (floor(dNumberAbsMin) == floor(dNumberAbsMax)) {
dNumberAbsMin = fmod(dNumberAbsMin, 1.0);
dNumberAbsMax = fmod(dNumberAbsMax, 1.0);
- int32_t iErrPosMin = 1, iErrPosMax = 38;
+ int32_t iErrPosMin = 1;
+ int32_t iErrPosMax = 38;
do {
int32_t iMid = (iErrPosMin + iErrPosMax) / 2;
double dPow = pow(10.0, iMid);
diff --git a/xfa/fgas/layout/cfgas_char.cpp b/xfa/fgas/layout/cfgas_char.cpp
index e36e98e..d94b05f 100644
--- a/xfa/fgas/layout/cfgas_char.cpp
+++ b/xfa/fgas/layout/cfgas_char.cpp
@@ -340,11 +340,10 @@
pTC->m_iBidiClass = eClsCur;
} else if (i < iCount) {
CFGAS_Char* pTCNext = &(*chars)[i + 1];
- int32_t iLevelNext, iLevelNew;
eClsNew = pTCNext->m_iBidiClass;
- iLevelNext = pTCNext->m_iBidiLevel;
+ int32_t iLevelNext = pTCNext->m_iBidiLevel;
if (eClsNew != FX_BIDICLASS::kBN && iLevelCur != iLevelNext) {
- iLevelNew = std::max(iLevelNext, iLevelCur);
+ int32_t iLevelNew = std::max(iLevelNext, iLevelCur);
pTC->m_iBidiLevel = static_cast<int16_t>(iLevelNew);
eClsCur = Direction(iLevelNew);
pTC->m_iBidiClass = eClsCur;
diff --git a/xfa/fxfa/cxfa_imagerenderer.cpp b/xfa/fxfa/cxfa_imagerenderer.cpp
index bc3abe8..20fe38f 100644
--- a/xfa/fxfa/cxfa_imagerenderer.cpp
+++ b/xfa/fxfa/cxfa_imagerenderer.cpp
@@ -57,9 +57,8 @@
dest_width = -dest_width;
if (m_ImageMatrix.d > 0)
dest_height = -dest_height;
- int dest_left, dest_top;
- dest_left = dest_width > 0 ? image_rect.left : image_rect.right;
- dest_top = dest_height > 0 ? image_rect.top : image_rect.bottom;
+ int dest_left = dest_width > 0 ? image_rect.left : image_rect.right;
+ int dest_top = dest_height > 0 ? image_rect.top : image_rect.bottom;
if (m_pDIBBase->IsOpaqueImage()) {
if (m_pDevice->StretchDIBitsWithFlagsAndBlend(
m_pDIBBase, dest_left, dest_top, dest_width, dest_height, options,
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 4cf2090..efe94f9 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -4989,31 +4989,32 @@
WideString CXFA_Node::NumericLimit(const WideString& wsValue) {
int32_t iLead = GetLeadDigits();
int32_t iTread = GetFracDigits();
-
- if ((iLead == -1) && (iTread == -1))
+ if (iLead == -1 && iTread == -1)
return wsValue;
- WideString wsRet;
- int32_t iLead_ = 0, iTread_ = -1;
int32_t iCount = wsValue.GetLength();
if (iCount == 0)
return wsValue;
+ WideString wsRet;
int32_t i = 0;
if (wsValue[i] == L'-') {
wsRet += L'-';
i++;
}
+
+ int32_t iLead2 = 0;
+ int32_t iTread2 = -1;
for (; i < iCount; i++) {
wchar_t wc = wsValue[i];
if (FXSYS_IsDecimalDigit(wc)) {
if (iLead >= 0) {
- iLead_++;
- if (iLead_ > iLead)
+ iLead2++;
+ if (iLead2 > iLead)
return L"0";
- } else if (iTread_ >= 0) {
- iTread_++;
- if (iTread_ > iTread) {
+ } else if (iTread2 >= 0) {
+ iTread2++;
+ if (iTread2 > iTread) {
if (iTread != -1) {
CFGAS_Decimal wsDeci = CFGAS_Decimal(wsValue.AsStringView());
wsDeci.SetScale(iTread);
@@ -5023,7 +5024,7 @@
}
}
} else if (wc == L'.') {
- iTread_ = 0;
+ iTread2 = 0;
iLead = -1;
}
wsRet += wc;