commit:     1c704f41e48524b9efe64ee8819472db4f9b509c
Author:     NHOrus <jy6x2b32pie9 <AT> yahoo <DOT> com>
AuthorDate: Thu Feb  6 15:19:00 2025 +0000
Commit:     Nowa Ammerlaan <nowa <AT> gentoo <DOT> org>
CommitDate: Fri Feb  7 15:00:28 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1c704f41

x11-libs/xbae: Finish porting to C99/C23

With this patch, it now compiles with GCC-15

Closes: https://bugs.gentoo.org/944748
Closes: https://bugs.gentoo.org/919195
Signed-off-by: NHOrus <jy6x2b32pie9 <AT> yahoo.com>
Signed-off-by: Nowa Ammerlaan <nowa <AT> gentoo.org>

 x11-libs/xbae/files/xbae-4.60.4-c23.patch | 167 ++++++++++++++++++++++++++++++
 x11-libs/xbae/xbae-4.60.4-r2.ebuild       |  76 ++++++++++++++
 2 files changed, 243 insertions(+)

diff --git a/x11-libs/xbae/files/xbae-4.60.4-c23.patch 
b/x11-libs/xbae/files/xbae-4.60.4-c23.patch
new file mode 100644
index 000000000000..2031d744007a
--- /dev/null
+++ b/x11-libs/xbae/files/xbae-4.60.4-c23.patch
@@ -0,0 +1,167 @@
+Fix two remaining problems for C99/C23 compatibility.
+With this, package builds with GCC-15.
+true and false are strings, so replacement is trivial
+and doesn't interact with ABI.
+Casts to Widget are uses everywhere in this program, and
+are correct, as MatrixWidget embeds same core struct from Xt
+as Widget consists of, as first member.
+XtRImmediate indicates that next pointer would be interpreted
+as a value, so integer reinterpreted as a pointer to low mem is
+actually fine, it won't be dereferenced and won't crash whole
+program.
+https://bugs.gentoo.org/944748
+https://bugs.gentoo.org/919195
+--- a/examples/input/input.c
++++ b/examples/input/input.c
+@@ -126,7 +126,7 @@
+ {
+     Widget toplevel, rc, pattern, cw, radio, frame;
+     XtAppContext app;
+-    XmString true, false, begin, centre, end;
++    XmString true_str, false_str, begin, centre, end;
+ 
+     toplevel = XtVaAppInitialize(&app, "Input",
+                                NULL, 0,
+@@ -160,8 +160,8 @@
+ 
+     XtAddCallback(input, XmNvalidateCallback, validateCB, NULL);
+ 
+-    true = XmStringCreateSimple("True");
+-    false = XmStringCreateSimple("False");
++    true_str = XmStringCreateSimple("True");
++    false_str = XmStringCreateSimple("False");
+ 
+     cw = XtVaCreateManagedWidget(
+       "XmNautofill", xbaeCaptionWidgetClass, rc,
+@@ -173,8 +173,8 @@
+ 
+     radio = XmVaCreateSimpleRadioBox(
+       frame, "XmNautoFill", 0, autoFillToggle,
+-      XmVaRADIOBUTTON, false, NULL, NULL, NULL,
+-      XmVaRADIOBUTTON, true, NULL, NULL, NULL,
++      XmVaRADIOBUTTON, false_str, NULL, NULL, NULL,
++      XmVaRADIOBUTTON, true_str, NULL, NULL, NULL,
+       NULL);
+ 
+     XtVaSetValues(radio, XmNtraversalOn, False, NULL);
+@@ -191,8 +191,8 @@
+ 
+     radio = XmVaCreateSimpleRadioBox(
+       frame, "XmNconvertCase", 1, convertCaseToggle,
+-      XmVaRADIOBUTTON, false, NULL, NULL, NULL,
+-      XmVaRADIOBUTTON, true, NULL, NULL, NULL,
++      XmVaRADIOBUTTON, false_str, NULL, NULL, NULL,
++      XmVaRADIOBUTTON, true_str, NULL, NULL, NULL,
+       NULL);
+ 
+     XtVaSetValues(radio, XmNtraversalOn, False, NULL);
+@@ -224,8 +224,8 @@
+ 
+     radio = XmVaCreateSimpleRadioBox(
+       frame, "XmNoverwriteMode", 0, overwriteModeToggle,
+-      XmVaRADIOBUTTON, false, NULL, NULL, NULL,
+-      XmVaRADIOBUTTON, true, NULL, NULL, NULL,
++      XmVaRADIOBUTTON, false_str, NULL, NULL, NULL,
++      XmVaRADIOBUTTON, true_str, NULL, NULL, NULL,
+       NULL);
+ 
+     XtVaSetValues(radio, XmNtraversalOn, False, NULL);
+@@ -254,8 +254,8 @@
+ 
+     XtManageChild(radio);
+ 
+-    XmStringFree(true);
+-    XmStringFree(false);
++    XmStringFree(true_str);
++    XmStringFree(false_str);
+     XmStringFree(begin);
+     XmStringFree(centre);
+     XmStringFree(end);
+--- a/examples/input/pattern.c
++++ b/examples/input/pattern.c
+@@ -128,7 +128,7 @@
+ {
+     Widget toplevel, rc, pattern, cw, radio, frame;
+     XtAppContext app;
+-    XmString true, false, begin, centre, end;
++    XmString true_str, false_str, begin, centre, end;
+ 
+     toplevel = XtVaAppInitialize(&app, "Input",
+                                NULL, 0,
+@@ -167,8 +167,8 @@
+               XmNoverwriteMode,       False,
+               NULL);
+ 
+-    true = XmStringCreateSimple("True");
+-    false = XmStringCreateSimple("False");
++    true_str = XmStringCreateSimple("True");
++    false_str = XmStringCreateSimple("False");
+ 
+     cw = XtVaCreateManagedWidget(
+       "XmNautofill", xbaeCaptionWidgetClass, rc,
+@@ -180,8 +180,8 @@
+ 
+     radio = XmVaCreateSimpleRadioBox(
+       frame, "XmNautoFill", 0, autoFillToggle,
+-      XmVaRADIOBUTTON, false, NULL, NULL, NULL,
+-      XmVaRADIOBUTTON, true, NULL, NULL, NULL,
++      XmVaRADIOBUTTON, false_str, NULL, NULL, NULL,
++      XmVaRADIOBUTTON, true_str, NULL, NULL, NULL,
+       NULL);
+ 
+     XtVaSetValues(radio, XmNtraversalOn, False, NULL);
+@@ -198,8 +198,8 @@
+ 
+     radio = XmVaCreateSimpleRadioBox(
+       frame, "XmNconvertCase", 1, convertCaseToggle,
+-      XmVaRADIOBUTTON, false, NULL, NULL, NULL,
+-      XmVaRADIOBUTTON, true, NULL, NULL, NULL,
++      XmVaRADIOBUTTON, false_str, NULL, NULL, NULL,
++      XmVaRADIOBUTTON, true_str, NULL, NULL, NULL,
+       NULL);
+ 
+     XtVaSetValues(radio, XmNtraversalOn, False, NULL);
+@@ -231,8 +231,8 @@
+ 
+     radio = XmVaCreateSimpleRadioBox(
+       frame, "XmNoverwriteMode", 0, overwriteModeToggle,
+-      XmVaRADIOBUTTON, false, NULL, NULL, NULL,
+-      XmVaRADIOBUTTON, true, NULL, NULL, NULL,
++      XmVaRADIOBUTTON, false_str, NULL, NULL, NULL,
++      XmVaRADIOBUTTON, true_str, NULL, NULL, NULL,
+       NULL);
+ 
+     XtVaSetValues(radio, XmNtraversalOn, False, NULL);
+@@ -261,8 +261,8 @@
+ 
+     XtManageChild(radio);
+ 
+-    XmStringFree(true);
+-    XmStringFree(false);
++    XmStringFree(true_str);
++    XmStringFree(false_str);
+     XmStringFree(begin);
+     XmStringFree(centre);
+     XmStringFree(end);
+--- a/examples/tests/leak2.c
++++ b/examples/tests/leak2.c
+@@ -20,7 +20,7 @@
+ 
+ XtResource    resources[] = {
+       { "numIter", "NumIter", XtRInt, sizeof(int),
+-              XtOffsetOf(AppRes, numIter), XtRImmediate, 1000 },
++              XtOffsetOf(AppRes, numIter), XtRImmediate, (XtPointer)1000 },
+ };
+ 
+ int
+--- a/src/Methods.c
++++ b/src/Methods.c
+@@ -1688,7 +1688,7 @@
+                                          * The event must have occurred in a 
legal position
+                                          * otherwise control wouldn't have 
made it here
+                                          */
+-                                        xbaeEventToRowColumn(mw, event, &r, 
&c, &x, &y);
++                                        xbaeEventToRowColumn((Widget) mw, 
event, &r, &c, &x, &y);
+                                         x -= mw->matrix.cell_shadow_thickness;
+                                         y -= mw->matrix.cell_shadow_thickness;
+                                         position = 
XmTextXYToPos(TextField(mw), x, y);

diff --git a/x11-libs/xbae/xbae-4.60.4-r2.ebuild 
b/x11-libs/xbae/xbae-4.60.4-r2.ebuild
new file mode 100644
index 000000000000..66a6aa37f704
--- /dev/null
+++ b/x11-libs/xbae/xbae-4.60.4-r2.ebuild
@@ -0,0 +1,76 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+AT_M4DIR=${S}
+
+inherit autotools
+
+DESCRIPTION="Motif-based widget to display a grid of cells as a spreadsheet"
+HOMEPAGE="https://xbae.sourceforge.net/";
+SRC_URI="https://downloads.sourceforge.net/${PN}/${P}.tar.gz";
+
+LICENSE="BSD"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~hppa ~ppc ~ppc64 ~sparc ~x86 ~amd64-linux ~x86-linux"
+IUSE="doc examples"
+# tests need X display
+# and are interactive so virtualx will not help
+RESTRICT="test"
+
+RDEPEND="
+       x11-libs/motif:0
+       x11-libs/libXau
+       x11-libs/libXdmcp
+       x11-libs/libXext
+       x11-libs/libXmu
+       x11-libs/libXpm
+       x11-libs/libXt"
+DEPEND="${RDEPEND}"
+
+PATCHES=(
+       "${FILESDIR}"/${P}-tmpl.patch
+       "${FILESDIR}"/${P}-lxmp.patch
+       "${FILESDIR}"/${P}-Makefile.in.patch
+       # https://sourceforge.net/p/xbae/patches/3/
+       "${FILESDIR}"/${P}-configure-c99.patch
+       "${FILESDIR}"/${P}-modern-autotools.patch
+       "${FILESDIR}"/${P}-c99.patch
+       "${FILESDIR}"/${P}-c23.patch
+)
+
+src_prepare() {
+       default
+       eautoreconf
+}
+
+src_configure() {
+       econf --enable-production
+}
+
+src_test() {
+       emake -C examples
+       emake -C examples/testall clean
+}
+
+src_install() {
+       default
+
+       insinto /usr/share/aclocal
+       doins ac_find_xbae.m4
+
+       if use examples; then
+               find examples -name '*akefile*' -delete || die
+               rm examples/{testall,extest} || die
+               dodoc -r examples
+       fi
+       if use doc; then
+               rm doc/{,images/}Makefile* || die
+               docinto html
+               dodoc -r doc/.
+       fi
+
+       # no static archives
+       find "${D}" -name '*.la' -delete || die
+}

Reply via email to