[Libreoffice-commits] core.git: 4 commits - i18npool/qa i18npool/source sal/rtl sc/source
Caolán McNamara
caolanm at redhat.com
Mon Oct 28 08:52:51 PDT 2013
i18npool/qa/cppunit/test_characterclassification.cxx | 26 +++++++++++++
i18npool/source/characterclassification/cclass_unicode.cxx | 12 ++++--
sal/rtl/ustring.cxx | 12 +++---
sc/source/core/tool/interpr1.cxx | 4 +-
4 files changed, 43 insertions(+), 11 deletions(-)
New commits:
commit 9d5b07b9085f97edfff5d4ac474e9711036bb0c4
Author: Caolán McNamara <caolanm at redhat.com>
Date: Mon Oct 28 15:47:04 2013 +0000
Related: fdo#69641 add a regression test
Change-Id: Icf3324a224d02425acd679a286f3c4a0b7e3ed1c
diff --git a/i18npool/qa/cppunit/test_characterclassification.cxx b/i18npool/qa/cppunit/test_characterclassification.cxx
index a683c3a..92066c7 100644
--- a/i18npool/qa/cppunit/test_characterclassification.cxx
+++ b/i18npool/qa/cppunit/test_characterclassification.cxx
@@ -27,9 +27,11 @@ public:
virtual void tearDown();
void testTitleCase();
+ void testStringType();
CPPUNIT_TEST_SUITE(TestCharacterClassification);
CPPUNIT_TEST(testTitleCase);
+ CPPUNIT_TEST(testStringType);
CPPUNIT_TEST_SUITE_END();
private:
uno::Reference<i18n::XCharacterClassification> m_xCC;
@@ -68,6 +70,30 @@ void TestCharacterClassification::testTitleCase()
}
}
+//https://bugs.freedesktop.org/show_bug.cgi?id=69641
+void TestCharacterClassification::testStringType()
+{
+ lang::Locale aLocale;
+ aLocale.Language = OUString("en");
+ aLocale.Country = OUString("US");
+
+ {
+ //simple case
+ OUString sTest("Some text");
+ sal_Int32 nResult = m_xCC->getStringType(sTest, 0, sTest.getLength(), aLocale);
+ CPPUNIT_ASSERT_EQUAL(nResult, sal_Int32(230));
+ }
+
+ {
+ //tricky case
+ const sal_Unicode MATHEMATICAL_ITALIC_SMALL_THETA[] = { 0xD835, 0xDF03 };
+ OUString sTest(MATHEMATICAL_ITALIC_SMALL_THETA, SAL_N_ELEMENTS(MATHEMATICAL_ITALIC_SMALL_THETA));
+ sal_Int32 nResult = m_xCC->getStringType(sTest, 0, sTest.getLength(), aLocale);
+ CPPUNIT_ASSERT_EQUAL(nResult, sal_Int32(228));
+ }
+
+}
+
void TestCharacterClassification::setUp()
{
BootstrapFixtureBase::setUp();
commit 507e627d83dbfb6a35677450a3fc42d10c79a82e
Author: Caolán McNamara <caolanm at redhat.com>
Date: Mon Oct 28 15:40:01 2013 +0000
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
diff --git a/i18npool/source/characterclassification/cclass_unicode.cxx b/i18npool/source/characterclassification/cclass_unicode.cxx
index 045de39..5655059 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;
}
commit 08b7af126e546bdbd175023429f544baa9861dba
Author: Caolán McNamara <caolanm at redhat.com>
Date: Mon Oct 28 15:39:20 2013 +0000
Related: fdo#69641 check index against length before iterateCodePoints
Change-Id: I71346b12fcfe3e02015038c3c78db574ada873d6
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 04c484f..d1e008a 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -3190,11 +3190,11 @@ void ScInterpreter::ScNumberValue()
{
OUString aTemporary( nDecSep >= 0 ? aInputString.copy( 0, nDecSep ) : aInputString );
sal_Int32 nIndex = 0;
- do
+ while (nIndex < aGroupSeparator.getLength())
{
sal_uInt32 nChar = aGroupSeparator.iterateCodePoints( &nIndex );
aTemporary = aTemporary.replaceAll( OUString( &nChar, 1 ), "" );
- } while ( nIndex < aGroupSeparator.getLength() );
+ }
if ( nDecSep >= 0 )
aInputString = aTemporary + aInputString.copy( nDecSep );
else
commit 47c6eef77378d96d0921c76ec14c338169f14dbe
Author: Caolán McNamara <caolanm at redhat.com>
Date: Mon Oct 28 15:38:39 2013 +0000
Related: fdo#69641 convert OSL_ASSERT into assert
Change-Id: I63c32289c7ac6a428c8c50e49650fbac98c8c5e3
diff --git a/sal/rtl/ustring.cxx b/sal/rtl/ustring.cxx
index abf9db7..e27a1dd 100644
--- a/sal/rtl/ustring.cxx
+++ b/sal/rtl/ustring.cxx
@@ -980,11 +980,11 @@ sal_uInt32 SAL_CALL rtl_uString_iterateCodePoints(
sal_Int32 n;
sal_Unicode cu;
sal_uInt32 cp;
- OSL_ASSERT(string != NULL && indexUtf16 != NULL);
+ assert(string != NULL && indexUtf16 != NULL);
n = *indexUtf16;
- OSL_ASSERT(n >= 0 && n <= string->length);
+ assert(n >= 0 && n <= string->length);
while (incrementCodePoints < 0) {
- OSL_ASSERT(n > 0);
+ assert(n > 0);
cu = string->buffer[--n];
if (SAL_RTL_IS_LOW_SURROGATE(cu) && n != 0 &&
SAL_RTL_IS_HIGH_SURROGATE(string->buffer[n - 1]))
@@ -993,7 +993,7 @@ sal_uInt32 SAL_CALL rtl_uString_iterateCodePoints(
}
++incrementCodePoints;
}
- OSL_ASSERT(n >= 0 && n < string->length);
+ assert(n >= 0 && n < string->length);
cu = string->buffer[n];
if (SAL_RTL_IS_HIGH_SURROGATE(cu) && string->length - n >= 2 &&
SAL_RTL_IS_LOW_SURROGATE(string->buffer[n + 1]))
@@ -1003,7 +1003,7 @@ sal_uInt32 SAL_CALL rtl_uString_iterateCodePoints(
cp = cu;
}
while (incrementCodePoints > 0) {
- OSL_ASSERT(n < string->length);
+ assert(n < string->length);
cu = string->buffer[n++];
if (SAL_RTL_IS_HIGH_SURROGATE(cu) && n != string->length &&
SAL_RTL_IS_LOW_SURROGATE(string->buffer[n]))
@@ -1012,7 +1012,7 @@ sal_uInt32 SAL_CALL rtl_uString_iterateCodePoints(
}
--incrementCodePoints;
}
- OSL_ASSERT(n >= 0 && n <= string->length);
+ assert(n >= 0 && n <= string->length);
*indexUtf16 = n;
return cp;
}
More information about the Libreoffice-commits
mailing list