Index | Thread | Search

From:
Matthias Kilian <kili@outback.escape.de>
Subject:
Fix graphics/inkscape with new poppler
To:
rsadowski@openbsd.org
Cc:
ports@openbsd.org
Date:
Sun, 15 Jun 2025 21:00:53 +0200

Download raw body.

Thread
  • Matthias Kilian:

    Fix graphics/inkscape with new poppler

Hi,

this upstream diff fixes inkscape with the lates poppler.

ok?

Ciao,
	Kili

Index: patches/patch-src_extension_internal_pdfinput_pdf-parser_cpp
===================================================================
RCS file: patches/patch-src_extension_internal_pdfinput_pdf-parser_cpp
diff -N patches/patch-src_extension_internal_pdfinput_pdf-parser_cpp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_extension_internal_pdfinput_pdf-parser_cpp	15 Jun 2025 18:14:39 -0000
@@ -0,0 +1,81 @@
+Fix build with poppler-25.06.
+
+From upstream commit 1fdfb889bba9ee146c8b826e97bc58a88cb1e529.
+
+Index: src/extension/internal/pdfinput/pdf-parser.cpp
+--- src/extension/internal/pdfinput/pdf-parser.cpp.orig
++++ src/extension/internal/pdfinput/pdf-parser.cpp
+@@ -27,6 +27,7 @@
+ #include <cstdio>
+ #include <cstdlib>
+ #include <cstring>
++#include <memory>
+ #include <mutex> // std::call_once()
+ #include <utility>
+ #include <vector>
+@@ -686,7 +687,6 @@ void PdfParser::opSetLineWidth(Object args[], int /*nu
+ void PdfParser::opSetExtGState(Object args[], int /*numArgs*/)
+ {
+     Object obj1, obj2, obj3, obj4, obj5;
+-    Function *funcs[4] = {nullptr, nullptr, nullptr, nullptr};
+     GfxColor backdropColor;
+     GBool haveBackdropColor = gFalse;
+     GBool alpha = gFalse;
+@@ -744,13 +744,14 @@ void PdfParser::opSetExtGState(Object args[], int /*nu
+         state->setLineWidth(obj2.getNum());
+     }
+ 
++    _POPPLER_DECLARE_TRANSFER_FUNCTION_VECTOR(funcs);
++
+     // transfer function
+     if (_POPPLER_CALL_ARGS_DEREF(obj2, obj1.dictLookup, "TR2").isNull()) {
+         _POPPLER_CALL_ARGS(obj2, obj1.dictLookup, "TR");
+     }
+     if (obj2.isName(const_cast<char *>("Default")) || obj2.isName(const_cast<char *>("Identity"))) {
+-        funcs[0] = funcs[1] = funcs[2] = funcs[3] = nullptr;
+-        state->setTransfer(funcs);
++        state->setTransfer(std::move(funcs));
+     } else if (obj2.isArray() && obj2.arrayGetLength() == 4) {
+         int pos = 4;
+         for (int i = 0; i < 4; ++i) {
+@@ -763,12 +764,14 @@ void PdfParser::opSetExtGState(Object args[], int /*nu
+         }
+         _POPPLER_FREE(obj3);
+         if (pos == 4) {
+-            state->setTransfer(funcs);
++            state->setTransfer(std::move(funcs));
+         }
+     } else if (obj2.isName() || obj2.isDict() || obj2.isStream()) {
+         if ((funcs[0] = Function::parse(&obj2))) {
+-            funcs[1] = funcs[2] = funcs[3] = nullptr;
+-            state->setTransfer(funcs);
++            funcs[1] = nullptr;
++            funcs[2] = nullptr;
++            funcs[3] = nullptr;
++            state->setTransfer(std::move(funcs));
+         }
+     } else if (!obj2.isNull()) {
+         error(errSyntaxError, getPos(), "Invalid transfer function in ExtGState");
+@@ -790,8 +793,7 @@ void PdfParser::opSetExtGState(Object args[], int /*nu
+                 funcs[0] = Function::parse(&obj3);
+                 if (funcs[0]->getInputSize() != 1 || funcs[0]->getOutputSize() != 1) {
+                     error(errSyntaxError, getPos(), "Invalid transfer function in soft mask in ExtGState");
+-                    delete funcs[0];
+-                    funcs[0] = nullptr;
++                    _POPPLER_DELETE_TRANSFER_FUNCTION(funcs[0]);
+                 }
+             }
+             _POPPLER_FREE(obj3);
+@@ -835,9 +837,10 @@ void PdfParser::opSetExtGState(Object args[], int /*nu
+                             }
+                         }
+                     }
+-                    doSoftMask(&obj3, alpha, blendingColorSpace.get(), isolated, knockout, funcs[0], &backdropColor);
++                    doSoftMask(&obj3, alpha, blendingColorSpace.get(), isolated, knockout,
++                               _POPPLER_GET_TRANSFER_FUNCTION_POINTER(funcs[0]), &backdropColor);
+                     if (funcs[0]) {
+-                        delete funcs[0];
++                        _POPPLER_DELETE_TRANSFER_FUNCTION(funcs[0]);
+                     }
+                 } else {
+                     error(errSyntaxError, getPos(), "Invalid soft mask in ExtGState - missing group");
Index: patches/patch-src_extension_internal_pdfinput_poppler-transition-api_h
===================================================================
RCS file: patches/patch-src_extension_internal_pdfinput_poppler-transition-api_h
diff -N patches/patch-src_extension_internal_pdfinput_poppler-transition-api_h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_extension_internal_pdfinput_poppler-transition-api_h	15 Jun 2025 18:14:39 -0000
@@ -0,0 +1,26 @@
+Fix build with poppler-25.06.
+
+From upstream commit 1fdfb889bba9ee146c8b826e97bc58a88cb1e529.
+
+Index: src/extension/internal/pdfinput/poppler-transition-api.h
+--- src/extension/internal/pdfinput/poppler-transition-api.h.orig
++++ src/extension/internal/pdfinput/poppler-transition-api.h
+@@ -15,6 +15,18 @@
+ #include <glib/poppler-features.h>
+ #include <poppler/UTF.h>
+ 
++#if POPPLER_CHECK_VERSION(25, 6, 0)
++#define _POPPLER_DECLARE_TRANSFER_FUNCTION_VECTOR(name) std::vector<std::unique_ptr<Function>> name(4)
++#define _POPPLER_DELETE_TRANSFER_FUNCTION(name) name.reset()
++#define _POPPLER_GET_TRANSFER_FUNCTION_POINTER(name) name.get()
++#else
++#define _POPPLER_DECLARE_TRANSFER_FUNCTION_VECTOR(name) Function *name[4] = {}
++#define _POPPLER_DELETE_TRANSFER_FUNCTION(name) \
++    delete name;                                \
++    name = nullptr
++#define _POPPLER_GET_TRANSFER_FUNCTION_POINTER(name) name
++#endif
++
+ #if POPPLER_CHECK_VERSION(25,2,0)
+ #define _POPPLER_GET_CODE_TO_GID_MAP(ff, len) getCodeToGIDMap(ff)
+ #define _POPPLER_GET_CID_TO_GID_MAP(len) getCIDToGIDMap()