am eae7b293: Check the length of the word when add to FusionDictionary.

* commit 'eae7b293e4a854819aa0de663066cd0b6cdd52e7':
  Check the length of the word when add to FusionDictionary.
This commit is contained in:
Yuichiro Hanada 2012-09-09 20:43:37 -07:00 committed by Android Git Automerger
commit 0295a39845
4 changed files with 18 additions and 2 deletions

View file

@ -41,7 +41,7 @@ public class BinaryDictionary extends Dictionary {
* It is necessary to keep it at this value because some languages e.g. German have
* really long words.
*/
public static final int MAX_WORD_LENGTH = 48;
public static final int MAX_WORD_LENGTH = Constants.Dictionary.MAX_WORD_LENGTH;
public static final int MAX_WORDS = 18;
public static final int MAX_SPACES = 16;

View file

@ -128,6 +128,14 @@ public final class Constants {
}
}
public static class Dictionary {
public static final int MAX_WORD_LENGTH = 48;
private Dictionary() {
// This utility class is no publicly instantiable.
}
}
public static final int NOT_A_CODE = -1;
// See {@link KeyboardActionListener.Adapter#isInvalidCoordinate(int)}.

View file

@ -16,6 +16,7 @@
package com.android.inputmethod.latin.makedict;
import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.makedict.FusionDictionary.CharGroup;
import com.android.inputmethod.latin.makedict.FusionDictionary.DictionaryOptions;
import com.android.inputmethod.latin.makedict.FusionDictionary.Node;
@ -143,7 +144,7 @@ public class BinaryDictInputOutput {
// TODO: Make this value adaptative to content data, store it in the header, and
// use it in the reading code.
private static final int MAX_WORD_LENGTH = 48;
private static final int MAX_WORD_LENGTH = Constants.Dictionary.MAX_WORD_LENGTH;
private static final int MASK_GROUP_ADDRESS_TYPE = 0xC0;
private static final int FLAG_GROUP_ADDRESS_TYPE_NOADDRESS = 0x00;

View file

@ -16,6 +16,8 @@
package com.android.inputmethod.latin.makedict;
import com.android.inputmethod.latin.Constants;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@ -382,6 +384,11 @@ public class FusionDictionary implements Iterable<Word> {
final ArrayList<WeightedString> shortcutTargets,
final boolean isNotAWord, final boolean isBlacklistEntry) {
assert(frequency >= 0 && frequency <= 255);
if (word.length >= Constants.Dictionary.MAX_WORD_LENGTH) {
MakedictLog.w("Ignoring a word that is too long: word.length = " + word.length);
return;
}
Node currentNode = mRoot;
int charIndex = 0;