diff options
-rw-r--r-- | java/src/com/android/inputmethod/event/DeadKeyCombiner.java | 5 | ||||
-rw-r--r-- | native/jni/HostUnitTests.mk | 4 | ||||
-rw-r--r-- | native/jni/src/suggest/core/dicnode/dic_node_utils.cpp | 5 |
3 files changed, 11 insertions, 3 deletions
diff --git a/java/src/com/android/inputmethod/event/DeadKeyCombiner.java b/java/src/com/android/inputmethod/event/DeadKeyCombiner.java index cb1100d92..a3e4ad833 100644 --- a/java/src/com/android/inputmethod/event/DeadKeyCombiner.java +++ b/java/src/com/android/inputmethod/event/DeadKeyCombiner.java @@ -218,7 +218,10 @@ public class DeadKeyCombiner implements Combiner { @Nonnull private static Event createEventChainFromSequence(final @Nonnull CharSequence text, @Nonnull final Event originalEvent) { - Event lastEvent = originalEvent; + if (text.length() <= 0) { + return originalEvent; + } + Event lastEvent = null; int codePoint = 0; for (int i = text.length(); i > 0; i -= Character.charCount(codePoint)) { codePoint = Character.codePointBefore(text, i); diff --git a/native/jni/HostUnitTests.mk b/native/jni/HostUnitTests.mk index 40ec2558e..e30d50a2e 100644 --- a/native/jni/HostUnitTests.mk +++ b/native/jni/HostUnitTests.mk @@ -29,8 +29,10 @@ include $(LOCAL_PATH)/NativeFileList.mk #################### Host library for unit test # TODO: Remove -std=c++11 once it is set by default on host build. LATIN_IME_SRC_DIR := src +LOCAL_ADDRESS_SANITIZER := true LOCAL_CFLAGS += -std=c++11 -Wno-unused-parameter -Wno-unused-function LOCAL_CLANG := true +LOCAL_CXX_STL := libc++ LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(LATIN_IME_SRC_DIR) LOCAL_MODULE := liblatinime_host_static_for_unittests LOCAL_MODULE_TAGS := optional @@ -40,9 +42,11 @@ include $(BUILD_HOST_STATIC_LIBRARY) #################### Host native tests include $(CLEAR_VARS) LATIN_IME_TEST_SRC_DIR := tests +LOCAL_ADDRESS_SANITIZER := true # TODO: Remove -std=c++11 once it is set by default on host build. LOCAL_CFLAGS += -std=c++11 -Wno-unused-parameter -Wno-unused-function LOCAL_CLANG := true +LOCAL_CXX_STL := libc++ LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(LATIN_IME_SRC_DIR) LOCAL_MODULE := liblatinime_host_unittests LOCAL_MODULE_TAGS := tests diff --git a/native/jni/src/suggest/core/dicnode/dic_node_utils.cpp b/native/jni/src/suggest/core/dicnode/dic_node_utils.cpp index 7d2898b7a..ea438922f 100644 --- a/native/jni/src/suggest/core/dicnode/dic_node_utils.cpp +++ b/native/jni/src/suggest/core/dicnode/dic_node_utils.cpp @@ -74,8 +74,9 @@ namespace latinime { } const WordAttributes wordAttributes = dictionaryStructurePolicy->getWordAttributesInContext( dicNode->getPrevWordIds(), dicNode->getWordId(), multiBigramMap); - if (dicNode->hasMultipleWords() - && (wordAttributes.isBlacklisted() || wordAttributes.isNotAWord())) { + if (wordAttributes.getProbability() == NOT_A_PROBABILITY + || (dicNode->hasMultipleWords() + && (wordAttributes.isBlacklisted() || wordAttributes.isNotAWord()))) { return static_cast<float>(MAX_VALUE_FOR_WEIGHTING); } // TODO: This equation to calculate the improbability looks unreasonable. Investigate this. |