From af9c3fa41ba16ae4dc5e7ccbf626c8701ae0aa19 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 10 Nov 2015 10:18:46 +0100 Subject: loplugin:nullptr (automatic rewrite) Change-Id: I87dbff06345f24064b87c375e5381cb27118e614 --- l10ntools/inc/xmlparse.hxx | 10 +++++----- l10ntools/source/cfgmerge.cxx | 8 ++++---- l10ntools/source/export.cxx | 12 ++++++------ l10ntools/source/helper.cxx | 2 +- l10ntools/source/helpex.cxx | 4 ++-- l10ntools/source/helpmerge.cxx | 22 +++++++++++----------- l10ntools/source/lngmerge.cxx | 2 +- l10ntools/source/merge.cxx | 8 ++++---- l10ntools/source/po.cxx | 6 +++--- l10ntools/source/propmerge.cxx | 4 ++-- l10ntools/source/treemerge.cxx | 8 ++++---- l10ntools/source/uimerge.cxx | 8 ++++---- l10ntools/source/xmlparse.cxx | 36 ++++++++++++++++++------------------ l10ntools/source/xrmmerge.cxx | 6 +++--- 14 files changed, 68 insertions(+), 68 deletions(-) diff --git a/l10ntools/inc/xmlparse.hxx b/l10ntools/inc/xmlparse.hxx index 70d83fd925ec..94a6188df8b2 100644 --- a/l10ntools/inc/xmlparse.hxx +++ b/l10ntools/inc/xmlparse.hxx @@ -91,7 +91,7 @@ private: protected: XMLChildNode( XMLParentNode *pPar ); - XMLChildNode(): m_pParent( NULL ){}; + XMLChildNode(): m_pParent( nullptr ){}; XMLChildNode( const XMLChildNode& rObj); XMLChildNode& operator=(const XMLChildNode& rObj); public: @@ -154,15 +154,15 @@ public: XMLFile( const XMLFile& rObj ) ; virtual ~XMLFile(); - void Print( XMLNode *pCur = NULL, sal_uInt16 nLevel = 0 ); + void Print( XMLNode *pCur = nullptr, sal_uInt16 nLevel = 0 ); void SearchL10NElements( XMLChildNode *pCur, int pos = 0 ); - void Extract( XMLFile *pCur = NULL ); + void Extract( XMLFile *pCur = nullptr ); XMLHashMap* GetStrings(){ return m_pXMLStrings.get(); } void Write( OString const &rFilename ); - bool Write( std::ofstream &rStream, XMLNode *pCur = NULL ); + bool Write( std::ofstream &rStream, XMLNode *pCur = nullptr ); - bool CheckExportStatus( XMLParentNode *pCur = NULL ); + bool CheckExportStatus( XMLParentNode *pCur = nullptr ); XMLFile& operator=(const XMLFile& rObj); diff --git a/l10ntools/source/cfgmerge.cxx b/l10ntools/source/cfgmerge.cxx index b8724caeb8f9..50c2a15bd2f8 100644 --- a/l10ntools/source/cfgmerge.cxx +++ b/l10ntools/source/cfgmerge.cxx @@ -59,7 +59,7 @@ FILE * init(int argc, char ** argv) { global::inputPathname = aArgs.m_sInputFile; FILE * pFile = std::fopen(global::inputPathname.getStr(), "r"); - if (pFile == 0) { + if (pFile == nullptr) { std::fprintf( stderr, "Error: Cannot open file \"%s\"\n", global::inputPathname.getStr() ); @@ -126,7 +126,7 @@ CfgStackData *CfgStack::GetStackData() if (!maList.empty()) return maList[maList.size() - 1]; else - return 0; + return nullptr; } @@ -134,7 +134,7 @@ CfgStackData *CfgStack::GetStackData() CfgParser::CfgParser() - : pStackData( NULL ), + : pStackData( nullptr ), bLocalize( false ) { } @@ -398,7 +398,7 @@ void CfgExport::WorkOnText( CfgMerge::CfgMerge( const OString &rMergeSource, const OString &rOutputFile, const OString &rFilename, const OString &rLanguage ) - : pMergeDataFile( NULL ), + : pMergeDataFile( nullptr ), sFilename( rFilename ), bEnglish( false ) { diff --git a/l10ntools/source/export.cxx b/l10ntools/source/export.cxx index 3e963f62de57..7fd87c0ed164 100644 --- a/l10ntools/source/export.cxx +++ b/l10ntools/source/export.cxx @@ -39,7 +39,7 @@ void YYWarning( const char * ); namespace { -MergeDataFile * pMergeDataFile = 0; //TODO +MergeDataFile * pMergeDataFile = nullptr; //TODO namespace global { @@ -85,7 +85,7 @@ FILE * init(int argc, char ** argv) global::inputPathname = aArgs.m_sInputFile; FILE * pFile = std::fopen(global::inputPathname.getStr(), "r"); - if (pFile == 0) { + if (pFile == nullptr) { std::fprintf( stderr, "Error: Cannot open file \"%s\"\n", global::inputPathname.getStr()); @@ -303,10 +303,10 @@ int Export::Execute( int nToken, const char * pToken ) return 0; } - ResData *pResData = NULL; + ResData *pResData = nullptr; if ( nLevel ) { // res. exists at cur. level - pResData = ( (nLevel-1) < aResStack.size() ) ? aResStack[ nLevel-1 ] : NULL; + pResData = ( (nLevel-1) < aResStack.size() ) ? aResStack[ nLevel-1 ] : nullptr; } else if (( nToken != RESOURCE ) && ( nToken != RESOURCEEXPR ) && @@ -851,7 +851,7 @@ OString Export::FullId() void Export::InsertListEntry(const OString &rLine) { - ResData *pResData = ( nLevel-1 < aResStack.size() ) ? aResStack[ nLevel-1 ] : NULL; + ResData *pResData = ( nLevel-1 < aResStack.size() ) ? aResStack[ nLevel-1 ] : nullptr; if (!pResData) std::exit(EXIT_FAILURE); @@ -1065,7 +1065,7 @@ void Export::MergeRest( ResData *pResData ) } - MergeEntrys *pEntry = 0; + MergeEntrys *pEntry = nullptr; if( pResData->bText || pResData->bQuickHelpText || pResData->bTitle ) pEntry = pMergeDataFile->GetMergeEntrysCaseSensitive( pResData ); diff --git a/l10ntools/source/helper.cxx b/l10ntools/source/helper.cxx index 85bfe4a17f96..491df41b3392 100644 --- a/l10ntools/source/helper.cxx +++ b/l10ntools/source/helper.cxx @@ -128,7 +128,7 @@ bool isWellFormedXML( OString const & text ) content += text; content += ""; doc = xmlParseMemory(content.getStr(),(int)content.getLength()); - if (doc == NULL) { + if (doc == nullptr) { result = false; } xmlFreeDoc(doc); diff --git a/l10ntools/source/helpex.cxx b/l10ntools/source/helpex.cxx index e805ade1c1b9..aaf2dfd561e0 100644 --- a/l10ntools/source/helpex.cxx +++ b/l10ntools/source/helpex.cxx @@ -81,7 +81,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) std::cerr << "Helpex error: cannot open input file\n"; return 1; } - MergeDataFile* pMergeDataFile = 0; + MergeDataFile* pMergeDataFile = nullptr; if( aArgs.m_sLanguage != "qtz") { pMergeDataFile = new MergeDataFile(aArgs.m_sMergeSrc, OString(), false, false ); @@ -109,7 +109,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) else { HelpParser aParser( aArgs.m_sInputFile ); - MergeDataFile* pMergeDataFile = 0; + MergeDataFile* pMergeDataFile = nullptr; if( aArgs.m_sLanguage != "qtz") { pMergeDataFile = new MergeDataFile(aArgs.m_sMergeSrc, aArgs.m_sInputFile, false, false ); diff --git a/l10ntools/source/helpmerge.cxx b/l10ntools/source/helpmerge.cxx index 6567538ef1d1..d86abac0b189 100644 --- a/l10ntools/source/helpmerge.cxx +++ b/l10ntools/source/helpmerge.cxx @@ -84,7 +84,7 @@ bool HelpParser::CreatePO( std::unique_ptr file ( aParser.Execute( sHelpFile, pXmlFile ) ); - if(file.get() == NULL) + if(file.get() == nullptr) { printf( "%s: %s\n", @@ -117,7 +117,7 @@ bool HelpParser::CreatePO( XMLElement* pXMLElement = (*pElem)[ "en-US" ]; - if( pXMLElement != NULL ) + if( pXMLElement != nullptr ) { OString data( pXMLElement->ToOString(). @@ -128,7 +128,7 @@ bool HelpParser::CreatePO( "Helpex", aPoOutput, sHelpFile, rGsi1, posm->first, pXMLElement->GetOldref(), OString(), data); - pXMLElement=NULL; + pXMLElement=nullptr; } else { @@ -197,20 +197,20 @@ bool HelpParser::MergeSingleFile( XMLFile* file , MergeDataFile* pMergeDataFile /* ProcessHelp Methode: search for en-US entry and replace it with the current language*/ void HelpParser::ProcessHelp( LangHashMap* aLangHM , const OString& sCur , ResData *pResData , MergeDataFile* pMergeDataFile ){ - XMLElement* pXMLElement = NULL; - MergeEntrys *pEntrys = NULL; + XMLElement* pXMLElement = nullptr; + MergeEntrys *pEntrys = nullptr; OString sLId; - pEntrys = NULL; + pEntrys = nullptr; if( !sCur.equalsIgnoreAsciiCase("en-US") ){ pXMLElement = (*aLangHM)[ "en-US" ]; - if( pXMLElement == NULL ) + if( pXMLElement == nullptr ) { printf("Error: Can't find en-US entry\n"); } - if( pXMLElement != NULL ) + if( pXMLElement != nullptr ) { sLId = pXMLElement->GetOldref(); pResData->sId = sLId; @@ -239,7 +239,7 @@ void HelpParser::ProcessHelp( LangHashMap* aLangHM , const OString& sCur , ResDa else if( pMergeDataFile ) { pEntrys = pMergeDataFile->GetMergeEntrys( pResData ); - if( pEntrys != NULL) + if( pEntrys != nullptr) { pEntrys->GetText( sNewText, STRING_TYP_TEXT, sCur, true ); if (helper::isWellFormedXML(XMLUtil::QuotHTML(sNewText))) @@ -250,9 +250,9 @@ void HelpParser::ProcessHelp( LangHashMap* aLangHM , const OString& sCur , ResDa } if (!sNewdata.isEmpty()) { - if( pXMLElement != NULL ) + if( pXMLElement != nullptr ) { - XMLData *data = new XMLData( sNewdata , NULL ); // Add new one + XMLData *data = new XMLData( sNewdata , nullptr ); // Add new one pXMLElement->RemoveAndDeleteAllChildren(); pXMLElement->AddChild( data ); aLangHM->erase( sCur ); diff --git a/l10ntools/source/lngmerge.cxx b/l10ntools/source/lngmerge.cxx index 959a93c2961f..da26398d710d 100644 --- a/l10ntools/source/lngmerge.cxx +++ b/l10ntools/source/lngmerge.cxx @@ -49,7 +49,7 @@ static void lcl_RemoveUTF8ByteOrderMarker( OString &rString ) LngParser::LngParser(const OString &rLngFile) : nError( LNG_OK ) - , pLines( NULL ) + , pLines( nullptr ) , sSource( rLngFile ) { pLines = new LngLineList(); diff --git a/l10ntools/source/merge.cxx b/l10ntools/source/merge.cxx index a8323be61884..e7b552222e6a 100644 --- a/l10ntools/source/merge.cxx +++ b/l10ntools/source/merge.cxx @@ -371,7 +371,7 @@ MergeData *MergeDataFile::GetMergeData( ResData *pResData , bool bCaseSensitive } pResData->sGId = sOldG; pResData->sId = sOldL; - return NULL; + return nullptr; } MergeEntrys *MergeDataFile::GetMergeEntrys( ResData *pResData ) @@ -380,7 +380,7 @@ MergeEntrys *MergeDataFile::GetMergeEntrys( ResData *pResData ) MergeData *pData = GetMergeData( pResData ); if ( pData ) return pData->GetMergeEntries(); - return NULL; + return nullptr; } MergeEntrys *MergeDataFile::GetMergeEntrysCaseSensitive( ResData *pResData ) @@ -389,7 +389,7 @@ MergeEntrys *MergeDataFile::GetMergeEntrysCaseSensitive( ResData *pResData ) MergeData *pData = GetMergeData( pResData , true ); if ( pData ) return pData->GetMergeEntries(); - return NULL; + return nullptr; } void MergeDataFile::InsertEntry( @@ -399,7 +399,7 @@ void MergeDataFile::InsertEntry( const OString &rTITLE, const OString &rInFilename, bool bFirstLang, bool bCaseSensitive ) { - MergeData *pData = 0; + MergeData *pData = nullptr; // search for MergeData OString sKey = CreateKey(rTYP , rGID , rLID , rInFilename , bCaseSensitive); diff --git a/l10ntools/source/po.cxx b/l10ntools/source/po.cxx index 5dfa0b7a5f45..00f7d8270414 100644 --- a/l10ntools/source/po.cxx +++ b/l10ntools/source/po.cxx @@ -164,7 +164,7 @@ void GenPoEntry::writeToFile(std::ofstream& rOFStream) const void GenPoEntry::readFromFile(std::ifstream& rIFStream) { *this = GenPoEntry(); - OString* pLastMsg = 0; + OString* pLastMsg = nullptr; std::string sTemp; getline(rIFStream,sTemp); if( rIFStream.eof() || sTemp.empty() ) @@ -274,7 +274,7 @@ PoEntry::~PoEntry() } PoEntry::PoEntry( const PoEntry& rPo ) - : m_pGenPo( rPo.m_pGenPo ? new GenPoEntry( *(rPo.m_pGenPo) ) : 0 ) + : m_pGenPo( rPo.m_pGenPo ? new GenPoEntry( *(rPo.m_pGenPo) ) : nullptr ) , m_bIsInitialized( rPo.m_bIsInitialized ) { } @@ -408,7 +408,7 @@ namespace // Get actual time in "YEAR-MO-DA HO:MI+ZONE" form static OString lcl_GetTime() { - time_t aNow = time(NULL); + time_t aNow = time(nullptr); struct tm* pNow = localtime(&aNow); char pBuff[50]; strftime( pBuff, sizeof pBuff, "%Y-%m-%d %H:%M%z", pNow ); diff --git a/l10ntools/source/propmerge.cxx b/l10ntools/source/propmerge.cxx index 513cb79cb59c..44e879263204 100644 --- a/l10ntools/source/propmerge.cxx +++ b/l10ntools/source/propmerge.cxx @@ -49,7 +49,7 @@ namespace { const OString sHex = sResult.copy( nIndex + 2, 4 ); const sal_Unicode cDec = - static_cast( strtol( sHex.getStr(), NULL, 16 ) ); + static_cast( strtol( sHex.getStr(), nullptr, 16 ) ); const OString sNewChar = OString( &cDec, 1, RTL_TEXTENCODING_UTF8 ); sResult = sResult.replaceAll( "\\u" + sHex, sNewChar ); @@ -166,7 +166,7 @@ void PropParser::Merge( const OString &rMergeSrc, const OString &rDestinationFil return; } - MergeDataFile* pMergeDataFile = 0; + MergeDataFile* pMergeDataFile = nullptr; if( m_sLang != "qtz" ) { pMergeDataFile = new MergeDataFile( rMergeSrc, m_sSource, false, false ); diff --git a/l10ntools/source/treemerge.cxx b/l10ntools/source/treemerge.cxx index 049f272b5335..b98b0621e952 100644 --- a/l10ntools/source/treemerge.cxx +++ b/l10ntools/source/treemerge.cxx @@ -119,7 +119,7 @@ namespace replaceAll("$[officeversion]","%PRODUCTVERSION"); xmlNodeSetContent( pReturn, - xmlEncodeSpecialChars( NULL, + xmlEncodeSpecialChars( nullptr, reinterpret_cast( sNewTitle.getStr() ))); xmlFree( sTitle ); @@ -131,7 +131,7 @@ namespace std::cerr << "Treex error: Cannot find title in " << sXhpPath.getStr() << std::endl; - return 0; + return nullptr; } xmlFree( pXhpFile ); xmlCleanupParser(); @@ -200,7 +200,7 @@ namespace TreeParser::TreeParser( const OString& rInputFile, const OString& rLang ) - : m_pSource( 0 ) + : m_pSource( nullptr ) , m_sLang( rLang ) , m_bIsInitialized( false ) { @@ -253,7 +253,7 @@ void TreeParser::Merge( assert( m_bIsInitialized ); const xmlNodePtr pRootNode = xmlDocGetRootElement( m_pSource ); - MergeDataFile* pMergeDataFile = 0; + MergeDataFile* pMergeDataFile = nullptr; if( m_sLang != "qtz" && m_sLang != "en-US" ) { pMergeDataFile = new MergeDataFile( diff --git a/l10ntools/source/uimerge.cxx b/l10ntools/source/uimerge.cxx index c2e42dd9c26f..5a53f49c9918 100644 --- a/l10ntools/source/uimerge.cxx +++ b/l10ntools/source/uimerge.cxx @@ -49,16 +49,16 @@ int extractTranslations() xmlDocPtr doc = xmlParseFile(sInputFileName.getStr()); - xmlDocPtr res = xsltApplyStylesheet(stylesheet, doc, NULL); + xmlDocPtr res = xsltApplyStylesheet(stylesheet, doc, nullptr); - for( xmlNodePtr nodeLevel1 = res->children; nodeLevel1 != NULL; nodeLevel1 = nodeLevel1->next) + for( xmlNodePtr nodeLevel1 = res->children; nodeLevel1 != nullptr; nodeLevel1 = nodeLevel1->next) { - for( xmlNodePtr nodeLevel2 = nodeLevel1->children; nodeLevel2 != NULL; nodeLevel2 = nodeLevel2->next) + for( xmlNodePtr nodeLevel2 = nodeLevel1->children; nodeLevel2 != nullptr; nodeLevel2 = nodeLevel2->next) { if (nodeLevel2->type == XML_ELEMENT_NODE) { std::vector vIDs; - for(xmlAttrPtr attribute = nodeLevel2->properties; attribute != NULL; attribute = attribute->next) + for(xmlAttrPtr attribute = nodeLevel2->properties; attribute != nullptr; attribute = attribute->next) { xmlChar *content = xmlNodeListGetString(res, attribute->children, 1); vIDs.push_back(helper::xmlStrToOString(content)); diff --git a/l10ntools/source/xmlparse.cxx b/l10ntools/source/xmlparse.cxx index 1fa5920ae997..10a41e3a2945 100644 --- a/l10ntools/source/xmlparse.cxx +++ b/l10ntools/source/xmlparse.cxx @@ -90,7 +90,7 @@ XMLParentNode::XMLParentNode( const XMLParentNode& rObj) for ( size_t i = 0; i < rObj.m_pChildList->size(); i++ ) { XMLChildNode* pNode = (*rObj.m_pChildList)[ i ]; - if( pNode != NULL) + if( pNode != nullptr) { switch(pNode->GetNodeType()) { @@ -312,7 +312,7 @@ XMLFile::~XMLFile() } XMLFile::XMLFile( const OString &rFileName ) // the file name, empty if created from memory stream - : XMLParentNode( NULL ) + : XMLParentNode( nullptr ) , m_sFileName( rFileName ) { m_aNodes_localize.insert( TagMap::value_type(OString("bookmark") , sal_True) ); @@ -343,7 +343,7 @@ void XMLFile::InsertL10NElement( XMLElement* pElement ) OString sId, sLanguage(""); LangHashMap* pElem; - if( pElement->GetAttributeList() != NULL ) + if( pElement->GetAttributeList() != nullptr ) { for ( size_t j = 0; j < pElement->GetAttributeList()->size(); j++ ) { @@ -654,11 +654,11 @@ void XMLElement::ChangeLanguageTag( const OString &rValue ) XMLElement* pElem = static_cast< XMLElement* >(pNode); pElem->ChangeLanguageTag( rValue ); pElem->SetLanguageId(rValue); - pElem = NULL; - pNode = NULL; + pElem = nullptr; + pNode = nullptr; } } - pCList = NULL; + pCList = nullptr; } } @@ -800,10 +800,10 @@ static OUString lcl_pathnameToAbsoluteUrl(const OString& rPathname) SimpleXMLParser::SimpleXMLParser() - : m_pCurNode(NULL) - , m_pCurData(NULL) + : m_pCurNode(nullptr) + , m_pCurData(nullptr) { - m_aParser = XML_ParserCreate( NULL ); + m_aParser = XML_ParserCreate( nullptr ); XML_SetUserData( m_aParser, this ); XML_SetElementHandler( m_aParser, reinterpret_cast(StartElementHandler), reinterpret_cast(EndElementHandler) ); XML_SetCharacterDataHandler( m_aParser, reinterpret_cast(CharacterDataHandler) ); @@ -851,7 +851,7 @@ void SimpleXMLParser::StartElement( { XMLElement *pElement = new XMLElement( OString(name), m_pCurNode ); m_pCurNode = pElement; - m_pCurData = NULL; + m_pCurData = nullptr; int i = 0; while( atts[i] ) @@ -864,7 +864,7 @@ void SimpleXMLParser::StartElement( void SimpleXMLParser::EndElement( const XML_Char * /*name*/ ) { m_pCurNode = m_pCurNode->GetParent(); - m_pCurData = NULL; + m_pCurData = nullptr; } void SimpleXMLParser::CharacterData( const XML_Char *s, int len ) @@ -884,13 +884,13 @@ void SimpleXMLParser::CharacterData( const XML_Char *s, int len ) void SimpleXMLParser::Comment( const XML_Char *data ) { - m_pCurData = NULL; + m_pCurData = nullptr; new XMLComment( OString( data ), m_pCurNode ); } void SimpleXMLParser::Default( const XML_Char *s, int len ) { - m_pCurData = NULL; + m_pCurData = nullptr; new XMLDefault(OString( s, len ), m_pCurNode ); } @@ -908,12 +908,12 @@ XMLFile *SimpleXMLParser::Execute( const OString &rFileName, XMLFile* pXMLFileIn if (osl_openFile(aFileURL.pData, &h, osl_File_OpenFlag_Read) != osl_File_E_None) { - return 0; + return nullptr; } sal_uInt64 s; oslFileError e = osl_getFileSize(h, &s); - void * p = NULL; + void * p = nullptr; if (e == osl_File_E_None) { e = osl_mapFile(h, &p, s, 0, 0); @@ -921,14 +921,14 @@ XMLFile *SimpleXMLParser::Execute( const OString &rFileName, XMLFile* pXMLFileIn if (e != osl_File_E_None) { osl_closeFile(h); - return 0; + return nullptr; } XMLFile* pXMLFile = pXMLFileIn; pXMLFile->SetName( rFileName ); m_pCurNode = pXMLFile; - m_pCurData = NULL; + m_pCurData = nullptr; m_aErrorInformation.m_eCode = XML_ERROR_NONE; m_aErrorInformation.m_nLine = 0; @@ -1030,7 +1030,7 @@ XMLFile *SimpleXMLParser::Execute( const OString &rFileName, XMLFile* pXMLFileIn break; } delete pXMLFile; - pXMLFile = NULL; + pXMLFile = nullptr; } osl_unmapMappedFile(h, p, s); diff --git a/l10ntools/source/xrmmerge.cxx b/l10ntools/source/xrmmerge.cxx index 480ec2913b34..230f6a62f7fb 100644 --- a/l10ntools/source/xrmmerge.cxx +++ b/l10ntools/source/xrmmerge.cxx @@ -49,7 +49,7 @@ OString sOutputFile; OString sMergeSrc; OString sLangAttribute; OString sResourceType; -XRMResParser *pParser = NULL; +XRMResParser *pParser = nullptr; extern "C" { // the whole interface to lexer is in this extern "C" section @@ -116,7 +116,7 @@ extern FILE *GetXrmFile() } } // this means the file could not be opened - return NULL; + return nullptr; } int WorkOnTokenSet( int nTyp, char *pTokenText ) @@ -372,7 +372,7 @@ XRMResMerge::XRMResMerge( const OString &rMergeSource, const OString &rOutputFile, const OString &rFilename ) : XRMResParser(), - pMergeDataFile( NULL ), + pMergeDataFile( nullptr ), sFilename( rFilename ) { if (!rMergeSource.isEmpty() && sLanguage.equalsIgnoreAsciiCase("ALL")) -- cgit