diff options
author | Peng Wu <alexepico@gmail.com> | 2012-07-20 15:43:59 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2012-07-20 15:43:59 +0800 |
commit | ed5fb85f0ac78119761e92c2d038961e17b637d8 (patch) | |
tree | 13d1d36fd7ddb1ab80af3747abfea7aec3910367 /src/PYEnglishEditor.cc | |
parent | a1d11baae9a76eb690ca87e7e4a28e9d8295d99b (diff) | |
download | ibus-libpinyin-ed5fb85f0ac78119761e92c2d038961e17b637d8.tar.gz ibus-libpinyin-ed5fb85f0ac78119761e92c2d038961e17b637d8.tar.xz ibus-libpinyin-ed5fb85f0ac78119761e92c2d038961e17b637d8.zip |
refine english editor
Diffstat (limited to 'src/PYEnglishEditor.cc')
-rw-r--r-- | src/PYEnglishEditor.cc | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/PYEnglishEditor.cc b/src/PYEnglishEditor.cc index 6bc8e0b..5b49f63 100644 --- a/src/PYEnglishEditor.cc +++ b/src/PYEnglishEditor.cc @@ -76,16 +76,21 @@ public: const char *tail = NULL; m_sql = "SELECT value FROM desc WHERE name = 'version';"; result = sqlite3_prepare_v2 (tmp_db, m_sql.c_str(), -1, &stmt, &tail); - g_assert (result == SQLITE_OK); + if (result != SQLITE_OK) + return FALSE; + result = sqlite3_step (stmt); if (result != SQLITE_ROW) return FALSE; + result = sqlite3_column_type (stmt, 0); if (result != SQLITE_TEXT) return FALSE; + const char *version = (const char *) sqlite3_column_text (stmt, 0); if (strcmp("1.2.0", version ) != 0) return FALSE; + result = sqlite3_finalize (stmt); g_assert (result == SQLITE_OK); sqlite3_close (tmp_db); @@ -176,20 +181,24 @@ public: const char *SQL_DB_LIST = "SELECT word FROM ( " "SELECT * FROM english UNION ALL SELECT * FROM userdb.english) " - " WHERE word LIKE '%s%%' GROUP BY word ORDER BY SUM(freq) DESC;"; + " WHERE word LIKE '%s%' GROUP BY word ORDER BY SUM(freq) DESC;"; m_sql.printf (SQL_DB_LIST, prefix); int result = sqlite3_prepare_v2 (m_sqlite, m_sql.c_str(), -1, &stmt, &tail); - g_assert(result == SQLITE_OK); + if (result != SQLITE_OK) + return FALSE; + result = sqlite3_step (stmt); while (result == SQLITE_ROW){ /* get the words. */ result = sqlite3_column_type (stmt, 0); if (result != SQLITE_TEXT) return FALSE; + const char *word = (const char *)sqlite3_column_text (stmt, 0); words.push_back (word); result = sqlite3_step (stmt); } + sqlite3_finalize (stmt); if (result != SQLITE_DONE) return FALSE; |