summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2013-09-22 13:31:53 +0800
committerPeng Wu <alexepico@gmail.com>2013-09-22 13:34:28 +0800
commit69f46d03e53398ba9df3f75d939353d18ac7c4ed (patch)
tree4cb5114ab7fd7961e9dcaec0ffaff1803a2ad272
parentf99293209fcf94abbadb319f4c3e25b7cdae5b3f (diff)
downloadlibzhuyin-69f46d03e53398ba9df3f75d939353d18ac7c4ed.tar.gz
libzhuyin-69f46d03e53398ba9df3f75d939353d18ac7c4ed.tar.xz
libzhuyin-69f46d03e53398ba9df3f75d939353d18ac7c4ed.zip
write search_chewing_symbols2 function
-rw-r--r--src/storage/pinyin_parser2.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/storage/pinyin_parser2.cpp b/src/storage/pinyin_parser2.cpp
index 85875f2..dde1cd2 100644
--- a/src/storage/pinyin_parser2.cpp
+++ b/src/storage/pinyin_parser2.cpp
@@ -714,3 +714,32 @@ bool ChewingDiscreteParser2::in_chewing_scheme(pinyin_option_t options,
return false;
}
+
+static int search_chewing_symbols2(const chewing_symbol_item_t * symbol_table,
+ const char key,
+ const char ** first,
+ const char ** second) {
+ int num = 0;
+ *first = NULL; *second = NULL;
+
+ /* just iterate the table, as we only have < 50 items. */
+ while (symbol_table->m_input != '\0') {
+ if (symbol_table->m_input == key) {
+ ++num;
+ if (NULL == *first) {
+ *first = symbol_table->m_chewing;
+ } else {
+ *second = symbol_table->m_chewing;
+ }
+ }
+
+ /* search done */
+ if (symbol_table->m_input > key)
+ break;
+
+ symbol_table++;
+ }
+
+ assert(0 <= num && num <= 2);
+ return num;
+}