summaryrefslogtreecommitdiffstats
path: root/src/storage/pinyin_parser2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/storage/pinyin_parser2.cpp')
-rw-r--r--src/storage/pinyin_parser2.cpp60
1 files changed, 38 insertions, 22 deletions
diff --git a/src/storage/pinyin_parser2.cpp b/src/storage/pinyin_parser2.cpp
index b8e603f..5d406ae 100644
--- a/src/storage/pinyin_parser2.cpp
+++ b/src/storage/pinyin_parser2.cpp
@@ -682,7 +682,7 @@ bool DoublePinyinParser2::parse_one_key(pinyin_option_t options,
const char * sheng = m_shengmu_table[charid].m_shengmu;
if (NULL == sheng)
return false;
- if (strcmp(sheng, "'") == 0)
+ if (0 == strcmp(sheng, "'"))
sheng = "";
/* parse yunmu here. */
@@ -690,33 +690,49 @@ bool DoublePinyinParser2::parse_one_key(pinyin_option_t options,
if (!IS_KEY(ch))
return false;
- charid = ch == ';' ? 26 : ch - 'a';
- /* first yunmu */
- const char * yun = m_yunmu_table[charid].m_yunmus[0];
- if (NULL == yun)
- return false;
+ gchar * pinyin = NULL;
+ do {
+
+ charid = ch == ';' ? 26 : ch - 'a';
+ /* first yunmu */
+ const char * yun = m_yunmu_table[charid].m_yunmus[0];
+ if (NULL == yun)
+ break;
- gchar * pinyin = g_strdup_printf("%s%s", sheng, yun);
- if (search_pinyin_index(options, pinyin, key)) {
- key.m_tone = tone;
+ pinyin = g_strdup_printf("%s%s", sheng, yun);
+ if (search_pinyin_index(options, pinyin, key)) {
+ key.m_tone = tone;
+ g_free(pinyin);
+ return true;
+ }
g_free(pinyin);
- return true;
- }
- g_free(pinyin);
- /* second yunmu */
- yun = m_yunmu_table[charid].m_yunmus[1];
- if (NULL == yun)
- return false;
+ /* second yunmu */
+ yun = m_yunmu_table[charid].m_yunmus[1];
+ if (NULL == yun)
+ break;
- pinyin = g_strdup_printf("%s%s", sheng, yun);
- if (search_pinyin_index(options, pinyin, key)) {
- key.m_tone = tone;
+ pinyin = g_strdup_printf("%s%s", sheng, yun);
+ if (search_pinyin_index(options, pinyin, key)) {
+ key.m_tone = tone;
+ g_free(pinyin);
+ return true;
+ }
g_free(pinyin);
- return true;
- }
- g_free(pinyin);
+ } while(0);
+#if 1
+ /* support two letter yunmu from full pinyin */
+ if (0 == strcmp(sheng, "")) {
+ pinyin = g_strndup(str, 2);
+ if (search_pinyin_index(options, pinyin, key)) {
+ key.m_tone = tone;
+ g_free(pinyin);
+ return true;
+ }
+ g_free(pinyin);
+ }
+#endif
}
return false;