commit:     f9fa51dc6c9febe526943d56483881b147f1990a
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Nov 17 03:22:47 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Nov 17 03:49:21 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f9fa51dc

games-simulation/pmars-sdl: EAPI 8, ncurses opaque struct fixes, C23

Closes: https://bugs.gentoo.org/932139
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../pmars-sdl/files/pmars-sdl-0.9.2e-c23.patch     |  11 +++
 .../files/pmars-sdl-0.9.2e-ncurses-opaque.patch    |  45 +++++++++
 .../pmars-sdl/pmars-sdl-0.9.2e-r2.ebuild           | 104 +++++++++++++++++++++
 3 files changed, 160 insertions(+)

diff --git a/games-simulation/pmars-sdl/files/pmars-sdl-0.9.2e-c23.patch 
b/games-simulation/pmars-sdl/files/pmars-sdl-0.9.2e-c23.patch
new file mode 100644
index 000000000000..b9a61a24a452
--- /dev/null
+++ b/games-simulation/pmars-sdl/files/pmars-sdl-0.9.2e-c23.patch
@@ -0,0 +1,11 @@
+sort_by_score appeared twice.
+--- a/src/global.h
++++ b/src/global.h
+@@ -411,7 +411,6 @@ extern int score(int warnum);
+ extern void sort_by_score(int *idxV, int *scrV);
+ extern int deaths(int warnum);
+ extern void results(FILE * outp);
+-extern void sort_by_score();
+ extern void Exit(int code);
+ extern void reset_regs(void);
+ extern void set_reg(char regChr, long val);

diff --git 
a/games-simulation/pmars-sdl/files/pmars-sdl-0.9.2e-ncurses-opaque.patch 
b/games-simulation/pmars-sdl/files/pmars-sdl-0.9.2e-ncurses-opaque.patch
new file mode 100644
index 000000000000..543ece1d6ce5
--- /dev/null
+++ b/games-simulation/pmars-sdl/files/pmars-sdl-0.9.2e-ncurses-opaque.patch
@@ -0,0 +1,45 @@
+https://bugs.gentoo.org/932139
+https://github.com/mbarbon/pMARS/commit/a39970c724591c3c8625819cab7ca298ae71e12d
+--- a/src/curdisp.c
++++ b/src/curdisp.c
+@@ -428,18 +428,18 @@ agets5(str, maxchar, attr)
+           str--;
+           maxchar++;
+           leaveok(curwin, TRUE);
+-          if (ox = curwin->_curx) {
++          if (ox = getcurx(curwin)) {
+ #if 0
+ #ifdef ATTRIBUTE
+-            mvwaddch(curwin, curwin->_cury, --ox, ' ' | attr);
++            mvwaddch(curwin, getcury(curwin), --ox, ' ' | attr);
+ #else
+-            mvwaddch(curwin, curwin->_cury, --ox, ' ');
++            mvwaddch(curwin, getcury(curwin), --ox, ' ');
+ #endif
+ #endif                                /* 0 */
+-            mvwaddch(curwin, curwin->_cury, --ox, ' ');
+-            wmove(curwin, curwin->_cury, ox);
++            mvwaddch(curwin, getcury(curwin), --ox, ' ');
++            wmove(curwin, getcury(curwin), ox);
+           } else {
+-            oy = curwin->_cury - 1;
++            oy = getcury(curwin) - 1;
+ #if 0
+ #ifdef ATTRIBUTE
+             mvwaddch(curwin, oy, COLS - 1, ' ' | attr);
+@@ -470,12 +470,12 @@ agets5(str, maxchar, attr)
+           if (ox--)
+ #if 0
+ #ifdef ATTRIBUTE
+-            mvwaddch(curwin, curwin->_cury, ox, ' ' | attr);
++            mvwaddch(curwin, getcury(curwin), ox, ' ' | attr);
+ #else
+-            mvwaddch(curwin, curwin->_cury, ox, ' ');
++            mvwaddch(curwin, getcury(curwin), ox, ' ');
+ #endif
+ #endif                                /* 0 */
+-          mvwaddch(curwin, curwin->_cury, ox, ' ');
++          mvwaddch(curwin, getcury(curwin), ox, ' ');
+           else
+ #if 0
+ #ifdef ATTRIBUTE

diff --git a/games-simulation/pmars-sdl/pmars-sdl-0.9.2e-r2.ebuild 
b/games-simulation/pmars-sdl/pmars-sdl-0.9.2e-r2.ebuild
new file mode 100644
index 000000000000..ee9eb60c147c
--- /dev/null
+++ b/games-simulation/pmars-sdl/pmars-sdl-0.9.2e-r2.ebuild
@@ -0,0 +1,104 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit flag-o-matic toolchain-funcs readme.gentoo-r1
+
+MY_PN="${PN/-sdl/}"
+MY_PV="${PV/e/-5}"
+MY_P="${MY_PN}-${MY_PV}"
+
+DESCRIPTION="Portable redcode simulator's sdl port for core war"
+HOMEPAGE="https://corewar.co.uk/pihlaja/pmars-sdl/";
+SRC_URI="https://corewar.co.uk/pihlaja/pmars-sdl/${MY_P}.tar.gz";
+S="${WORKDIR}/${MY_P}"
+
+LICENSE="BSD GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 ~x86"
+IUSE="sdl X"
+
+RDEPEND="
+       sdl? ( x11-libs/libX11 media-libs/libsdl[video] )
+       X? ( x11-libs/libX11 )
+       !sdl? ( !X? ( sys-libs/ncurses:0= ) )
+"
+DEPEND="${RDEPEND}"
+BDEPEND="virtual/pkgconfig"
+
+PATCHES=(
+       "${FILESDIR}"/${P}-format.patch
+       "${FILESDIR}"/${P}-ncurses-opaque.patch
+       "${FILESDIR}"/${P}-c23.patch
+)
+
+DOC_CONTENTS="
+       There are some macros in /usr/share/pmars/macros
+       which you should make accessible to pmars by typing
+       export PMARSHOME=/usr/share/pmars/macros\n
+"
+
+src_compile() {
+       local LIB=""
+       export LFLAGS="-x"
+
+       append-cppflags -DEXT94 -DPERMUTATE
+
+       if use sdl ; then
+               append-cflags $(sdl-config --cflags)
+               append-cppflags -DSDLGRAPHX
+
+               LIB="$(sdl-config --libs)"
+       elif use X ; then
+               append-cppflags -DXWINGRAPHX
+
+               LIB="$($(tc-getPKG_CONFIG) --libs x11)"
+       else
+               append-cppflags -DCURSESGRAPHX
+
+               LIB="$($(tc-getPKG_CONFIG) --libs ncurses)"
+       fi
+
+       cd src || die
+
+       local programs=(
+               asm.c
+               cdb.c
+               clparse.c
+               disasm.c
+               eval.c
+               global.c
+               pmars.c
+               sim.c
+               pos.c
+               str_eng.c
+               token.c
+       )
+
+       for program in "${programs[@]}" ; do
+               einfo "Compiling ${program}"
+               $(tc-getCC) ${CPPFLAGS} ${CFLAGS} ${program} -c || die
+       done
+
+       einfo "Linking with LIB: ${LIB}"
+       $(tc-getCC) ${LDFLAGS} *.o ${LIB} -o ${MY_PN} || die
+}
+
+src_install() {
+       dobin src/${MY_PN}
+       doman doc/${MY_PN}.6
+
+       dodoc AUTHORS CONTRIB ChangeLog README doc/redcode.ref
+       readme.gentoo_create_doc
+
+       insinto /usr/share/${MY_PN}/warriors
+       doins warriors/*
+
+       insinto /usr/share/${MY_PN}/macros
+       doins config/*.mac
+}
+
+pkg_postinst() {
+       readme.gentoo_print_elog
+}

Reply via email to