summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2018-08-23 20:58:14 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-08-23 20:58:14 +0000
commit203339a2aa88bb31576233220d7ced73920a596f (patch)
tree895fc5fcc07107c8cc6f81b9c6e0f12faef9fc1e /core
parent3b45012d57884b06915eb5a1f54fbba04a45e807 (diff)
downloadpdfium-203339a2aa88bb31576233220d7ced73920a596f.tar.xz
Fix shadowed variables
This CL fixes instances of variable shadowing that are discovered by turning on -Wshadow. BUG=pdfium:1137 Change-Id: I418d50de89ecbeb12e85b23a358bc61e8f16e888 Reviewed-on: https://pdfium-review.googlesource.com/41150 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'core')
-rw-r--r--core/fpdfapi/parser/cpdf_syntax_parser.cpp14
-rw-r--r--core/fpdftext/cpdf_textpage.cpp8
-rw-r--r--core/fxcodec/bmp/cfx_bmpdecompressor.cpp4
-rw-r--r--core/fxge/android/cfpf_skiafontmgr.cpp19
-rw-r--r--core/fxge/cfx_fontmapper.cpp41
5 files changed, 45 insertions, 41 deletions
diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.cpp b/core/fpdfapi/parser/cpdf_syntax_parser.cpp
index 3acad525f7..89bf991cd4 100644
--- a/core/fpdfapi/parser/cpdf_syntax_parser.cpp
+++ b/core/fpdfapi/parser/cpdf_syntax_parser.cpp
@@ -477,22 +477,22 @@ std::unique_ptr<CPDF_Object> CPDF_SyntaxParser::GetObjectBodyInternal(
std::unique_ptr<CPDF_Dictionary> pDict =
pdfium::MakeUnique<CPDF_Dictionary>(m_pPool);
while (1) {
- ByteString word = GetNextWord(nullptr);
- if (word.IsEmpty())
+ ByteString inner_word = GetNextWord(nullptr);
+ if (inner_word.IsEmpty())
return nullptr;
- FX_FILESIZE SavedPos = m_Pos - word.GetLength();
- if (word == ">>")
+ FX_FILESIZE SavedPos = m_Pos - inner_word.GetLength();
+ if (inner_word == ">>")
break;
- if (word == "endobj") {
+ if (inner_word == "endobj") {
m_Pos = SavedPos;
break;
}
- if (word[0] != '/')
+ if (inner_word[0] != '/')
continue;
- ByteString key = PDF_NameDecode(word.AsStringView());
+ ByteString key = PDF_NameDecode(inner_word.AsStringView());
if (key.IsEmpty() && parse_type == ParseType::kLoose)
continue;
diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp
index 2353317796..8375d1f8cc 100644
--- a/core/fpdftext/cpdf_textpage.cpp
+++ b/core/fpdftext/cpdf_textpage.cpp
@@ -494,11 +494,11 @@ void CPDF_TextPage::CheckMarkedContentObject(int32_t* pStart,
if (FPDFTEXT_CHAR_PIECE == charinfo2.m_Flag) {
PAGECHAR_INFO charinfo3 = charinfo2;
int endIndex = start + nCount - 1;
- const int nCount = CountChars();
+ const int innerCount = CountChars();
while (FPDFTEXT_CHAR_PIECE == charinfo3.m_Flag &&
charinfo3.m_Index == charinfo2.m_Index) {
endIndex++;
- if (endIndex >= nCount)
+ if (endIndex >= innerCount)
break;
charinfo3 = m_CharList[endIndex];
}
@@ -1316,8 +1316,8 @@ CPDF_TextPage::GenerateCharacter CPDF_TextPage::ProcessInsertObject(
if (re.Contains(pObj->GetPos())) {
bNewline = false;
} else {
- CFX_FloatRect rect(0, pObj->m_Bottom, 1000, pObj->m_Top);
- if (rect.Contains(m_pPreTextObj->GetPos()))
+ if (CFX_FloatRect(0, pObj->m_Bottom, 1000, pObj->m_Top)
+ .Contains(m_pPreTextObj->GetPos()))
bNewline = false;
}
}
diff --git a/core/fxcodec/bmp/cfx_bmpdecompressor.cpp b/core/fxcodec/bmp/cfx_bmpdecompressor.cpp
index 739853aa13..383955624c 100644
--- a/core/fxcodec/bmp/cfx_bmpdecompressor.cpp
+++ b/core/fxcodec/bmp/cfx_bmpdecompressor.cpp
@@ -65,9 +65,9 @@ void CFX_BmpDecompressor::Error() {
longjmp(jmpbuf_, 1);
}
-void CFX_BmpDecompressor::ReadScanline(uint32_t row_num_,
+void CFX_BmpDecompressor::ReadScanline(uint32_t row_num,
const std::vector<uint8_t>& row_buf) {
- context_ptr_->m_pDelegate->BmpReadScanline(row_num_, row_buf);
+ context_ptr_->m_pDelegate->BmpReadScanline(row_num, row_buf);
}
bool CFX_BmpDecompressor::GetDataPosition(uint32_t rcd_pos) {
diff --git a/core/fxge/android/cfpf_skiafontmgr.cpp b/core/fxge/android/cfpf_skiafontmgr.cpp
index f9afdabb93..2288a86e92 100644
--- a/core/fxge/android/cfpf_skiafontmgr.cpp
+++ b/core/fxge/android/cfpf_skiafontmgr.cpp
@@ -252,9 +252,9 @@ CFPF_SkiaFont* CFPF_SkiaFontMgr::CreateFont(const ByteStringView& bsFamilyname,
uint8_t uCharset,
uint32_t dwStyle) {
uint32_t dwHash = FPF_SKIAGetFamilyHash(bsFamilyname, dwStyle, uCharset);
- auto it = m_FamilyFonts.find(dwHash);
- if (it != m_FamilyFonts.end())
- return it->second.get();
+ auto family_iter = m_FamilyFonts.find(dwHash);
+ if (family_iter != m_FamilyFonts.end())
+ return family_iter->second.get();
uint32_t dwFaceName = FPF_SKIANormalizeFontName(bsFamilyname);
uint32_t dwSubst = FPF_SkiaGetSubstFont(dwFaceName, g_SkiaFontmap,
@@ -273,8 +273,9 @@ CFPF_SkiaFont* CFPF_SkiaFontMgr::CreateFont(const ByteStringView& bsFamilyname,
const CFPF_SkiaPathFont* pBestFont = nullptr;
int32_t nMax = -1;
int32_t nGlyphNum = 0;
- for (auto it = m_FontFaces.rbegin(); it != m_FontFaces.rend(); ++it) {
- const CFPF_SkiaPathFont* pFont = it->get();
+ for (auto face_iter = m_FontFaces.rbegin(); face_iter != m_FontFaces.rend();
+ ++face_iter) {
+ const CFPF_SkiaPathFont* pFont = face_iter->get();
if (!(pFont->charsets() & FPF_SkiaGetCharset(uCharset)))
continue;
int32_t nFind = 0;
@@ -301,19 +302,19 @@ CFPF_SkiaFont* CFPF_SkiaFontMgr::CreateFont(const ByteStringView& bsFamilyname,
if (uCharset == FX_CHARSET_Default || bMaybeSymbol) {
if (nFind > nMax && bMatchedName) {
nMax = nFind;
- pBestFont = it->get();
+ pBestFont = face_iter->get();
}
} else if (FPF_SkiaIsCJK(uCharset)) {
if (bMatchedName || pFont->glyph_num() > nGlyphNum) {
- pBestFont = it->get();
+ pBestFont = face_iter->get();
nGlyphNum = pFont->glyph_num();
}
} else if (nFind > nMax) {
nMax = nFind;
- pBestFont = it->get();
+ pBestFont = face_iter->get();
}
if (nExpectVal <= nFind) {
- pBestFont = it->get();
+ pBestFont = face_iter->get();
break;
}
}
diff --git a/core/fxge/cfx_fontmapper.cpp b/core/fxge/cfx_fontmapper.cpp
index c7a7015680..461094d81e 100644
--- a/core/fxge/cfx_fontmapper.cpp
+++ b/core/fxge/cfx_fontmapper.cpp
@@ -149,6 +149,14 @@ const AltFontFamily g_AltFontFamilies[] = {
{"ForteMT", "Forte"},
};
+#if _FX_PLATFORM_ == _FX_PLATFORM_LINUX_
+const char kNarrowFamily[] = "LiberationSansNarrow";
+#elif _FX_PLATFORM_ == _FX_PLATFORM_ANDROID_
+const char kNarrowFamily[] = "RobotoCondensed";
+#else
+const char kNarrowFamily[] = "ArialNarrow";
+#endif // _FX_PLATFORM_ == _FX_PLATFORM_LINUX_
+
ByteString TT_NormalizeName(const char* family) {
ByteString norm(family);
norm.Remove(' ');
@@ -415,14 +423,16 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const ByteString& name,
ByteString style;
bool bHasComma = false;
bool bHasHyphen = false;
- auto pos = SubstName.Find(",", 0);
- if (pos.has_value()) {
- family = SubstName.Left(pos.value());
- PDF_GetStandardFontName(&family);
- style = SubstName.Right(SubstName.GetLength() - (pos.value() + 1));
- bHasComma = true;
- } else {
- family = SubstName;
+ {
+ Optional<size_t> pos = SubstName.Find(",", 0);
+ if (pos.has_value()) {
+ family = SubstName.Left(pos.value());
+ PDF_GetStandardFontName(&family);
+ style = SubstName.Right(SubstName.GetLength() - (pos.value() + 1));
+ bHasComma = true;
+ } else {
+ family = SubstName;
+ }
}
for (; iBaseFont < 12; iBaseFont++) {
if (family == ByteStringView(g_Base14FontNames[iBaseFont]))
@@ -443,7 +453,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const ByteString& name,
} else {
iBaseFont = kNumStandardFonts;
if (!bHasComma) {
- pos = family.ReverseFind('-');
+ Optional<size_t> pos = family.ReverseFind('-');
if (pos.has_value()) {
style = family.Right(family.GetLength() - (pos.value() + 1));
family = family.Left(pos.value());
@@ -540,19 +550,12 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const ByteString& name,
bItalic = italic_angle != 0;
weight = old_weight;
}
-#if _FX_PLATFORM_ == _FX_PLATFORM_LINUX_
- const char* narrow_family = "LiberationSansNarrow";
-#elif _FX_PLATFORM_ == _FX_PLATFORM_ANDROID_
- const char* narrow_family = "RobotoCondensed";
-#else
- const char* narrow_family = "ArialNarrow";
-#endif // _FX_PLATFORM_ == _FX_PLATFORM_LINUX_
- auto pos = SubstName.Find("Narrow");
+ Optional<size_t> pos = SubstName.Find("Narrow");
if (pos.has_value() && pos.value() != 0)
- family = narrow_family;
+ family = kNarrowFamily;
pos = SubstName.Find("Condensed");
if (pos.has_value() && pos.value() != 0)
- family = narrow_family;
+ family = kNarrowFamily;
} else {
pSubstFont->m_bSubstCJK = true;
if (nStyle)