diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-01-10 11:29:36 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-01-11 07:36:26 +0100 |
commit | 96d9bd226215194632b6b0b7b0153f41ade1fc47 (patch) | |
tree | c45412f68d86cd23e4405882af6b3a4aa8ac1bf2 /l10ntools/source | |
parent | f14b9d30293f180500fc56d81e5390021758e7c1 (diff) |
loplugin:useuniqueptr in l10ntools
update plugin to find all places where we are unconditionally deleting
stuff in a destructor
Change-Id: Ia0fedc2420c7717ed2bdd8d3bb00262d2a63e0bc
Reviewed-on: https://gerrit.libreoffice.org/47724
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'l10ntools/source')
-rw-r--r-- | l10ntools/source/cfgmerge.cxx | 8 | ||||
-rw-r--r-- | l10ntools/source/lngmerge.cxx | 50 | ||||
-rw-r--r-- | l10ntools/source/xrmmerge.cxx | 5 |
3 files changed, 24 insertions, 39 deletions
diff --git a/l10ntools/source/cfgmerge.cxx b/l10ntools/source/cfgmerge.cxx index 60e05d1863ad..2eda993d72f7 100644 --- a/l10ntools/source/cfgmerge.cxx +++ b/l10ntools/source/cfgmerge.cxx @@ -103,9 +103,6 @@ CfgStackData* CfgStack::Push(const OString &rTag, const OString &rId) CfgStack::~CfgStack() { - for ( size_t i = 0, n = maList.size(); i < n; i++ ) - delete maList[ i ]; - maList.clear(); } OString CfgStack::GetAccessPath( size_t nPos ) @@ -410,8 +407,8 @@ CfgMerge::CfgMerge( if (!rMergeSource.isEmpty()) { - pMergeDataFile = new MergeDataFile( - rMergeSource, global::inputPathname, true ); + pMergeDataFile.reset(new MergeDataFile( + rMergeSource, global::inputPathname, true )); if (rLanguage.equalsIgnoreAsciiCase("ALL") ) { aLanguages = pMergeDataFile->GetLanguages(); @@ -425,7 +422,6 @@ CfgMerge::CfgMerge( CfgMerge::~CfgMerge() { pOutputStream.close(); - delete pMergeDataFile; } void CfgMerge::WorkOnText(OString &, const OString& rLangIndex) diff --git a/l10ntools/source/lngmerge.cxx b/l10ntools/source/lngmerge.cxx index b913a81249c8..f5215e4d14b2 100644 --- a/l10ntools/source/lngmerge.cxx +++ b/l10ntools/source/lngmerge.cxx @@ -49,10 +49,8 @@ void lcl_RemoveUTF8ByteOrderMarker( OString &rString ) // class LngParser LngParser::LngParser(const OString &rLngFile) - : pLines( nullptr ) - , sSource( rLngFile ) + : sSource( rLngFile ) { - pLines = new LngLineList; std::ifstream aStream(sSource.getStr()); if (aStream.is_open()) { @@ -70,19 +68,15 @@ LngParser::LngParser(const OString &rLngFile) bFirstLine = false; } - pLines->push_back( new OString(sLine) ); + mvLines.push_back( sLine ); std::getline(aStream, s); } - pLines->push_back( new OString() ); + mvLines.push_back( OString() ); } } LngParser::~LngParser() { - for ( size_t i = 0, n = pLines->size(); i < n; ++i ) - delete (*pLines)[ i ]; - pLines->clear(); - delete pLines; } bool LngParser::CreatePO( const OString &rPOFile ) @@ -98,12 +92,12 @@ bool LngParser::CreatePO( const OString &rPOFile ) OStringHashMap Text; OString sID; - while( nPos < pLines->size() ) { - sLine = *(*pLines)[ nPos++ ]; - while( nPos < pLines->size() && !isNextGroup( sGroup , sLine ) ) { + while( nPos < mvLines.size() ) { + sLine = mvLines[ nPos++ ]; + while( nPos < mvLines.size() && !isNextGroup( sGroup , sLine ) ) { ReadLine( sLine , Text ); sID = sGroup; - sLine = *(*pLines)[ nPos++ ]; + sLine = mvLines[ nPos++ ]; } if( bStart ) { bStart = false; @@ -168,9 +162,9 @@ bool LngParser::Merge( OString sGroup; // seek to next group - while ( nPos < pLines->size() && !bGroup ) + while ( nPos < mvLines.size() && !bGroup ) { - OString sLine( *(*pLines)[ nPos ] ); + OString sLine( mvLines[ nPos ] ); sLine = sLine.trim(); if ( sLine.startsWith("[") && sLine.endsWith("]") ) { @@ -180,7 +174,7 @@ bool LngParser::Merge( nPos ++; } - while ( nPos < pLines->size()) { + while ( nPos < mvLines.size()) { OStringHashMap Text; OString sID( sGroup ); std::size_t nLastLangPos = 0; @@ -193,9 +187,9 @@ bool LngParser::Merge( OString sLanguagesDone; - while ( nPos < pLines->size() && !bGroup ) + while ( nPos < mvLines.size() && !bGroup ) { - OString sLine( *(*pLines)[ nPos ] ); + OString sLine( mvLines[ nPos ] ); sLine = sLine.trim(); if ( sLine.startsWith("[") && sLine.endsWith("]") ) { @@ -221,9 +215,7 @@ bool LngParser::Merge( sSearch += ";"; if ( sLanguagesDone.indexOf( sSearch ) != -1 ) { - LngLineList::iterator it = pLines->begin(); - std::advance( it, nPos ); - pLines->erase( it ); + mvLines.erase( mvLines.begin() + nPos ); } if( pEntrys ) { @@ -235,14 +227,14 @@ bool LngParser::Merge( continue; if ( !sNewText.isEmpty()) { - OString *pLine = (*pLines)[ nPos ]; + OString & rLine = mvLines[ nPos ]; OString sText1( sLang ); sText1 += " = \""; // escape quotes, unescape double escaped quotes fdo#56648 sText1 += sNewText.replaceAll("\"","\\\"").replaceAll("\\\\\"","\\\""); sText1 += "\""; - *pLine = sText1; + rLine = sText1; Text[ sLang ] = sNewText; } } @@ -283,12 +275,10 @@ bool LngParser::Merge( nLastLangPos++; nPos++; - if ( nLastLangPos < pLines->size() ) { - LngLineList::iterator it = pLines->begin(); - std::advance( it, nLastLangPos ); - pLines->insert( it, new OString(sLine) ); + if ( nLastLangPos < mvLines.size() ) { + mvLines.insert( mvLines.begin() + nLastLangPos, sLine ); } else { - pLines->push_back( new OString(sLine) ); + mvLines.push_back( sLine ); } } } @@ -296,8 +286,8 @@ bool LngParser::Merge( } } - for ( size_t i = 0; i < pLines->size(); ++i ) - aDestination << *(*pLines)[i] << '\n'; + for ( size_t i = 0; i < mvLines.size(); ++i ) + aDestination << mvLines[i] << '\n'; aDestination.close(); return true; diff --git a/l10ntools/source/xrmmerge.cxx b/l10ntools/source/xrmmerge.cxx index b9102d793d39..6c747ad98654 100644 --- a/l10ntools/source/xrmmerge.cxx +++ b/l10ntools/source/xrmmerge.cxx @@ -375,8 +375,8 @@ XRMResMerge::XRMResMerge( { if (!rMergeSource.isEmpty() && sLanguage.equalsIgnoreAsciiCase("ALL")) { - pMergeDataFile = new MergeDataFile( - rMergeSource, sInputFileName, false); + pMergeDataFile.reset(new MergeDataFile( + rMergeSource, sInputFileName, false)); aLanguages = pMergeDataFile->GetLanguages(); } else @@ -393,7 +393,6 @@ XRMResMerge::XRMResMerge( XRMResMerge::~XRMResMerge() { pOutputStream.close(); - delete pMergeDataFile; } void XRMResMerge::WorkOnDesc( |