diff options
author | Caolán McNamara <caolanm@redhat.com> | 2013-10-28 15:40:01 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-10-28 15:52:30 +0000 |
commit | 507e627d83dbfb6a35677450a3fc42d10c79a82e (patch) | |
tree | 2a4a679f20df25b0ab87116d3e09fda82430a8a3 /i18npool | |
parent | 08b7af126e546bdbd175023429f544baa9861dba (diff) |
Related: fdo#69641 double iterateCodePoints doesn't make sense to me
This came in with 04212c3015cd4ab118a0aec2bb04bc153a64af41 but
the bug number of #i86439# appears to be the wrong id. It doesn't
make sense to me. Rework cclass_Unicode::getStringType to iterate
safely over the codepoints of the requested range. Perhaps that
was the reason for the original commit.
Change-Id: Ice4287eb6f9fc6a9705845c0cf995263815de2e7
Diffstat (limited to 'i18npool')
-rw-r--r-- | i18npool/source/characterclassification/cclass_unicode.cxx | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/i18npool/source/characterclassification/cclass_unicode.cxx b/i18npool/source/characterclassification/cclass_unicode.cxx index 045de399227a..56550597e1d4 100644 --- a/i18npool/source/characterclassification/cclass_unicode.cxx +++ b/i18npool/source/characterclassification/cclass_unicode.cxx @@ -132,7 +132,6 @@ cclass_Unicode::getCharType( const OUString& Text, sal_Int32* nPos, sal_Int32 in using namespace ::com::sun::star::i18n::KCharacterType; sal_uInt32 ch = Text.iterateCodePoints(nPos, increment); - if (increment > 0) ch = Text.iterateCodePoints(nPos, 0); switch ( u_charType(ch) ) { // Upper case U_UPPERCASE_LETTER : @@ -204,9 +203,16 @@ sal_Int32 SAL_CALL cclass_Unicode::getStringType( const OUString& Text, sal_Int32 nPos, sal_Int32 nCount, const Locale& /*rLocale*/ ) throw(RuntimeException) { if ( nPos < 0 || Text.getLength() <= nPos ) return 0; - sal_Int32 result = getCharType(Text, &nPos, 0); - for (sal_Int32 i = 1; i < nCount && nPos < Text.getLength(); i++) + sal_Int32 result = 0; + + while (nCount && nPos < Text.getLength()) + { + sal_Int32 nOrigPos = nPos; result |= getCharType(Text, &nPos, 1); + sal_Int32 nUtf16Units = nPos - nOrigPos; + nCount -= nUtf16Units; + } + return result; } |