summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-12-14 13:39:06 +0800
committerPeng Wu <alexepico@gmail.com>2011-12-14 13:39:06 +0800
commit9ffdfaa1b77c0a9e2136ad49768bc7df4329d454 (patch)
tree494495408df9ed82bf258bcfda4b87afdaacfd55 /src
parent2970679b136f91607f7db1d1a64c3158b1d60881 (diff)
downloadlibpinyin-9ffdfaa1b77c0a9e2136ad49768bc7df4329d454.tar.gz
libpinyin-9ffdfaa1b77c0a9e2136ad49768bc7df4329d454.tar.xz
libpinyin-9ffdfaa1b77c0a9e2136ad49768bc7df4329d454.zip
refine ChewingKeyRest
Diffstat (limited to 'src')
-rw-r--r--src/storage/chewing_key.h13
-rw-r--r--src/storage/pinyin_parser2.cpp22
2 files changed, 2 insertions, 33 deletions
diff --git a/src/storage/chewing_key.h b/src/storage/chewing_key.h
index 9f6526e..68733d4 100644
--- a/src/storage/chewing_key.h
+++ b/src/storage/chewing_key.h
@@ -212,21 +212,8 @@ struct ChewingKeyRest
m_raw_begin = 0;
m_raw_end = 0;
}
-
- const char * get_pinyin_string();
- const char * get_chewing_string();
};
-static inline gchar * get_pinyin_string(ChewingKey key,
- ChewingKeyRest key_rest) {
- if (CHEWING_ZERO_TONE != key.m_tone) {
- return g_strdup_printf
- ("%s%d", key_rest.get_pinyin_string(), key.m_tone);
- } else {
- return g_strdup(key_rest.get_pinyin_string());
- }
-}
-
};
#endif
diff --git a/src/storage/pinyin_parser2.cpp b/src/storage/pinyin_parser2.cpp
index 7adf9a7..f79695f 100644
--- a/src/storage/pinyin_parser2.cpp
+++ b/src/storage/pinyin_parser2.cpp
@@ -84,6 +84,7 @@ gint ChewingKey::get_table_index() {
gchar * ChewingKey::get_pinyin_string() {
assert(m_tone < CHEWING_NUMBER_OF_TONES);
gint index = get_table_index();
+ assert(index < G_N_ELEMENTS(content_table));
const content_table_item_t & item = content_table[index];
if (CHEWING_ZERO_TONE == m_tone) {
@@ -96,6 +97,7 @@ gchar * ChewingKey::get_pinyin_string() {
gchar * ChewingKey::get_chewing_string() {
assert(m_tone < CHEWING_NUMBER_OF_TONES);
gint index = get_table_index();
+ assert(index < G_N_ELEMENTS(content_table));
const content_table_item_t & item = content_table[index];
if (CHEWING_ZERO_TONE == m_tone) {
@@ -107,26 +109,6 @@ gchar * ChewingKey::get_chewing_string() {
}
-/* methods for Chewing Keys to access pinyin parser table. */
-const char * ChewingKeyRest::get_pinyin_string(){
- if (m_table_index == 0)
- return NULL;
-
- /* check end boundary. */
- assert(m_table_index < G_N_ELEMENTS(content_table));
- return content_table[m_table_index].m_pinyin_str;
-}
-
-const char * ChewingKeyRest::get_chewing_string(){
- if (m_table_index == 0)
- return NULL;
-
- /* check end boundary. */
- assert(m_table_index < G_N_ELEMENTS(content_table));
- return content_table[m_table_index].m_chewing_str;
-}
-
-
/* Pinyin Parsers */
/* internal information for pinyin parsers. */