diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-06-22 10:21:21 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-06-28 10:47:34 +0200 |
commit | bfc1600c6ade6f006eb774bffe7caa9c948e8603 (patch) | |
tree | c660fa18fc6a9e5f05c3cc58fa34411cdc4f4257 /i18npool | |
parent | f9514beb9bfed51aee69227797e74504afed31c6 (diff) |
loplugin:indentation improve checks for brace alignment
Change-Id: I333100fda7e181f68f36b03279b3fbb8cb768310
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117615
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'i18npool')
-rw-r--r-- | i18npool/source/breakiterator/breakiterator_th.cxx | 20 | ||||
-rw-r--r-- | i18npool/source/breakiterator/breakiterator_unicode.cxx | 244 | ||||
-rw-r--r-- | i18npool/source/localedata/LocaleNode.cxx | 5 |
3 files changed, 141 insertions, 128 deletions
diff --git a/i18npool/source/breakiterator/breakiterator_th.cxx b/i18npool/source/breakiterator/breakiterator_th.cxx index 659a50e44e70..df78aeab3afe 100644 --- a/i18npool/source/breakiterator/breakiterator_th.cxx +++ b/i18npool/source/breakiterator/breakiterator_th.cxx @@ -62,9 +62,13 @@ sal_Int32 SAL_CALL BreakIterator_th::previousCharacters( const OUString& Text, if (m_aNextCellIndex[nStartPos-1] == 0) // not a CTL character return BreakIterator_Unicode::previousCharacters(Text, nStartPos, rLocale, nCharacterIteratorMode, nCount, nDone); - else while (nCount > 0 && m_aNextCellIndex[nStartPos - 1] > 0) { - nCount--; nDone++; - nStartPos = m_aPreviousCellIndex[nStartPos - 1]; + else + { + while (nCount > 0 && m_aNextCellIndex[nStartPos - 1] > 0) + { + nCount--; nDone++; + nStartPos = m_aPreviousCellIndex[nStartPos - 1]; + } } } else nStartPos = 0; @@ -89,9 +93,13 @@ sal_Int32 SAL_CALL BreakIterator_th::nextCharacters(const OUString& Text, if (m_aNextCellIndex[nStartPos] == 0) // not a CTL character return BreakIterator_Unicode::nextCharacters(Text, nStartPos, rLocale, nCharacterIteratorMode, nCount, nDone); - else while (nCount > 0 && m_aNextCellIndex[nStartPos] > 0) { - nCount--; nDone++; - nStartPos = m_aNextCellIndex[nStartPos]; + else + { + while (nCount > 0 && m_aNextCellIndex[nStartPos] > 0) + { + nCount--; nDone++; + nStartPos = m_aNextCellIndex[nStartPos]; + } } } else nStartPos = len; diff --git a/i18npool/source/breakiterator/breakiterator_unicode.cxx b/i18npool/source/breakiterator/breakiterator_unicode.cxx index ca34f91e157b..a4a00c46a1ad 100644 --- a/i18npool/source/breakiterator/breakiterator_unicode.cxx +++ b/i18npool/source/breakiterator/breakiterator_unicode.cxx @@ -145,77 +145,52 @@ void BreakIterator_Unicode::loadICUBreakIterator(const css::lang::Locale& rLocal else icuBI->mpValue.reset(); - if (!bInMap && rule) do { - const uno::Sequence< OUString > breakRules = LocaleDataImpl::get()->getBreakIteratorRules(rLocale); + if (!bInMap && rule) + do + { + const uno::Sequence< OUString > breakRules = LocaleDataImpl::get()->getBreakIteratorRules(rLocale); - status = U_ZERO_ERROR; - udata_setAppData("OpenOffice", OpenOffice_dat, &status); - if ( !U_SUCCESS(status) ) throw uno::RuntimeException(); + status = U_ZERO_ERROR; + udata_setAppData("OpenOffice", OpenOffice_dat, &status); + if ( !U_SUCCESS(status) ) throw uno::RuntimeException(); - std::shared_ptr<OOoRuleBasedBreakIterator> rbi; + std::shared_ptr<OOoRuleBasedBreakIterator> rbi; - if (breakRules.getLength() > breakType && !breakRules[breakType].isEmpty()) - { - // langtag;rule;breakType - const OString aBIMapRuleTypeKey( aLangtagStr + ";" + rule + ";" + OString::number(breakType)); - aMapIt = theBIMap.find( aBIMapRuleTypeKey); - bInMap = (aMapIt != theBIMap.end()); - if (bInMap) + if (breakRules.getLength() > breakType && !breakRules[breakType].isEmpty()) { - icuBI->mpValue = aMapIt->second; - icuBI->maBIMapKey = aBIMapGlobalKey; - theBIMap.insert( std::make_pair( aBIMapGlobalKey, icuBI->mpValue)); - break; // do - } + // langtag;rule;breakType + const OString aBIMapRuleTypeKey( aLangtagStr + ";" + rule + ";" + OString::number(breakType)); + aMapIt = theBIMap.find( aBIMapRuleTypeKey); + bInMap = (aMapIt != theBIMap.end()); + if (bInMap) + { + icuBI->mpValue = aMapIt->second; + icuBI->maBIMapKey = aBIMapGlobalKey; + theBIMap.insert( std::make_pair( aBIMapGlobalKey, icuBI->mpValue)); + break; // do + } - rbi = std::make_shared<OOoRuleBasedBreakIterator>(udata_open("OpenOffice", "brk", - OUStringToOString(breakRules[breakType], RTL_TEXTENCODING_ASCII_US).getStr(), &status), status); + rbi = std::make_shared<OOoRuleBasedBreakIterator>(udata_open("OpenOffice", "brk", + OUStringToOString(breakRules[breakType], RTL_TEXTENCODING_ASCII_US).getStr(), &status), status); - if (U_SUCCESS(status)) - { - icuBI->mpValue = std::make_shared<BI_ValueData>(); - icuBI->mpValue->mpBreakIterator = rbi; - theBIMap.insert( std::make_pair( aBIMapRuleTypeKey, icuBI->mpValue)); - } - else - { - rbi.reset(); - } - } - //use icu's breakiterator for Thai, Tibetan and Dzongkha - else if (rLocale.Language != "th" && rLocale.Language != "lo" && rLocale.Language != "bo" && rLocale.Language != "dz" && rLocale.Language != "km") - { - // language;rule (not langtag, unless we'd actually load such) - OString aLanguage( LanguageTag( rLocale).getLanguage().toUtf8()); - const OString aBIMapRuleKey( aLanguage + ";" + rule); - aMapIt = theBIMap.find( aBIMapRuleKey); - bInMap = (aMapIt != theBIMap.end()); - if (bInMap) - { - icuBI->mpValue = aMapIt->second; - icuBI->maBIMapKey = aBIMapGlobalKey; - theBIMap.insert( std::make_pair( aBIMapGlobalKey, icuBI->mpValue)); - break; // do - } - - status = U_ZERO_ERROR; - OString aUDName = OString::Concat(rule) + "_" + aLanguage; - UDataMemory* pUData = udata_open("OpenOffice", "brk", aUDName.getStr(), &status); - if( U_SUCCESS(status) ) - rbi = std::make_shared<OOoRuleBasedBreakIterator>( pUData, status); - if ( U_SUCCESS(status) ) - { - icuBI->mpValue = std::make_shared<BI_ValueData>(); - icuBI->mpValue->mpBreakIterator = rbi; - theBIMap.insert( std::make_pair( aBIMapRuleKey, icuBI->mpValue)); + if (U_SUCCESS(status)) + { + icuBI->mpValue = std::make_shared<BI_ValueData>(); + icuBI->mpValue->mpBreakIterator = rbi; + theBIMap.insert( std::make_pair( aBIMapRuleTypeKey, icuBI->mpValue)); + } + else + { + rbi.reset(); + } } - else + //use icu's breakiterator for Thai, Tibetan and Dzongkha + else if (rLocale.Language != "th" && rLocale.Language != "lo" && rLocale.Language != "bo" && rLocale.Language != "dz" && rLocale.Language != "km") { - rbi.reset(); - - // ;rule (only) - const OString aBIMapRuleOnlyKey( OString::Concat(";") + rule); - aMapIt = theBIMap.find( aBIMapRuleOnlyKey); + // language;rule (not langtag, unless we'd actually load such) + OString aLanguage( LanguageTag( rLocale).getLanguage().toUtf8()); + const OString aBIMapRuleKey( aLanguage + ";" + rule); + aMapIt = theBIMap.find( aBIMapRuleKey); bInMap = (aMapIt != theBIMap.end()); if (bInMap) { @@ -226,78 +201,107 @@ void BreakIterator_Unicode::loadICUBreakIterator(const css::lang::Locale& rLocal } status = U_ZERO_ERROR; - pUData = udata_open("OpenOffice", "brk", rule, &status); + OString aUDName = OString::Concat(rule) + "_" + aLanguage; + UDataMemory* pUData = udata_open("OpenOffice", "brk", aUDName.getStr(), &status); if( U_SUCCESS(status) ) rbi = std::make_shared<OOoRuleBasedBreakIterator>( pUData, status); if ( U_SUCCESS(status) ) { icuBI->mpValue = std::make_shared<BI_ValueData>(); icuBI->mpValue->mpBreakIterator = rbi; - theBIMap.insert( std::make_pair( aBIMapRuleOnlyKey, icuBI->mpValue)); + theBIMap.insert( std::make_pair( aBIMapRuleKey, icuBI->mpValue)); } else { rbi.reset(); + + // ;rule (only) + const OString aBIMapRuleOnlyKey( OString::Concat(";") + rule); + aMapIt = theBIMap.find( aBIMapRuleOnlyKey); + bInMap = (aMapIt != theBIMap.end()); + if (bInMap) + { + icuBI->mpValue = aMapIt->second; + icuBI->maBIMapKey = aBIMapGlobalKey; + theBIMap.insert( std::make_pair( aBIMapGlobalKey, icuBI->mpValue)); + break; // do + } + + status = U_ZERO_ERROR; + pUData = udata_open("OpenOffice", "brk", rule, &status); + if( U_SUCCESS(status) ) + rbi = std::make_shared<OOoRuleBasedBreakIterator>( pUData, status); + if ( U_SUCCESS(status) ) + { + icuBI->mpValue = std::make_shared<BI_ValueData>(); + icuBI->mpValue->mpBreakIterator = rbi; + theBIMap.insert( std::make_pair( aBIMapRuleOnlyKey, icuBI->mpValue)); + } + else + { + rbi.reset(); + } } } - } - if (rbi) { -#if (U_ICU_VERSION_MAJOR_NUM < 58) - // ICU 58 made RuleBasedBreakIterator::setBreakType() private - // instead of protected, so the old workaround of - // https://ssl.icu-project.org/trac/ticket/5498 - // doesn't work anymore. However, they also claim to have fixed - // the cause that an initial fBreakType==-1 would lead to an - // endless loop under some circumstances. - // Let's see ... - switch (rBreakType) { - case LOAD_CHARACTER_BREAKITERATOR: rbi->publicSetBreakType(UBRK_CHARACTER); break; - case LOAD_WORD_BREAKITERATOR: rbi->publicSetBreakType(UBRK_WORD); break; - case LOAD_SENTENCE_BREAKITERATOR: rbi->publicSetBreakType(UBRK_SENTENCE); break; - case LOAD_LINE_BREAKITERATOR: rbi->publicSetBreakType(UBRK_LINE); break; + if (rbi) { + #if (U_ICU_VERSION_MAJOR_NUM < 58) + // ICU 58 made RuleBasedBreakIterator::setBreakType() private + // instead of protected, so the old workaround of + // https://ssl.icu-project.org/trac/ticket/5498 + // doesn't work anymore. However, they also claim to have fixed + // the cause that an initial fBreakType==-1 would lead to an + // endless loop under some circumstances. + // Let's see ... + switch (rBreakType) { + case LOAD_CHARACTER_BREAKITERATOR: rbi->publicSetBreakType(UBRK_CHARACTER); break; + case LOAD_WORD_BREAKITERATOR: rbi->publicSetBreakType(UBRK_WORD); break; + case LOAD_SENTENCE_BREAKITERATOR: rbi->publicSetBreakType(UBRK_SENTENCE); break; + case LOAD_LINE_BREAKITERATOR: rbi->publicSetBreakType(UBRK_LINE); break; + } + #endif } -#endif - } - } while (false); - - if (!icuBI->mpValue || !icuBI->mpValue->mpBreakIterator) do { - // langtag;;;rBreakType (empty rule; empty breakType) - const OString aBIMapLocaleTypeKey( aLangtagStr + ";;;" + OString::number(rBreakType)); - aMapIt = theBIMap.find( aBIMapLocaleTypeKey); - bInMap = (aMapIt != theBIMap.end()); - if (bInMap) + } while (false); + + if (!icuBI->mpValue || !icuBI->mpValue->mpBreakIterator) + do { - icuBI->mpValue = aMapIt->second; - icuBI->maBIMapKey = aBIMapGlobalKey; - theBIMap.insert( std::make_pair( aBIMapGlobalKey, icuBI->mpValue)); - break; // do - } + // langtag;;;rBreakType (empty rule; empty breakType) + const OString aBIMapLocaleTypeKey( aLangtagStr + ";;;" + OString::number(rBreakType)); + aMapIt = theBIMap.find( aBIMapLocaleTypeKey); + bInMap = (aMapIt != theBIMap.end()); + if (bInMap) + { + icuBI->mpValue = aMapIt->second; + icuBI->maBIMapKey = aBIMapGlobalKey; + theBIMap.insert( std::make_pair( aBIMapGlobalKey, icuBI->mpValue)); + break; // do + } - icu::Locale icuLocale( LanguageTagIcu::getIcuLocale( LanguageTag( rLocale))); - std::shared_ptr< icu::BreakIterator > pBI; - - status = U_ZERO_ERROR; - switch (rBreakType) { - case LOAD_CHARACTER_BREAKITERATOR: - pBI.reset( icu::BreakIterator::createCharacterInstance(icuLocale, status) ); - break; - case LOAD_WORD_BREAKITERATOR: - pBI.reset( icu::BreakIterator::createWordInstance(icuLocale, status) ); - break; - case LOAD_SENTENCE_BREAKITERATOR: - pBI.reset( icu::BreakIterator::createSentenceInstance(icuLocale, status) ); - break; - case LOAD_LINE_BREAKITERATOR: - pBI.reset( icu::BreakIterator::createLineInstance(icuLocale, status) ); - break; - } - if ( !U_SUCCESS(status) || !pBI ) { - throw uno::RuntimeException(); - } - icuBI->mpValue = std::make_shared<BI_ValueData>(); - icuBI->mpValue->mpBreakIterator = pBI; - theBIMap.insert( std::make_pair( aBIMapLocaleTypeKey, icuBI->mpValue)); - } while (false); + icu::Locale icuLocale( LanguageTagIcu::getIcuLocale( LanguageTag( rLocale))); + std::shared_ptr< icu::BreakIterator > pBI; + + status = U_ZERO_ERROR; + switch (rBreakType) { + case LOAD_CHARACTER_BREAKITERATOR: + pBI.reset( icu::BreakIterator::createCharacterInstance(icuLocale, status) ); + break; + case LOAD_WORD_BREAKITERATOR: + pBI.reset( icu::BreakIterator::createWordInstance(icuLocale, status) ); + break; + case LOAD_SENTENCE_BREAKITERATOR: + pBI.reset( icu::BreakIterator::createSentenceInstance(icuLocale, status) ); + break; + case LOAD_LINE_BREAKITERATOR: + pBI.reset( icu::BreakIterator::createLineInstance(icuLocale, status) ); + break; + } + if ( !U_SUCCESS(status) || !pBI ) { + throw uno::RuntimeException(); + } + icuBI->mpValue = std::make_shared<BI_ValueData>(); + icuBI->mpValue->mpBreakIterator = pBI; + theBIMap.insert( std::make_pair( aBIMapLocaleTypeKey, icuBI->mpValue)); + } while (false); if (!icuBI->mpValue || !icuBI->mpValue->mpBreakIterator) { throw uno::RuntimeException(); } diff --git a/i18npool/source/localedata/LocaleNode.cxx b/i18npool/source/localedata/LocaleNode.cxx index 28ef390f4939..942e03271029 100644 --- a/i18npool/source/localedata/LocaleNode.cxx +++ b/i18npool/source/localedata/LocaleNode.cxx @@ -75,11 +75,12 @@ const LocaleNode* LocaleNode::getRoot() const const LocaleNode * LocaleNode::findNode ( const char *name) const { if (aName.equalsAscii(name)) return this; - for (size_t i = 0; i< children.size(); i++) { + for (size_t i = 0; i< children.size(); i++) + { const LocaleNode *n=children[i]->findNode(name); if (n) return n; - } + } return nullptr; } |