commit: 4d87ba468e61b48b847ea98369a987e9b6f04683 Author: Ulrich Müller <ulm <AT> gentoo <DOT> org> AuthorDate: Tue Dec 30 14:33:31 2025 +0000 Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org> CommitDate: Tue Dec 30 14:33:31 2025 +0000 URL: https://gitweb.gentoo.org/repo/dev/ulm.git/commit/?id=4d87ba46
x11-libs/motif: Some fixes from upstream, enable tests Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org> x11-libs/motif/files/motif-2.4.0-Mrmwcrw.patch | 20 +++ x11-libs/motif/files/motif-2.4.0-XmString.patch | 152 +++++++++++++++++++++ x11-libs/motif/files/motif-2.4.0-tests.patch | 167 ++++++++++++++++++++++++ x11-libs/motif/motif-2.4.0.ebuild | 18 ++- 4 files changed, 353 insertions(+), 4 deletions(-) diff --git a/x11-libs/motif/files/motif-2.4.0-Mrmwcrw.patch b/x11-libs/motif/files/motif-2.4.0-Mrmwcrw.patch new file mode 100644 index 0000000..c694674 --- /dev/null +++ b/x11-libs/motif/files/motif-2.4.0-Mrmwcrw.patch @@ -0,0 +1,20 @@ +commit f5b0a4ee4760a9963e71b19ee59b063a1aec8592 +Author: Tim Hentenaar <[email protected]> +Date: Mon Dec 29 11:31:02 2025 -0500 + + fix: Mrm/Mrmwcrw: Avoid breaking strict aliasing rules, add -Wstrict-aliasing to diagnostic flags + + Closes #4 + +--- a/lib/Mrm/Mrmwcrw.c ++++ b/lib/Mrm/Mrmwcrw.c +@@ -2480,7 +2480,8 @@ + screen = DefaultScreenOfDisplay(display); + unitsfloatvalue = (RGMUnitsFloatPtr) *val; + float_units = unitsfloatvalue->units; +- float_val = (float)*(double *)unitsfloatvalue->value; ++ memcpy(&double_val, unitsfloatvalue->value, sizeof double_val); ++ float_val = (float)double_val; + + if (float_val != 0) + { diff --git a/x11-libs/motif/files/motif-2.4.0-XmString.patch b/x11-libs/motif/files/motif-2.4.0-XmString.patch new file mode 100644 index 0000000..5518b8e --- /dev/null +++ b/x11-libs/motif/files/motif-2.4.0-XmString.patch @@ -0,0 +1,152 @@ +commit 7f1185a3c813bb3a01d63f57c1f1c229ed6af3c3 +Author: Tim Hentenaar <[email protected]> +Date: Mon Dec 29 12:22:09 2025 -0500 + + fix: XmString: Make sure we have a string entry before operating on it + + Closes #5 + +--- a/lib/Xm/XmString.c ++++ b/lib/Xm/XmString.c +@@ -1205,14 +1205,15 @@ + static Boolean + IsUnopt(_XmString str, int lines) + { +- _XmStringEntry line; ++ _XmStringEntry *line; + + if (lines > 0) + { +- line = _XmStrEntry(str)[0]; ++ if (!(line = _XmStrEntryGet(str)) || !*line) ++ return False; + +- if ((_XmEntrySegmentCountGet(line) > 0) && +- (_XmEntryType(_XmEntrySegmentGet(line)[0]) != ++ if ((_XmEntrySegmentCountGet(*line) > 0) && ++ (_XmEntryType(_XmEntrySegmentGet(*line)[0]) != + XmSTRING_ENTRY_OPTIMIZED)) + return True; + } +@@ -1220,7 +1221,7 @@ + } + + static _XmStringEntry +-Unoptimize(_XmStringEntry entry, int free) ++Unoptimize(_XmStringEntry entry, int do_free) + { + _XmStringEntry new_entry = NULL; + _XmStringNREntry tmp_seg; +@@ -1231,10 +1232,10 @@ + + if (_XmEntryType(entry) == XmSTRING_ENTRY_OPTIMIZED) { + new_entry = EntryCvtToUnopt(entry); +- if (free) ++ if (do_free) + _XmStringEntryFree(entry); + } else if (_XmEntryMultiple(entry)) { +- if (free) { ++ if (do_free) { + for (j = 0; j < _XmEntrySegmentCount(entry); j++) { + tmp_seg = _XmEntrySegment(entry)[j]; + if (_XmEntryType(tmp_seg) == XmSTRING_ENTRY_OPTIMIZED) { +@@ -1262,7 +1263,7 @@ + } + } + } else { +- if (free) ++ if (do_free) + new_entry = entry; + else + new_entry = _XmStringEntryCopy(entry); +@@ -1289,7 +1290,7 @@ + XmTextType a_type, b_type; + XmString a_str, b_str; + _XmStringMultiRec b_tmp; +- _XmStringEntry a_line, b_line, tmp_line, *segs=NULL; ++ _XmStringEntry a_line, b_line, *tmp_line=NULL, *segs=NULL; + _XmStringNREntry a_last, b_seg = NULL, tmp_seg; + String a_tag; + String b_tag; +@@ -1687,9 +1688,10 @@ + else /* Need to figure out last direction set. */ + { + for (i = a_lc; i > 0; i--) { +- tmp_line = _XmStrEntry(a_str)[i - 1]; +- for (j = _XmEntrySegmentCountGet(tmp_line); j > 0; j--) { +- tmp_seg = _XmEntrySegmentGet(tmp_line)[j - 1]; ++ tmp_line = _XmStrEntryGet(a_str); ++ if (!tmp_line) break; ++ for (j = _XmEntrySegmentCountGet(tmp_line[i - 1]); j > 0; j--) { ++ tmp_seg = _XmEntrySegmentGet(tmp_line[i - 1])[j - 1]; + if (_XmEntryDirectionGet((_XmStringEntry)tmp_seg) != + XmSTRING_DIRECTION_UNSET) { + last = _XmEntryDirectionGet((_XmStringEntry)tmp_seg); +@@ -1792,11 +1794,11 @@ + + /* Set layout cache dirty */ + if (a_str && _XmStrEntryCount(a_str) > 0 ) { +- tmp_line = _XmStrEntry(a_str)[0]; +- if (tmp_line && _XmEntrySegmentCountGet(tmp_line) > 0) { ++ tmp_line = _XmStrEntryGet(a_str); ++ if (tmp_line && *tmp_line && _XmEntrySegmentCountGet(*tmp_line) > 0) { + _XmStringCache cache; + +- tmp_seg = _XmEntrySegmentGet(tmp_line)[0]; ++ tmp_seg = _XmEntrySegmentGet(*tmp_line)[0]; + for (cache = _XmStringCacheGet(_XmEntryCacheGet((_XmStringEntry)tmp_seg), + _XmSCANNING_CACHE); + cache; +@@ -4337,17 +4339,16 @@ + XmDirection direction) + { + int seg_index=0, line_index=0; +- _XmStringEntry line; ++ _XmStringEntry *line; + _XmStringNREntry seg; + Boolean needs_recompute = False; + + if (!_XmStrMultiple(string)) + return; + +- if (_XmStrEntryCount(string)) { +- line = _XmStrEntry(string)[0]; +- if (_XmEntrySegmentCountGet(line)) { +- seg = _XmEntrySegmentGet(line)[0]; ++ if (_XmStrEntryCount(string) && (line = _XmStrEntryGet(string)) && *line) { ++ if (_XmEntrySegmentCountGet(*line)) { ++ seg = _XmEntrySegmentGet(*line)[0]; + needs_recompute = _XmEntryDirtyGet(seg, _XmSCANNING_CACHE, direction); + } + } +@@ -4355,11 +4356,10 @@ + if (!needs_recompute) + return; + +- while (line_index < _XmStrEntryCount(string)) { +- line = _XmStrEntry(string)[line_index]; +- while (seg_index < _XmEntrySegmentCountGet(line)) { +- seg = _XmEntrySegmentGet(line)[seg_index]; +- if (_XmEntrySegmentCountGet(line) > 1) { ++ while (line_index < _XmStrEntryCount(string) && (line = _XmStrEntryGet(string))) { ++ while (seg_index < _XmEntrySegmentCountGet(line[line_index])) { ++ seg = _XmEntrySegmentGet(line[line_index])[seg_index]; ++ if (_XmEntrySegmentCountGet(line[line_index]) > 1) { + _XmEntryDirtySet(seg, _XmSCANNING_CACHE, direction, True); + _XmEntryLeftSet(seg, direction, NULL); + _XmEntryRightSet(seg, direction, NULL); +@@ -4375,11 +4375,11 @@ + direction, direction, 0); + + /* if there are pops w/o matching pushes, ignore them */ ++ line = _XmStrEntryGet(string); + while (line_index < _XmStrLineCountGet(string) && +- seg_index < _XmEntrySegmentCountGet(_XmStrEntry(string)[line_index])) ++ seg_index < _XmEntrySegmentCountGet(line[line_index])) + { +- line = _XmStrEntry(string)[line_index]; +- seg = _XmEntrySegmentGet(line)[seg_index]; ++ seg = _XmEntrySegmentGet(line[line_index])[seg_index]; + _XmEntryPopSet(seg, False); + recursive_layout(string, &line_index, &seg_index, + direction, direction, 0); diff --git a/x11-libs/motif/files/motif-2.4.0-tests.patch b/x11-libs/motif/files/motif-2.4.0-tests.patch new file mode 100644 index 0000000..e24dada --- /dev/null +++ b/x11-libs/motif/files/motif-2.4.0-tests.patch @@ -0,0 +1,167 @@ +commit 31eaf86bbfdff8bc4ff62a254403560d1d24f245 +Author: Tim Hentenaar <[email protected]> +Date: Tue Dec 30 08:39:21 2025 -0500 + + tests: Use absolute resource paths so that tests can run in out-of-tree builds + + Fixes #7 + +--- a/tests/Jpeg.c ++++ b/tests/Jpeg.c +@@ -23,7 +23,7 @@ + + #include <stdio.h> + #include <X11/Xlib.h> +-#include <JpegI.h> ++#include <Xm/JpegI.h> + #include <check.h> + + #include "suites.h" +@@ -34,7 +34,8 @@ + XImage *img = NULL; + int ret; + +- ck_assert_msg(fp = fopen("jpeg/invalid_header.jpeg", "rb"), "Failed to open jpeg/invalid_header.jpeg"); ++ ck_assert_msg((fp = fopen(RESOURCE(jpeg/invalid_header.jpeg), "rb")), ++ "Failed to open jpeg/invalid_header.jpeg"); + ret = _XmJpegGetImage(fp, &img); + fclose(fp); + +@@ -49,7 +50,8 @@ + XImage *img = NULL; + int ret; + +- ck_assert_msg(fp = fopen("jpeg/rgb24.jpeg", "rb"), "Failed to open jpeg/rgb24.jpeg"); ++ ck_assert_msg((fp = fopen(RESOURCE(jpeg/rgb24.jpeg), "rb")), ++ "Failed to open jpeg/rgb24.jpeg"); + ret = _XmJpegGetImage(fp, &img); + fclose(fp); + +@@ -81,7 +83,8 @@ + XImage *img = NULL; + int ret; + +- ck_assert_msg(fp = fopen("jpeg/grayscale.jpeg", "rb"), "Failed to open jpeg/grayscale.jpeg"); ++ ck_assert_msg((fp = fopen(RESOURCE(jpeg/grayscale.jpeg), "rb")), ++ "Failed to open jpeg/grayscale.jpeg"); + ret = _XmJpegGetImage(fp, &img); + fclose(fp); + +--- a/tests/Makefile.am ++++ b/tests/Makefile.am +@@ -3,7 +3,8 @@ + AM_TESTS_ENVIRONMENT = env AM_TAP_AWK='$(AWK)' + LOG_DRIVER = $(SHELL) $(top_srcdir)/tap-driver.sh + TESTS = tests +-AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_builddir)/lib $(X_CFLAGS) $(XFT_CFLAGS) $(CHECK_CFLAGS) ++AM_CPPFLAGS = -I${top_builddir}/include -I$(top_srcdir)/include -I$(top_srcdir)/lib \ ++ -DRESDIR="$(abs_top_srcdir)/tests/" $(X_CFLAGS) $(XFT_CFLAGS) $(CHECK_CFLAGS) + check_PROGRAMS = tests + noinst_HEADERS = suites.h + tests_LDADD = $(top_builddir)/lib/Xm/libXm.la $(X_LIBS) $(XFT_LIBS) $(CHECK_LIBS) +--- a/tests/Png.c ++++ b/tests/Png.c +@@ -23,7 +23,7 @@ + + #include <stdio.h> + #include <X11/Xlib.h> +-#include <PngI.h> ++#include <Xm/PngI.h> + #include <check.h> + + #include "suites.h" +@@ -34,7 +34,8 @@ + XImage *img = NULL; + int ret; + +- ck_assert_msg(fp = fopen("png/invalid_header.png", "rb"), "Failed to open png/invalid_header.png"); ++ ck_assert_msg((fp = fopen(RESOURCE(png/invalid_header.png), "rb")), ++ "Failed to open png/invalid_header.png"); + ret = _XmPngGetImage(fp, NULL, &img); + fclose(fp); + +@@ -49,7 +50,8 @@ + XImage *img = NULL; + int ret; + +- ck_assert_msg(fp = fopen("png/rgb24.png", "rb"), "Failed to open png/rgb24.png"); ++ ck_assert_msg((fp = fopen(RESOURCE(png/rgb24.png), "rb")), ++ "Failed to open png/rgb24.png"); + ret = _XmPngGetImage(fp, NULL, &img); + fclose(fp); + +@@ -85,7 +87,8 @@ + XImage *img = NULL; + int ret; + +- ck_assert_msg(fp = fopen("png/rgba32.png", "rb"), "Failed to open png/rgba32.png"); ++ ck_assert_msg((fp = fopen(RESOURCE(png/rgba32.png), "rb")), ++ "Failed to open png/rgba32.png"); + ret = _XmPngGetImage(fp, NULL, &img); + fclose(fp); + +@@ -126,7 +129,8 @@ + bg.green = 0xcc; + bg.blue = 0xcc; + +- ck_assert_msg(fp = fopen("png/rgba32.png", "rb"), "Failed to open png/rgba32.png"); ++ ck_assert_msg((fp = fopen(RESOURCE(png/rgba32.png), "rb")), ++ "Failed to open png/rgba32.png"); + ret = _XmPngGetImage(fp, &bg, &img); + fclose(fp); + +--- a/tests/Svg.c ++++ b/tests/Svg.c +@@ -23,7 +23,7 @@ + + #include <stdio.h> + #include <X11/Xlib.h> +-#include <SvgI.h> ++#include <Xm/SvgI.h> + #include <check.h> + + #include "suites.h" +@@ -34,7 +34,8 @@ + XImage *img = NULL; + int ret; + +- ck_assert_msg(fp = fopen("svg/invalid_file.svg", "rb"), "Failed to open svg/invalid_file.svg"); ++ ck_assert_msg((fp = fopen(RESOURCE(svg/invalid_file.svg), "rb")), ++ "Failed to open svg/invalid_file.svg"); + ret = _XmSvgGetImage(fp, &img); + fclose(fp); + +@@ -49,7 +50,8 @@ + XImage *img = NULL, *rast = NULL; + int ret; + +- ck_assert_msg(fp = fopen("svg/test.svg", "rb"), "Failed to open svg/test.svg"); ++ ck_assert_msg((fp = fopen(RESOURCE(svg/test.svg), "rb")), ++ "Failed to open svg/test.svg"); + ret = _XmSvgGetImage(fp, &img); + fclose(fp); + +@@ -67,7 +69,8 @@ + XImage *img = NULL, *rast = NULL; + int ret; + +- ck_assert_msg(fp = fopen("svg/test.svg", "rb"), "Failed to open svg/test.svg"); ++ ck_assert_msg((fp = fopen(RESOURCE(svg/test.svg), "rb")), ++ "Failed to open svg/test.svg"); + ret = _XmSvgGetImage(fp, &img); + fclose(fp); + +--- a/tests/suites.h ++++ b/tests/suites.h +@@ -27,6 +27,11 @@ + #include <X11/Intrinsic.h> + #include <check.h> + ++/* For locating resources in out-of-tree builds */ ++#define __RESOURCE(dir, x) #dir x ++#define _RESOURCE(dir, x) __RESOURCE(dir, #x) ++#define RESOURCE(x) _RESOURCE(RESDIR, x) ++ + extern XtAppContext app; + + /* Xt fixture */ diff --git a/x11-libs/motif/motif-2.4.0.ebuild b/x11-libs/motif/motif-2.4.0.ebuild index 87b28e2..c940677 100644 --- a/x11-libs/motif/motif-2.4.0.ebuild +++ b/x11-libs/motif/motif-2.4.0.ebuild @@ -3,7 +3,7 @@ EAPI=8 -inherit autotools flag-o-matic toolchain-funcs multilib-minimal +inherit autotools multilib-minimal toolchain-funcs virtualx DESCRIPTION="The Motif user interface component toolkit" HOMEPAGE="https://github.com/thentenaar/motif" @@ -13,6 +13,7 @@ LICENSE="LGPL-2.1+ MIT" SLOT="0/5" KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86 ~x64-macos ~x64-solaris" IUSE="examples jpeg png static-libs unicode +xcursor xft +xrandr +xrender" +REQUIRED_USE="test? ( jpeg png xft )" RDEPEND="x11-libs/libX11[${MULTILIB_USEDEP}] x11-libs/libXext[${MULTILIB_USEDEP}] @@ -21,6 +22,7 @@ RDEPEND="x11-libs/libX11[${MULTILIB_USEDEP}] x11-libs/libXt[${MULTILIB_USEDEP}] jpeg? ( media-libs/libjpeg-turbo:0=[${MULTILIB_USEDEP}] ) png? ( media-libs/libpng:0=[${MULTILIB_USEDEP}] ) + test? ( dev-libs/check ) unicode? ( virtual/libiconv[${MULTILIB_USEDEP}] ) xcursor? ( x11-libs/libXcursor[${MULTILIB_USEDEP}] ) xft? ( @@ -37,14 +39,17 @@ DEPEND="${RDEPEND} BDEPEND="sys-devel/flex dev-util/byacc" +PATCHES=( + "${FILESDIR}/${P}-Mrmwcrw.patch" + "${FILESDIR}/${P}-XmString.patch" + "${FILESDIR}/${P}-tests.patch" +) + src_prepare() { default AT_M4DIR=. eautoreconf - # feel free to fix properly if you care - append-flags -fno-strict-aliasing - if use !elibc_glibc && use !elibc_musl; then # libiconv detection in configure script doesn't always work # http://bugs.motifzone.net/show_bug.cgi?id=1423 @@ -63,6 +68,7 @@ src_prepare() { multilib_src_configure() { local myconf=( $(use_enable static-libs static) + $(use_enable test tests) $(use_enable unicode utf8) $(use_with jpeg) $(use_with png) @@ -84,6 +90,10 @@ multilib_src_compile() { emake } +multilib_src_test() { + virtx emake check +} + multilib_src_install() { emake DESTDIR="${D}" install
