summaryrefslogtreecommitdiff
path: root/l10ntools
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-10-29 14:26:18 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-10-31 07:31:48 +0100
commitcdeb83ed3350c898af02dfe021f5da861517c2f6 (patch)
tree87461804ce621d29013aa52a692da72b36b57f13 /l10ntools
parenta3d5248b4e508ccacf7e90116df0bed347719e33 (diff)
loplugin:useuniqueptr in l10ntools
Change-Id: Ib8dafdb2b3831cdd9481fd19b340ac377c8dc9db Reviewed-on: https://gerrit.libreoffice.org/62649 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'l10ntools')
-rw-r--r--l10ntools/inc/xmlparse.hxx6
-rw-r--r--l10ntools/source/helpex.cxx3
-rw-r--r--l10ntools/source/helpmerge.cxx18
-rw-r--r--l10ntools/source/xmlparse.cxx14
4 files changed, 19 insertions, 22 deletions
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