[libpinyin] fixes pinyin parsers

Peng Wu pwu at fedoraproject.org
Sun Jan 29 04:52:17 UTC 2012


commit 00273806b659d3a6241844fc5319227225a895d0
Author: Peng Wu <alexepico at gmail.com>
Date:   Sun Jan 29 12:18:49 2012 +0800

    fixes pinyin parsers

 libpinyin-0.5.x-head.patch |   78 ++++++++++++++++++++++++++++++++++++++++++++
 libpinyin.spec             |    5 ++-
 2 files changed, 82 insertions(+), 1 deletions(-)
---
diff --git a/libpinyin-0.5.x-head.patch b/libpinyin-0.5.x-head.patch
index e69de29..d3fa975 100644
--- a/libpinyin-0.5.x-head.patch
+++ b/libpinyin-0.5.x-head.patch
@@ -0,0 +1,78 @@
+From b54a7e1600ba00d9886a0d17b0f923e40cf9672c Mon Sep 17 00:00:00 2001
+From: Peng Wu <alexepico at gmail.com>
+Date: Sun, 29 Jan 2012 10:26:17 +0800
+Subject: [PATCH 1/2] fixes pinyin parsers
+
+---
+ src/storage/pinyin_parser2.cpp |    4 +++-
+ 1 files changed, 3 insertions(+), 1 deletions(-)
+
+diff --git a/src/storage/pinyin_parser2.cpp b/src/storage/pinyin_parser2.cpp
+index deef306..4ab36aa 100644
+--- a/src/storage/pinyin_parser2.cpp
++++ b/src/storage/pinyin_parser2.cpp
+@@ -526,6 +526,7 @@ bool FullPinyinParser2::post_process(pinyin_option_t options,
+ bool DoublePinyinParser2::parse_one_key(pinyin_option_t options,
+                                         ChewingKey & key,
+                                         const char *str, int len) const {
++    options &= ~(PINYIN_CORRECT_ALL|PINYIN_AMB_ALL);
+ 
+     if (1 == len) {
+         if (!(options & PINYIN_INCOMPLETE))
+@@ -548,7 +549,7 @@ bool DoublePinyinParser2::parse_one_key(pinyin_option_t options,
+     }
+ 
+     ChewingTone tone = CHEWING_ZERO_TONE;
+-    options &= ~(PINYIN_CORRECT_ALL|PINYIN_AMB_ALL);
++    options &= ~(PINYIN_INCOMPLETE|CHEWING_INCOMPLETE);
+ 
+     /* parse tone */
+     if (3 == len) {
+@@ -718,6 +719,7 @@ static bool search_chewing_tones(const chewing_tone_item_t * tone_table,
+ bool ChewingParser2::parse_one_key(pinyin_option_t options,
+                                    ChewingKey & key,
+                                    const char *str, int len) const {
++    options &= ~(PINYIN_CORRECT_ALL|PINYIN_AMB_ALL);
+     char tone = CHEWING_ZERO_TONE;
+ 
+     int symbols_len = len;
+-- 
+1.7.7.5
+
+
+From 06668708392d044b0656b5f8e7569c71c169fb16 Mon Sep 17 00:00:00 2001
+From: Peng Wu <alexepico at gmail.com>
+Date: Sun, 29 Jan 2012 11:06:48 +0800
+Subject: [PATCH 2/2] fixes parse one key
+
+---
+ src/storage/pinyin_parser2.cpp |    6 ++++++
+ 1 files changed, 6 insertions(+), 0 deletions(-)
+
+diff --git a/src/storage/pinyin_parser2.cpp b/src/storage/pinyin_parser2.cpp
+index 4ab36aa..0437440 100644
+--- a/src/storage/pinyin_parser2.cpp
++++ b/src/storage/pinyin_parser2.cpp
+@@ -582,6 +582,9 @@ bool DoublePinyinParser2::parse_one_key(pinyin_option_t options,
+         charid = ch == ';' ? 26 : ch - 'a';
+         /* first yunmu */
+         const char * yun = m_yunmu_table[charid].m_yunmus[0];
++        if (NULL == yun)
++            return false;
++
+         gchar * pinyin = g_strdup_printf("%s%s", sheng, yun);
+         if (search_pinyin_index(options, pinyin, key)) {
+             key.m_tone = tone;
+@@ -592,6 +595,9 @@ bool DoublePinyinParser2::parse_one_key(pinyin_option_t options,
+ 
+         /* second yunmu */
+         yun = m_yunmu_table[charid].m_yunmus[1];
++        if (NULL == yun)
++            return false;
++
+         pinyin = g_strdup_printf("%s%s", sheng, yun);
+         if (search_pinyin_index(options, pinyin, key)) {
+             key.m_tone = tone;
+-- 
+1.7.7.5
+
diff --git a/libpinyin.spec b/libpinyin.spec
index 0adcf96..790c2db 100644
--- a/libpinyin.spec
+++ b/libpinyin.spec
@@ -1,6 +1,6 @@
 Name:           libpinyin
 Version:        0.5.0
-Release:        1%{?dist}
+Release:        2%{?dist}
 Summary:        Library to deal with pinyin
 
 License:        GPLv2+
@@ -81,6 +81,9 @@ find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';'
 %{_bindir}/gen_unigram
 
 %changelog
+* Sun Jan 29 2012  Peng Wu <pwu at redhat.com> - 0.5.0-2
+- Fixes pinyin parsers
+
 * Wed Jan 18 2012  Peng Wu <pwu at redhat.com> - 0.5.0-1
 - Update to 0.5.0
 


More information about the scm-commits mailing list