Cosmetic fixes and a bug fix in UnigramDictionary::testCharGroupForContinuedLikeness().
This change has actually been extracted from a change work in progress I4fe423834b8131fb122251892c98228a6e08ba25
Change-Id: I52568fa09da2ea22be7f8bfe9676b7cd73c31fa4
diff --git a/native/jni/src/defines.h b/native/jni/src/defines.h
index 28661ab..2ce10d0 100644
--- a/native/jni/src/defines.h
+++ b/native/jni/src/defines.h
@@ -17,6 +17,8 @@
#ifndef LATINIME_DEFINES_H
#define LATINIME_DEFINES_H
+#include <stdint.h>
+
#if defined(FLAG_DO_PROFILE) || defined(FLAG_DBG)
#include <android/log.h>
#ifndef LOG_TAG
@@ -26,9 +28,9 @@
#define AKLOGI(fmt, ...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, fmt, ##__VA_ARGS__)
#define DUMP_RESULT(words, frequencies, maxWordCount, maxWordLength) do { \
- dumpResult(words, frequencies, maxWordCount, maxWordLength); } while(0)
-#define DUMP_WORD(word, length) do { dumpWord(word, length); } while(0)
-#define DUMP_WORD_INT(word, length) do { dumpWordInt(word, length); } while(0)
+ dumpResult(words, frequencies, maxWordCount, maxWordLength); } while (0)
+#define DUMP_WORD(word, length) do { dumpWord(word, length); } while (0)
+#define DUMP_WORD_INT(word, length) do { dumpWordInt(word, length); } while (0)
static inline void dumpWordInfo(const unsigned short *word, const int length,
const int rank, const int frequency) {
@@ -39,7 +41,8 @@
if (c == 0) {
break;
}
- charBuf[i] = c;
+ // static_cast only for debugging
+ charBuf[i] = static_cast<char>(c);
}
charBuf[i] = 0;
if (i > 1) {
@@ -65,7 +68,8 @@
if (c == 0) {
break;
}
- charBuf[i] = c;
+ // static_cast only for debugging
+ charBuf[i] = static_cast<char>(c);
}
charBuf[i] = 0;
if (i > 1) {
@@ -84,7 +88,7 @@
}
#ifndef __ANDROID__
-#define ASSERT(success) do { if(!success) { showStackTrace(); assert(success);};} while (0)
+#define ASSERT(success) do { if (!success) { showStackTrace(); assert(success);};} while (0)
#define SHOW_STACK_TRACE do { showStackTrace(); } while (0)
#include <execinfo.h>
@@ -128,14 +132,14 @@
#define PROF_RESET prof_reset()
#define PROF_COUNT(prof_buf_id) ++profile_counter[prof_buf_id]
-#define PROF_OPEN do { PROF_RESET; PROF_START(PROF_BUF_SIZE - 1); } while(0)
+#define PROF_OPEN do { PROF_RESET; PROF_START(PROF_BUF_SIZE - 1); } while (0)
#define PROF_START(prof_buf_id) do { \
- PROF_COUNT(prof_buf_id); profile_old[prof_buf_id] = (clock()); } while(0)
-#define PROF_CLOSE do { PROF_END(PROF_BUF_SIZE - 1); PROF_OUTALL; } while(0)
+ PROF_COUNT(prof_buf_id); profile_old[prof_buf_id] = (clock()); } while (0)
+#define PROF_CLOSE do { PROF_END(PROF_BUF_SIZE - 1); PROF_OUTALL; } while (0)
#define PROF_END(prof_buf_id) profile_buf[prof_buf_id] += ((clock()) - profile_old[prof_buf_id])
#define PROF_CLOCKOUT(prof_buf_id) \
AKLOGI("%s : clock is %f", __FUNCTION__, (clock() - profile_old[prof_buf_id]))
-#define PROF_OUTALL do { AKLOGI("--- %s ---", __FUNCTION__); prof_out(); } while(0)
+#define PROF_OUTALL do { AKLOGI("--- %s ---", __FUNCTION__); prof_out(); } while (0)
static inline void prof_reset(void) {
for (int i = 0; i < PROF_BUF_SIZE; ++i) {
@@ -236,15 +240,15 @@
#define FLAG_BIGRAM_FREQ 0x7F
#define DICTIONARY_VERSION_MIN 200
-#define NOT_VALID_WORD -99
-#define NOT_A_CHARACTER -1
-#define NOT_A_DISTANCE -1
-#define NOT_A_COORDINATE -1
-#define EQUIVALENT_CHAR_WITHOUT_DISTANCE_INFO -2
-#define PROXIMITY_CHAR_WITHOUT_DISTANCE_INFO -3
-#define ADDITIONAL_PROXIMITY_CHAR_DISTANCE_INFO -4
-#define NOT_AN_INDEX -1
-#define NOT_A_PROBABILITY -1
+#define NOT_VALID_WORD (-99)
+#define NOT_A_CODE_POINT (-1)
+#define NOT_A_DISTANCE (-1)
+#define NOT_A_COORDINATE (-1)
+#define EQUIVALENT_CHAR_WITHOUT_DISTANCE_INFO (-2)
+#define PROXIMITY_CHAR_WITHOUT_DISTANCE_INFO (-3)
+#define ADDITIONAL_PROXIMITY_CHAR_DISTANCE_INFO (-4)
+#define NOT_AN_INDEX (-1)
+#define NOT_A_PROBABILITY (-1)
#define KEYCODE_SPACE ' '
@@ -355,8 +359,8 @@
#define NEUTRAL_AREA_RADIUS_RATIO 1.3f
// DEBUG
-#define INPUTLENGTH_FOR_DEBUG -1
-#define MIN_OUTPUT_INDEX_FOR_DEBUG -1
+#define INPUTLENGTH_FOR_DEBUG (-1)
+#define MIN_OUTPUT_INDEX_FOR_DEBUG (-1)
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
TypeName(const TypeName&); \