ERROR_OK = 0, /* operate ok */
ERROR_INSERT_ITEM_EXISTS, /* item already exists */
ERROR_REMOVE_ITEM_DONOT_EXISTS, /* item don't exists */
+ ERROR_PHRASE_TOO_LONG, /* the phrase is too long */
ERROR_NO_SUB_PHRASE_INDEX, /* sub phrase index is not loaded */
ERROR_NO_ITEM, /* item has a null slot */
ERROR_OUT_OF_RANGE, /* beyond the end of the sub phrase index */
int ChewingLengthIndexLevel::add_index(int phrase_length,
/* in */ ChewingKey keys[],
/* in */ phrase_token_t token) {
- assert(phrase_length + 1 < MAX_PHRASE_LENGTH);
+ if (!(phrase_length + 1 < MAX_PHRASE_LENGTH))
+ return ERROR_PHRASE_TOO_LONG;
if (m_chewing_array_indexes->len <= phrase_length)
g_array_set_size(m_chewing_array_indexes, phrase_length + 1);
int ChewingLengthIndexLevel::remove_index(int phrase_length,
/* in */ ChewingKey keys[],
/* in */ phrase_token_t token) {
- assert(phrase_length + 1 < MAX_PHRASE_LENGTH);
+ if (!(phrase_length + 1 < MAX_PHRASE_LENGTH))
+ return ERROR_PHRASE_TOO_LONG;
if (m_chewing_array_indexes->len <= phrase_length)
return ERROR_REMOVE_ITEM_DONOT_EXISTS;
}
int PhraseLengthIndexLevel::add_index( int phrase_length, /* in */ ucs4_t phrase[], /* in */ phrase_token_t token){
- assert(phrase_length + 1 < MAX_PHRASE_LENGTH);
+ if (!(phrase_length + 1 < MAX_PHRASE_LENGTH))
+ return ERROR_PHRASE_TOO_LONG;
+
if ( m_phrase_array_indexes -> len <= phrase_length )
g_array_set_size(m_phrase_array_indexes, phrase_length + 1);
}
int PhraseLengthIndexLevel::remove_index( int phrase_length, /* in */ ucs4_t phrase[], /* out */ phrase_token_t & token){
- assert(phrase_length + 1 < MAX_PHRASE_LENGTH);
+ if (!(phrase_length + 1 < MAX_PHRASE_LENGTH))
+ return ERROR_PHRASE_TOO_LONG;
+
if ( m_phrase_array_indexes -> len <= phrase_length )
return ERROR_REMOVE_ITEM_DONOT_EXISTS;
#define CASE(len) case len: \