[packages/pyzy] - added opencc-1 patch (adjust for opencc 1.0.x API) - update boost.m4 to support current compilers

qboosh qboosh at pld-linux.org
Sun Apr 26 08:33:13 CEST 2020


commit c940682d8f16308850ce27a55082aabac2806a9e
Author: Jakub Bogusz <qboosh at pld-linux.org>
Date:   Sun Apr 26 08:33:26 2020 +0200

    - added opencc-1 patch (adjust for opencc 1.0.x API)
    - update boost.m4 to support current compilers
    - release 4

 pyzy-opencc-1.patch | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 pyzy.spec           | 25 +++++++++++++++++++++---
 2 files changed, 78 insertions(+), 3 deletions(-)
---
diff --git a/pyzy.spec b/pyzy.spec
index 61706ea..50bd2a8 100644
--- a/pyzy.spec
+++ b/pyzy.spec
@@ -6,7 +6,7 @@ Summary:	The Chinese PinYin and Bopomofo conversion library
 Summary(pl.UTF-8):	Biblioteka konwersji pisma chińskiego PinYin i Bopomofo
 Name:		pyzy
 Version:	0.1.0
-Release:	3
+Release:	4
 License:	LGPL v2.1+
 Group:		Libraries
 #Source0Download: http://code.google.com/p/pyzy/downloads/list
@@ -14,12 +14,19 @@ Source0:	http://pyzy.googlecode.com/files/%{name}-%{version}.tar.gz
 # Source0-md5:	73afc3c20808af2fee5f9fca47c64630
 Source1:	http://pyzy.googlecode.com/files/%{name}-database-1.0.0.tar.bz2
 # Source1-md5:	d0951b8daa7f56a2cbd3b6b4e42532e0
+Source2:	https://raw.githubusercontent.com/tsuna/boost.m4/3d67ee84e9149f6279a8df2113f5a86f0a83bd0d/build-aux/boost.m4
+# Source2-md5:	86092bd75ae3e9109891646b21cc433e
+# https://github.com/hillwoodroc/pyzy/commit/344872231b95ce7c2808288101cc563dcd011940.patch
+Patch0:		%{name}-opencc-1.patch
 URL:		https://github.com/pyzy/pyzy
+BuildRequires:	autoconf >= 2.62
+BuildRequires:	automake >= 1:1.11
 BuildRequires:	boost-devel >= 1.39
 BuildRequires:	glib2-devel >= 1:2.24.0
 BuildRequires:	libstdc++-devel
+BuildRequires:	libtool >= 2:1.5
 BuildRequires:	libuuid-devel
-BuildRequires:	opencc-devel
+BuildRequires:	opencc-devel >= 1.0.2
 BuildRequires:	pkgconfig
 BuildRequires:	sqlite3-devel
 Requires:	glib2 >= 1:2.24.0
@@ -108,9 +115,19 @@ Baza danych fraz dla pyzy pochodząca z projektu android.
 
 %prep
 %setup -q
-cp %{SOURCE1} data/db/open-phrase
+%patch0 -p1
+
+cp -f %{SOURCE1} data/db/open-phrase
+
+# update to support newer compilers
+cp -f %{SOURCE2} m4/boost.m4
 
 %build
+%{__libtoolize}
+%{__aclocal} -I m4
+%{__autoconf}
+%{__autoheader}
+%{__automake}
 %configure \
 	--disable-silent-rules \
 	--enable-boost \
@@ -153,9 +170,11 @@ rm -rf $RPM_BUILD_ROOT
 %{_includedir}/pyzy-1.0
 %{_pkgconfigdir}/pyzy-1.0.pc
 
+%if %{with static_libs}
 %files static
 %defattr(644,root,root,755)
 %{_libdir}/libpyzy-1.0.a
+%endif
 
 %files db-open-phrase
 %defattr(644,root,root,755)
diff --git a/pyzy-opencc-1.patch b/pyzy-opencc-1.patch
new file mode 100644
index 0000000..2075b07
--- /dev/null
+++ b/pyzy-opencc-1.patch
@@ -0,0 +1,56 @@
+From 344872231b95ce7c2808288101cc563dcd011940 Mon Sep 17 00:00:00 2001
+From: Hillwood Yang <hillwoodroc at gmail.com>
+Date: Thu, 26 Feb 2015 11:04:29 +0800
+Subject: [PATCH] Update SimpTradConverter.cc
+
+Use opencc 1.0.2
+---
+ src/SimpTradConverter.cc | 42 +++++++++++++---------------------------
+ 1 file changed, 13 insertions(+), 29 deletions(-)
+
+diff --git a/src/SimpTradConverter.cc b/src/SimpTradConverter.cc
+index 6fe9123..7be0749 100644
+--- a/src/SimpTradConverter.cc
++++ b/src/SimpTradConverter.cc
+@@ -40,7 +41,6 @@ namespace PyZy {
+ #ifdef HAVE_OPENCC
+ 
+ class opencc {
+-    static const int BUFFER_SIZE = 64;
+ public:
+     opencc (void)
+     {
+@@ -55,29 +55,13 @@ class opencc {
+ 
+     void convert (const char *in, String &out)
+     {
+-        long n_char;
+-        unichar *in_ucs4 = g_utf8_to_ucs4_fast (in, -1, &n_char);
+-
+-        ucs4_t *pinbuf = (ucs4_t *)in_ucs4;
+-        size_t inbuf_left = n_char;
+-        while (inbuf_left != 0) {
+-            ucs4_t *poutbuf = (ucs4_t *)m_buffer;
+-            size_t outbuf_left = BUFFER_SIZE;
+-            size_t retval = opencc_convert(m_od, &pinbuf, &inbuf_left, &poutbuf, &outbuf_left);
+-            if (retval == (size_t) -1) {
+-                /* append left chars in pinbuf */
+-                g_warning ("opencc_convert return failed");
+-                out << (unichar *) pinbuf;
+-                break;
+-            }
+-            *poutbuf = L'\0';
+-            out << m_buffer;
+-        }
+-        g_free (in_ucs4);
++        char * converted = opencc_convert_utf8 (m_od, in, -1);
++        g_assert (converted != NULL);
++        out = converted;
++        opencc_convert_utf8_free (converted);
+     }
+ private:
+     opencc_t m_od;
+-    unichar m_buffer[BUFFER_SIZE + 1];
+ };
+ 
+ void
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/pyzy.git/commitdiff/c940682d8f16308850ce27a55082aabac2806a9e



More information about the pld-cvs-commit mailing list