summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam James <sam@gentoo.org>2022-10-04 06:00:18 +0100
committerSam James <sam@gentoo.org>2022-10-04 06:07:12 +0100
commitd7838f82889905b9bb599a551b8ed2a89a7181a0 (patch)
tree64730a9951d0765c379017734d2de2b8b5d21bce /app-i18n/nkf
parentsci-astronomy/pyephem: fix build w/ Clang 15 (diff)
downloadgentoo-d7838f82889905b9bb599a551b8ed2a89a7181a0.tar.gz
gentoo-d7838f82889905b9bb599a551b8ed2a89a7181a0.tar.bz2
gentoo-d7838f82889905b9bb599a551b8ed2a89a7181a0.zip
app-i18n/nkf: fix build w/ Clang 15
Closes: https://bugs.gentoo.org/874303 Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'app-i18n/nkf')
-rw-r--r--app-i18n/nkf/files/nkf-2.1.5-python-ssize_t-deux.patch45
-rw-r--r--app-i18n/nkf/files/nkf-2.1.5-python-ssize_t.patch71
-rw-r--r--app-i18n/nkf/nkf-2.1.5-r1.ebuild117
3 files changed, 233 insertions, 0 deletions
diff --git a/app-i18n/nkf/files/nkf-2.1.5-python-ssize_t-deux.patch b/app-i18n/nkf/files/nkf-2.1.5-python-ssize_t-deux.patch
new file mode 100644
index 000000000000..355951cab319
--- /dev/null
+++ b/app-i18n/nkf/files/nkf-2.1.5-python-ssize_t-deux.patch
@@ -0,0 +1,45 @@
+https://github.com/fumiyas/python-nkf/pull/7
+
+From abdebb9d49619d9b9cafa172d2ad7c171f3977d4 Mon Sep 17 00:00:00 2001
+From: Sam James <sam@gentoo.org>
+Date: Tue, 4 Oct 2022 05:56:12 +0100
+Subject: [PATCH] Use designated initialiser syntax for PyModuleDef
+
+Fixes build with Clang. Switch to the more readable designated
+initialiser syntax to avoid having to lookup member order.
+
+Before, Clang would complain:
+```
+nkf.c:205:3: error: incompatible pointer to integer conversion initializing 'Py_ssize_t' (aka 'long') with an expression of type 'void *' [-Wint-conversion]
+ NULL,
+ ^~~~
+/usr/lib/llvm/16/bin/../../../../lib/clang/16.0.0/include/stddef.h:89:16: note: expanded from macro 'NULL'
+ ^~~~~~~~~~
+2 warnings and 1 error generated.
+```
+
+This is because some of PyModuleDef's members are actually
+Py_ssize_t so chucking a NULL in looks like a codesmell to Clang.
+
+Bug: https://bugs.gentoo.org/874303
+Signed-off-by: Sam James <sam@gentoo.org>
+--- a/NKF.python/nkf.c
++++ b/NKF.python/nkf.c
+@@ -200,14 +200,8 @@ nkfmethods[] = {
+ static struct PyModuleDef
+ moduledef = {
+ PyModuleDef_HEAD_INIT,
+- "nkf",
+- NULL,
+- NULL,
+- nkfmethods,
+- NULL,
+- NULL,
+- NULL,
+- NULL
++ .m_name = "nkf",
++ .m_methods = nkfmethods
+ };
+
+ /* Module initialization function */
+
diff --git a/app-i18n/nkf/files/nkf-2.1.5-python-ssize_t.patch b/app-i18n/nkf/files/nkf-2.1.5-python-ssize_t.patch
new file mode 100644
index 000000000000..6aa986866e0d
--- /dev/null
+++ b/app-i18n/nkf/files/nkf-2.1.5-python-ssize_t.patch
@@ -0,0 +1,71 @@
+https://github.com/nurse/nkf/commit/8246108073f739d45a21ef42ad2d9342fa3c6c28
+
+From 8246108073f739d45a21ef42ad2d9342fa3c6c28 Mon Sep 17 00:00:00 2001
+From: slic <slic-io@users.noreply.github.com>
+Date: Sun, 6 Mar 2022 18:05:54 +0900
+Subject: [PATCH] fix: python3 extention ABI # variant when parsing warning
+
+--- a/NKF.python3/NKF_python.c
++++ b/NKF.python3/NKF_python.c
+@@ -20,6 +20,8 @@ Changes.
+ ** THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE.
+ ***************************************************************************/
+
++#define PY_SSIZE_T_CLEAN
++
+ #include "Python.h"
+ #include <setjmp.h>
+
+@@ -33,7 +35,7 @@ Changes.
+ #undef FALSE
+ #define putchar(c) pynkf_putchar(c)
+
+-static int pynkf_ibufsize, pynkf_obufsize;
++static Py_ssize_t pynkf_ibufsize, pynkf_obufsize;
+ static unsigned char *pynkf_inbuf, *pynkf_outbuf;
+ static int pynkf_icount,pynkf_ocount;
+ static unsigned char *pynkf_iptr, *pynkf_optr;
+@@ -62,7 +64,7 @@ pynkf_ungetc(int c, FILE *f)
+ static void
+ pynkf_putchar(int c)
+ {
+- size_t size;
++ Py_ssize_t size;
+ unsigned char *p;
+
+ if (pynkf_guess_flag) {
+@@ -89,7 +91,7 @@ pynkf_putchar(int c)
+ #include "../nkf.c"
+
+ static PyObject *
+-pynkf_convert(unsigned char* str, int strlen, char* opts, int optslen)
++pynkf_convert(unsigned char* str, Py_ssize_t strlen, char* opts, Py_ssize_t optslen)
+ {
+ PyObject * res;
+
+@@ -157,12 +159,12 @@ static
+ PyObject *pynkf_nkf(PyObject *self, PyObject *args)
+ {
+ unsigned char *str;
+- int strlen;
++ Py_ssize_t strlen;
+ char *opts;
+- int optslen;
++ Py_ssize_t optslen;
+ PyObject* res;
+
+- if (!PyArg_ParseTuple(args, "s#y#", &opts, &optslen, &str, &strlen)) {
++ if (!PyArg_ParseTuple(args, "s#s#", &opts, &optslen, &str, &strlen)) {
+ return NULL;
+ }
+ res = pynkf_convert(str, strlen, opts, optslen);
+@@ -178,7 +180,7 @@ PyObject *pynkf_guess(PyObject *self, PyObject *args)
+ int strlen;
+ PyObject* res;
+
+- if (!PyArg_ParseTuple(args, "y#", &str, &strlen)) {
++ if (!PyArg_ParseTuple(args, "s#", &str, &strlen)) {
+ return NULL;
+ }
+ res = pynkf_convert_guess(str, strlen);
+
diff --git a/app-i18n/nkf/nkf-2.1.5-r1.ebuild b/app-i18n/nkf/nkf-2.1.5-r1.ebuild
new file mode 100644
index 000000000000..095d49cf0515
--- /dev/null
+++ b/app-i18n/nkf/nkf-2.1.5-r1.ebuild
@@ -0,0 +1,117 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+PYTHON_COMPAT=( python3_{8..10} )
+DISTUTILS_OPTIONAL="1"
+
+inherit distutils-r1 perl-module toolchain-funcs vcs-snapshot
+
+PY_P="python-${PN}-0.2.0_p20191121"
+PY_COMMIT="c2c6724714b66f295137c8818dae4c09fc09e0a3"
+
+DESCRIPTION="Network Kanji code conversion Filter with UTF-8/16 support"
+HOMEPAGE="https://osdn.net/projects/nkf/"
+SRC_URI="mirror://sourceforge.jp/${PN}/70406/${P}.tar.gz
+ python? ( https://github.com/fumiyas/python-${PN}/archive/${PY_COMMIT}.tar.gz -> ${PY_P}.tar.gz )"
+
+LICENSE="ZLIB python? ( BSD )"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~hppa ~ia64 ~ppc ~ppc64 ~sparc ~x86"
+IUSE="perl python l10n_ja"
+REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
+
+RDEPEND="python? ( ${PYTHON_DEPS} )"
+DEPEND="${RDEPEND}"
+BDEPEND="python? (
+ ${PYTHON_DEPS}
+ dev-python/setuptools[${PYTHON_USEDEP}]
+ )"
+
+PATCHES=(
+ "${FILESDIR}"/${P}-python-ssize_t.patch
+ "${FILESDIR}"/${PN}-2.1.5-python-ssize_t-deux.patch
+)
+
+src_unpack() {
+ use python && vcs-snapshot_src_unpack || default
+}
+
+src_prepare() {
+ sed -i \
+ -e "/^CFLAGS/{ s/-g -O2//; s/=/+=/; }" \
+ -e "/ -o ${PN}/s/\(-o \)/\$(LDFLAGS) \1/" \
+ Makefile
+ if use python; then
+ mv "${WORKDIR}"/${PY_P} NKF.python || die
+ eapply "${FILESDIR}"/${PN}-python.patch
+ cd NKF.python || die
+ distutils-r1_src_prepare
+ cd - >/dev/null || die
+ fi
+
+ default
+}
+
+src_configure() {
+ default
+ if use perl; then
+ cd NKF.mod || die
+ perl-module_src_configure
+ cd - >/dev/null || die
+ fi
+ if use python; then
+ cd NKF.python || die
+ distutils-r1_src_configure
+ cd - >/dev/null || die
+ fi
+}
+
+src_compile() {
+ emake CC="$(tc-getCC)"
+ if use perl; then
+ cd NKF.mod || die
+ perl-module_src_compile
+ cd - >/dev/null || die
+ fi
+ if use python; then
+ cd NKF.python || die
+ distutils-r1_src_compile
+ cd - >/dev/null || die
+ fi
+}
+
+src_test() {
+ default
+ if use perl; then
+ cd NKF.mod || die
+ perl-module_src_test
+ cd - >/dev/null || die
+ fi
+}
+
+src_install() {
+ dobin ${PN}
+ doman ${PN}.1
+
+ if use l10n_ja; then
+ iconv -f ISO-2022-JP-3 -t UTF-8 ${PN}.1j > ${PN}.ja.1 || die
+ doman ${PN}.ja.1
+ fi
+ dodoc ${PN}.doc
+
+ if use perl; then
+ cd NKF.mod || die
+ docinto perl
+ perl-module_src_install
+ cd - >/dev/null || die
+ fi
+ if use python; then
+ cd NKF.python || die
+ docinto python
+ DOCS= distutils-r1_src_install
+ dodoc CHANGES README.md
+ cd - >/dev/null || die
+ fi
+}