summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYixun Lan <dlan@gentoo.org>2016-05-27 18:00:33 +0800
committerYixun Lan <dlan@gentoo.org>2016-05-27 18:20:30 +0800
commitc128d1b74954557d0e6d9df085b0a822450bb6e3 (patch)
tree19b98a815f3b1b2928916b3589f0ae8667ea7bd2 /app-i18n/pyzy
parentapp-i18n/fcitx-libpinyin: version bump 0.3.3 (diff)
downloadgentoo-c128d1b74954557d0e6d9df085b0a822450bb6e3.tar.gz
gentoo-c128d1b74954557d0e6d9df085b0a822450bb6e3.tar.bz2
gentoo-c128d1b74954557d0e6d9df085b0a822450bb6e3.zip
app-i18n/pyzy: support opencc-1.0.4
Gentoo-Bug: 580782 Package-Manager: portage-2.2.28
Diffstat (limited to 'app-i18n/pyzy')
-rw-r--r--app-i18n/pyzy/files/pyzy-support-opencc-1.0.0.patch49
-rw-r--r--app-i18n/pyzy/pyzy-0.1.0-r2.ebuild54
2 files changed, 103 insertions, 0 deletions
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 000000000000..055aad13ca1c
--- /dev/null
+++ b/app-i18n/pyzy/files/pyzy-support-opencc-1.0.0.patch
@@ -0,0 +1,49 @@
+commit 344872231b95ce7c2808288101cc563dcd011940
+Author: Hillwood Yang <hillwoodroc@gmail.com>
+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 000000000000..22cbf96ae2f2
--- /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/*
+}