packages: scim-pinyin/scim-pinyin-fix-load.patch (NEW), scim-pinyin/scim-pi...

baggins baggins at pld-linux.org
Mon Jul 25 00:33:08 CEST 2011


Author: baggins                      Date: Sun Jul 24 22:33:08 2011 GMT
Module: packages                      Tag: HEAD
---- Log message:
- initial revision

---- Files affected:
packages/scim-pinyin:
   scim-pinyin-fix-load.patch (NONE -> 1.1)  (NEW), scim-pinyin-fix-ms-shuangpin.patch (NONE -> 1.1)  (NEW), scim-pinyin-gcc43.patch (NONE -> 1.1)  (NEW), scim-pinyin-save-in-temp.patch (NONE -> 1.1)  (NEW), scim-pinyin-showallkeys.patch (NONE -> 1.1)  (NEW), scim-pinyin.spec (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: packages/scim-pinyin/scim-pinyin-fix-load.patch
diff -u /dev/null packages/scim-pinyin/scim-pinyin-fix-load.patch:1.1
--- /dev/null	Mon Jul 25 00:33:08 2011
+++ packages/scim-pinyin/scim-pinyin-fix-load.patch	Mon Jul 25 00:33:02 2011
@@ -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;
+ }

================================================================
Index: packages/scim-pinyin/scim-pinyin-fix-ms-shuangpin.patch
diff -u /dev/null packages/scim-pinyin/scim-pinyin-fix-ms-shuangpin.patch:1.1
--- /dev/null	Mon Jul 25 00:33:08 2011
+++ packages/scim-pinyin/scim-pinyin-fix-ms-shuangpin.patch	Mon Jul 25 00:33:02 2011
@@ -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
+
+-- 

================================================================
Index: packages/scim-pinyin/scim-pinyin-gcc43.patch
diff -u /dev/null packages/scim-pinyin/scim-pinyin-gcc43.patch:1.1
--- /dev/null	Mon Jul 25 00:33:08 2011
+++ packages/scim-pinyin/scim-pinyin-gcc43.patch	Mon Jul 25 00:33:02 2011
@@ -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"

================================================================
Index: packages/scim-pinyin/scim-pinyin-save-in-temp.patch
diff -u /dev/null packages/scim-pinyin/scim-pinyin-save-in-temp.patch:1.1
--- /dev/null	Mon Jul 25 00:33:08 2011
+++ packages/scim-pinyin/scim-pinyin-save-in-temp.patch	Mon Jul 25 00:33:02 2011
@@ -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

================================================================
Index: packages/scim-pinyin/scim-pinyin-showallkeys.patch
diff -u /dev/null packages/scim-pinyin/scim-pinyin-showallkeys.patch:1.1
--- /dev/null	Mon Jul 25 00:33:08 2011
+++ packages/scim-pinyin/scim-pinyin-showallkeys.patch	Mon Jul 25 00:33:02 2011
@@ -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;

================================================================
Index: packages/scim-pinyin/scim-pinyin.spec
diff -u /dev/null packages/scim-pinyin/scim-pinyin.spec:1.1
--- /dev/null	Mon Jul 25 00:33:08 2011
+++ packages/scim-pinyin/scim-pinyin.spec	Mon Jul 25 00:33:02 2011
@@ -0,0 +1,70 @@
+# $Revision$, $Date$
+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
+
+%define date	%(echo `LC_ALL="C" date +"%a %b %d %Y"`)
+%changelog
+* %{date} PLD Team <feedback at pld-linux.org>
+All persons listed below can be reached at <cvs_login>@pld-linux.org
+
+$Log$
+Revision 1.1  2011/07/24 22:33:02  baggins
+- initial revision
+
================================================================


More information about the pld-cvs-commit mailing list