summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-12-01 22:52:42 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-12-01 22:52:42 +0000
commitb8d86800487df4021860f08407c323ed82243c79 (patch)
treeac91e7e9405cf47594316623b26a0aadd9544e79 /core
parentdca380ffe0571be4023b11b06b8aecad9934bb06 (diff)
downloadpdfium-b8d86800487df4021860f08407c323ed82243c79.tar.xz
Get rid of else after break/continue/return.chromium/3284chromium/3283
Change-Id: I3efc57cd7325d16e3ca8ebdeeaec06012b2c56e3 Reviewed-on: https://pdfium-review.googlesource.com/20110 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core')
-rw-r--r--core/fpdfapi/edit/cpdf_creator.cpp5
-rw-r--r--core/fpdfapi/page/cpdf_streamparser.cpp12
-rw-r--r--core/fpdfapi/parser/cpdf_parser.cpp3
-rw-r--r--core/fpdfapi/parser/cpdf_syntax_parser.cpp7
-rw-r--r--core/fpdfapi/parser/fpdf_parser_decode.cpp4
-rw-r--r--core/fpdfdoc/cpdf_variabletext.cpp10
-rw-r--r--core/fpdftext/cpdf_textpage.cpp64
-rw-r--r--core/fpdftext/cpdf_textpagefind.cpp11
-rw-r--r--core/fxcodec/codec/fx_codec_flate.cpp5
-rw-r--r--core/fxcodec/jbig2/JBig2_SddProc.cpp26
-rw-r--r--core/fxcrt/xml/cfx_xmlnode.cpp6
-rw-r--r--core/fxcrt/xml/cfx_xmlparser.cpp3
-rw-r--r--core/fxcrt/xml/cfx_xmlsyntaxparser.cpp3
13 files changed, 75 insertions, 84 deletions
diff --git a/core/fpdfapi/edit/cpdf_creator.cpp b/core/fpdfapi/edit/cpdf_creator.cpp
index db5bd681d4..e31da13a4d 100644
--- a/core/fpdfapi/edit/cpdf_creator.cpp
+++ b/core/fpdfapi/edit/cpdf_creator.cpp
@@ -184,10 +184,7 @@ bool CPDF_Creator::WriteStream(const CPDF_Object* pStream,
return false;
}
- if (!m_Archive->WriteString("\r\nendstream"))
- return false;
-
- return true;
+ return m_Archive->WriteString("\r\nendstream");
}
bool CPDF_Creator::WriteIndirectObj(uint32_t objnum, const CPDF_Object* pObj) {
diff --git a/core/fpdfapi/page/cpdf_streamparser.cpp b/core/fpdfapi/page/cpdf_streamparser.cpp
index aa1d227de0..2c7e0256f5 100644
--- a/core/fpdfapi/page/cpdf_streamparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamparser.cpp
@@ -499,7 +499,13 @@ ByteString CPDF_StreamParser::ReadString() {
status = 2;
break;
}
- if (ch == 'n') {
+ if (ch == '\r') {
+ status = 4;
+ break;
+ }
+ if (ch == '\n') {
+ // Do nothing.
+ } else if (ch == 'n') {
buf << '\n';
} else if (ch == 'r') {
buf << '\r';
@@ -509,10 +515,6 @@ ByteString CPDF_StreamParser::ReadString() {
buf << '\b';
} else if (ch == 'f') {
buf << '\f';
- } else if (ch == '\r') {
- status = 4;
- break;
- } else if (ch == '\n') {
} else {
buf << static_cast<char>(ch);
}
diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp
index 5b57b949ba..4e77773a3b 100644
--- a/core/fpdfapi/parser/cpdf_parser.cpp
+++ b/core/fpdfapi/parser/cpdf_parser.cpp
@@ -394,9 +394,8 @@ bool CPDF_Parser::VerifyCrossRefV4() {
// If the object number read doesn't match the one stored,
// something is wrong with the cross reference table.
return false;
- } else {
- return true;
}
+ return true;
}
return true;
}
diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.cpp b/core/fpdfapi/parser/cpdf_syntax_parser.cpp
index ddf420b34a..66ce1838f2 100644
--- a/core/fpdfapi/parser/cpdf_syntax_parser.cpp
+++ b/core/fpdfapi/parser/cpdf_syntax_parser.cpp
@@ -208,6 +208,10 @@ ByteString CPDF_SyntaxParser::ReadString() {
break;
}
+ if (ch == '\r') {
+ status = ReadStatus::CarriageReturn;
+ break;
+ }
if (ch == 'n') {
buf << '\n';
} else if (ch == 'r') {
@@ -218,9 +222,6 @@ ByteString CPDF_SyntaxParser::ReadString() {
buf << '\b';
} else if (ch == 'f') {
buf << '\f';
- } else if (ch == '\r') {
- status = ReadStatus::CarriageReturn;
- break;
} else if (ch != '\n') {
buf << static_cast<char>(ch);
}
diff --git a/core/fpdfapi/parser/fpdf_parser_decode.cpp b/core/fpdfapi/parser/fpdf_parser_decode.cpp
index 9532b8242d..3a8660f0a4 100644
--- a/core/fpdfapi/parser/fpdf_parser_decode.cpp
+++ b/core/fpdfapi/parser/fpdf_parser_decode.cpp
@@ -361,6 +361,8 @@ bool PDF_DataDecode(const uint8_t* src_buf,
uint8_t* new_buf = nullptr;
uint32_t new_size = 0xFFFFFFFF;
int offset = -1;
+ if (decoder == "Crypt")
+ continue;
if (decoder == "FlateDecode" || decoder == "Fl") {
if (bImageAcc && i == nSize - 1) {
*ImageEncoding = "FlateDecode";
@@ -387,8 +389,6 @@ bool PDF_DataDecode(const uint8_t* src_buf,
return true;
}
offset = RunLengthDecode(last_buf, last_size, &new_buf, &new_size);
- } else if (decoder == "Crypt") {
- continue;
} else {
// If we get here, assume it's an image decoder.
if (decoder == "DCT")
diff --git a/core/fpdfdoc/cpdf_variabletext.cpp b/core/fpdfdoc/cpdf_variabletext.cpp
index 18aa95793f..82a8d6757b 100644
--- a/core/fpdfdoc/cpdf_variabletext.cpp
+++ b/core/fpdfdoc/cpdf_variabletext.cpp
@@ -897,15 +897,11 @@ float CPDF_VariableText::GetAutoFontSize() {
int32_t nRight = nTotal - 1;
int32_t nMid = nTotal / 2;
while (nLeft <= nRight) {
- if (IsBigger(gFontSizeSteps[nMid])) {
+ if (IsBigger(gFontSizeSteps[nMid]))
nRight = nMid - 1;
- nMid = (nLeft + nRight) / 2;
- continue;
- } else {
+ else
nLeft = nMid + 1;
- nMid = (nLeft + nRight) / 2;
- continue;
- }
+ nMid = (nLeft + nRight) / 2;
}
return (float)gFontSizeSteps[nMid];
}
diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp
index 8ef5522bae..98eacf3c14 100644
--- a/core/fpdftext/cpdf_textpage.cpp
+++ b/core/fpdftext/cpdf_textpage.cpp
@@ -1127,41 +1127,39 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) {
m_TempCharList.push_back(charinfo);
m_TempTextBuf.AppendChar(0xfffe);
continue;
- } else {
- int nTotal = wstrItem.GetLength();
- bool bDel = false;
- const int count =
- std::min(pdfium::CollectionSize<int>(m_TempCharList), 7);
- float threshold = charinfo.m_Matrix.TransformXDistance(
- (float)TEXT_CHARRATIO_GAPDELTA * pTextObj->GetFontSize());
- for (int n = pdfium::CollectionSize<int>(m_TempCharList);
- n > pdfium::CollectionSize<int>(m_TempCharList) - count; n--) {
- const PAGECHAR_INFO& charinfo1 = m_TempCharList[n - 1];
- CFX_PointF diff = charinfo1.m_Origin - charinfo.m_Origin;
- if (charinfo1.m_CharCode == charinfo.m_CharCode &&
- charinfo1.m_pTextObj->GetFont() == charinfo.m_pTextObj->GetFont() &&
- fabs(diff.x) < threshold && fabs(diff.y) < threshold) {
- bDel = true;
- break;
- }
+ }
+ int nTotal = wstrItem.GetLength();
+ bool bDel = false;
+ const int count = std::min(pdfium::CollectionSize<int>(m_TempCharList), 7);
+ float threshold = charinfo.m_Matrix.TransformXDistance(
+ (float)TEXT_CHARRATIO_GAPDELTA * pTextObj->GetFontSize());
+ for (int n = pdfium::CollectionSize<int>(m_TempCharList);
+ n > pdfium::CollectionSize<int>(m_TempCharList) - count; n--) {
+ const PAGECHAR_INFO& charinfo1 = m_TempCharList[n - 1];
+ CFX_PointF diff = charinfo1.m_Origin - charinfo.m_Origin;
+ if (charinfo1.m_CharCode == charinfo.m_CharCode &&
+ charinfo1.m_pTextObj->GetFont() == charinfo.m_pTextObj->GetFont() &&
+ fabs(diff.x) < threshold && fabs(diff.y) < threshold) {
+ bDel = true;
+ break;
}
- if (!bDel) {
- for (int nIndex = 0; nIndex < nTotal; nIndex++) {
- charinfo.m_Unicode = wstrItem[nIndex];
- if (charinfo.m_Unicode) {
- charinfo.m_Index = m_TextBuf.GetLength();
- m_TempTextBuf.AppendChar(charinfo.m_Unicode);
- } else {
- m_TempTextBuf.AppendChar(0xfffe);
- }
- m_TempCharList.push_back(charinfo);
- }
- } else if (i == 0) {
- WideString str = m_TempTextBuf.MakeString();
- if (!str.IsEmpty() && str[str.GetLength() - 1] == TEXT_SPACE_CHAR) {
- m_TempTextBuf.Delete(m_TempTextBuf.GetLength() - 1, 1);
- m_TempCharList.pop_back();
+ }
+ if (!bDel) {
+ for (int nIndex = 0; nIndex < nTotal; nIndex++) {
+ charinfo.m_Unicode = wstrItem[nIndex];
+ if (charinfo.m_Unicode) {
+ charinfo.m_Index = m_TextBuf.GetLength();
+ m_TempTextBuf.AppendChar(charinfo.m_Unicode);
+ } else {
+ m_TempTextBuf.AppendChar(0xfffe);
}
+ m_TempCharList.push_back(charinfo);
+ }
+ } else if (i == 0) {
+ WideString str = m_TempTextBuf.MakeString();
+ if (!str.IsEmpty() && str[str.GetLength() - 1] == TEXT_SPACE_CHAR) {
+ m_TempTextBuf.Delete(m_TempTextBuf.GetLength() - 1, 1);
+ m_TempCharList.pop_back();
}
}
}
diff --git a/core/fpdftext/cpdf_textpagefind.cpp b/core/fpdftext/cpdf_textpagefind.cpp
index 9f243a0aee..97aa34fafe 100644
--- a/core/fpdftext/cpdf_textpagefind.cpp
+++ b/core/fpdftext/cpdf_textpagefind.cpp
@@ -283,13 +283,12 @@ void CPDF_TextPageFind::ExtractFindWhat(const WideString& findwhat) {
int ret =
ExtractSubString(csWord, findwhat.c_str(), index, TEXT_SPACE_CHAR);
if (csWord.IsEmpty()) {
- if (ret) {
- m_csFindWhatArray.push_back(L"");
- index++;
- continue;
- } else {
+ if (!ret)
break;
- }
+
+ m_csFindWhatArray.push_back(L"");
+ index++;
+ continue;
}
size_t pos = 0;
while (pos < csWord.GetLength()) {
diff --git a/core/fxcodec/codec/fx_codec_flate.cpp b/core/fxcodec/codec/fx_codec_flate.cpp
index 5b1df38913..95902bb699 100644
--- a/core/fxcodec/codec/fx_codec_flate.cpp
+++ b/core/fxcodec/codec/fx_codec_flate.cpp
@@ -190,6 +190,8 @@ int CLZWDecoder::Decode(uint8_t* dest_buf,
}
}
m_InPos += m_CodeLen;
+ if (code == 257)
+ break;
if (code < 256) {
if (m_OutPos == dest_size) {
return -5;
@@ -206,9 +208,8 @@ int CLZWDecoder::Decode(uint8_t* dest_buf,
m_CodeLen = 9;
m_nCodes = 0;
old_code = 0xFFFFFFFF;
- } else if (code == 257) {
- break;
} else {
+ // Else 257 or greater.
if (old_code == 0xFFFFFFFF)
return 2;
diff --git a/core/fxcodec/jbig2/JBig2_SddProc.cpp b/core/fxcodec/jbig2/JBig2_SddProc.cpp
index 43768bd823..ee0c0f37f3 100644
--- a/core/fxcodec/jbig2/JBig2_SddProc.cpp
+++ b/core/fxcodec/jbig2/JBig2_SddProc.cpp
@@ -310,25 +310,23 @@ std::unique_ptr<CJBig2_SymbolDict> CJBig2_SDDProc::decode_Huffman(
HCFIRSTSYM = NSYMSDECODED;
for (;;) {
nVal = pHuffmanDecoder->decodeAValue(SDHUFFDW, &DW);
- if (nVal == JBIG2_OOB) {
+ if (nVal == JBIG2_OOB)
break;
- } else if (nVal != 0) {
+ if (nVal != 0)
+ return nullptr;
+ if (NSYMSDECODED >= SDNUMNEWSYMS)
return nullptr;
- } else {
- if (NSYMSDECODED >= SDNUMNEWSYMS)
- return nullptr;
- SYMWIDTH = SYMWIDTH + DW;
- if ((int)SYMWIDTH < 0 || (int)SYMWIDTH > JBIG2_MAX_IMAGE_SIZE) {
- return nullptr;
- } else if (HCHEIGHT == 0 || SYMWIDTH == 0) {
- TOTWIDTH = TOTWIDTH + SYMWIDTH;
- SDNEWSYMS[NSYMSDECODED] = nullptr;
- NSYMSDECODED = NSYMSDECODED + 1;
- continue;
- }
+ SYMWIDTH = SYMWIDTH + DW;
+ if ((int)SYMWIDTH < 0 || (int)SYMWIDTH > JBIG2_MAX_IMAGE_SIZE)
+ return nullptr;
+ if (HCHEIGHT == 0 || SYMWIDTH == 0) {
TOTWIDTH = TOTWIDTH + SYMWIDTH;
+ SDNEWSYMS[NSYMSDECODED] = nullptr;
+ NSYMSDECODED = NSYMSDECODED + 1;
+ continue;
}
+ TOTWIDTH = TOTWIDTH + SYMWIDTH;
if (SDREFAGG == 1) {
if (pHuffmanDecoder->decodeAValue(SDHUFFAGGINST, (int*)&REFAGGNINST) !=
0) {
diff --git a/core/fxcrt/xml/cfx_xmlnode.cpp b/core/fxcrt/xml/cfx_xmlnode.cpp
index f2b9006ebf..601999cbad 100644
--- a/core/fxcrt/xml/cfx_xmlnode.cpp
+++ b/core/fxcrt/xml/cfx_xmlnode.cpp
@@ -90,11 +90,9 @@ CFX_XMLNode* CFX_XMLNode::GetPath(const wchar_t* pPath,
wchar_t ch;
while (pStart < pEnd) {
ch = *pStart++;
- if (ch == L'/') {
+ if (ch == L'/')
break;
- } else {
- csPath += ch;
- }
+ csPath += ch;
}
iLength -= pStart - pPath;
CFX_XMLNode* pFind = nullptr;
diff --git a/core/fxcrt/xml/cfx_xmlparser.cpp b/core/fxcrt/xml/cfx_xmlparser.cpp
index a8bb2c9565..0f08b06255 100644
--- a/core/fxcrt/xml/cfx_xmlparser.cpp
+++ b/core/fxcrt/xml/cfx_xmlparser.cpp
@@ -72,7 +72,8 @@ int32_t CFX_XMLParser::DoParser() {
if (m_NodeStack.empty()) {
m_syntaxParserResult = FX_XmlSyntaxResult::Error;
break;
- } else if (m_dwCurrentCheckStatus != 0 && m_NodeStack.size() == 2) {
+ }
+ if (m_dwCurrentCheckStatus != 0 && m_NodeStack.size() == 2) {
m_nSize[m_dwCurrentCheckStatus - 1] =
m_pParser->GetCurrentBinaryPos() -
m_nStart[m_dwCurrentCheckStatus - 1];
diff --git a/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp b/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp
index d72e7afa1d..c0cc1a6ac9 100644
--- a/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp
+++ b/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp
@@ -535,7 +535,8 @@ FX_XmlSyntaxResult CFX_XMLSyntaxParser::DoSyntaxParse() {
if (m_BlockBuffer.IsEmpty()) {
m_Start++;
break;
- } else if (m_wQuotationMark == 0) {
+ }
+ if (m_wQuotationMark == 0) {
m_iTextDataLength = m_BlockBuffer.GetDataLength();
m_wQuotationMark = 0;
m_BlockBuffer.Reset(true);