Source: gambas3
Version: 3.18.4-3
Severity: important
Tags: ftbfs patch upstream
X-Debbugs-Cc: band...@debian.org

Dear Maintainer,

I recently uploaded new poppler 24.02.0 to experimental, and gambas3
is one of the affected packages that fails to build from source with
it.  Please find attached a patch to fix the build, forwarded upstream
as well.

>From f5177f706b71a0ef918021c95ace9f60c0754313 Mon Sep 17 00:00:00 2001
From: Amin Bandali <band...@canonical.com>
Date: Wed, 14 Feb 2024 09:56:10 -0500
Subject: [PATCH] make 'gb.pdf' compile with poppler 24.02.0
Forwarded: https://gitlab.com/gambas/gambas/-/merge_requests/330

---
 gb.pdf/configure.ac         |  2 ++
 gb.pdf/src/CPdfDocument.cpp | 21 +++++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/gb.pdf/configure.ac b/gb.pdf/configure.ac
index 6931e2c48..6e612e40a 100644
--- a/gb.pdf/configure.ac
+++ b/gb.pdf/configure.ac
@@ -34,6 +34,8 @@ if test "$have_poppler" = "yes"; then
   AC_DEFINE_UNQUOTED(POPPLER_VERSION_21_06_0, $((1-$?)), Poppler version >= 21.06.0)
   $PKG_CONFIG --atleast-version=22.06.0 poppler
   AC_DEFINE_UNQUOTED(POPPLER_VERSION_22_06_0, $((1-$?)), Poppler version >= 22.06.0)
+  $PKG_CONFIG --atleast-version=24.02.0 poppler
+  AC_DEFINE_UNQUOTED(POPPLER_VERSION_24_02_0, $((1-$?)), Poppler version >= 24.02.0)
 fi
 
 AC_CONFIG_FILES([\
diff --git a/gb.pdf/src/CPdfDocument.cpp b/gb.pdf/src/CPdfDocument.cpp
index 8f4aac7fb..5dfbfefc1 100644
--- a/gb.pdf/src/CPdfDocument.cpp
+++ b/gb.pdf/src/CPdfDocument.cpp
@@ -102,6 +102,22 @@ END_PROPERTY
 
 ****************************************************************************/
 
+#if POPPLER_VERSION_24_02_0
+static void return_unicode_string(const std::vector<Unicode> &unicode)
+{
+	GooString gstr;
+	char buf[8]; /* 8 is enough for mapping an unicode char to a string */
+	int n;
+
+	const UnicodeMap *uMap = globalParams->getUtf8Map();
+	for (const auto &c : unicode) {
+		n = uMap->mapUnicode(c, buf, sizeof(buf));
+		gstr.append(buf, n);
+	}
+
+	GB.ReturnNewZeroString(gstr.getCString());
+}
+#else
 static void return_unicode_string(const Unicode *unicode, int len)
 {
 	GooString gstr;
@@ -128,6 +144,7 @@ static void return_unicode_string(const Unicode *unicode, int len)
 
 	GB.ReturnNewZeroString(gstr.getCString());
 }
+#endif
 
 
 static void aux_return_string_info(void *_object, const char *key)
@@ -776,7 +793,11 @@ END_PROPERTY
 BEGIN_PROPERTY(PDFINDEX_title)
 
 	OutlineItem *item = CPDF_index_get(THIS->currindex);
+#if POPPLER_VERSION_24_02_0
+	return_unicode_string(item->getTitle());
+#else
 	return_unicode_string(item->getTitle(), item->getTitleLength());
+#endif
 
 END_PROPERTY
 
-- 
2.43.0

Reply via email to