diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2018-08-14 13:34:13 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2018-08-14 16:07:02 +0200 |
commit | 9b4013ef522fe1faebf76f7f9c624e7e2a90c8c9 (patch) | |
tree | a7d3a4f9f5e0034188c25514cfe31e7d13fc8f52 /i18npool/source | |
parent | a6ca38e610df2536c07d92a0fa87340886bbdf7d (diff) |
cclass_Unicode::StrChr needs to support non-BMP chars
...as seen with Clang's new -fsanitize=implicit-cast during
CppunitTest_starmath_qa_cppunit:
> i18npool/source/characterclassification/cclass_unicode_parser.cxx:565:46: runtime error: implicit conversion from type 'sal_uInt32' (aka 'unsigned int') of value 119886 (32-bit, unsigned) to type 'sal_Unicode' (aka 'char16_t') changed the value to 54350 (16-bit, unsigned)
> #0 in i18npool::cclass_Unicode::getFlags(unsigned int) at i18npool/source/characterclassification/cclass_unicode_parser.cxx:565:46 (instdir/program/libi18npoollo.so +0x3ae807)
> #1 in i18npool::cclass_Unicode::parseText(com::sun::star::i18n::ParseResult&, rtl::OUString const&, int, int) at i18npool/source/characterclassification/cclass_unicode_parser.cxx:712:29 (instdir/program/libi18npoollo.so +0x3b04c3)
> #2 in i18npool::cclass_Unicode::parsePredefinedToken(int, rtl::OUString const&, int, com::sun::star::lang::Locale const&, int, rtl::OUString const&, int, rtl::OUString const&) at i18npool/source/characterclassification/cclass_unicode.cxx:275:5 (instdir/program/libi18npoollo.so +0x3a17ea)
> #3 in non-virtual thunk to i18npool::cclass_Unicode::parsePredefinedToken(int, rtl::OUString const&, int, com::sun::star::lang::Locale const&, int, rtl::OUString const&, int, rtl::OUString const&) at i18npool/source/characterclassification/cclass_unicode.cxx (instdir/program/libi18npoollo.so +0x3a18dc)
> #4 in i18npool::CharacterClassificationImpl::parsePredefinedToken(int, rtl::OUString const&, int, com::sun::star::lang::Locale const&, int, rtl::OUString const&, int, rtl::OUString const&) at i18npool/source/characterclassification/characterclassificationImpl.cxx:118:63 (instdir/program/libi18npoollo.so +0x3c48ba)
> #5 in non-virtual thunk to i18npool::CharacterClassificationImpl::parsePredefinedToken(int, rtl::OUString const&, int, com::sun::star::lang::Locale const&, int, rtl::OUString const&, int, rtl::OUString const&) at i18npool/source/characterclassification/characterclassificationImpl.cxx (instdir/program/libi18npoollo.so +0x3c497c)
> #6 in CharClass::parsePredefinedToken(int, rtl::OUString const&, int, int, rtl::OUString const&, int, rtl::OUString const&) const at unotools/source/i18n/charclass.cxx:443:25 (instdir/program/libutllo.so +0x904d17)
> #7 in SmParser::NextToken() at starmath/source/parse.cxx:391:25 (workdir/LinkTarget/CppunitTest/libtest_starmath_qa_cppunit.so +0xa4a3e7)
> #8 in SmParser::DoTerm(bool) at starmath/source/parse.cxx:1337:13 (workdir/LinkTarget/CppunitTest/libtest_starmath_qa_cppunit.so +0xa5951b)
> #9 in SmParser::DoPower() at starmath/source/parse.cxx:1285:35 (workdir/LinkTarget/CppunitTest/libtest_starmath_qa_cppunit.so +0xa57d46)
> #10 in SmParser::DoProduct() at starmath/source/parse.cxx:1105:19 (workdir/LinkTarget/CppunitTest/libtest_starmath_qa_cppunit.so +0xa5685a)
> #11 in SmParser::DoSum() at starmath/source/parse.cxx:1087:19 (workdir/LinkTarget/CppunitTest/libtest_starmath_qa_cppunit.so +0xa55ebc)
> #12 in SmParser::DoRelation() at starmath/source/parse.cxx:1069:19 (workdir/LinkTarget/CppunitTest/libtest_starmath_qa_cppunit.so +0xa558dc)
> #13 in SmParser::DoExpression(bool) at starmath/source/parse.cxx:1043:29 (workdir/LinkTarget/CppunitTest/libtest_starmath_qa_cppunit.so +0xa54ff5)
> #14 in SmParser::ParseExpression(rtl::OUString const&) at starmath/source/parse.cxx:2366:12 (workdir/LinkTarget/CppunitTest/libtest_starmath_qa_cppunit.so +0xa671dc)
> #15 in (anonymous namespace)::Test::ParseAndCompare(char const*, char const*, char const*) at starmath/qa/cppunit/test_nodetotextvisitors.cxx:485:30 (workdir/LinkTarget/CppunitTest/libtest_starmath_qa_cppunit.so +0x5f7ea6)
> #16 in (anonymous namespace)::Test::testMiscEquivalent() at starmath/qa/cppunit/test_nodetotextvisitors.cxx:637:5 (workdir/LinkTarget/CppunitTest/libtest_starmath_qa_cppunit.so +0x5f2dc8)
Change-Id: Iaf62efd60bd6132e005ab69ce385bbf5c2db5d19
Reviewed-on: https://gerrit.libreoffice.org/58979
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'i18npool/source')
-rw-r--r-- | i18npool/source/characterclassification/cclass_unicode_parser.cxx | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/i18npool/source/characterclassification/cclass_unicode_parser.cxx b/i18npool/source/characterclassification/cclass_unicode_parser.cxx index 8192d7ddab16..96882a8ef3c2 100644 --- a/i18npool/source/characterclassification/cclass_unicode_parser.cxx +++ b/i18npool/source/characterclassification/cclass_unicode_parser.cxx @@ -20,6 +20,7 @@ #include <cclass_unicode.hxx> #include <unicode/uchar.h> +#include <rtl/character.hxx> #include <rtl/math.hxx> #include <rtl/ustring.hxx> #include <com/sun/star/i18n/KParseTokens.hpp> @@ -317,13 +318,15 @@ const sal_Int32 cclass_Unicode::pParseTokensType[ nDefCnt ] = // static -const sal_Unicode* cclass_Unicode::StrChr( const sal_Unicode* pStr, sal_Unicode c ) +const sal_Unicode* cclass_Unicode::StrChr( const sal_Unicode* pStr, sal_uInt32 c ) { if ( !pStr ) return nullptr; + sal_Unicode cs[2]; + auto const n = rtl::splitSurrogates(c, cs); while ( *pStr ) { - if ( *pStr == c ) + if ( *pStr == cs[0] && (n == 1 || pStr[1] == cs[1]) ) return pStr; pStr++; } @@ -659,7 +662,7 @@ ParserFlags cclass_Unicode::getFlagsExtended(sal_uInt32 const c) } -ParserFlags cclass_Unicode::getStartCharsFlags( sal_Unicode c ) +ParserFlags cclass_Unicode::getStartCharsFlags( sal_uInt32 c ) { if ( pStart ) { |