diff options
Diffstat (limited to 'i18npool/source')
-rw-r--r-- | i18npool/source/breakiterator/xdictionary.cxx | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/i18npool/source/breakiterator/xdictionary.cxx b/i18npool/source/breakiterator/xdictionary.cxx index b930f46d9840..567a2db1aced 100644 --- a/i18npool/source/breakiterator/xdictionary.cxx +++ b/i18npool/source/breakiterator/xdictionary.cxx @@ -414,11 +414,13 @@ Boundary xdictionary::nextWord(const OUString& rText, sal_Int32 anyPos, sal_Int1 { boundary = getWordBoundary(rText, anyPos, wordType, true); anyPos = boundary.endPos; - if (anyPos < rText.getLength()) { + const sal_Int32 nLen = rText.getLength(); + if (anyPos < nLen) { // looknig for the first non-whitespace character from anyPos sal_uInt32 ch = rText.iterateCodePoints(&anyPos, 1); - while (u_isWhitespace(ch)) ch=rText.iterateCodePoints(&anyPos, 1); - rText.iterateCodePoints(&anyPos, -1); + while (u_isWhitespace(ch) && (anyPos < nLen)) ch=rText.iterateCodePoints(&anyPos, 1); + if (anyPos > 0) + rText.iterateCodePoints(&anyPos, -1); } return getWordBoundary(rText, anyPos, wordType, true); |