From 64d1b574ad79ef3bbbab6dade75dbdafecb6bb6b Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 10 Nov 2015 10:19:06 +0100 Subject: loplugin:nullptr (automatic rewrite) Change-Id: I1aa63ce279fe3914e0f5153b7d8559880a3fccc3 --- .../source/hyphenator/hyphen/hyphenimp.cxx | 56 +++++++++++----------- .../source/languageguessing/guesslang.cxx | 4 +- .../source/languageguessing/simpleguesser.cxx | 2 +- lingucomponent/source/spellcheck/spell/sreg.cxx | 2 +- .../source/spellcheck/spell/sspellimp.cxx | 40 ++++++++-------- .../source/thesaurus/libnth/nthesimp.cxx | 48 +++++++++---------- 6 files changed, 76 insertions(+), 76 deletions(-) (limited to 'lingucomponent/source') diff --git a/lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx b/lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx index b540778c085d..ddbb8436aa6d 100644 --- a/lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx +++ b/lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx @@ -70,8 +70,8 @@ Hyphenator::Hyphenator() : aEvtListeners ( GetLinguMutex() ) { bDisposing = false; - pPropHelper = NULL; - aDicts = NULL; + pPropHelper = nullptr; + aDicts = nullptr; numdict = 0; } @@ -197,7 +197,7 @@ Sequence< Locale > SAL_CALL Hyphenator::getLocales() for (sal_Int32 i = 0; i < nLocales; ++i) { LanguageTag aLanguageTag( aDictIt->aLocaleNames[i] ); - aDicts[k].aPtr = NULL; + aDicts[k].aPtr = nullptr; aDicts[k].eEnc = RTL_TEXTENCODING_DONTKNOW; aDicts[k].aLoc = aLanguageTag.getLocale(); aDicts[k].apCC = new CharClass( aLanguageTag ); @@ -219,7 +219,7 @@ Sequence< Locale > SAL_CALL Hyphenator::getLocales() { // no dictionary found so register no dictionaries numdict = 0; - aDicts = NULL; + aDicts = nullptr; aSuppLocales.realloc(0); } } @@ -263,7 +263,7 @@ Reference< XHyphenatedWord > SAL_CALL Hyphenator::hyphenate( const OUString& aWo sal_Int16 minLead = rHelper.GetMinLeading(); sal_Int16 minLen = rHelper.GetMinWordLength(); - HyphenDict *dict = NULL; + HyphenDict *dict = nullptr; rtl_TextEncoding eEnc = RTL_TEXTENCODING_DONTKNOW; Reference< XHyphenatedWord > xRes; @@ -297,10 +297,10 @@ Reference< XHyphenatedWord > SAL_CALL Hyphenator::hyphenate( const OUString& aWo OString sTmp( OU2ENC( dictpath, osl_getThreadTextEncoding() ) ); #endif - if ( ( dict = hnj_hyphen_load ( sTmp.getStr()) ) == NULL ) + if ( ( dict = hnj_hyphen_load ( sTmp.getStr()) ) == nullptr ) { fprintf(stderr, "Couldn't find file %s\n", OU2ENC(dictpath, osl_getThreadTextEncoding()) ); - return NULL; + return nullptr; } aDicts[k].aPtr = dict; aDicts[k].eEnc = getTextEncodingFromCharset(dict->cset); @@ -317,7 +317,7 @@ Reference< XHyphenatedWord > SAL_CALL Hyphenator::hyphenate( const OUString& aWo // Hopefully something not working at all will raise proper attention quickly. ;-) DBG_ASSERT( eEnc != RTL_TEXTENCODING_DONTKNOW, "failed to get text encoding! (maybe incorrect encoding string in file)" ); if (eEnc == RTL_TEXTENCODING_DONTKNOW) - return NULL; + return nullptr; CapType ct = capitalType(aWord, pCC); @@ -345,9 +345,9 @@ Reference< XHyphenatedWord > SAL_CALL Hyphenator::hyphenate( const OUString& aWo std::unique_ptr lcword(new char[wordlen + 1]); std::unique_ptr hyphens(new char[wordlen + 5]); - char ** rep = NULL; // replacements of discretionary hyphenation - int * pos = NULL; // array of [hyphenation point] minus [deletion position] - int * cut = NULL; // length of deletions in original word + char ** rep = nullptr; // replacements of discretionary hyphenation + int * pos = nullptr; // array of [hyphenation point] minus [deletion position] + int * cut = nullptr; // length of deletions in original word // copy converted word into simple char buffer strcpy(lcword.get(),encWord.getStr()); @@ -359,7 +359,7 @@ Reference< XHyphenatedWord > SAL_CALL Hyphenator::hyphenate( const OUString& aWo n++; if (n > 0) { - const bool bFailed = 0 != hnj_hyphen_hyphenate3( dict, lcword.get(), n, hyphens.get(), NULL, + const bool bFailed = 0 != hnj_hyphen_hyphenate3( dict, lcword.get(), n, hyphens.get(), nullptr, &rep, &pos, &cut, minLead, minTrail, Max(dict->clhmin, Max(dict->clhmin, 2) + Max(0, minLead - Max(dict->lhmin, 2))), Max(dict->crhmin, Max(dict->crhmin, 2) + Max(0, minTrail - Max(dict->rhmin, 2))) ); @@ -376,7 +376,7 @@ Reference< XHyphenatedWord > SAL_CALL Hyphenator::hyphenate( const OUString& aWo } if (pos) free(pos); if (cut) free(cut); - return NULL; + return nullptr; } } @@ -426,7 +426,7 @@ Reference< XHyphenatedWord > SAL_CALL Hyphenator::hyphenate( const OUString& aWo if (nHyphenationPos == -1) { - xRes = NULL; + xRes = nullptr; } else { @@ -491,7 +491,7 @@ Reference< XHyphenatedWord > SAL_CALL Hyphenator::hyphenate( const OUString& aWo if (cut) free(cut); return xRes; } - return NULL; + return nullptr; } Reference < XHyphenatedWord > SAL_CALL Hyphenator::queryAlternativeSpelling( @@ -508,7 +508,7 @@ Reference < XHyphenatedWord > SAL_CALL Hyphenator::queryAlternativeSpelling( if (xRes.is() && xRes->isAlternativeSpelling() && xRes->getHyphenationPos() == nIndex) return xRes; } - return NULL; + return nullptr; } #if defined(WNT) @@ -562,7 +562,7 @@ Reference< XPossibleHyphens > SAL_CALL Hyphenator::createPossibleHyphens( const // if we have a hyphenation dictionary matching this locale if (k != -1) { - HyphenDict *dict = NULL; + HyphenDict *dict = nullptr; // if this dictioanry has not been loaded yet do that if (!aDicts[k].aPtr) { @@ -580,10 +580,10 @@ Reference< XPossibleHyphens > SAL_CALL Hyphenator::createPossibleHyphens( const sTmp = Win_GetShortPathName( dictpath ); #endif - if ( ( dict = hnj_hyphen_load ( sTmp.getStr()) ) == NULL ) + if ( ( dict = hnj_hyphen_load ( sTmp.getStr()) ) == nullptr ) { fprintf(stderr, "Couldn't find file %s and %s\n", sTmp.getStr(), OU2ENC(dictpath, osl_getThreadTextEncoding()) ); - return NULL; + return nullptr; } aDicts[k].aPtr = dict; aDicts[k].eEnc = getTextEncodingFromCharset(dict->cset); @@ -600,7 +600,7 @@ Reference< XPossibleHyphens > SAL_CALL Hyphenator::createPossibleHyphens( const // Hopefully something not working at all will raise proper attention quickly. ;-) DBG_ASSERT( eEnc != RTL_TEXTENCODING_DONTKNOW, "failed to get text encoding! (maybe incorrect encoding string in file)" ); if (eEnc == RTL_TEXTENCODING_DONTKNOW) - return NULL; + return nullptr; // first handle smart quotes both single and double OUStringBuffer rBuf(aWord); @@ -625,9 +625,9 @@ Reference< XPossibleHyphens > SAL_CALL Hyphenator::createPossibleHyphens( const int wordlen = encWord.getLength(); std::unique_ptr lcword(new char[wordlen+1]); std::unique_ptr hyphens(new char[wordlen+5]); - char ** rep = NULL; // replacements of discretionary hyphenation - int * pos = NULL; // array of [hyphenation point] minus [deletion position] - int * cut = NULL; // length of deletions in original word + char ** rep = nullptr; // replacements of discretionary hyphenation + int * pos = nullptr; // array of [hyphenation point] minus [deletion position] + int * cut = nullptr; // length of deletions in original word // copy converted word into simple char buffer strcpy(lcword.get(),encWord.getStr()); @@ -639,7 +639,7 @@ Reference< XPossibleHyphens > SAL_CALL Hyphenator::createPossibleHyphens( const n++; if (n > 0) { - const bool bFailed = 0 != hnj_hyphen_hyphenate3(dict, lcword.get(), n, hyphens.get(), NULL, + const bool bFailed = 0 != hnj_hyphen_hyphenate3(dict, lcword.get(), n, hyphens.get(), nullptr, &rep, &pos, &cut, minLead, minTrail, Max(dict->clhmin, Max(dict->clhmin, 2) + Max(0, minLead - Max(dict->lhmin, 2))), Max(dict->crhmin, Max(dict->crhmin, 2) + Max(0, minTrail - Max(dict->rhmin, 2))) ); @@ -656,7 +656,7 @@ Reference< XPossibleHyphens > SAL_CALL Hyphenator::createPossibleHyphens( const if (pos) free(pos); if (cut) free(cut); - return NULL; + return nullptr; } } // now backfill hyphens[] for any removed periods @@ -709,7 +709,7 @@ Reference< XPossibleHyphens > SAL_CALL Hyphenator::createPossibleHyphens( const return xRes; } - return NULL; + return nullptr; } OUString SAL_CALL Hyphenator::makeLowerCase(const OUString& aTerm, CharClass * pCC) @@ -824,7 +824,7 @@ void SAL_CALL Hyphenator::dispose() { pPropHelper->RemoveAsPropListener(); delete pPropHelper; - pPropHelper = NULL; + pPropHelper = nullptr; } } } @@ -883,7 +883,7 @@ Sequence< OUString > Hyphenator::getSupportedServiceNames_Static() void * SAL_CALL Hyphenator_getFactory( const sal_Char * pImplName, XMultiServiceFactory * pServiceManager, void * ) { - void * pRet = 0; + void * pRet = nullptr; if ( Hyphenator::getImplementationName_Static().equalsAscii( pImplName ) ) { Reference< XSingleServiceFactory > xFactory = diff --git a/lingucomponent/source/languageguessing/guesslang.cxx b/lingucomponent/source/languageguessing/guesslang.cxx index 678277fbae62..500f672a49bd 100644 --- a/lingucomponent/source/languageguessing/guesslang.cxx +++ b/lingucomponent/source/languageguessing/guesslang.cxx @@ -366,9 +366,9 @@ static const struct ::cppu::ImplementationEntry s_component_entries [] = LangGuess_Impl_create, getImplementationName_LangGuess_Impl, getSupportedServiceNames_LangGuess_Impl, ::cppu::createSingleComponentFactory, - 0, 0 + nullptr, 0 }, - { 0, 0, 0, 0, 0, 0 } + { nullptr, nullptr, nullptr, nullptr, nullptr, 0 } }; extern "C" diff --git a/lingucomponent/source/languageguessing/simpleguesser.cxx b/lingucomponent/source/languageguessing/simpleguesser.cxx index a777cf3ef56b..5d7caec5a6c0 100644 --- a/lingucomponent/source/languageguessing/simpleguesser.cxx +++ b/lingucomponent/source/languageguessing/simpleguesser.cxx @@ -84,7 +84,7 @@ typedef struct textcat_t{ SimpleGuesser::SimpleGuesser() { - h = NULL; + h = nullptr; } SimpleGuesser& SimpleGuesser::operator=(const SimpleGuesser& sg){ diff --git a/lingucomponent/source/spellcheck/spell/sreg.cxx b/lingucomponent/source/spellcheck/spell/sreg.cxx index 5fb211071e7e..5a783e66205b 100644 --- a/lingucomponent/source/spellcheck/spell/sreg.cxx +++ b/lingucomponent/source/spellcheck/spell/sreg.cxx @@ -34,7 +34,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL spell_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) { - void * pRet = NULL; + void * pRet = nullptr; pRet = SpellChecker_getFactory( pImplName, static_cast< XMultiServiceFactory * >( pServiceManager ), diff --git a/lingucomponent/source/spellcheck/spell/sspellimp.cxx b/lingucomponent/source/spellcheck/spell/sspellimp.cxx index 2fd0f581b8e3..ccb3c3beb2c4 100644 --- a/lingucomponent/source/spellcheck/spell/sspellimp.cxx +++ b/lingucomponent/source/spellcheck/spell/sspellimp.cxx @@ -59,13 +59,13 @@ using namespace linguistic; #define SPELLML_HEADER "" SpellChecker::SpellChecker() : - aDicts(NULL), - aDEncs(NULL), - aDLocs(NULL), - aDNames(NULL), + aDicts(nullptr), + aDEncs(nullptr), + aDLocs(nullptr), + aDNames(nullptr), numdict(0), aEvtListeners(GetLinguMutex()), - pPropHelper(NULL), + pPropHelper(nullptr), bDisposing(false) { } @@ -192,7 +192,7 @@ Sequence< Locale > SAL_CALL SpellChecker::getLocales() // Once for each of it's supported locales. for (sal_Int32 i = 0; i < nLocales; ++i) { - aDicts[k] = NULL; + aDicts[k] = nullptr; aDEncs[k] = RTL_TEXTENCODING_DONTKNOW; aDLocs[k] = LanguageTag::convertToLocale( aLocaleNames[i] ); // also both files have to be in the same directory and the @@ -214,13 +214,13 @@ Sequence< Locale > SAL_CALL SpellChecker::getLocales() // no dictionary found so register no dictionaries numdict = 0; delete[] aDicts; - aDicts = NULL; + aDicts = nullptr; delete[] aDEncs; - aDEncs = NULL; + aDEncs = nullptr; delete[] aDLocs; - aDLocs = NULL; + aDLocs = nullptr; delete[] aDNames; - aDNames = NULL; + aDNames = nullptr; aSuppLocales.realloc(0); } } @@ -252,7 +252,7 @@ sal_Bool SAL_CALL SpellChecker::hasLocale(const Locale& rLocale) sal_Int16 SpellChecker::GetSpellFailure( const OUString &rWord, const Locale &rLocale ) { - Hunspell * pMS = NULL; + Hunspell * pMS = nullptr; rtl_TextEncoding eEnc = RTL_TEXTENCODING_DONTKNOW; // initialize a myspell object for each dictionary once @@ -287,7 +287,7 @@ sal_Int16 SpellChecker::GetSpellFailure( const OUString &rWord, const Locale &rL { for (sal_Int32 i = 0; i < numdict; ++i) { - pMS = NULL; + pMS = nullptr; eEnc = RTL_TEXTENCODING_DONTKNOW; if (rLocale == aDLocs[i]) @@ -359,7 +359,7 @@ sal_Int16 SpellChecker::GetSpellFailure( const OUString &rWord, const Locale &rL } else { return -1; } - pMS = NULL; + pMS = nullptr; } } } @@ -416,7 +416,7 @@ Reference< XSpellAlternatives > Reference< XSpellAlternatives > xRes; // note: mutex is held by higher up by spell which covers both - Hunspell* pMS = NULL; + Hunspell* pMS = nullptr; rtl_TextEncoding eEnc = RTL_TEXTENCODING_DONTKNOW; // first handle smart quotes (single and double) @@ -441,7 +441,7 @@ Reference< XSpellAlternatives > Sequence< OUString > aStr( 0 ); for (int i = 0; i < numdict; i++) { - pMS = NULL; + pMS = nullptr; eEnc = RTL_TEXTENCODING_DONTKNOW; if (rLocale == aDLocs[i]) @@ -452,7 +452,7 @@ Reference< XSpellAlternatives > if (pMS) { - char ** suglst = NULL; + char ** suglst = nullptr; OString aWrd(OU2ENC(nWord,eEnc)); int count = pMS->suggest(&suglst, aWrd.getStr()); @@ -488,10 +488,10 @@ Reference< XSpellAlternatives > SAL_CALL SpellChecker::spell( MutexGuard aGuard( GetLinguMutex() ); if (rLocale == Locale() || rWord.isEmpty()) - return NULL; + return nullptr; if (!hasLocale( rLocale )) - return NULL; + return nullptr; Reference< XSpellAlternatives > xAlt; if (!isValid( rWord, rLocale, rProperties )) @@ -586,7 +586,7 @@ void SAL_CALL SpellChecker::dispose() { pPropHelper->RemoveAsPropListener(); delete pPropHelper; - pPropHelper = NULL; + pPropHelper = nullptr; } } } @@ -645,7 +645,7 @@ Sequence< OUString > SpellChecker::getSupportedServiceNames_Static() void * SAL_CALL SpellChecker_getFactory( const sal_Char * pImplName, XMultiServiceFactory * pServiceManager, void * ) { - void * pRet = 0; + void * pRet = nullptr; if ( SpellChecker::getImplementationName_Static().equalsAscii( pImplName ) ) { Reference< XSingleServiceFactory > xFactory = diff --git a/lingucomponent/source/thesaurus/libnth/nthesimp.cxx b/lingucomponent/source/thesaurus/libnth/nthesimp.cxx index 017429ef4b4a..8aa4dcd960e4 100644 --- a/lingucomponent/source/thesaurus/libnth/nthesimp.cxx +++ b/lingucomponent/source/thesaurus/libnth/nthesimp.cxx @@ -65,12 +65,12 @@ Thesaurus::Thesaurus() : aEvtListeners ( GetLinguMutex() ) { bDisposing = false; - pPropHelper = NULL; - aThes = NULL; - aCharSetInfo = NULL; - aTEncs = NULL; - aTLocs = NULL; - aTNames = NULL; + pPropHelper = nullptr; + aThes = nullptr; + aCharSetInfo = nullptr; + aTEncs = nullptr; + aTLocs = nullptr; + aTNames = nullptr; numthes = 0; prevLocale = LANGUAGE_DONTKNOW; } @@ -82,28 +82,28 @@ Thesaurus::~Thesaurus() for (int i = 0; i < numthes; i++) { if (aThes[i]) delete aThes[i]; - aThes[i] = NULL; + aThes[i] = nullptr; } delete[] aThes; } - aThes = NULL; + aThes = nullptr; if (aCharSetInfo) { for (int i = 0; i < numthes; i++) { if (aCharSetInfo[i]) delete aCharSetInfo[i]; - aCharSetInfo[i] = NULL; + aCharSetInfo[i] = nullptr; } delete[] aCharSetInfo; } - aCharSetInfo = NULL; + aCharSetInfo = nullptr; numthes = 0; if (aTEncs) delete[] aTEncs; - aTEncs = NULL; + aTEncs = nullptr; if (aTLocs) delete[] aTLocs; - aTLocs = NULL; + aTLocs = nullptr; if (aTNames) delete[] aTNames; - aTNames = NULL; + aTNames = nullptr; if (pPropHelper) { @@ -216,7 +216,7 @@ Sequence< Locale > SAL_CALL Thesaurus::getLocales() for (sal_Int32 i = 0; i < nLocales; ++i) { LanguageTag aLanguageTag( aDictIt->aLocaleNames[i] ); - aThes[k] = NULL; + aThes[k] = nullptr; aTEncs[k] = RTL_TEXTENCODING_DONTKNOW; aTLocs[k] = aLanguageTag.getLocale(); aCharSetInfo[k] = new CharClass( aLanguageTag ); @@ -238,11 +238,11 @@ Sequence< Locale > SAL_CALL Thesaurus::getLocales() { /* no dictionary found so register no dictionaries */ numthes = 0; - aThes = NULL; - aTEncs = NULL; - aTLocs = NULL; - aTNames = NULL; - aCharSetInfo = NULL; + aThes = nullptr; + aTEncs = nullptr; + aTLocs = nullptr; + aTNames = nullptr; + aCharSetInfo = nullptr; aSuppLocales.realloc(0); } } @@ -304,15 +304,15 @@ Sequence < Reference < css::linguistic2::XMeaning > > SAL_CALL Thesaurus::queryM if (prevTerm == qTerm && prevLocale == nLanguage) return prevMeanings; - mentry * pmean = NULL; + mentry * pmean = nullptr; sal_Int32 nmean = 0; PropertyHelper_Thesaurus &rHelper = GetPropHelper(); rHelper.SetTmpPropVals( rProperties ); - MyThes * pTH = NULL; + MyThes * pTH = nullptr; rtl_TextEncoding eEnc = RTL_TEXTENCODING_DONTKNOW; - CharClass * pCC = NULL; + CharClass * pCC = nullptr; // find the first thesaurus that matches the locale for (int i =0; i < numthes; i++) @@ -596,7 +596,7 @@ void SAL_CALL Thesaurus::dispose() { pPropHelper->RemoveAsPropListener(); delete pPropHelper; - pPropHelper = NULL; + pPropHelper = nullptr; } } } @@ -653,7 +653,7 @@ Sequence< OUString > Thesaurus::getSupportedServiceNames_Static() void * SAL_CALL Thesaurus_getFactory( const sal_Char * pImplName, XMultiServiceFactory * pServiceManager, void * ) { - void * pRet = 0; + void * pRet = nullptr; if ( Thesaurus::getImplementationName_Static().equalsAscii( pImplName ) ) { -- cgit