[Libreoffice-commits] core.git: 2 commits - l10ntools/inc l10ntools/source registry/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Oct 31 06:32:15 UTC 2018
l10ntools/inc/xmlparse.hxx | 6 +++---
l10ntools/source/helpex.cxx | 3 ++-
l10ntools/source/helpmerge.cxx | 18 ++++++++----------
l10ntools/source/xmlparse.cxx | 14 ++++++--------
registry/source/reflwrit.cxx | 6 +++---
5 files changed, 22 insertions(+), 25 deletions(-)
New commits:
commit 167a2a0a89771f94b9f1124667cfd92459d03869
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Oct 29 14:26:36 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Oct 31 07:32:04 2018 +0100
loplugin:useuniqueptr in TypeWriter::createBlop
Change-Id: Iafc9fdcaeb83d1a383ed60b3b610043d0325cde2
Reviewed-on: https://gerrit.libreoffice.org/62650
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/registry/source/reflwrit.cxx b/registry/source/reflwrit.cxx
index 3fe279b28483..9c753cf9c444 100644
--- a/registry/source/reflwrit.cxx
+++ b/registry/source/reflwrit.cxx
@@ -728,7 +728,7 @@ void TypeWriter::createBlop()
CPInfo root(CP_TAG_INVALID, nullptr);
sal_uInt16 cpIndexThisName = 0;
- sal_uInt16* cpIndexSuperNames = nullptr;
+ std::unique_ptr<sal_uInt16[]> cpIndexSuperNames;
sal_uInt16 cpIndexDoku = 0;
sal_uInt16 cpIndexFileName = 0;
CPInfo* pInfo = nullptr;
@@ -755,7 +755,7 @@ void TypeWriter::createBlop()
{
blopSize += m_nSuperTypes * entrySize;
- cpIndexSuperNames = new sal_uInt16[m_nSuperTypes];
+ cpIndexSuperNames.reset(new sal_uInt16[m_nSuperTypes]);
for (sal_uInt32 i=0; i < m_nSuperTypes; i++)
{
@@ -1059,7 +1059,7 @@ void TypeWriter::createBlop()
{
pBuffer += writeUINT16(pBuffer, cpIndexSuperNames[i]);
}
- delete[] cpIndexSuperNames;
+ cpIndexSuperNames.reset();
}
pBuffer += writeUINT16(pBuffer, cpCount);
commit cdeb83ed3350c898af02dfe021f5da861517c2f6
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Oct 29 14:26:18 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Oct 31 07:31:48 2018 +0100
loplugin:useuniqueptr in l10ntools
Change-Id: Ib8dafdb2b3831cdd9481fd19b340ac377c8dc9db
Reviewed-on: https://gerrit.libreoffice.org/62649
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/l10ntools/inc/xmlparse.hxx b/l10ntools/inc/xmlparse.hxx
index d07dd1b86afb..67b40ac2205c 100644
--- a/l10ntools/inc/xmlparse.hxx
+++ b/l10ntools/inc/xmlparse.hxx
@@ -354,10 +354,10 @@ public:
SimpleXMLParser();
~SimpleXMLParser();
- /// parse a file, returns NULL on critical errors
- XMLFile *Execute(
+ /// parse a file, return false on critical errors
+ bool Execute(
const OString &rFileName, // the file name
- XMLFile *pXMLFileIn // the XMLFile
+ XMLFile* pXMLFile // the XMLFile
);
/// returns an error struct
diff --git a/l10ntools/source/helpex.cxx b/l10ntools/source/helpex.cxx
index 95b84c23bc78..3bfacb823025 100644
--- a/l10ntools/source/helpex.cxx
+++ b/l10ntools/source/helpex.cxx
@@ -120,10 +120,11 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
else
{
HelpParser aParser( aArgs.m_sInputFile );
+ std::unique_ptr<XMLFile> xmlfile(new XMLFile( OString('0') ));
hasNoError =
HelpParser::CreatePO(
aArgs.m_sOutputFile, aArgs.m_sInputFile,
- new XMLFile( OString('0') ), "help" );
+ xmlfile.get(), "help" );
}
}
catch (std::exception& e)
diff --git a/l10ntools/source/helpmerge.cxx b/l10ntools/source/helpmerge.cxx
index fbe9e2bee283..7608cbfa88b7 100644
--- a/l10ntools/source/helpmerge.cxx
+++ b/l10ntools/source/helpmerge.cxx
@@ -81,13 +81,11 @@ HelpParser::HelpParser( const OString &rHelpFile )
bool HelpParser::CreatePO(
/*****************************************************************************/
const OString &rPOFile_in, const OString &sHelpFile,
- XMLFile *pXmlFile, const OString &rGsi1){
+ XMLFile* pXmlFile, const OString &rGsi1){
SimpleXMLParser aParser;
//TODO: explicit BOM handling?
- std::unique_ptr <XMLFile> file ( aParser.Execute( sHelpFile, pXmlFile ) );
-
- if (file == nullptr)
+ if (!aParser.Execute( sHelpFile, pXmlFile ))
{
printf(
"%s: %s\n",
@@ -95,8 +93,8 @@ bool HelpParser::CreatePO(
aParser.GetError().m_sMessage.getStr());
exit(-1);
}
- file->Extract();
- if( !file->CheckExportStatus() ){
+ pXmlFile->Extract();
+ if( !pXmlFile->CheckExportStatus() ){
return true;
}
@@ -107,9 +105,9 @@ bool HelpParser::CreatePO(
return false;
}
- XMLHashMap* aXMLStrHM = file->GetStrings();
+ XMLHashMap* aXMLStrHM = pXmlFile->GetStrings();
- std::vector<OString> order = file->getOrder();
+ std::vector<OString> order = pXmlFile->getOrder();
for (auto const& pos : order)
{
@@ -150,8 +148,8 @@ bool HelpParser::Merge( const OString &rDestinationFile,
//TODO: explicit BOM handling?
- std::unique_ptr<XMLFile> xmlfile(aParser.Execute( sHelpFile, new XMLFile( OString('0') ) ));
- if (!xmlfile)
+ std::unique_ptr<XMLFile> xmlfile(new XMLFile( OString('0') ));
+ if (!aParser.Execute( sHelpFile, xmlfile.get()))
{
SAL_WARN("l10ntools", "could not parse " << sHelpFile);
return false;
diff --git a/l10ntools/source/xmlparse.cxx b/l10ntools/source/xmlparse.cxx
index 462c4d2e1ce9..d1380208d263 100644
--- a/l10ntools/source/xmlparse.cxx
+++ b/l10ntools/source/xmlparse.cxx
@@ -869,7 +869,7 @@ void SimpleXMLParser::Default( const XML_Char *s, int len )
new XMLDefault(OString( s, len ), m_pCurNode );
}
-XMLFile *SimpleXMLParser::Execute( const OString &rFileName, XMLFile* pXMLFileIn )
+bool SimpleXMLParser::Execute( const OString &rFileName, XMLFile* pXMLFile )
{
m_aErrorInformation.m_eCode = XML_ERROR_NONE;
m_aErrorInformation.m_nLine = 0;
@@ -883,7 +883,7 @@ XMLFile *SimpleXMLParser::Execute( const OString &rFileName, XMLFile* pXMLFileIn
if (osl_openFile(aFileURL.pData, &h, osl_File_OpenFlag_Read)
!= osl_File_E_None)
{
- return nullptr;
+ return false;
}
sal_uInt64 s;
@@ -896,10 +896,9 @@ XMLFile *SimpleXMLParser::Execute( const OString &rFileName, XMLFile* pXMLFileIn
if (e != osl_File_E_None)
{
osl_closeFile(h);
- return nullptr;
+ return false;
}
- XMLFile* pXMLFile = pXMLFileIn;
pXMLFile->SetName( rFileName );
m_pCurNode = pXMLFile;
@@ -915,7 +914,8 @@ XMLFile *SimpleXMLParser::Execute( const OString &rFileName, XMLFile* pXMLFileIn
else
m_aErrorInformation.m_sMessage = "XML-File parsed successfully";
- if (!XML_Parse(m_aParser, static_cast< char * >(p), s, true))
+ bool result = XML_Parse(m_aParser, static_cast< char * >(p), s, true);
+ if (!result)
{
m_aErrorInformation.m_eCode = XML_GetErrorCode( m_aParser );
m_aErrorInformation.m_nLine = XML_GetErrorLineNumber( m_aParser );
@@ -1004,14 +1004,12 @@ XMLFile *SimpleXMLParser::Execute( const OString &rFileName, XMLFile* pXMLFileIn
default:
break;
}
- delete pXMLFile;
- pXMLFile = nullptr;
}
osl_unmapMappedFile(h, p, s);
osl_closeFile(h);
- return pXMLFile;
+ return result;
}
namespace
More information about the Libreoffice-commits
mailing list