diff options
author | Jan Rękorajski | 2011-07-24 22:33:02 (GMT) |
---|---|---|
committer | cvs2git | 2012-06-24 12:13:13 (GMT) |
commit | 2166246438c2f572451c7c8701c43de3cb81f42a (patch) | |
tree | 83a906f4547eeb283b3810510be780cc2077c79e | |
download | scim-pinyin-2166246438c2f572451c7c8701c43de3cb81f42a.zip scim-pinyin-2166246438c2f572451c7c8701c43de3cb81f42a.tar.gz |
- initial revision
Changed files:
scim-pinyin-fix-load.patch -> 1.1
scim-pinyin-fix-ms-shuangpin.patch -> 1.1
scim-pinyin-gcc43.patch -> 1.1
scim-pinyin-save-in-temp.patch -> 1.1
scim-pinyin-showallkeys.patch -> 1.1
scim-pinyin.spec -> 1.1
-rw-r--r-- | scim-pinyin-fix-load.patch | 203 | ||||
-rw-r--r-- | scim-pinyin-fix-ms-shuangpin.patch | 14 | ||||
-rw-r--r-- | scim-pinyin-gcc43.patch | 44 | ||||
-rw-r--r-- | scim-pinyin-save-in-temp.patch | 43 | ||||
-rw-r--r-- | scim-pinyin-showallkeys.patch | 31 | ||||
-rw-r--r-- | scim-pinyin.spec | 59 |
6 files changed, 394 insertions, 0 deletions
diff --git a/scim-pinyin-fix-load.patch b/scim-pinyin-fix-load.patch new file mode 100644 index 0000000..c48c127 --- /dev/null +++ b/scim-pinyin-fix-load.patch @@ -0,0 +1,203 @@ +diff -up scim-pinyin-0.5.91/src/scim_pinyin_phrase.cpp.fix-load scim-pinyin-0.5.91/src/scim_pinyin_phrase.cpp +--- scim-pinyin-0.5.91/src/scim_pinyin_phrase.cpp.fix-load 2007-11-15 15:06:10.000000000 +0800 ++++ scim-pinyin-0.5.91/src/scim_pinyin_phrase.cpp 2007-11-15 15:06:27.000000000 +0800 +@@ -351,17 +351,24 @@ PinyinPhraseLib::input (std::istream &is + std::istream &is_pylib, + std::istream &is_idx) + { +- if (m_phrase_lib.input (is_lib)) { +- if (is_idx && input_pinyin_lib (*m_validator, is_pylib)) { +- if (!input_indexes (is_idx)) { ++ is_lib.exceptions (std::ifstream::failbit); ++ is_pylib.exceptions (std::ifstream::failbit); ++ is_idx.exceptions (std::ifstream::failbit); ++ try { ++ if (m_phrase_lib.input (is_lib)) { ++ if (is_idx && input_pinyin_lib (*m_validator, is_pylib)) { ++ if (!input_indexes (is_idx)) { ++ create_pinyin_index (); ++ return true; ++ } ++ } else { + create_pinyin_index (); + return true; + } +- } else { +- create_pinyin_index (); + return true; + } +- return true; ++ } catch (std::ifstream::failure e) { ++ std::cerr << "Reading pinyin phrase lib failed" << std::endl; + } + return false; + } +diff -up scim-pinyin-0.5.91/src/scim_pinyin.cpp.fix-load scim-pinyin-0.5.91/src/scim_pinyin.cpp +--- scim-pinyin-0.5.91/src/scim_pinyin.cpp.fix-load 2005-08-08 14:11:16.000000000 +0800 ++++ scim-pinyin-0.5.91/src/scim_pinyin.cpp 2007-11-15 15:06:20.000000000 +0800 +@@ -1561,83 +1561,92 @@ PinyinTable::input (std::istream &is) + bool binary; + + if (!is) return false; +- +- is.getline (header, 40); + +- if (strncmp (header, +- scim_pinyin_table_text_header, +- strlen (scim_pinyin_table_text_header)) == 0) { +- binary = false; +- } else if (strncmp (header, +- scim_pinyin_table_binary_header, +- strlen (scim_pinyin_table_binary_header)) == 0) { +- binary = true; +- } else { +- return false; +- } ++ is.exceptions (std::ifstream::failbit); + +- is.getline (header, 40); +- if (strncmp (header, scim_pinyin_table_version, strlen (scim_pinyin_table_version)) != 0) ++ try { ++ ++ is.getline (header, 40); ++ ++ if (strncmp (header, ++ scim_pinyin_table_text_header, ++ strlen (scim_pinyin_table_text_header)) == 0) { ++ binary = false; ++ } else if (strncmp (header, ++ scim_pinyin_table_binary_header, ++ strlen (scim_pinyin_table_binary_header)) == 0) { ++ binary = true; ++ } else { ++ return false; ++ } ++ ++ is.getline (header, 40); ++ if (strncmp (header, scim_pinyin_table_version, strlen (scim_pinyin_table_version)) != 0) ++ return false; ++ ++ uint32 i; ++ uint32 n; ++ PinyinEntryVector::iterator ev; ++ ++ if (!binary) { ++ is >> n; ++ ++ // load pinyin table ++ for (i=0; i<n; i++) { ++ PinyinEntry entry (*m_validator, is, false); ++ ++ if (!m_custom.use_tone) { ++ entry.set_key (PinyinKey (entry.get_key ().get_initial (), ++ entry.get_key ().get_final (), ++ SCIM_PINYIN_ZeroTone)); ++ } ++ ++ if (entry.get_key().get_final() == SCIM_PINYIN_ZeroFinal) { ++ std::cerr << "Invalid entry: " << entry << "\n"; ++ } else { ++ if ((ev = find_exact_entry (entry)) == m_table.end()) ++ m_table.push_back (entry); ++ else { ++ for (uint32 i=0; i<entry.size(); i++) { ++ ev->insert (entry.get_char_with_frequency_by_index (i)); ++ } ++ } ++ } ++ } ++ } else { ++ unsigned char bytes [8]; ++ is.read ((char*) bytes, sizeof (unsigned char) * 4); ++ n = scim_bytestouint32 (bytes); ++ ++ // load pinyin table ++ for (i=0; i<n; i++) { ++ PinyinEntry entry (*m_validator, is, true); ++ ++ if (!m_custom.use_tone) { ++ entry.set_key (PinyinKey (entry.get_key ().get_initial (), ++ entry.get_key ().get_final (), ++ SCIM_PINYIN_ZeroTone)); ++ } ++ ++ if (entry.get_key().get_final() == SCIM_PINYIN_ZeroFinal) { ++ std::cerr << "Invalid entry: " << entry << "\n"; ++ } else { ++ if ((ev = find_exact_entry (entry)) == m_table.end()) ++ m_table.push_back (entry); ++ else { ++ for (uint32 i=0; i<entry.size(); i++) { ++ ev->insert (entry.get_char_with_frequency_by_index (i)); ++ } ++ } ++ } ++ } ++ } ++ sort (); ++ } ++ catch (std::ifstream::failure e) { ++ std::cerr << "Reading pinyin table failed" << std::endl; + return false; +- +- uint32 i; +- uint32 n; +- PinyinEntryVector::iterator ev; +- +- if (!binary) { +- is >> n; +- +- // load pinyin table +- for (i=0; i<n; i++) { +- PinyinEntry entry (*m_validator, is, false); +- +- if (!m_custom.use_tone) { +- entry.set_key (PinyinKey (entry.get_key ().get_initial (), +- entry.get_key ().get_final (), +- SCIM_PINYIN_ZeroTone)); +- } +- +- if (entry.get_key().get_final() == SCIM_PINYIN_ZeroFinal) { +- std::cerr << "Invalid entry: " << entry << "\n"; +- } else { +- if ((ev = find_exact_entry (entry)) == m_table.end()) +- m_table.push_back (entry); +- else { +- for (uint32 i=0; i<entry.size(); i++) { +- ev->insert (entry.get_char_with_frequency_by_index (i)); +- } +- } +- } +- } +- } else { +- unsigned char bytes [8]; +- is.read ((char*) bytes, sizeof (unsigned char) * 4); +- n = scim_bytestouint32 (bytes); +- +- // load pinyin table +- for (i=0; i<n; i++) { +- PinyinEntry entry (*m_validator, is, true); +- +- if (!m_custom.use_tone) { +- entry.set_key (PinyinKey (entry.get_key ().get_initial (), +- entry.get_key ().get_final (), +- SCIM_PINYIN_ZeroTone)); +- } +- +- if (entry.get_key().get_final() == SCIM_PINYIN_ZeroFinal) { +- std::cerr << "Invalid entry: " << entry << "\n"; +- } else { +- if ((ev = find_exact_entry (entry)) == m_table.end()) +- m_table.push_back (entry); +- else { +- for (uint32 i=0; i<entry.size(); i++) { +- ev->insert (entry.get_char_with_frequency_by_index (i)); +- } +- } +- } +- } + } +- sort (); + + return true; + } diff --git a/scim-pinyin-fix-ms-shuangpin.patch b/scim-pinyin-fix-ms-shuangpin.patch new file mode 100644 index 0000000..ec013cc --- /dev/null +++ b/scim-pinyin-fix-ms-shuangpin.patch @@ -0,0 +1,14 @@ +diff -Naur scim-pinyin-0.5.91/src/scim_pinyin.cpp scim-pinyin/src/scim_pinyin.cpp +--- scim-pinyin-0.5.91/src/scim_pinyin.cpp 2007-12-11 10:42:07.000000000 +0800 ++++ scim-pinyin/src/scim_pinyin.cpp 2007-12-12 13:23:28.000000000 +0800 +@@ -370,7 +370,7 @@ + { SCIM_PINYIN_Ong, SCIM_PINYIN_Iong }, // S + { SCIM_PINYIN_Ue, SCIM_PINYIN_ZeroFinal }, // T + { SCIM_PINYIN_U, SCIM_PINYIN_ZeroFinal }, // U +- { SCIM_PINYIN_V, SCIM_PINYIN_Ui }, // V ++ { SCIM_PINYIN_Ui, SCIM_PINYIN_Ue }, // V + { SCIM_PINYIN_Ia, SCIM_PINYIN_Ua }, // W + { SCIM_PINYIN_Ie, SCIM_PINYIN_ZeroFinal }, // X + { SCIM_PINYIN_Uai, SCIM_PINYIN_V }, // Y + +-- diff --git a/scim-pinyin-gcc43.patch b/scim-pinyin-gcc43.patch new file mode 100644 index 0000000..91a948d --- /dev/null +++ b/scim-pinyin-gcc43.patch @@ -0,0 +1,44 @@ +diff -up scim-pinyin-0.5.91/src/scim_phrase.cpp.gcc43 scim-pinyin-0.5.91/src/scim_phrase.cpp +--- scim-pinyin-0.5.91/src/scim_phrase.cpp.gcc43 2008-02-25 16:27:05.000000000 +0800 ++++ scim-pinyin-0.5.91/src/scim_phrase.cpp 2008-02-25 16:26:41.000000000 +0800 +@@ -28,6 +28,7 @@ + #define SCIM_PHRASE_MAX_RELATION 1000 + + #include <scim.h> ++#include <cstring> + #include "scim_pinyin_private.h" + #include "scim_phrase.h" + +diff -up scim-pinyin-0.5.91/src/scim_special_table.cpp.gcc43 scim-pinyin-0.5.91/src/scim_special_table.cpp +--- scim-pinyin-0.5.91/src/scim_special_table.cpp.gcc43 2008-02-25 16:27:55.000000000 +0800 ++++ scim-pinyin-0.5.91/src/scim_special_table.cpp 2008-02-25 16:28:08.000000000 +0800 +@@ -22,6 +22,7 @@ + + #include <time.h> + #include <scim.h> ++#include <cstring> + #include "scim_pinyin_private.h" + #include "scim_special_table.h" + +diff -up scim-pinyin-0.5.91/src/scim_pinyin.cpp.gcc43 scim-pinyin-0.5.91/src/scim_pinyin.cpp +--- scim-pinyin-0.5.91/src/scim_pinyin.cpp.gcc43 2008-02-25 16:26:10.000000000 +0800 ++++ scim-pinyin-0.5.91/src/scim_pinyin.cpp 2008-02-25 16:26:26.000000000 +0800 +@@ -29,6 +29,7 @@ + #define Uses_SCIM_LOOKUP_TABLE + + #include <scim.h> ++#include <cstring> + #include "scim_pinyin.h" + + // Internal functions +diff -up scim-pinyin-0.5.91/src/scim_pinyin_phrase.cpp.gcc43 scim-pinyin-0.5.91/src/scim_pinyin_phrase.cpp +--- scim-pinyin-0.5.91/src/scim_pinyin_phrase.cpp.gcc43 2008-02-25 16:27:15.000000000 +0800 ++++ scim-pinyin-0.5.91/src/scim_pinyin_phrase.cpp 2008-02-25 16:27:28.000000000 +0800 +@@ -27,6 +27,7 @@ + #define Uses_SCIM_LOOKUP_TABLE + + #include <scim.h> ++#include <cstring> + #include "scim_pinyin_private.h" + #include "scim_phrase.h" + #include "scim_pinyin.h" diff --git a/scim-pinyin-save-in-temp.patch b/scim-pinyin-save-in-temp.patch new file mode 100644 index 0000000..7ee4b40 --- /dev/null +++ b/scim-pinyin-save-in-temp.patch @@ -0,0 +1,43 @@ +diff -up scim-pinyin-0.5.91/src/scim_pinyin_imengine.cpp.orig scim-pinyin-0.5.91/src/scim_pinyin_imengine.cpp +--- scim-pinyin-0.5.91/src/scim_pinyin_imengine.cpp.orig 2007-11-09 16:51:49.000000000 +0800 ++++ scim-pinyin-0.5.91/src/scim_pinyin_imengine.cpp 2007-11-09 16:52:06.000000000 +0800 +@@ -656,6 +656,11 @@ PinyinFactory::refresh () + void + PinyinFactory::save_user_library () + { ++ String tmp_user_pinyin_table = m_user_pinyin_table + ".tmp"; ++ String tmp_user_phrase_lib = m_user_phrase_lib + ".tmp"; ++ String tmp_user_pinyin_phrase_lib = m_user_pinyin_phrase_lib + ".tmp"; ++ String tmp_user_pinyin_phrase_index = m_user_pinyin_phrase_index + ".tmp"; ++ + // First make the user data directory. + if (access (m_user_data_directory.c_str (), R_OK | W_OK) != 0) { + mkdir (m_user_data_directory.c_str (), S_IRUSR | S_IWUSR | S_IXUSR); +@@ -670,11 +675,23 @@ PinyinFactory::save_user_library () + lib->optimize_phrase_frequencies (); + } + +- m_pinyin_global.save_pinyin_table (m_user_pinyin_table.c_str (), m_user_data_binary); +- m_pinyin_global.save_user_phrase_lib (m_user_phrase_lib.c_str (), +- m_user_pinyin_phrase_lib.c_str (), +- m_user_pinyin_phrase_index.c_str (), ++ // save user data in tmp files ++ m_pinyin_global.save_pinyin_table (tmp_user_pinyin_table.c_str (), m_user_data_binary); ++ m_pinyin_global.save_user_phrase_lib (tmp_user_phrase_lib.c_str (), ++ tmp_user_pinyin_phrase_lib.c_str (), ++ tmp_user_pinyin_phrase_index.c_str (), + m_user_data_binary); ++ ++ // unlink old user data files, and rename tmp files. ++ unlink (m_user_pinyin_table.c_str ()); ++ rename (tmp_user_pinyin_table.c_str (), m_user_pinyin_table.c_str ()); ++ ++ unlink (m_user_phrase_lib.c_str ()); ++ unlink (m_user_pinyin_phrase_lib.c_str ()); ++ unlink (m_user_pinyin_phrase_index.c_str ()); ++ rename (tmp_user_phrase_lib.c_str (), m_user_phrase_lib.c_str ()); ++ rename (tmp_user_pinyin_phrase_lib.c_str (), m_user_pinyin_phrase_lib.c_str ()); ++ rename (tmp_user_pinyin_phrase_index.c_str (), m_user_pinyin_phrase_index.c_str ()); + } + + void diff --git a/scim-pinyin-showallkeys.patch b/scim-pinyin-showallkeys.patch new file mode 100644 index 0000000..46f5573 --- /dev/null +++ b/scim-pinyin-showallkeys.patch @@ -0,0 +1,31 @@ +--- scim-pinyin-0.5.91/src/scim_pinyin_imengine.cpp.allkeys-back 2006-02-13 16:03:12.000000000 +0800 ++++ scim-pinyin-0.5.91/src/scim_pinyin_imengine.cpp 2006-02-13 16:04:53.000000000 +0800 +@@ -153,7 +153,7 @@ + m_auto_combine_phrase (false), + m_auto_fill_preedit (false), + m_always_show_lookup (false), +- m_show_all_keys (false), ++ m_show_all_keys (true), + m_user_data_binary (true), + m_valid (false), + m_shuang_pin (false), +@@ -269,7 +269,7 @@ + true); + m_show_all_keys = + m_config->read (String (SCIM_CONFIG_IMENGINE_PINYIN_SHOW_ALL_KEYS), +- false); ++ true); + m_user_data_binary = + m_config->read (String (SCIM_CONFIG_IMENGINE_PINYIN_USER_DATA_BINARY), + true); +--- scim-pinyin-0.5.91/src/scim_pinyin_imengine_setup.cpp.allkeys-back 2006-02-13 16:03:42.000000000 +0800 ++++ scim-pinyin-0.5.91/src/scim_pinyin_imengine_setup.cpp 2006-02-13 16:04:06.000000000 +0800 +@@ -107,7 +107,7 @@ + static bool __config_auto_fill_preedit = true; + static bool __config_match_longer_phrase = false; + static bool __config_always_show_lookup = true; +-static bool __config_show_all_keys = false; ++static bool __config_show_all_keys = true; + static bool __config_dynamic_adjust = true; + + static int __config_max_user_phrase_length = 8; diff --git a/scim-pinyin.spec b/scim-pinyin.spec new file mode 100644 index 0000000..bba6fc6 --- /dev/null +++ b/scim-pinyin.spec @@ -0,0 +1,59 @@ +Summary: Smart Pinyin IMEngine for Smart Common Input Method platform +Name: scim-pinyin +Version: 0.5.91 +Release: 0.1 +License: GPL v2 +Group: Libraries +Source0: http://downloads.sourceforge.net/scim/%{name}-%{version}.tar.gz +# Source0-md5: fb96d3545090d7681ea03edaced4eccb +Patch0: %{name}-showallkeys.patch +Patch1: %{name}-save-in-temp.patch +Patch2: %{name}-fix-load.patch +Patch3: %{name}-fix-ms-shuangpin.patch +Patch4: %{name}-gcc43.patch +URL: http://www.scim-im.org/projects/imengines/ +BuildRequires: autoconf +BuildRequires: automake +BuildRequires: libtool +BuildRequires: scim-devel +BuildRequires: gtk+2-devel +BuildRequires: gettext +BuildRequires: gettext-devel +Requires: scim +BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) + +%description +Simplified Chinese Smart Pinyin IMEngine for SCIM. + +%prep +%setup -q +%patch0 -p1 +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 +%patch4 -p1 + +%build +%configure + +%{__make} + +%install +rm -rf $RPM_BUILD_ROOT +%{__make} install \ + DESTDIR=$RPM_BUILD_ROOT + +%{__rm} $RPM_BUILD_ROOT%{_libdir}/scim-1.0/*/*/*.{la,a} + +%find_lang %{name} + +%clean +rm -rf $RPM_BUILD_ROOT + +%files -f %{name}.lang +%defattr(644,root,root,755) +%doc AUTHORS README +%attr(755,root,root) %{_libdir}/scim-1.0/*/IMEngine/pinyin.so +%attr(755,root,root) %{_libdir}/scim-1.0/*/SetupUI/pinyin-imengine-setup.so +%{_datadir}/scim/pinyin +%{_datadir}/scim/icons/smart-pinyin.png |