Hello community, here is the log from the commit of package libzhuyin for openSUSE:Factory checked in at 2016-10-20 23:07:57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/libzhuyin (Old) and /work/SRC/openSUSE:Factory/.libzhuyin.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "libzhuyin" Changes: -------- --- /work/SRC/openSUSE:Factory/libzhuyin/libzhuyin.changes 2015-12-29 12:59:27.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.libzhuyin.new/libzhuyin.changes 2016-10-20 23:07:57.000000000 +0200 @@ -1,0 +2,6 @@ +Sat Sep 10 08:08:23 UTC 2016 - [email protected] + +- Update to 1.1.1 + * simplify ZhuyinDaChenCP26Parser2 + +------------------------------------------------------------------- Old: ---- libzhuyin-1.1.0.tar.gz New: ---- libzhuyin-1.1.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libzhuyin.spec ++++++ --- /var/tmp/diff_new_pack.Rpfl8s/_old 2016-10-20 23:07:59.000000000 +0200 +++ /var/tmp/diff_new_pack.Rpfl8s/_new 2016-10-20 23:07:59.000000000 +0200 @@ -1,7 +1,7 @@ # # spec file for package libzhuyin # -# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -18,7 +18,7 @@ %define soname 7 Name: libzhuyin -Version: 1.1.0 +Version: 1.1.1 Release: 0 Summary: Library to deal with zhuyin License: GPL-2.0 ++++++ libzhuyin-1.1.0.tar.gz -> libzhuyin-1.1.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzhuyin-1.1.0/configure.ac new/libzhuyin-1.1.1/configure.ac --- old/libzhuyin-1.1.0/configure.ac 2015-12-17 08:11:48.000000000 +0100 +++ new/libzhuyin-1.1.1/configure.ac 2016-09-02 07:12:23.000000000 +0200 @@ -6,7 +6,7 @@ m4_define([libzhuyin_released], [1]) m4_define([libzhuyin_major_version], [1]) m4_define([libzhuyin_minor_version], [1]) -m4_define([libzhuyin_micro_version], [0]) +m4_define([libzhuyin_micro_version], [1]) m4_define(libzhuyin_maybe_datestamp, m4_esyscmd([if test x]libzhuyin_released[ != x1; then date +.%Y%m%d | tr -d '\n\r'; fi])) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzhuyin-1.1.0/src/storage/pinyin_parser2.cpp new/libzhuyin-1.1.1/src/storage/pinyin_parser2.cpp --- old/libzhuyin-1.1.0/src/storage/pinyin_parser2.cpp 2015-12-17 08:11:48.000000000 +0100 +++ new/libzhuyin-1.1.1/src/storage/pinyin_parser2.cpp 2016-09-02 07:12:23.000000000 +0200 @@ -938,6 +938,22 @@ m_tone_table = chewing_dachen_cp26_tones; } +static int count_same_chars(const char * str, int len) { + assert(len > 0); + + int count = 0; + const char cur_char = str[0]; + + for (int i = 0; i < len; ++i) { + if (cur_char != str[i]) + break; + ++count; + } + + assert(count >= 1); + return count; +} + bool ChewingDaChenCP26Parser2::parse_one_key(pinyin_option_t options, ChewingKey & key, const char *str, int len) const { @@ -975,26 +991,19 @@ if (0 == len) return false; - int i; int choice; + int choice; int count; /* probe initial */ do { ch = input[index]; + count = count_same_chars(input + index, len - index); if (search_chewing_symbols2(m_initial_table, ch, &first, &second)) { - index ++; + index += count; if (NULL == second) { initial = first; break; } else { - choice = 0; - /* zero out the same char */ - for (i = index; i < len; ++i) { - if (input[i] == ch) { - input[i] = '\0'; - choice ++; - } - } - choice = choice % 2; + choice = (count - 1) % 2; if (0 == choice) initial = first; if (1 == choice) @@ -1003,12 +1012,6 @@ } } while (0); - /* skip zeros */ - for (; index < len; index ++) { - if ('\0' != input[index]) - break; - } - if (index == len) goto probe; @@ -1016,57 +1019,37 @@ /* probe middle */ do { ch = input[index]; + count = count_same_chars(input + index, len - index); /* handle 'u' */ if ('u' == ch) { - index ++; - choice = 0; - /* zero out the same char */ - for (i = index; i < len; ++i) { - if ('u' == input[i]) { - input[i] = '\0'; - choice ++; - } - choice = choice % 3; - if (0 == choice) - middle = "ㄧ"; - if (1 == choice) - final = "ㄚ"; - if (2 == choice) { - middle = "ㄧ"; - final = "ㄚ"; - } + choice = (count - 1) % 3; + if (0 == choice) + middle = "ㄧ"; + if (1 == choice) + final = "ㄚ"; + if (2 == choice) { + middle = "ㄧ"; + final = "ㄚ"; } } /* handle 'm' */ if ('m' == ch) { - index ++; - choice = 0; - /* zero out the same char */ - for (i = index; i < len; ++i) { - if ('m' == input[i]) { - input[i] = '\0'; - choice ++; - } - choice = choice % 2; - if (0 == choice) - middle = "ㄩ"; - if (1 == choice) - final = "ㄡ"; - } + choice = (count - 1) % 2; + if (0 == choice) + middle = "ㄩ"; + if (1 == choice) + final = "ㄡ"; + } + /* handle 'j' */ + if ('j' == ch) { + middle = "ㄨ"; } if (search_chewing_symbols2(m_middle_table, ch, &first, &second)) { + index += count; assert(NULL == second); - index ++; - middle = first; } } while(0); - /* skip zeros */ - for (; index < len; index ++) { - if ('\0' != input[index]) - break; - } - if (index == len) goto probe; @@ -1077,21 +1060,14 @@ break; ch = input[index]; + count = count_same_chars(input + index, len - index); if (search_chewing_symbols2(m_final_table, ch, &first, &second)) { - index ++; + index += count; if (NULL == second) { final = first; break; } else { - choice = 0; - /* zero out the same char */ - for (i = index; i < len; ++i) { - if (input[i] == ch) { - input[i] = '\0'; - choice ++; - } - } - choice = choice % 2; + choice = (count - 1) % 2; if (0 == choice) final = first; if (1 == choice) @@ -1100,12 +1076,6 @@ } } while(0); - /* skip zeros */ - for (; index < len; index ++) { - if ('\0' != input[index]) - break; - } - if (index == len) goto probe;
