commit:     c128d1b74954557d0e6d9df085b0a822450bb6e3
Author:     Yixun Lan <dlan <AT> gentoo <DOT> org>
AuthorDate: Fri May 27 10:00:33 2016 +0000
Commit:     Yixun Lan <dlan <AT> gentoo <DOT> org>
CommitDate: Fri May 27 10:20:30 2016 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c128d1b7

app-i18n/pyzy: support opencc-1.0.4

Gentoo-Bug: 580782

Package-Manager: portage-2.2.28

 .../pyzy/files/pyzy-support-opencc-1.0.0.patch     | 49 ++++++++++++++++++++
 app-i18n/pyzy/pyzy-0.1.0-r2.ebuild                 | 54 ++++++++++++++++++++++
 2 files changed, 103 insertions(+)

diff --git a/app-i18n/pyzy/files/pyzy-support-opencc-1.0.0.patch 
b/app-i18n/pyzy/files/pyzy-support-opencc-1.0.0.patch
new file mode 100644
index 0000000..055aad1
--- /dev/null
+++ b/app-i18n/pyzy/files/pyzy-support-opencc-1.0.0.patch
@@ -0,0 +1,49 @@
+commit 344872231b95ce7c2808288101cc563dcd011940
+Author: Hillwood Yang <[email protected]>
+Date:   Thu Feb 26 11:04:29 2015 +0800
+
+diff -urN a/src/SimpTradConverter.cc b/src/SimpTradConverter.cc
+--- 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 @@ public:
+ 
+     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

diff --git a/app-i18n/pyzy/pyzy-0.1.0-r2.ebuild 
b/app-i18n/pyzy/pyzy-0.1.0-r2.ebuild
new file mode 100644
index 0000000..22cbf96
--- /dev/null
+++ b/app-i18n/pyzy/pyzy-0.1.0-r2.ebuild
@@ -0,0 +1,54 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=5
+
+PYTHON_COMPAT=( python2_7 )
+inherit eutils python-any-r1 autotools
+
+PY_DATABASE=${PN}-database-1.0.0
+DESCRIPTION="The Chinese PinYin and Bopomofo conversion library"
+HOMEPAGE="https://github.com/pyzy/pyzy";
+SRC_URI="https://pyzy.googlecode.com/files/${P}.tar.gz
+       https://pyzy.googlecode.com/files/${PY_DATABASE}.tar.bz2";
+
+LICENSE="LGPL-2.1"
+SLOT="0"
+KEYWORDS="~amd64 ~x86"
+IUSE="boost doc opencc test"
+
+RDEPEND="dev-libs/glib:2
+       dev-db/sqlite:3
+       sys-apps/util-linux
+       boost? ( dev-libs/boost )
+       opencc? ( app-i18n/opencc )"
+
+DEPEND="${RDEPEND}
+       ${PYTHON_DEPS}
+       doc? ( app-doc/doxygen )"
+
+# Currently it fails to build test code
+RESTRICT="test"
+
+src_prepare() {
+       epatch "${FILESDIR}"/${PN}-dont-download-dictionary-file.patch
+       epatch "${FILESDIR}"/${PN}-support-opencc-1.0.0.patch
+
+       mv ../db ./data/db/open-phrase/ || die
+       eautoreconf
+}
+
+src_configure() {
+       econf \
+               --enable-db-open-phrase \
+               --enable-db-android \
+               $(use_enable boost) \
+               $(use_enable opencc) \
+               $(use_enable test tests)
+}
+
+src_install() {
+       default
+       use doc && dohtml -r docs/html/*
+}

Reply via email to