commit: af86b7379a9561ee144978edd332f6cce2b9240e Author: Sam James <sam <AT> gentoo <DOT> org> AuthorDate: Wed Mar 4 04:35:56 2026 +0000 Commit: Sam James <sam <AT> gentoo <DOT> org> CommitDate: Wed Mar 4 04:35:56 2026 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=af86b737
sys-apps/gawk: backport gensub and allocation fix Bug: https://lists.gnu.org/archive/html/bug-gawk/2026-02/msg00036.html Bug: https://lists.gnu.org/archive/html/bug-gawk/2026-02/msg00039.html Bug: https://lists.gnu.org/archive/html/bug-gawk/2026-03/msg00001.html Signed-off-by: Sam James <sam <AT> gentoo.org> ...sub-bug-for-use-with-MinRX.-Add-test-case.patch | 20 ++++ ...awk-5.4.0-Small-efficiency-fix-in-array.c.patch | 34 ++++++ .../files/gawk-5.4.0-no-assertions-for-pma.patch | 4 - sys-apps/gawk/gawk-5.4.0-r2.ebuild | 125 +++++++++++++++++++++ 4 files changed, 179 insertions(+), 4 deletions(-) diff --git a/sys-apps/gawk/files/gawk-5.4.0-Fix-gensub-bug-for-use-with-MinRX.-Add-test-case.patch b/sys-apps/gawk/files/gawk-5.4.0-Fix-gensub-bug-for-use-with-MinRX.-Add-test-case.patch new file mode 100644 index 000000000000..9b178f59aed4 --- /dev/null +++ b/sys-apps/gawk/files/gawk-5.4.0-Fix-gensub-bug-for-use-with-MinRX.-Add-test-case.patch @@ -0,0 +1,20 @@ +From 00be99d6ceae1439fd73a15f37d20710dd5798a5 Mon Sep 17 00:00:00 2001 +Message-ID: <00be99d6ceae1439fd73a15f37d20710dd5798a5.1772593597.git....@gentoo.org> +In-Reply-To: <32e6f04bf47ea95773ea0d6d876c5fad8bb90834.1772593597.git....@gentoo.org> +References: <32e6f04bf47ea95773ea0d6d876c5fad8bb90834.1772593597.git....@gentoo.org> +From: "Arnold D. Robbins" <[email protected]> +Date: Fri, 27 Feb 2026 11:03:04 +0200 +Subject: [PATCH 4/9] Fix gensub() bug for use with MinRX. Add test case. + +--- a/builtin.c ++++ b/builtin.c +@@ -2116,7 +2116,7 @@ do_sub(int nargs, unsigned int flags) + || ((long) textlen <= 0 && matchstart == matchend) + || research(rp, target->stptr, text - target->stptr, + use_gnu_matchers ? textlen : target->stlen, +- RE_NEED_START) == -1) ++ searchflags) == -1) + break; + + } + diff --git a/sys-apps/gawk/files/gawk-5.4.0-Small-efficiency-fix-in-array.c.patch b/sys-apps/gawk/files/gawk-5.4.0-Small-efficiency-fix-in-array.c.patch new file mode 100644 index 000000000000..35cd4c801833 --- /dev/null +++ b/sys-apps/gawk/files/gawk-5.4.0-Small-efficiency-fix-in-array.c.patch @@ -0,0 +1,34 @@ +From de8f760a6bea360dd90c9daafc035999c83a3056 Mon Sep 17 00:00:00 2001 +Message-ID: <de8f760a6bea360dd90c9daafc035999c83a3056.1772593597.git....@gentoo.org> +In-Reply-To: <32e6f04bf47ea95773ea0d6d876c5fad8bb90834.1772593597.git....@gentoo.org> +References: <32e6f04bf47ea95773ea0d6d876c5fad8bb90834.1772593597.git....@gentoo.org> +From: "Arnold D. Robbins" <[email protected]> +Date: Sun, 1 Mar 2026 20:52:16 +0200 +Subject: [PATCH 6/9] Small efficiency fix in array.c. + +--- a/array.c ++++ b/array.c +@@ -210,17 +210,17 @@ make_aname(const NODE *symbol) + slen = strlen(symbol->vname); /* subscript in parent array */ + if (alen + slen + 4 > max_alen) { /* sizeof("[\"\"]") = 4 */ + max_alen = alen + slen + 4 + SLEN; +- erealloc(aname, char *, (max_alen + 1) * sizeof(char *)); ++ erealloc(aname, char *, (max_alen + 1) * sizeof(char)); + } + alen += sprintf(aname + alen, "[\"%s\"]", symbol->vname); + } else { + alen = strlen(symbol->vname); + if (aname == NULL) { + max_alen = alen + SLEN; +- emalloc(aname, char *, (max_alen + 1) * sizeof(char *)); ++ emalloc(aname, char *, (max_alen + 1) * sizeof(char)); + } else if (alen > max_alen) { + max_alen = alen + SLEN; +- erealloc(aname, char *, (max_alen + 1) * sizeof(char *)); ++ erealloc(aname, char *, (max_alen + 1) * sizeof(char)); + } + memcpy(aname, symbol->vname, alen + 1); + } +-- +2.53.0 + diff --git a/sys-apps/gawk/files/gawk-5.4.0-no-assertions-for-pma.patch b/sys-apps/gawk/files/gawk-5.4.0-no-assertions-for-pma.patch index d729d58a5c7c..e58bf201eaad 100644 --- a/sys-apps/gawk/files/gawk-5.4.0-no-assertions-for-pma.patch +++ b/sys-apps/gawk/files/gawk-5.4.0-no-assertions-for-pma.patch @@ -5,10 +5,6 @@ From: "Arnold D. Robbins" <[email protected]> Date: Mon, 23 Feb 2026 10:59:41 +0200 Subject: Disable assertions in support/pma.c. ---- - support/pma.c | 1 + - 2 files changed, 7 insertions(+) - --- a/support/pma.c +++ b/support/pma.c @@ -27,6 +27,7 @@ diff --git a/sys-apps/gawk/gawk-5.4.0-r2.ebuild b/sys-apps/gawk/gawk-5.4.0-r2.ebuild new file mode 100644 index 000000000000..e015e439214a --- /dev/null +++ b/sys-apps/gawk/gawk-5.4.0-r2.ebuild @@ -0,0 +1,125 @@ +# Copyright 1999-2026 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +GAWK_IS_BETA=no + +DESCRIPTION="GNU awk pattern-matching language" +HOMEPAGE="https://www.gnu.org/software/gawk/gawk.html" + +if [[ ${GAWK_IS_BETA} == yes || ${PV} == *_beta* ]] ; then + if [[ ${PV} == *_beta* ]] ; then + # Beta versioning is sometimes for the release prior, e.g. + # 5.2.1_beta is labelled upstream as 5.2.0b. + MY_PV=${PV/_beta/b} + MY_PV=$(ver_cut 1-2 ${MY_PV}).$(($(ver_cut 3 ${MY_PV}) - 1))$(ver_cut 4- ${MY_PV}) + MY_P=${PN}-${MY_PV} + + S="${WORKDIR}"/${MY_P} + else + MY_P=${P} + fi + + SRC_URI="https://www.skeeve.com/gawk/${MY_P}.tar.gz" +else + VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/gawk.asc + inherit verify-sig flag-o-matic + + SRC_URI="mirror://gnu/gawk/${P}.tar.xz" + SRC_URI+=" verify-sig? ( mirror://gnu/gawk/${P}.tar.xz.sig )" + + KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~arm64-macos ~x64-macos ~x64-solaris" +fi + +LICENSE="GPL-3+ pma? ( AGPL-3+ )" +SLOT="0" +# The gawk docs claim MPFR support is "on parole" and may be removed, +# https://www.gnu.org/software/gawk/manual/html_node/MPFR-On-Parole.html +# however this is somewhat outdated information, see +# https://public-inbox.org/libc-alpha/[email protected]/ +IUSE="+mpfr pma nls readline" + +RDEPEND=" + mpfr? ( + dev-libs/gmp:= + dev-libs/mpfr:= + ) + readline? ( sys-libs/readline:= ) +" +DEPEND="${RDEPEND}" +BDEPEND=" + >=sys-apps/texinfo-7.1 + >=sys-devel/bison-3.5.4 + nls? ( sys-devel/gettext ) +" + +if [[ ${GAWK_IS_BETA} != yes ]] ; then + BDEPEND+=" verify-sig? ( sec-keys/openpgp-keys-gawk )" +fi + +PATCHES=( + "${FILESDIR}"/${P}-no-assertions-for-pma.patch + "${FILESDIR}"/${P}-Fix-gensub-bug-for-use-with-MinRX.-Add-test-case.patch + "${FILESDIR}"/${P}-Small-efficiency-fix-in-array.c.patch +) + +src_prepare() { + default + + use elibc_musl && append-cppflags -D__GNU_LIBRARY__ + + # Use symlinks rather than hardlinks, and disable version links + sed -i \ + -e '/^LN =/s:=.*:= $(LN_S):' \ + -e '/install-exec-hook:/s|$|\nfoo:|' \ + Makefile.in doc/Makefile.in || die + + # bug #413327 + sed -i '/^pty1:$/s|$|\n_pty1:|' test/Makefile.in || die + + # Fix standards conflict on Solaris + if [[ ${CHOST} == *-solaris* ]] ; then + sed -i \ + -e '/\<_XOPEN_SOURCE\>/s/1$/600/' \ + -e '/\<_XOPEN_SOURCE_EXTENDED\>/s/1//' \ + extension/inplace.c || die + fi +} + +src_configure() { + # README says gawk may not work properly if built with non-Bison. + # We already BDEPEND on Bison, so just unset YACC rather than + # guessing if we need to do yacc.bison or bison -y. + unset YACC + + local myeconfargs=( + --cache-file="${S}"/config.cache + --libexec='$(libdir)/misc' + $(use_with mpfr) + $(use_enable nls) + $(use_enable pma) + $(use_with readline) + ) + + econf "${myeconfargs[@]}" +} + +src_test() { + # bug #970495 + local -x PAGER=cat + + emake check +} + +src_install() { + # Automatic dodocs barfs + rm -rf README_d || die + + default + + # Install headers + insinto /usr/include/awk + doins *.h + rm "${ED}"/usr/include/awk/config.h || die +}
