From 7cc97521db1e52d5927f5605de5f9a7102f8af40 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Wed, 22 Jul 2015 14:59:55 -0700 Subject: Fix else-after-returns throughout pdfium. Driven by CS search for pcre:yes file:third_party/pdfium/ -file:pdfium/third_party/ \breturn\b[^;]*;\s*\n*\s*\}*\s*\n*\r*else Note: Care is required to ensure the preceding block is not an else-if. As usual, removed any tabs I saw. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1243883003 . --- core/src/fpdfdoc/doc_form.cpp | 208 ++++++++++++++++++++---------------------- 1 file changed, 97 insertions(+), 111 deletions(-) (limited to 'core/src/fpdfdoc/doc_form.cpp') diff --git a/core/src/fpdfdoc/doc_form.cpp b/core/src/fpdfdoc/doc_form.cpp index 2b59bee6ee..735231cc1d 100644 --- a/core/src/fpdfdoc/doc_form.cpp +++ b/core/src/fpdfdoc/doc_form.cpp @@ -354,12 +354,11 @@ static int CALLBACK EnumFontFamExProc( ENUMLOGFONTEXA *lpelfe, { if (FontType != 0x004 || strchr(lpelfe->elfLogFont.lfFaceName, '@') != NULL) { return 1; - } else { - LPDF_FONTDATA pData = (LPDF_FONTDATA)lParam; - memcpy(&pData->lf, &lpelfe->elfLogFont, sizeof(LOGFONTA)); - pData->bFind = TRUE; - return 0; } + LPDF_FONTDATA pData = (LPDF_FONTDATA)lParam; + memcpy(&pData->lf, &lpelfe->elfLogFont, sizeof(LOGFONTA)); + pData->bFind = TRUE; + return 0; } static FX_BOOL RetrieveSpecificFont(LOGFONTA& lf) { @@ -697,41 +696,39 @@ int CPDF_InterForm::CompareFieldName(const CFX_ByteString& name1, const CFX_Byte { const FX_CHAR* ptr1 = name1; const FX_CHAR* ptr2 = name2; - if (name1.GetLength() != name2.GetLength()) { - int i = 0; - while (ptr1[i] == ptr2[i]) { - i ++; - } - if (i == name1.GetLength()) { - return 2; - } - if (i == name2.GetLength()) { - return 3; - } - return 0; - } else { + if (name1.GetLength() == name2.GetLength()) { return name1 == name2 ? 1 : 0; } + int i = 0; + while (ptr1[i] == ptr2[i]) { + i ++; + } + if (i == name1.GetLength()) { + return 2; + } + if (i == name2.GetLength()) { + return 3; + } + return 0; } int CPDF_InterForm::CompareFieldName(const CFX_WideString& name1, const CFX_WideString& name2) { const FX_WCHAR* ptr1 = name1.c_str(); const FX_WCHAR* ptr2 = name2.c_str(); - if (name1.GetLength() != name2.GetLength()) { - int i = 0; - while (ptr1[i] == ptr2[i]) { - i ++; - } - if (i == name1.GetLength()) { - return 2; - } - if (i == name2.GetLength()) { - return 3; - } - return 0; - } else { + if (name1.GetLength() == name2.GetLength()) { return name1 == name2 ? 1 : 0; } + int i = 0; + while (ptr1[i] == ptr2[i]) { + i ++; + } + if (i == name1.GetLength()) { + return 2; + } + if (i == name2.GetLength()) { + return 3; + } + return 0; } FX_DWORD CPDF_InterForm::CountFields(const CFX_WideString &csFieldName) { @@ -900,115 +897,104 @@ CPDF_FormControl* CPDF_InterForm::GetControlByDict(CPDF_Dictionary* pWidgetDict) } FX_DWORD CPDF_InterForm::CountInternalFields(const CFX_WideString& csFieldName) const { - if (m_pFormDict == NULL) { + if (!m_pFormDict) { return 0; } CPDF_Array* pArray = m_pFormDict->GetArray("Fields"); - if (pArray == NULL) { + if (!pArray) { return 0; } if (csFieldName.IsEmpty()) { return pArray->GetCount(); - } else { - int iLength = csFieldName.GetLength(); - int iPos = 0; - CPDF_Dictionary* pDict = NULL; - while (pArray != NULL) { - CFX_WideString csSub; - if (iPos < iLength && csFieldName[iPos] == L'.') { - iPos ++; - } - while (iPos < iLength && csFieldName[iPos] != L'.') { - csSub += csFieldName[iPos ++]; - } - int iCount = pArray->GetCount(); - FX_BOOL bFind = FALSE; - for (int i = 0; i < iCount; i ++) { - pDict = pArray->GetDict(i); - if (pDict == NULL) { - continue; - } - CFX_WideString csT = pDict->GetUnicodeText("T"); - if (csT == csSub) { - bFind = TRUE; - break; - } - } - if (!bFind) { - return 0; + } + int iLength = csFieldName.GetLength(); + int iPos = 0; + CPDF_Dictionary* pDict = NULL; + while (pArray != NULL) { + CFX_WideString csSub; + if (iPos < iLength && csFieldName[iPos] == L'.') { + iPos ++; + } + while (iPos < iLength && csFieldName[iPos] != L'.') { + csSub += csFieldName[iPos ++]; + } + int iCount = pArray->GetCount(); + FX_BOOL bFind = FALSE; + for (int i = 0; i < iCount; i ++) { + pDict = pArray->GetDict(i); + if (pDict == NULL) { + continue; } - if (iPos >= iLength) { + CFX_WideString csT = pDict->GetUnicodeText("T"); + if (csT == csSub) { + bFind = TRUE; break; } - pArray = pDict->GetArray("Kids"); } - if (pDict == NULL) { + if (!bFind) { return 0; - } else { - pArray = pDict->GetArray("Kids"); - if (pArray == NULL) { - return 1; - } else { - return pArray->GetCount(); - } } + if (iPos >= iLength) { + break; + } + pArray = pDict->GetArray("Kids"); + } + if (!pDict) { + return 0; } + pArray = pDict->GetArray("Kids"); + return pArray ? pArray->GetCount() : 1; } + CPDF_Dictionary* CPDF_InterForm::GetInternalField(FX_DWORD index, const CFX_WideString& csFieldName) const { - if (m_pFormDict == NULL) { - return NULL; + if (!m_pFormDict) { + return nullptr; } CPDF_Array* pArray = m_pFormDict->GetArray("Fields"); - if (pArray == NULL) { - return 0; + if (!pArray) { + return nullptr; } if (csFieldName.IsEmpty()) { return pArray->GetDict(index); - } else { - int iLength = csFieldName.GetLength(); - int iPos = 0; - CPDF_Dictionary* pDict = NULL; - while (pArray != NULL) { - CFX_WideString csSub; - if (iPos < iLength && csFieldName[iPos] == L'.') { - iPos ++; - } - while (iPos < iLength && csFieldName[iPos] != L'.') { - csSub += csFieldName[iPos ++]; - } - int iCount = pArray->GetCount(); - FX_BOOL bFind = FALSE; - for (int i = 0; i < iCount; i ++) { - pDict = pArray->GetDict(i); - if (pDict == NULL) { - continue; - } - CFX_WideString csT = pDict->GetUnicodeText("T"); - if (csT == csSub) { - bFind = TRUE; - break; - } - } - if (!bFind) { - return NULL; + } + int iLength = csFieldName.GetLength(); + int iPos = 0; + CPDF_Dictionary* pDict = NULL; + while (pArray != NULL) { + CFX_WideString csSub; + if (iPos < iLength && csFieldName[iPos] == L'.') { + iPos ++; + } + while (iPos < iLength && csFieldName[iPos] != L'.') { + csSub += csFieldName[iPos ++]; + } + int iCount = pArray->GetCount(); + FX_BOOL bFind = FALSE; + for (int i = 0; i < iCount; i ++) { + pDict = pArray->GetDict(i); + if (pDict == NULL) { + continue; } - if (iPos >= iLength) { + CFX_WideString csT = pDict->GetUnicodeText("T"); + if (csT == csSub) { + bFind = TRUE; break; } - pArray = pDict->GetArray("Kids"); } - if (pDict == NULL) { + if (!bFind) { return NULL; - } else { - pArray = pDict->GetArray("Kids"); - if (pArray == NULL) { - return pDict; - } else { - return pArray->GetDict(index); - } } + if (iPos >= iLength) { + break; + } + pArray = pDict->GetArray("Kids"); + } + if (!pDict) { + return nullptr; } + pArray = pDict->GetArray("Kids"); + return pArray ? pArray->GetDict(index) : pDict; } FX_BOOL CPDF_InterForm::NeedConstructAP() { -- cgit v1.2.3