commit:     d3e76c26607e0aba7839c871ad6a569c0ff0e037
Author:     NHOrus <jy6x2b32pie9 <AT> yahoo <DOT> com>
AuthorDate: Tue Mar 11 16:49:54 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Mar 14 20:59:54 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d3e76c26

games-action/maelstrom: update EAPI 7 -> 8, fix build with GCC-15 and Clang

Issues are more of Cisms in C++ code, and some of them had rather
horrific fixes.
One is from the bug report, for wrong type of main().
Another one is about macros in string literals and register keyword.

Closes: https://bugs.gentoo.org/730822
Closes: https://bugs.gentoo.org/875431
Signed-off-by: NHOrus <jy6x2b32pie9 <AT> yahoo.com>
Signed-off-by: Stephane Bakhos <nuitari <AT> nuitari.net>
Closes: https://github.com/gentoo/gentoo/pull/41019
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../files/maelstrom-3.0.6-clang-sprintf.patch      | 112 +++++++++++++++++++++
 .../files/maelstrom-3.0.6-fix_return_type.patch    |  17 ++++
 games-action/maelstrom/maelstrom-3.0.6-r4.ebuild   |  61 +++++++++++
 3 files changed, 190 insertions(+)

diff --git a/games-action/maelstrom/files/maelstrom-3.0.6-clang-sprintf.patch 
b/games-action/maelstrom/files/maelstrom-3.0.6-clang-sprintf.patch
new file mode 100644
index 000000000000..c080b1ab9c26
--- /dev/null
+++ b/games-action/maelstrom/files/maelstrom-3.0.6-clang-sprintf.patch
@@ -0,0 +1,112 @@
+Fix build errors with clang caused by strict denial of Cisms in C++ code
+Folded sed to install the high scores file in ${GAMES_STATEDIR}
+sed -i -e "s:path.Path(MAELSTROM_SCORES):\"/var/games/\"MAELSTROM_SCORES:" 
scores.cpp
+and mangled it to work with C++
+https://bugs.gentoo.org/730822
+--- a/load.h
++++ b/load.h
+@@ -106,7 +106,7 @@
+               if ( strcmp(directory, DIR_SEP) == 0 ) {
+                       sprintf(path, DIR_SEP"%s", filename);
+               } else {
+-                      sprintf(path, "%s"DIR_SEP"%s", directory, filename);
++                      sprintf(path, "%s%s%s", directory, DIR_SEP, filename);
+               }
+               return(path);
+       }
+--- a/screenlib/SDL_FrameBuf.cpp
++++ b/screenlib/SDL_FrameBuf.cpp
+@@ -519,7 +519,7 @@
+       }
+ #else
+       /* Swap two buffers using a temporary variable */
+-      register Uint8 tmp;
++      Uint8 tmp;
+ 
+       while ( len-- ) {
+               tmp = *dst;
+--- a/controls.cpp
++++ b/controls.cpp
+@@ -83,7 +83,7 @@
+       if ( fname ) {
+               *fname = datafile;
+       }
+-      snprintf(datafile, sizeof(datafile), "%s"DIR_SEP"%s", home, 
MAELSTROM_DATA);
++      snprintf(datafile, sizeof(datafile), "%s%s%s", home, DIR_SEP, 
MAELSTROM_DATA);
+       if ( (data=fopen(datafile, mode)) == NULL )
+               return(NULL);
+       return(data);
+--- a/fastrand.cpp
++++ b/fastrand.cpp
+@@ -30,10 +30,10 @@
+ Uint16 FastRandom(Uint16 range)
+ {
+       Uint16 result;
+-      register Uint32 calc;
+-      register Uint32 regD0;
+-      register Uint32 regD1;
+-      register Uint32 regD2;
++      Uint32 calc;
++      Uint32 regD0;
++      Uint32 regD1;
++      Uint32 regD2;
+ 
+ #ifdef SERIOUS_DEBUG
+   fprintf(stderr, "FastRandom(%hd)  Seed in: %lu ", range, randomSeed);
+--- a/load.cpp
++++ b/load.cpp
+@@ -81,7 +81,7 @@
+       SDL_Surface *bmp, *title;
+       
+       /* Open the title file -- we know its colormap is our global one */
+-      snprintf(file, sizeof(file), "Images"DIR_SEP"Maelstrom_Titles#%d.bmp", 
title_id);
++      snprintf(file, sizeof(file), "Images%sMaelstrom_Titles#%d.bmp", 
DIR_SEP, title_id);
+       bmp = SDL_LoadBMP(path.Path(file));
+       if ( bmp == NULL ) {
+               return(NULL);
+@@ -103,7 +103,7 @@
+       Uint16 w, h;
+       
+       /* Open the cicn sprite file.. */
+-      snprintf(file, sizeof(file), "Images"DIR_SEP"Maelstrom_Icon#%hd.cicn", 
cicn_id);
++      snprintf(file, sizeof(file), "Images%sMaelstrom_Icon#%hd.cicn", 
DIR_SEP, cicn_id);
+       if ( (cicn_src=SDL_RWFromFile(path.Path(file), "r")) == NULL ) {
+               error("GetCIcon(%hd): Can't open CICN %s: ",
+                                       cicn_id, path.Path(file));
+--- a/scores.cpp
++++ b/scores.cpp
+@@ -10,6 +10,7 @@
+ #include <stdio.h>
+ 
+ #include "SDL_endian.h"
++#include <string>
+ 
+ #include "Maelstrom_Globals.h"
+ #include "load.h"
+@@ -44,7 +45,7 @@
+       }
+       memset(&hScores, 0, sizeof(hScores));
+ 
+-      scores_src = SDL_RWFromFile(path.Path(MAELSTROM_SCORES), "rb");
++      scores_src = SDL_RWFromFile((std::string("/var/games/") + 
MAELSTROM_SCORES).c_str(), "rb");
+       if ( scores_src != NULL ) {
+               for ( i=0; i<NUM_SCORES; ++i ) {
+                       SDL_RWread(scores_src, hScores[i].name,
+@@ -72,7 +73,7 @@
+ #ifdef unix
+       omask=umask(SCORES_PERMMASK);
+ #endif
+-      scores_src = SDL_RWFromFile(path.Path(MAELSTROM_SCORES), "wb");
++      scores_src = SDL_RWFromFile((std::string("/var/games/") + 
MAELSTROM_SCORES).c_str(), "wb");
+       if ( scores_src != NULL ) {
+               for ( i=0; i<NUM_SCORES; ++i ) {
+                       SDL_RWwrite(scores_src, hScores[i].name,
+@@ -83,7 +84,7 @@
+               SDL_RWclose(scores_src);
+       } else {
+               error("Warning: Couldn't save scores to %s\n",
+-                                              path.Path(MAELSTROM_SCORES));
++                                              (std::string("/var/games/") + 
MAELSTROM_SCORES).c_str());
+       }
+ #ifdef unix
+       umask(omask);

diff --git a/games-action/maelstrom/files/maelstrom-3.0.6-fix_return_type.patch 
b/games-action/maelstrom/files/maelstrom-3.0.6-fix_return_type.patch
new file mode 100644
index 000000000000..4950b5b6d5e7
--- /dev/null
+++ b/games-action/maelstrom/files/maelstrom-3.0.6-fix_return_type.patch
@@ -0,0 +1,17 @@
+Adds void to main()
+
+Quick fix to the compile issue on main. There is no return statement, so 
return type is set to void. 
+
+Signed-off-by: Stephane Bakhos <[email protected]>
+https://bugs.gentoo.org/875431
+--- a/Maelstrom-netd.c
++++ b/Maelstrom-netd.c
+@@ -184,7 +184,7 @@
+        exit(sig);
+ }
+ 
+-main(int argc, char *argv[])
++void main(int argc, char *argv[])
+ {
+        int netfd, i, slot;
+        struct sockaddr_in serv_addr;

diff --git a/games-action/maelstrom/maelstrom-3.0.6-r4.ebuild 
b/games-action/maelstrom/maelstrom-3.0.6-r4.ebuild
new file mode 100644
index 000000000000..05c954287609
--- /dev/null
+++ b/games-action/maelstrom/maelstrom-3.0.6-r4.ebuild
@@ -0,0 +1,61 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit autotools desktop
+
+DESCRIPTION="An asteroids battle game"
+HOMEPAGE="https://www.libsdl.org/projects/Maelstrom/";
+SRC_URI="https://www.libsdl.org/projects/Maelstrom/src/${P^}.tar.gz";
+S="${WORKDIR}/${P^}"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 ~x86"
+
+DEPEND="
+       acct-group/gamestat
+       media-libs/libsdl[sound,joystick,video]
+       media-libs/sdl-net"
+RDEPEND="${DEPEND}"
+
+PATCHES=(
+       "${FILESDIR}"/${P}-security.patch
+       "${FILESDIR}"/${P}-64bits.patch
+       "${FILESDIR}"/${P}-gcc34.patch
+       "${FILESDIR}"/${P}-warnings.patch
+       "${FILESDIR}"/${P}-gcc53.patch
+       "${FILESDIR}"/${P}-autotools.patch
+       "${FILESDIR}"/${P}-fix_return_type.patch
+       "${FILESDIR}"/${P}-clang-sprintf.patch
+)
+
+src_prepare() {
+       default
+
+       rm aclocal.m4 acinclude.m4 || die
+       eautoreconf
+}
+
+src_install() {
+       default
+       dodoc Changelog 
Docs/{Maelstrom-Announce,*FAQ,MaelstromGPL_press_release,*.Paper,Technical_Notes*}
+
+       newicon "${ED}"/usr/share/Maelstrom/icon.xpm maelstrom.xpm
+       make_desktop_entry Maelstrom "Maelstrom" maelstrom
+
+       # Put the high scores file in the right place
+       insinto /var/games
+       doins "${ED}"/usr/share/Maelstrom/Maelstrom-Scores
+
+       # clean up some cruft
+       rm \
+               "${ED}"/usr/share/Maelstrom/Maelstrom-Scores \
+               "${ED}"/usr/share/Maelstrom/Images/Makefile* || die
+
+       # make sure we can update the high scores
+       fowners root:gamestat /var/games/Maelstrom-Scores 
/usr/bin/Maelstrom{,-netd}
+       fperms 2755 /usr/bin/Maelstrom{,-netd}
+       fperms 660 /var/games/Maelstrom-Scores
+}

Reply via email to