A bug fix for the mistyped space algorithm

Bug: 3311719

-- also fixed compiler warnings

Change-Id: I6941c0d02f10d67af88bc943748dde8d8783fabb
main
satok 2011-03-04 22:50:19 -08:00
parent eaecb56f94
commit 3c4bb7747d
4 changed files with 7 additions and 9 deletions

View File

@ -103,7 +103,7 @@ static void prof_out(void) {
#define U_SHORT_MAX 1 << 16
#endif
#ifndef S_INT_MAX
#define S_INT_MAX ((1 << 31) - 1)
#define S_INT_MAX 2147483647 // ((1 << 31) - 1)
#endif
// Define this to use mmap() for dictionary loading. Undefine to use malloc() instead of mmap().

View File

@ -42,7 +42,7 @@ ProximityInfo::~ProximityInfo() {
}
inline int ProximityInfo::getStartIndexFromCoordinates(const int x, const int y) const {
return (y / CELL_HEIGHT) * GRID_WIDTH + (x / CELL_WIDTH)
return ((y / CELL_HEIGHT) * GRID_WIDTH + (x / CELL_WIDTH))
* MAX_PROXIMITY_CHARS_SIZE;
}

View File

@ -81,7 +81,7 @@ bool UnigramDictionary::isDigraph(const int* codes, const int i, const int codes
void UnigramDictionary::getWordWithDigraphSuggestionsRec(const ProximityInfo *proximityInfo,
const int *xcoordinates, const int* ycoordinates, const int *codesBuffer,
const int codesBufferSize, const int flags, const int* codesSrc, const int codesRemain,
int currentDepth, int* codesDest, unsigned short* outWords, int* frequencies) {
const int currentDepth, int* codesDest, unsigned short* outWords, int* frequencies) {
if (currentDepth < MAX_UMLAUT_SEARCH_DEPTH) {
for (int i = 0; i < codesRemain; ++i) {
@ -232,11 +232,9 @@ void UnigramDictionary::getWordSuggestions(const ProximityInfo *proximityInfo,
if (DEBUG_PROXIMITY_INFO)
LOGI("Input[%d] x = %d, y = %d, has space proximity = %d",
i, x, y, proximityInfo->hasSpaceProximity(x, y));
if (proximityInfo->hasSpaceProximity(x, y)) {
getMistypedSpaceWords(mInputLength, i);
}
}
}
PROF_END(6);
@ -405,7 +403,7 @@ bool UnigramDictionary::getSplitTwoWordsSuggestion(const int inputLength,
const int secondWordLength) {
if (inputLength >= MAX_WORD_LENGTH) return false;
if (0 >= firstWordLength || 0 >= secondWordLength || firstWordStartPos >= secondWordStartPos
|| firstWordStartPos < 0 || secondWordStartPos >= inputLength)
|| firstWordStartPos < 0 || secondWordStartPos + secondWordLength > inputLength)
return false;
const int newWordLength = firstWordLength + secondWordLength + 1;
// Allocating variable length array on stack
@ -487,7 +485,7 @@ void UnigramDictionary::getWordsRec(const int childrenCount, const int pos, cons
}
}
static const int TWO_31ST_DIV_255 = ((1 << 31) - 1) / 255;
static const int TWO_31ST_DIV_255 = S_INT_MAX / 255;
static inline int capped255MultForFullMatchAccentsOrCapitalizationDifference(const int num) {
return (num < TWO_31ST_DIV_255 ? 255 * num : S_INT_MAX);
}

View File

@ -46,7 +46,7 @@ private:
void getWordWithDigraphSuggestionsRec(const ProximityInfo *proximityInfo,
const int *xcoordinates, const int* ycoordinates, const int *codesBuffer,
const int codesBufferSize, const int flags, const int* codesSrc, const int codesRemain,
int currentDepth, int* codesDest, unsigned short* outWords, int* frequencies);
const int currentDepth, int* codesDest, unsigned short* outWords, int* frequencies);
void initSuggestions(const int *codes, const int codesSize, unsigned short *outWords,
int *frequencies);
void getSuggestionCandidates(const int skipPos, const int excessivePos,
@ -113,7 +113,7 @@ private:
const int FULL_WORD_MULTIPLIER;
const int ROOT_POS;
const unsigned int BYTES_IN_ONE_CHAR;
const unsigned int MAX_UMLAUT_SEARCH_DEPTH;
const int MAX_UMLAUT_SEARCH_DEPTH;
// Flags for special processing
// Those *must* match the flags in BinaryDictionary.Flags.ALL_FLAGS in BinaryDictionary.java