dev-libs/gmime: backport several patches to 3.2.15

Looking into a test failure I have on one machine and noticed these.

Especially worth it as I don't think there'll be a new release soon:
https://github.com/jstedfast/gmime/issues/172#issuecomment-2778761044.

Signed-off-by: Sam James <sam@gentoo.org>
This commit is contained in:
Sam James
2025-04-21 11:57:18 +01:00
parent c8c2994304
commit 7cf1051144
4 changed files with 283 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
https://github.com/jstedfast/gmime/commit/2972da2f28e6c5cf51465cdaef6e169fe7710f8b
From 2972da2f28e6c5cf51465cdaef6e169fe7710f8b Mon Sep 17 00:00:00 2001
From: Biswapriyo Nath <nathbappai@gmail.com>
Date: Sat, 6 Jul 2024 13:46:11 +0000
Subject: [PATCH] Fix compiler error with 32 bit gcc 14 in Windows
This fixes the following compiler error.
../../gmime/gmime-gpgme-utils.c:69:9: error: initialization of
'gpgme_ssize_t (*)(void *, void *, size_t)' {aka 'long int (*)(void *, void *, unsigned int)'}
from incompatible pointer type
'ssize_t (*)(void *, void *, size_t)' {aka 'int (*)(void *, void *, unsigned int)'}
[-Wincompatible-pointer-types]
69 | g_mime_gpgme_stream_read,
| ^~~~~~~~~~~~~~~~~~~~~~~~
---
gmime/gmime-gpgme-utils.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/gmime/gmime-gpgme-utils.c b/gmime/gmime-gpgme-utils.c
index 2b87c22a..621d9db1 100644
--- a/gmime/gmime-gpgme-utils.c
+++ b/gmime/gmime-gpgme-utils.c
@@ -32,28 +32,28 @@
#define _(x) x
-static ssize_t
+static gpgme_ssize_t
g_mime_gpgme_stream_read (void *stream, void *buffer, size_t size)
{
return g_mime_stream_read ((GMimeStream *) stream, (char *) buffer, size);
}
-static ssize_t
+static gpgme_ssize_t
g_mime_gpgme_stream_write (void *stream, const void *buffer, size_t size)
{
return g_mime_stream_write ((GMimeStream *) stream, (const char *) buffer, size);
}
-static off_t
-g_mime_gpgme_stream_seek (void *stream, off_t offset, int whence)
+static gpgme_off_t
+g_mime_gpgme_stream_seek (void *stream, gpgme_off_t offset, int whence)
{
switch (whence) {
case SEEK_SET:
- return (off_t) g_mime_stream_seek ((GMimeStream *) stream, (gint64) offset, GMIME_STREAM_SEEK_SET);
+ return (gpgme_off_t) g_mime_stream_seek ((GMimeStream *) stream, (gint64) offset, GMIME_STREAM_SEEK_SET);
case SEEK_CUR:
- return (off_t) g_mime_stream_seek ((GMimeStream *) stream, (gint64) offset, GMIME_STREAM_SEEK_CUR);
+ return (gpgme_off_t) g_mime_stream_seek ((GMimeStream *) stream, (gint64) offset, GMIME_STREAM_SEEK_CUR);
case SEEK_END:
- return (off_t) g_mime_stream_seek ((GMimeStream *) stream, (gint64) offset, GMIME_STREAM_SEEK_END);
+ return (gpgme_off_t) g_mime_stream_seek ((GMimeStream *) stream, (gint64) offset, GMIME_STREAM_SEEK_END);
default:
return -1;
}

View File

@@ -0,0 +1,111 @@
https://github.com/jstedfast/gmime/issues/172
https://github.com/jstedfast/gmime/commit/df1151b32fbf45b10d27801c49f2db883be7d5b7
From df1151b32fbf45b10d27801c49f2db883be7d5b7 Mon Sep 17 00:00:00 2001
From: Jeffrey Stedfast <jestedfa@microsoft.com>
Date: Fri, 4 Apr 2025 09:37:48 -0400
Subject: [PATCH] Revert g_mime_parser_options_set_warning_callback() and added
_full() version
Fixes issue #172
---
examples/msgcheck.c | 2 +-
gmime/gmime-parser-options.c | 33 +++++++++++++++++++++++----------
gmime/gmime-parser-options.h | 4 ++--
3 files changed, 26 insertions(+), 13 deletions(-)
diff --git a/examples/msgcheck.c b/examples/msgcheck.c
index 46e018c4..8b91e662 100644
--- a/examples/msgcheck.c
+++ b/examples/msgcheck.c
@@ -110,7 +110,7 @@ check_msg_file (const gchar *filename)
parser = g_mime_parser_new ();
g_mime_parser_init_with_stream (parser, stream);
options = g_mime_parser_options_new ();
- g_mime_parser_options_set_warning_callback (options, parser_issue, NULL, NULL);
+ g_mime_parser_options_set_warning_callback (options, parser_issue, NULL);
message = g_mime_parser_construct_message (parser, options);
g_mime_parser_options_free (options);
g_object_unref (parser);
diff --git a/gmime/gmime-parser-options.c b/gmime/gmime-parser-options.c
index ae84d671..820c3299 100644
--- a/gmime/gmime-parser-options.c
+++ b/gmime/gmime-parser-options.c
@@ -70,9 +70,9 @@ g_mime_parser_options_shutdown (void)
if (default_options == NULL)
return;
- if (default_options->notify) {
- default_options->notify(default_options->warning_user_data);
- }
+ if (default_options->notify)
+ default_options->notify (default_options->warning_user_data);
+
g_strfreev (default_options->charsets);
g_slice_free (GMimeParserOptions, default_options);
default_options = NULL;
@@ -193,9 +193,9 @@ g_mime_parser_options_free (GMimeParserOptions *options)
g_return_if_fail (options != NULL);
if (options != default_options) {
- if (options->notify) {
- options->notify(options->warning_user_data);
- }
+ if (options->notify)
+ options->notify (options->warning_user_data);
+
g_strfreev (options->charsets);
g_slice_free (GMimeParserOptions, options);
}
@@ -450,18 +450,31 @@ g_mime_parser_options_get_warning_callback (GMimeParserOptions *options)
* @options: a #GMimeParserOptions
* @warning_cb: a #GMimeParserWarningFunc or %NULL to clear the callback
* @user_data: data passed to the warning callback function
+ *
+ * Registers the callback function being called if the parser detects any issues.
+ **/
+void
+g_mime_parser_options_set_warning_callback (GMimeParserOptions *options, GMimeParserWarningFunc warning_cb, gpointer user_data)
+{
+ g_mime_parser_options_set_warning_callback_full (options, warning_cb, user_data, NULL);
+}
+
+/**
+ * g_mime_parser_options_set_warning_callback_full:
+ * @options: a #GMimeParserOptions
+ * @warning_cb: a #GMimeParserWarningFunc or %NULL to clear the callback
+ * @user_data: data passed to the warning callback function
* @notify: callback function ran on destruction
*
* Registers the callback function being called if the parser detects any issues.
**/
void
-g_mime_parser_options_set_warning_callback (GMimeParserOptions *options, GMimeParserWarningFunc warning_cb, gpointer user_data, GDestroyNotify notify)
+g_mime_parser_options_set_warning_callback_full (GMimeParserOptions *options, GMimeParserWarningFunc warning_cb, gpointer user_data, GDestroyNotify notify)
{
g_return_if_fail (options != NULL);
- if (options->notify) {
- options->notify(options->warning_user_data);
- }
+ if (options->notify)
+ options->notify (options->warning_user_data);
options->warning_cb = warning_cb;
options->warning_user_data = user_data;
diff --git a/gmime/gmime-parser-options.h b/gmime/gmime-parser-options.h
index c37d9999..b26160cf 100644
--- a/gmime/gmime-parser-options.h
+++ b/gmime/gmime-parser-options.h
@@ -128,8 +128,8 @@ const char **g_mime_parser_options_get_fallback_charsets (GMimeParserOptions *op
void g_mime_parser_options_set_fallback_charsets (GMimeParserOptions *options, const char **charsets);
GMimeParserWarningFunc g_mime_parser_options_get_warning_callback (GMimeParserOptions *options);
-void g_mime_parser_options_set_warning_callback (GMimeParserOptions *options,
- GMimeParserWarningFunc warning_cb, gpointer user_data, GDestroyNotify notify);
+void g_mime_parser_options_set_warning_callback (GMimeParserOptions *options, GMimeParserWarningFunc warning_cb, gpointer user_data);
+void g_mime_parser_options_set_warning_callback_full (GMimeParserOptions *options, GMimeParserWarningFunc warning_cb, gpointer user_data, GDestroyNotify notify);
G_END_DECLS

View File

@@ -0,0 +1,35 @@
https://github.com/jstedfast/gmime/commit/3f7005f4c7576de581bb5164c7990aaa4031c2c1
From 3f7005f4c7576de581bb5164c7990aaa4031c2c1 Mon Sep 17 00:00:00 2001
From: Jeffrey Stedfast <jestedfa@microsoft.com>
Date: Fri, 4 Oct 2024 16:03:24 -0400
Subject: [PATCH] Fixed issue in decode_route() when ENABLE_WARNINGS is enabled
Fixes issue #169
---
gmime/internet-address.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/gmime/internet-address.c b/gmime/internet-address.c
index cd6baa90..a89eab0e 100644
--- a/gmime/internet-address.c
+++ b/gmime/internet-address.c
@@ -45,7 +45,7 @@
#ifdef ENABLE_WARNINGS
-#define w(x) x
+#define w(x) (x)
#else
#define w(x)
#endif /* ENABLE_WARNINGS */
@@ -1437,7 +1437,7 @@ decode_route (const char **in)
skip_cfws (&inptr);
if (*inptr != ':') {
- w(g_warning ("Invalid route domain-list, missing ':': %.*s", inptr - start, start));
+ w(g_warning ("Invalid route domain-list, missing ':': %.*s", inptr - *in, *in));
goto error;
}

View File

@@ -0,0 +1,76 @@
# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
inherit flag-o-matic gnome2 vala
DESCRIPTION="Library for creating and parsing MIME messages"
HOMEPAGE="https://github.com/jstedfast/gmime http://spruce.sourceforge.net/gmime/"
SRC_URI="https://github.com/jstedfast/${PN}/releases/download/${PV}/${P}.tar.xz"
SLOT="3.0"
LICENSE="LGPL-2.1+"
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ppc ~ppc64 ~riscv ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris"
IUSE="crypt doc idn test +vala"
RESTRICT="!test? ( test )"
RDEPEND="
>=dev-libs/glib-2.68.0:2
sys-libs/zlib
crypt? ( >=app-crypt/gpgme-1.8.0:= )
idn? ( net-dns/libidn2:= )
vala? (
$(vala_depend)
>=dev-libs/gobject-introspection-1.30.0:=
)
"
DEPEND="${RDEPEND}
virtual/libiconv
"
BDEPEND="
>=dev-build/gtk-doc-am-1.8
virtual/pkgconfig
doc? ( app-text/docbook-sgml-utils )
"
PATCHES=(
"${FILESDIR}"/${P}-32-bit.patch
"${FILESDIR}"/${P}-warning.patch
"${FILESDIR}"/${P}-ub-fix.patch
)
src_prepare() {
gnome2_src_prepare
use vala && vala_setup
}
src_configure() {
if [[ ${CHOST} == *-solaris* ]]; then
# bug #???, why not use --with-libiconv
append-libs iconv
fi
gnome2_src_configure \
--enable-largefile \
$(use_enable crypt crypto) \
$(use_enable vala) \
$(use_with idn libidn) \
$(usex doc "" DB2HTML=)
}
src_compile() {
gnome2_src_compile
if use doc; then
emake -C docs/tutorial html
fi
}
src_install() {
gnome2_src_install
if use doc ; then
docinto tutorial
dodoc -r docs/tutorial/html/
fi
}