summaryrefslogtreecommitdiff
path: root/i18npool
diff options
context:
space:
mode:
Diffstat (limited to 'i18npool')
-rw-r--r--i18npool/qa/cppunit/test_breakiterator.cxx23
-rw-r--r--i18npool/source/breakiterator/breakiterator_ctl.cxx8
-rw-r--r--i18npool/source/breakiterator/breakiterator_th.cxx2
3 files changed, 28 insertions, 5 deletions
diff --git a/i18npool/qa/cppunit/test_breakiterator.cxx b/i18npool/qa/cppunit/test_breakiterator.cxx
index 552274864035..0c132acf3a43 100644
--- a/i18npool/qa/cppunit/test_breakiterator.cxx
+++ b/i18npool/qa/cppunit/test_breakiterator.cxx
@@ -919,6 +919,29 @@ void TestBreakIterator::testThai()
}
while (nPos > 0);
}
+
+ // tdf#113694
+ {
+ const sal_Unicode NON_BMP[] = { 0xD800, 0xDC00 };
+ OUString aTest(NON_BMP, SAL_N_ELEMENTS(NON_BMP));
+
+ sal_Int32 nDone=0;
+ sal_Int32 nPos;
+
+ nPos = m_xBreak->nextCharacters(aTest, 0, aLocale,
+ i18n::CharacterIteratorMode::SKIPCELL, 1, nDone);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Should skip full surrogate pair", static_cast<sal_Int32>(SAL_N_ELEMENTS(NON_BMP)), nPos);
+ nPos = m_xBreak->previousCharacters(aTest, SAL_N_ELEMENTS(NON_BMP), aLocale,
+ i18n::CharacterIteratorMode::SKIPCELL, 1, nDone);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Should skip full surrogate pair", static_cast<sal_Int32>(0), nPos);
+
+ nPos = m_xBreak->nextCharacters(aTest, 0, aLocale,
+ i18n::CharacterIteratorMode::SKIPCHARACTER, 1, nDone);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Should skip full surrogate pair", static_cast<sal_Int32>(SAL_N_ELEMENTS(NON_BMP)), nPos);
+ nPos = m_xBreak->previousCharacters(aTest, SAL_N_ELEMENTS(NON_BMP), aLocale,
+ i18n::CharacterIteratorMode::SKIPCHARACTER, 1, nDone);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Should skip full surrogate pair", static_cast<sal_Int32>(0), nPos);
+ }
}
#ifdef TODO
diff --git a/i18npool/source/breakiterator/breakiterator_ctl.cxx b/i18npool/source/breakiterator/breakiterator_ctl.cxx
index b307c37fd9ac..932fb1b77182 100644
--- a/i18npool/source/breakiterator/breakiterator_ctl.cxx
+++ b/i18npool/source/breakiterator/breakiterator_ctl.cxx
@@ -71,8 +71,8 @@ sal_Int32 SAL_CALL BreakIterator_CTL::previousCharacters( const OUString& Text,
} else
nStartPos = 0;
} else { // for BS to delete one char.
- nDone = std::min(nStartPos, nCount);
- nStartPos -= nDone;
+ for (nDone = 0; nDone < nCount && nStartPos > 0; nDone++)
+ Text.iterateCodePoints(&nStartPos, -1);
}
return nStartPos;
@@ -98,8 +98,8 @@ sal_Int32 SAL_CALL BreakIterator_CTL::nextCharacters(const OUString& Text,
} else
nStartPos = len;
} else {
- nDone = std::min(len - nStartPos, nCount);
- nStartPos += nDone;
+ for (nDone = 0; nDone < nCount && nStartPos < Text.getLength(); nDone++)
+ Text.iterateCodePoints(&nStartPos);
}
return nStartPos;
diff --git a/i18npool/source/breakiterator/breakiterator_th.cxx b/i18npool/source/breakiterator/breakiterator_th.cxx
index 36ced38daba8..49f81047247c 100644
--- a/i18npool/source/breakiterator/breakiterator_th.cxx
+++ b/i18npool/source/breakiterator/breakiterator_th.cxx
@@ -127,7 +127,7 @@ void BreakIterator_th::makeIndex(const OUString& Text, sal_Int32 const nStartPos
sal_Int32 startPos = nStartPos;
while (startPos > 0 && is_Thai(str[startPos-1])) startPos--;
- sal_Int32 endPos = std::min(len, nStartPos+1);
+ sal_Int32 endPos = nStartPos;
while (endPos < len && is_Thai(str[endPos])) endPos++;
sal_Int32 start, end, pos;