From ce9efbff53ba04bd719c3c15d8a5a501ff12714f Mon Sep 17 00:00:00 2001 From: Doug Kwan Date: Thu, 7 Jul 2011 22:53:50 -0700 Subject: [PATCH] Compile code used in logging conditionally so that gcc does not complain about unused-but-set variables. Change-Id: I141f438694a1854d54d08cb5a74c23222dd9d85e --- native/src/bigram_dictionary.cpp | 2 ++ native/src/unigram_dictionary.cpp | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/native/src/bigram_dictionary.cpp b/native/src/bigram_dictionary.cpp index 11e6dc250..d11aee28e 100644 --- a/native/src/bigram_dictionary.cpp +++ b/native/src/bigram_dictionary.cpp @@ -42,8 +42,10 @@ BigramDictionary::~BigramDictionary() { bool BigramDictionary::addWordBigram(unsigned short *word, int length, int frequency) { word[length] = 0; if (DEBUG_DICT) { +#ifdef FLAG_DBG char s[length + 1]; for (int i = 0; i <= length; i++) s[i] = word[i]; +#endif LOGI("Bigram: Found word = %s, freq = %d :", s, frequency); } diff --git a/native/src/unigram_dictionary.cpp b/native/src/unigram_dictionary.cpp index 290e9f997..42951bf7a 100644 --- a/native/src/unigram_dictionary.cpp +++ b/native/src/unigram_dictionary.cpp @@ -155,9 +155,11 @@ int UnigramDictionary::getSuggestions(const ProximityInfo *proximityInfo, const LOGI("Returning %d words", suggestedWordsCount); /// Print the returned words for (int j = 0; j < suggestedWordsCount; ++j) { +#ifdef FLAG_DBG short unsigned int* w = mOutputChars + j * MAX_WORD_LENGTH; char s[MAX_WORD_LENGTH]; for (int i = 0; i <= MAX_WORD_LENGTH; i++) s[i] = w[i]; +#endif LOGI("%s %i", s, mFrequencies[j]); } LOGI("Next letters: "); @@ -283,8 +285,10 @@ static inline void registerNextLetter(unsigned short c, int *nextLetters, int ne bool UnigramDictionary::addWord(unsigned short *word, int length, int frequency) { word[length] = 0; if (DEBUG_DICT && DEBUG_SHOW_FOUND_WORD) { +#ifdef FLAG_DBG char s[length + 1]; for (int i = 0; i <= length; i++) s[i] = word[i]; +#endif LOGI("Found word = %s, freq = %d", s, frequency); } if (length > MAX_WORD_LENGTH) { @@ -305,8 +309,10 @@ bool UnigramDictionary::addWord(unsigned short *word, int length, int frequency) } if (insertAt < MAX_WORDS) { if (DEBUG_DICT) { +#ifdef FLAG_DBG char s[length + 1]; for (int i = 0; i <= length; i++) s[i] = word[i]; +#endif LOGI("Added word = %s, freq = %d, %d", s, frequency, S_INT_MAX); } memmove((char*) mFrequencies + (insertAt + 1) * sizeof(mFrequencies[0]), @@ -788,9 +794,11 @@ inline int UnigramDictionary::getMostFrequentWordLike(const int startInputIndex, if (newFreq > maxFreq) { for (int i = 0; i < inputLength; ++i) word[i] = newWord[i]; if (DEBUG_DICT && DEBUG_NODE) { +#ifdef FLAG_DBG char s[inputLength + 1]; for (int i = 0; i < inputLength; ++i) s[i] = word[i]; s[inputLength] = 0; +#endif LOGI("New missing space word found: %d > %d (%s), %d, %d", newFreq, maxFreq, s, inputLength, depth); }