From 0701aca589b819b845d08ea60263ad89718cfd7f Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Thu, 7 Jan 2021 16:42:41 +0100 Subject: Use o3tl::temporary in calls to OUString::iterateCodePoints ...that are not interested in the updated *indexUtf16 value Change-Id: Iaaa0fe45dcb54c4a8a347bcdb6fca6041218d009 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108941 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- i18npool/source/breakiterator/xdictionary.cxx | 5 ++--- i18npool/source/indexentry/indexentrysupplier_asian.cxx | 5 +++-- .../source/indexentry/indexentrysupplier_common.cxx | 4 ++-- .../source/indexentry/indexentrysupplier_default.cxx | 4 ++-- i18npool/source/localedata/LocaleNode.cxx | 17 +++++++---------- .../source/transliteration/transliteration_body.cxx | 4 ++-- 6 files changed, 18 insertions(+), 21 deletions(-) (limited to 'i18npool') diff --git a/i18npool/source/breakiterator/xdictionary.cxx b/i18npool/source/breakiterator/xdictionary.cxx index 947a23c5073b..25dc8bb0ee9b 100644 --- a/i18npool/source/breakiterator/xdictionary.cxx +++ b/i18npool/source/breakiterator/xdictionary.cxx @@ -18,7 +18,7 @@ */ #include - +#include #include #include #include @@ -447,8 +447,7 @@ Boundary const & xdictionary::getWordBoundary(const OUString& rText, sal_Int32 a // if bDirection is false if (!bDirection && startPos > 0 && startPos == (anyPos - boundary.startPos)) { - sal_Int32 indexUtf16 = anyPos-1; - sal_uInt32 ch = rText.iterateCodePoints(&indexUtf16); + sal_uInt32 ch = rText.iterateCodePoints(&o3tl::temporary(sal_Int32(anyPos-1))); if (u_isWhitespace(ch)) i--; } diff --git a/i18npool/source/indexentry/indexentrysupplier_asian.cxx b/i18npool/source/indexentry/indexentrysupplier_asian.cxx index ed7e74f63d0b..abe6c490e5b2 100644 --- a/i18npool/source/indexentry/indexentrysupplier_asian.cxx +++ b/i18npool/source/indexentry/indexentrysupplier_asian.cxx @@ -17,7 +17,9 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include +#include #include #include #include @@ -80,8 +82,7 @@ OUString SAL_CALL IndexEntrySupplier_asian::getIndexCharacter( const OUString& rIndexEntry, const Locale& rLocale, const OUString& rAlgorithm ) { - sal_Int32 i=0; - sal_uInt32 ch = rIndexEntry.iterateCodePoints(&i, 0); + sal_uInt32 ch = rIndexEntry.iterateCodePoints(&o3tl::temporary(sal_Int32(0)), 0); sal_uInt16** (*func)(sal_Int16*)=nullptr; #ifndef DISABLE_DYNLOADING diff --git a/i18npool/source/indexentry/indexentrysupplier_common.cxx b/i18npool/source/indexentry/indexentrysupplier_common.cxx index 3d11a4ac2836..b7c08a0ed82a 100644 --- a/i18npool/source/indexentry/indexentrysupplier_common.cxx +++ b/i18npool/source/indexentry/indexentrysupplier_common.cxx @@ -21,6 +21,7 @@ #include #include #include +#include using namespace ::com::sun::star::uno; using namespace ::com::sun::star; @@ -72,8 +73,7 @@ sal_Bool SAL_CALL IndexEntrySupplier_Common::loadAlgorithm( const lang::Locale& OUString SAL_CALL IndexEntrySupplier_Common::getIndexKey( const OUString& rIndexEntry, const OUString&, const lang::Locale& ) { - sal_Int32 nPos=0; - sal_uInt32 indexChar=rIndexEntry.iterateCodePoints(&nPos, 0); + sal_uInt32 indexChar=rIndexEntry.iterateCodePoints(&o3tl::temporary(sal_Int32(0)), 0); return OUString(&indexChar, 1); } diff --git a/i18npool/source/indexentry/indexentrysupplier_default.cxx b/i18npool/source/indexentry/indexentrysupplier_default.cxx index 519c99ce860e..5e541f139708 100644 --- a/i18npool/source/indexentry/indexentrysupplier_default.cxx +++ b/i18npool/source/indexentry/indexentrysupplier_default.cxx @@ -22,6 +22,7 @@ #include #include #include +#include using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -158,8 +159,7 @@ OUString Index::getIndexDescription(const OUString& rIndexEntry) else return keys[wgt].mkey; } - sal_Int32 nPos=0; - sal_uInt32 indexChar=rIndexEntry.iterateCodePoints(&nPos, 0); + sal_uInt32 indexChar=rIndexEntry.iterateCodePoints(&o3tl::temporary(sal_Int32(0)), 0); return OUString(&indexChar, 1); } diff --git a/i18npool/source/localedata/LocaleNode.cxx b/i18npool/source/localedata/LocaleNode.cxx index 34c77516cc73..28ef390f4939 100644 --- a/i18npool/source/localedata/LocaleNode.cxx +++ b/i18npool/source/localedata/LocaleNode.cxx @@ -24,7 +24,7 @@ #include #include #include - +#include #include #include #include @@ -977,12 +977,12 @@ void LCFormatNode::generateCode (const OFileWriter &of) const // that one. /* XXX NOTE: only simple [...] modifier and "..." quotes detected and * ignored, not nested, no fancy stuff. */ - sal_Int32 nIndex = 0; // aDateSep can be empty if LC_CTYPE was a ref=..., determine from // FormatCode then. - sal_uInt32 cDateSep = (aDateSep.isEmpty() ? 0 : aDateSep.iterateCodePoints( &nIndex)); + sal_uInt32 cDateSep = (aDateSep.isEmpty() + ? 0 : aDateSep.iterateCodePoints( &o3tl::temporary(sal_Int32(0)))); sal_uInt32 cDateSep2 = cDateSep; - nIndex = 0; + sal_Int32 nIndex = 0; OUStringBuffer aPatternBuf(5); OUStringBuffer aPatternBuf2(5); sal_uInt8 nDetected = 0; // bits Y,M,D @@ -1194,14 +1194,12 @@ void LCFormatNode::generateCode (const OFileWriter &of) const // But only if not inherited in which case we don't have aDecSep here. if (!aDecSep.isEmpty()) { - nIndex = 0; - sal_uInt32 cDecSep = aDecSep.iterateCodePoints( &nIndex); + sal_uInt32 cDecSep = aDecSep.iterateCodePoints( &o3tl::temporary(sal_Int32(0))); for (auto const& elem : theDateAcceptancePatterns) { if (elem.getLength() == (cDecSep <= 0xffff ? 3 : 4)) { - nIndex = 1; - if (elem.iterateCodePoints( &nIndex) == cDecSep) + if (elem.iterateCodePoints( &o3tl::temporary(sal_Int32(1))) == cDecSep) { ++nError; fprintf( stderr, "Error: Date acceptance pattern '%s' matches decimal number '#%s#'\n", @@ -1481,8 +1479,7 @@ static void lcl_writeAbbrFullNarrNames( const OFileWriter & of, const LocaleNode aNarrName = p->getValue(); else { - sal_Int32 nIndex = 0; - sal_uInt32 nChar = aFullName.iterateCodePoints( &nIndex); + sal_uInt32 nChar = aFullName.iterateCodePoints( &o3tl::temporary(sal_Int32(0))); aNarrName = OUString( &nChar, 1); } of.writeParameter( elementTag, "DefaultAbbrvName", aAbbrName, i, j); diff --git a/i18npool/source/transliteration/transliteration_body.cxx b/i18npool/source/transliteration/transliteration_body.cxx index a7eae7243835..f873c33374ce 100644 --- a/i18npool/source/transliteration/transliteration_body.cxx +++ b/i18npool/source/transliteration/transliteration_body.cxx @@ -24,6 +24,7 @@ #include #include #include +#include #include @@ -244,8 +245,7 @@ static OUString transliterate_titlecase_Impl( // an exception we need to handle the first chara manually... // we don't want to change surrogates by accident, thuse we use proper code point iteration - sal_Int32 nPos = 0; - sal_uInt32 cFirstChar = aText.iterateCodePoints( &nPos ); + sal_uInt32 cFirstChar = aText.iterateCodePoints( &o3tl::temporary(sal_Int32(0)) ); OUString aResolvedLigature( &cFirstChar, 1 ); // toUpper can be used to properly resolve ligatures and characters like Beta aResolvedLigature = xCharClassImpl->toUpper( aResolvedLigature, 0, aResolvedLigature.getLength(), rLocale ); -- cgit