diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2017-02-25 16:50:23 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2017-02-25 16:50:23 +0100 |
commit | 4520435ad59802b6a567b3bb6c77927663be0f81 (patch) | |
tree | 5bdc61e908c05805995becd067d43df6ba6dff84 /lingucomponent | |
parent | 283e843be91ef4d727c0815d1b8a0420fd16a7fd (diff) |
Clean up use of integer types
Change-Id: I06364be5bbbe7862d20ea24ee155cf468f63f0b0
Diffstat (limited to 'lingucomponent')
-rw-r--r-- | lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx b/lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx index 4b1358392133..5bf39b19ed76 100644 --- a/lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx +++ b/lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx @@ -50,6 +50,7 @@ #include <stdio.h> #include <string.h> +#include <cassert> #include <list> #include <set> #include <memory> @@ -617,7 +618,7 @@ Reference< XPossibleHyphens > SAL_CALL Hyphenator::createPossibleHyphens( const // now convert word to needed encoding OString encWord(OU2ENC(nTerm,eEnc)); - int wordlen = encWord.getLength(); + sal_Int32 wordlen = encWord.getLength(); std::unique_ptr<char[]> lcword(new char[wordlen+1]); std::unique_ptr<char[]> hyphens(new char[wordlen+5]); char ** rep = nullptr; // replacements of discretionary hyphenation @@ -628,7 +629,7 @@ Reference< XPossibleHyphens > SAL_CALL Hyphenator::createPossibleHyphens( const strcpy(lcword.get(),encWord.getStr()); // first remove any trailing periods - int n = wordlen-1; + sal_Int32 n = wordlen-1; while((n >=0) && (lcword[n] == '.')) n--; n++; @@ -655,14 +656,13 @@ Reference< XPossibleHyphens > SAL_CALL Hyphenator::createPossibleHyphens( const } } // now backfill hyphens[] for any removed periods - for (int c = n; c < wordlen; c++) + for (sal_Int32 c = n; c < wordlen; c++) hyphens[c] = '0'; hyphens[wordlen] = '\0'; - sal_Int16 nHyphCount = 0; - sal_Int16 i; + sal_Int32 nHyphCount = 0; - for ( i = 0; i < encWord.getLength(); i++) + for ( sal_Int32 i = 0; i < encWord.getLength(); i++) { if (hyphens[i]&1) nHyphCount++; @@ -673,12 +673,25 @@ Reference< XPossibleHyphens > SAL_CALL Hyphenator::createPossibleHyphens( const OUStringBuffer hyphenatedWordBuffer; nHyphCount = 0; - for (i = 0; i < nWord.getLength(); i++) + for (sal_Int32 i = 0; i < nWord.getLength(); i++) { hyphenatedWordBuffer.append(aWord[i]); // hyphenation position if (hyphens[i]&1) { + // linguistic::PossibleHyphens is stuck with + // css::uno::Sequence<sal_Int16> because of + // css.linguistic2.XPossibleHpyhens.getHyphenationPositions, so + // any further positions need to be ignored: + assert(i >= SAL_MIN_INT16); + if (i > SAL_MAX_INT16) + { + SAL_WARN( + "lingucomponent", + "hyphen pos " << i << " > SAL_MAX_INT16 in \"" << aWord + << "\""); + continue; + } pPos[nHyphCount] = i; hyphenatedWordBuffer.append('='); nHyphCount++; |