fdo#39440 reduce scope of local variables
This addresses some cppcheck warnings. Change-Id: Ib16e4ecc0e0c43b2c1fb527eb0668a960ae9756e Reviewed-on: https://gerrit.libreoffice.org/13513 Reviewed-by: Noel Grandin <noelgrandin@gmail.com> Tested-by: Noel Grandin <noelgrandin@gmail.com>
This commit is contained in:
parent
36936c2580
commit
a23f6eb3ae
@ -69,11 +69,10 @@ bool AstModule::dump(RegistryKey& rKey)
|
||||
|
||||
DeclList::const_iterator iter = getIteratorBegin();
|
||||
DeclList::const_iterator end = getIteratorEnd();
|
||||
AstDeclaration* pDecl = NULL;
|
||||
sal_uInt16 index = 0;
|
||||
while ( iter != end )
|
||||
{
|
||||
pDecl = *iter;
|
||||
AstDeclaration* pDecl = *iter;
|
||||
if ( pDecl->getNodeType() == NT_const &&
|
||||
pDecl->isInMainfile() )
|
||||
{
|
||||
|
@ -37,13 +37,11 @@ AstConstant* AstEnum::checkValue(AstExpression* pExpr)
|
||||
{
|
||||
DeclList::const_iterator iter = getIteratorBegin();
|
||||
DeclList::const_iterator end = getIteratorEnd();
|
||||
AstConstant* pConst = NULL;
|
||||
AstDeclaration* pDecl = NULL;
|
||||
|
||||
while ( iter != end)
|
||||
{
|
||||
pDecl = *iter;
|
||||
pConst = static_cast<AstConstant*>(pDecl);
|
||||
AstDeclaration* pDecl = *iter;
|
||||
AstConstant* pConst = static_cast<AstConstant*>(pDecl);
|
||||
|
||||
if (pConst->getConstValue()->compare(pExpr))
|
||||
return pConst;
|
||||
@ -80,11 +78,10 @@ bool AstEnum::dump(RegistryKey& rKey)
|
||||
|
||||
DeclList::const_iterator iter = getIteratorBegin();
|
||||
DeclList::const_iterator end = getIteratorEnd();
|
||||
AstDeclaration* pDecl = NULL;
|
||||
sal_uInt16 index = 0;
|
||||
while ( iter != end )
|
||||
{
|
||||
pDecl = *iter;
|
||||
AstDeclaration* pDecl = *iter;
|
||||
if ( pDecl->getNodeType() == NT_enum_val )
|
||||
static_cast<AstConstant*>(pDecl)->dumpBlob(aBlob, index++, false);
|
||||
|
||||
|
@ -60,12 +60,11 @@ bool AstOperation::dumpBlob(typereg::Writer & rBlob, sal_uInt16 index)
|
||||
{
|
||||
DeclList::const_iterator iter = getIteratorBegin();
|
||||
DeclList::const_iterator end = getIteratorEnd();
|
||||
AstDeclaration* pDecl = NULL;
|
||||
RTParamMode paramMode;
|
||||
sal_uInt16 paramIndex = 0;
|
||||
while ( iter != end )
|
||||
{
|
||||
pDecl = *iter;
|
||||
AstDeclaration* pDecl = *iter;
|
||||
if ( pDecl->getNodeType() == NT_parameter )
|
||||
{
|
||||
AstParameter* pParam = static_cast<AstParameter*>(pDecl);
|
||||
|
@ -121,12 +121,11 @@ bool AstStruct::dump(RegistryKey& rKey)
|
||||
{
|
||||
DeclList::const_iterator iter = getIteratorBegin();
|
||||
DeclList::const_iterator end = getIteratorEnd();
|
||||
AstDeclaration* pDecl = NULL;
|
||||
AstMember* pMember = NULL;
|
||||
sal_uInt16 index = 0;
|
||||
while ( iter != end )
|
||||
{
|
||||
pDecl = *iter;
|
||||
AstDeclaration* pDecl = *iter;
|
||||
if ( pDecl->getNodeType() == NT_member )
|
||||
{
|
||||
pMember = static_cast<AstMember*>(pDecl);
|
||||
|
@ -186,11 +186,11 @@ bool copyFile(const OString* source, const OString& target)
|
||||
}
|
||||
|
||||
size_t totalSize = 512;
|
||||
size_t readSize = 0;
|
||||
char pBuffer[513];
|
||||
|
||||
while ( !feof(pSource) )
|
||||
{
|
||||
size_t readSize;
|
||||
if ( (readSize = fread(pBuffer, 1, totalSize, pSource)) > 0 && !ferror(pSource) )
|
||||
{
|
||||
if ( (fwrite(pBuffer, 1, readSize, pTarget)) != readSize || ferror(pTarget) )
|
||||
|
@ -103,9 +103,7 @@ bool HelpParser::CreatePO(
|
||||
return false;
|
||||
}
|
||||
|
||||
XMLHashMap* aXMLStrHM = file->GetStrings();
|
||||
LangHashMap* pElem;
|
||||
XMLElement* pXMLElement = NULL;
|
||||
XMLHashMap* aXMLStrHM = file->GetStrings();
|
||||
|
||||
std::vector<OString> order = file->getOrder();
|
||||
std::vector<OString>::iterator pos;
|
||||
@ -114,9 +112,9 @@ bool HelpParser::CreatePO(
|
||||
for( pos = order.begin(); pos != order.end() ; ++pos )
|
||||
{
|
||||
posm = aXMLStrHM->find( *pos );
|
||||
pElem = posm->second;
|
||||
LangHashMap* pElem = posm->second;
|
||||
|
||||
pXMLElement = (*pElem)[ "en-US" ];
|
||||
XMLElement* pXMLElement = (*pElem)[ "en-US" ];
|
||||
|
||||
if( pXMLElement != NULL )
|
||||
{
|
||||
@ -167,8 +165,7 @@ bool HelpParser::MergeSingleFile( XMLFile* file , MergeDataFile* pMergeDataFile
|
||||
{
|
||||
file->Extract();
|
||||
|
||||
XMLHashMap* aXMLStrHM = file->GetStrings();
|
||||
LangHashMap* aLangHM;
|
||||
XMLHashMap* aXMLStrHM = file->GetStrings();
|
||||
static ResData pResData("","");
|
||||
pResData.sResTyp = "help";
|
||||
|
||||
@ -179,7 +176,7 @@ bool HelpParser::MergeSingleFile( XMLFile* file , MergeDataFile* pMergeDataFile
|
||||
for( pos = order.begin(); pos != order.end() ; ++pos ) // Merge every l10n related string in the same order as export
|
||||
{
|
||||
posm = aXMLStrHM->find( *pos );
|
||||
aLangHM = posm->second;
|
||||
LangHashMap* aLangHM = posm->second;
|
||||
#if OSL_DEBUG_LEVEL > 2
|
||||
printf("*********************DUMPING HASHMAP***************************************");
|
||||
Dump(aXMLStrHM);
|
||||
|
@ -89,10 +89,9 @@ XMLParentNode::XMLParentNode( const XMLParentNode& rObj)
|
||||
if( rObj.m_pChildList )
|
||||
{
|
||||
m_pChildList=new XMLChildNodeList();
|
||||
XMLChildNode* pNode = NULL;
|
||||
for ( size_t i = 0; i < rObj.m_pChildList->size(); i++ )
|
||||
{
|
||||
pNode = (*rObj.m_pChildList)[ i ];
|
||||
XMLChildNode* pNode = (*rObj.m_pChildList)[ i ];
|
||||
if( pNode != NULL)
|
||||
{
|
||||
switch(pNode->GetNodeType())
|
||||
@ -529,12 +528,11 @@ bool XMLFile::CheckExportStatus( XMLParentNode *pCur )
|
||||
{
|
||||
case XML_NODE_TYPE_FILE:
|
||||
{
|
||||
XMLParentNode* pElement;
|
||||
if( GetChildList())
|
||||
{
|
||||
for ( size_t i = 0; i < GetChildList()->size(); i++ )
|
||||
{
|
||||
pElement = static_cast<XMLParentNode*>((*GetChildList())[ i ]);
|
||||
XMLParentNode* pElement = static_cast<XMLParentNode*>((*GetChildList())[ i ]);
|
||||
if( pElement->GetNodeType() == XML_NODE_TYPE_ELEMENT ) CheckExportStatus( pElement );//, i);
|
||||
}
|
||||
}
|
||||
@ -660,18 +658,16 @@ void XMLElement::ChangeLanguageTag( const OString &rValue )
|
||||
(*m_pAttributes)[ i ]->setValue(rValue);
|
||||
}
|
||||
}
|
||||
XMLChildNode* pNode = NULL;
|
||||
XMLElement* pElem = NULL;
|
||||
XMLChildNodeList* pCList = GetChildList();
|
||||
|
||||
if( pCList )
|
||||
{
|
||||
for ( size_t i = 0; i < pCList->size(); i++ )
|
||||
{
|
||||
pNode = (*pCList)[ i ];
|
||||
XMLChildNode* pNode = (*pCList)[ i ];
|
||||
if( pNode && pNode->GetNodeType() == XML_NODE_TYPE_ELEMENT )
|
||||
{
|
||||
pElem = static_cast< XMLElement* >(pNode);
|
||||
XMLElement* pElem = static_cast< XMLElement* >(pNode);
|
||||
pElem->ChangeLanguageTag( rValue );
|
||||
pElem->SetLanguageId(rValue);
|
||||
pElem = NULL;
|
||||
@ -712,10 +708,9 @@ void XMLElement::Print(XMLNode *pCur, OStringBuffer& rBuffer, bool bRootelement
|
||||
{
|
||||
if ( pElement->GetChildList())
|
||||
{
|
||||
XMLChildNode* pTmp = 0;
|
||||
for ( size_t k = 0; k < pElement->GetChildList()->size(); k++ )
|
||||
{
|
||||
pTmp = (*pElement->GetChildList())[ k ];
|
||||
XMLChildNode* pTmp = (*pElement->GetChildList())[ k ];
|
||||
Print( pTmp, rBuffer , false);
|
||||
}
|
||||
}
|
||||
@ -751,10 +746,9 @@ void XMLElement::Print(XMLNode *pCur, OStringBuffer& rBuffer, bool bRootelement
|
||||
else
|
||||
{
|
||||
rBuffer.append( ">" );
|
||||
XMLChildNode* pTmp = 0;
|
||||
for ( size_t k = 0; k < pElement->GetChildList()->size(); k++ )
|
||||
{
|
||||
pTmp = (*pElement->GetChildList())[ k ];
|
||||
XMLChildNode* pTmp = (*pElement->GetChildList())[ k ];
|
||||
Print( pTmp, rBuffer , false);
|
||||
}
|
||||
rBuffer.append( "</" + pElement->GetName() + ">" );
|
||||
|
@ -255,10 +255,6 @@ Reference< XHyphenatedWord > SAL_CALL Hyphenator::hyphenate( const OUString& aWo
|
||||
const ::com::sun::star::beans::PropertyValues& aProperties )
|
||||
throw (com::sun::star::uno::RuntimeException, com::sun::star::lang::IllegalArgumentException, std::exception)
|
||||
{
|
||||
int nHyphenationPos = -1;
|
||||
int nHyphenationPosAlt = -1;
|
||||
int nHyphenationPosAltHyph = -1;
|
||||
int wordlen;
|
||||
int k = 0;
|
||||
|
||||
PropertyHelper_Hyphenation& rHelper = GetPropHelper();
|
||||
@ -269,7 +265,6 @@ Reference< XHyphenatedWord > SAL_CALL Hyphenator::hyphenate( const OUString& aWo
|
||||
|
||||
HyphenDict *dict = NULL;
|
||||
rtl_TextEncoding eEnc = RTL_TEXTENCODING_DONTKNOW;
|
||||
CharClass * pCC = NULL;
|
||||
|
||||
Reference< XHyphenatedWord > xRes;
|
||||
|
||||
@ -283,6 +278,10 @@ Reference< XHyphenatedWord > SAL_CALL Hyphenator::hyphenate( const OUString& aWo
|
||||
// if we have a hyphenation dictionary matching this locale
|
||||
if (k != -1)
|
||||
{
|
||||
int nHyphenationPos = -1;
|
||||
int nHyphenationPosAlt = -1;
|
||||
int nHyphenationPosAltHyph = -1;
|
||||
|
||||
// if this dictinary has not been loaded yet do that
|
||||
if (!aDicts[k].aPtr)
|
||||
{
|
||||
@ -310,7 +309,7 @@ Reference< XHyphenatedWord > SAL_CALL Hyphenator::hyphenate( const OUString& aWo
|
||||
// other wise hyphenate the word with that dictionary
|
||||
dict = aDicts[k].aPtr;
|
||||
eEnc = aDicts[k].eEnc;
|
||||
pCC = aDicts[k].apCC;
|
||||
CharClass * pCC = aDicts[k].apCC;
|
||||
|
||||
// we don't want to work with a default text encoding since following incorrect
|
||||
// results may occur only for specific text and thus may be hard to notice.
|
||||
@ -342,7 +341,7 @@ Reference< XHyphenatedWord > SAL_CALL Hyphenator::hyphenate( const OUString& aWo
|
||||
// now convert word to needed encoding
|
||||
OString encWord(OU2ENC(nTerm,eEnc));
|
||||
|
||||
wordlen = encWord.getLength();
|
||||
int wordlen = encWord.getLength();
|
||||
boost::scoped_array<char> lcword(new char[wordlen + 1]);
|
||||
boost::scoped_array<char> hyphens(new char[wordlen + 5]);
|
||||
|
||||
|
@ -700,10 +700,9 @@ bool DictionaryNeo::addEntry_Impl(const uno::Reference< XDictionaryEntry > xDicE
|
||||
// look for position to insert entry at
|
||||
// if there is already an entry do not insert the new one
|
||||
sal_Int32 nPos = 0;
|
||||
bool bFound = false;
|
||||
if (bAddEntry)
|
||||
{
|
||||
bFound = seekEntry( xDicEntry->getDictionaryWord(), &nPos );
|
||||
const bool bFound = seekEntry( xDicEntry->getDictionaryWord(), &nPos );
|
||||
if (bFound)
|
||||
bAddEntry = false;
|
||||
}
|
||||
|
@ -529,7 +529,6 @@ void GrammarCheckingIterator::DequeueAndCheck()
|
||||
uno::Reference< text::XFlatParagraph > xFlatPara;
|
||||
FPEntry aFPEntryItem;
|
||||
OUString aCurDocId;
|
||||
bool bModified = false;
|
||||
// ---- THREAD SAFE START ----
|
||||
{
|
||||
::osl::Guard< ::osl::Mutex > aGuard( MyMutex::get() );
|
||||
@ -548,7 +547,7 @@ void GrammarCheckingIterator::DequeueAndCheck()
|
||||
OUString aCurTxt( xFlatPara->getText() );
|
||||
lang::Locale aCurLocale = lcl_GetPrimaryLanguageOfSentence( xFlatPara, aFPEntryItem.m_nStartIndex );
|
||||
|
||||
bModified = xFlatPara->isModified();
|
||||
const bool bModified = xFlatPara->isModified();
|
||||
if (!bModified)
|
||||
{
|
||||
// ---- THREAD SAFE START ----
|
||||
|
Loading…
x
Reference in New Issue
Block a user