Merge "Fix typing incremental decoder"
diff --git a/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java b/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java
index fb1eb27..f1a7e97 100644
--- a/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java
+++ b/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java
@@ -1412,8 +1412,6 @@
     private static WeightedString getWordAtAddressWithParentAddress(
             final FusionDictionaryBufferInterface buffer, final int headerSize, final int address,
             final FormatOptions options) {
-        final StringBuilder builder = new StringBuilder();
-
         int currentAddress = address;
         int index = FormatSpec.MAX_WORD_LENGTH - 1;
         int frequency = Integer.MIN_VALUE;
diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
index 2f146f8..89d6c90 100644
--- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
+++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
@@ -294,6 +294,8 @@
             final String[] gatheredSuggestions;
             final boolean hasRecommendedSuggestions;
             if (0 == mLength) {
+                // TODO: the comment below describes what is intended, but in the practice
+                // mBestSuggestion is only ever set to null so it doesn't work. Fix this.
                 // Either we found no suggestions, or we found some BUT the max length was 0.
                 // If we found some mBestSuggestion will not be null. If it is null, then
                 // we found none, regardless of the max length.
diff --git a/native/jni/src/correction.cpp b/native/jni/src/correction.cpp
index 50f33fe..46ca911 100644
--- a/native/jni/src/correction.cpp
+++ b/native/jni/src/correction.cpp
@@ -14,11 +14,6 @@
  * limitations under the License.
  */
 
-#include <cassert>
-#include <cctype>
-#include <cmath>
-#include <cstring>
-
 #define LOG_TAG "LatinIME: correction.cpp"
 
 #include "char_utils.h"
@@ -1002,7 +997,7 @@
 float Correction::RankingAlgorithm::calcNormalizedScore(const int *before, const int beforeLength,
         const int *after, const int afterLength, const int score) {
     if (0 == beforeLength || 0 == afterLength) {
-        return 0;
+        return 0.0f;
     }
     const int distance = editDistance(before, beforeLength, after, afterLength);
     int spaceCount = 0;
@@ -1013,7 +1008,7 @@
     }
 
     if (spaceCount == afterLength) {
-        return 0;
+        return 0.0f;
     }
 
     const float maxScore = score >= S_INT_MAX ? static_cast<float>(S_INT_MAX)
diff --git a/native/jni/src/correction.h b/native/jni/src/correction.h
index 912cd83..4184c64 100644
--- a/native/jni/src/correction.h
+++ b/native/jni/src/correction.h
@@ -19,7 +19,6 @@
 
 #include <cassert>
 #include <cstring> // for memset()
-#include <stdint.h>
 
 #include "correction_state.h"
 #include "defines.h"
@@ -237,7 +236,7 @@
     int mTerminalOutputIndex;
     int mMaxErrors;
 
-    uint8_t mTotalTraverseCount;
+    int mTotalTraverseCount;
 
     // The following arrays are state buffer.
     int mWord[MAX_WORD_LENGTH_INTERNAL];
@@ -352,7 +351,7 @@
     const int prevCO = outputLength >= 2 ? toBaseLowerCase(output[outputLength - 2]) : 0;
     for (int i = 1; i <= inputSize; ++i) {
         const int ci = toBaseLowerCase(input[i - 1]);
-        const uint16_t cost = (ci == co) ? 0 : 1;
+        const int cost = (ci == co) ? 0 : 1;
         current[i] = min(current[i - 1] + 1, min(prev[i] + 1, prev[i - 1] + cost));
         if (i >= 2 && prevprev && ci == prevCO && co == toBaseLowerCase(input[i - 2])) {
             current[i] = min(current[i], prevprev[i - 2] + 1);
diff --git a/native/jni/src/defines.h b/native/jni/src/defines.h
index 3d7ba4f..90f714b 100644
--- a/native/jni/src/defines.h
+++ b/native/jni/src/defines.h
@@ -237,9 +237,6 @@
 
 #endif // FLAG_DBG
 
-#ifndef U_SHORT_MAX
-#define U_SHORT_MAX 65535    // ((1 << 16) - 1)
-#endif
 #ifndef S_INT_MAX
 #define S_INT_MAX 2147483647 // ((1 << 31) - 1)
 #endif
diff --git a/native/jni/src/proximity_info.cpp b/native/jni/src/proximity_info.cpp
index d38ea67..ffe12ce 100644
--- a/native/jni/src/proximity_info.cpp
+++ b/native/jni/src/proximity_info.cpp
@@ -15,7 +15,6 @@
  */
 
 #include <cassert>
-#include <cmath>
 #include <cstring>
 
 #define LOG_TAG "LatinIME: proximity_info.cpp"
diff --git a/native/jni/src/terminal_attributes.h b/native/jni/src/terminal_attributes.h
index fed3c72..6c2e0dc 100644
--- a/native/jni/src/terminal_attributes.h
+++ b/native/jni/src/terminal_attributes.h
@@ -17,6 +17,7 @@
 #ifndef LATINIME_TERMINAL_ATTRIBUTES_H
 #define LATINIME_TERMINAL_ATTRIBUTES_H
 
+#include <stdint.h>
 #include "binary_format.h"
 
 namespace latinime {