Blame texlive-base-20210325-configure-poppler-xpdf-fix.patch

1007fe9
diff -up texlive-base-20210325/source/configure.poppler-xpdf-fix texlive-base-20210325/source/configure
1007fe9
--- texlive-base-20210325/source/configure.poppler-xpdf-fix	2021-03-24 17:28:22.000000000 -0400
1007fe9
+++ texlive-base-20210325/source/configure	2021-05-10 15:21:08.254142588 -0400
1007fe9
@@ -21497,7 +21497,27 @@ if test "x$with_mpfr_libdir" != x && tes
1007fe9
   MPFR_LIBS="-L$with_mpfr_libdir $MPFR_LIBS"
1007fe9
 fi
1007fe9
 
1007fe9
-: "kpse_xpdf_system_flags - no-op"
1007fe9
+if $PKG_CONFIG poppler --atleast-version=0.30; then
1007fe9
+  POPPLER_INCLUDES=`$PKG_CONFIG poppler --cflags`
1007fe9
+  POPPLER_LIBS=`$PKG_CONFIG poppler --libs`
1007fe9
+elif test "x$need_poppler:$with_system_poppler" = xyes:yes; then
1007fe9
+  as_fn_error $? "did not find poppler 0.30 or better" "$LINENO" 5
1007fe9
+fi
1007fe9
+
1007fe9
+POPPLER_VERSION='-DPOPPLER_VERSION=\"'`$PKG_CONFIG poppler --modversion`'\"'
1007fe9
+POPPLER_INCLUDES="$POPPLER_VERSION $POPPLER_INCLUDES"
1007fe9
+
1007fe9
+if $PKG_CONFIG poppler --atleast-version=0.12; then
1007fe9
+  XPDF_INCLUDES=`$PKG_CONFIG poppler --cflags`
1007fe9
+  XPDF_LIBS=`$PKG_CONFIG poppler --libs`
1007fe9
+elif test "x$need_xpdf:$with_system_xpdf" = xyes:yes; then
1007fe9
+  as_fn_error $? "did not find poppler 0.12 or better" "$LINENO" 5
1007fe9
+fi
1007fe9
+
1007fe9
+POPPLER_VERSION='-DPOPPLER_VERSION=\"'`$PKG_CONFIG poppler --modversion`'\"'
1007fe9
+XPDF_INCLUDES="$POPPLER_VERSION $XPDF_INCLUDES"
1007fe9
+
1007fe9
+# : "kpse_xpdf_system_flags - no-op"
1007fe9
 
1007fe9
 if $PKG_CONFIG zziplib --atleast-version=0.12; then
1007fe9
   ZZIPLIB_INCLUDES=`$PKG_CONFIG zziplib --cflags`
1007fe9
diff -up texlive-base-20210325/source/texk/web2c/configure.poppler-xpdf-fix texlive-base-20210325/source/texk/web2c/configure
1007fe9
--- texlive-base-20210325/source/texk/web2c/configure.poppler-xpdf-fix	2021-02-16 22:03:54.000000000 -0500
1007fe9
+++ texlive-base-20210325/source/texk/web2c/configure	2021-05-10 15:21:08.256142617 -0400
1007fe9
@@ -25500,9 +25500,21 @@ fi
1007fe9
 ##tldbg _KPSE_LIB_FLAGS: Setup xpdf (-lxpdf) flags.
1007fe9
 echo 'tldbg:_KPSE_LIB_FLAGS called: libdir=xpdf, libname=xpdf, options=, tlincl=-DPDF_PARSER_ONLY -IBLD/libs/xpdf -IBLD/libs/xpdf/goo -IBLD/libs/xpdf/xpdf, tllib=BLD/libs/xpdf/libxpdf.a, tlextra=, rebuildsrcdeps=, rebuildblddeps=${top_builddir}/../../libs/xpdf/xpdf/Stream.h.' >&5
1007fe9
 ##tldbg _KPSE_LIB_FLAGS_TL: xpdf (xpdf) .
1007fe9
-: "kpse_xpdf_options - no-op"
1007fe9
+# Check whether --with-system-xpdf was given.
1007fe9
+if test "${with_system_xpdf+set}" = set; then :
1007fe9
+  withval=$with_system_xpdf;
1007fe9
+fi
1007fe9
+
1007fe9
 if test "x$with_system_xpdf" = xyes; then
1007fe9
-  : "kpse_xpdf_system_flags - no-op"
1007fe9
+  if $PKG_CONFIG poppler --atleast-version=0.12; then
1007fe9
+   XPDF_INCLUDES=`$PKG_CONFIG poppler --cflags`
1007fe9
+   XPDF_LIBS=`$PKG_CONFIG poppler --libs`
1007fe9
+elif test "x$need_xpdf:$with_system_xpdf" = xyes:yes; then
1007fe9
+  as_fn_error $? "did not find poppler 0.12 or better" "$LINENO" 5
1007fe9
+fi
1007fe9
+
1007fe9
+POPPLER_VERSION='-DPOPPLER_VERSION=\"'`$PKG_CONFIG poppler --modversion`'\"'
1007fe9
+XPDF_INCLUDES="$POPPLER_VERSION $XPDF_INCLUDES"
1007fe9
 else
1007fe9
   XPDF_INCLUDES="-DPDF_PARSER_ONLY -I$kpse_BLD/libs/xpdf -I$kpse_BLD/libs/xpdf/goo -I$kpse_BLD/libs/xpdf/xpdf"
1007fe9
   XPDF_LIBS="$kpse_BLD/libs/xpdf/libxpdf.a"
1007fe9
diff -up texlive-base-20210325/source/texk/web2c/pdftexdir/pdftoepdf.cc.poppler-xpdf-fix texlive-base-20210325/source/texk/web2c/pdftexdir/pdftoepdf.cc
1007fe9
--- texlive-base-20210325/source/texk/web2c/pdftexdir/pdftoepdf.cc.poppler-xpdf-fix	2021-05-10 15:56:50.770034767 -0400
1007fe9
+++ texlive-base-20210325/source/texk/web2c/pdftexdir/pdftoepdf.cc	2021-05-10 16:05:07.939283063 -0400
1007fe9
@@ -49,10 +49,16 @@ POPPLER_VERSION should be defined.
1007fe9
 #include <string.h>
1007fe9
 #include <ctype.h>
1007fe9
 
1007fe9
-#include <aconf.h>
1007fe9
-#include <GString.h>
1007fe9
-#include <gmem.h>
1007fe9
-#include <gfile.h>
1007fe9
+#ifdef POPPLER_VERSION
1007fe9
+#include <dirent.h>
1007fe9
+#include <poppler-config.h>
1007fe9
+#include <goo/GooString.h>
1007fe9
+#include <goo/gmem.h>
1007fe9
+#include <goo/gfile.h>
1007fe9
+#define GString GooString
1007fe9
+#else
1007fe9
+#error POPPLER_VERSION should be defined.
1007fe9
+#endif
1007fe9
 #include <assert.h>
1007fe9
 
1007fe9
 #include "Object.h"
1007fe9
@@ -676,7 +682,7 @@ static void writeEncodings()
1007fe9
     }
1007fe9
     for (r = encodingList; r != 0; r = n) {
1007fe9
         n = r->next;
1007fe9
-        delete r->font;
1007fe9
+	r->font->decRefCnt();
1007fe9
         delete r;
1007fe9
     }
1007fe9
 }
1007fe9
@@ -715,7 +721,7 @@ read_pdf_info(char *image_name, char *pa
1007fe9
     PdfDocument *pdf_doc;
1007fe9
     Page *page;
1007fe9
     const PDFRectangle *pagebox;
1007fe9
-    float pdf_version_found, pdf_version_wanted;
1007fe9
+    int pdf_major_version_found, pdf_minor_version_found;
1007fe9
     // initialize
1007fe9
     if (!isInit) {
1007fe9
         globalParams = std::unique_ptr<GlobalParams>(new GlobalParams());
1007fe9
@@ -730,17 +736,18 @@ read_pdf_info(char *image_name, char *pa
1007fe9
     // this works only for PDF 1.x -- but since any versions of PDF newer
1007fe9
     // than 1.x will not be backwards compatible to PDF 1.x, pdfTeX will
1007fe9
     // then have to changed drastically anyway.
1007fe9
-    pdf_version_found = pdf_doc->doc->getPDFVersion();
1007fe9
-    pdf_version_wanted = major_pdf_version_wanted + (minor_pdf_version_wanted * 0.1);
1007fe9
-    if (pdf_version_found > pdf_version_wanted + 0.01) {
1007fe9
-        char msg[] =
1007fe9
-            "PDF inclusion: found PDF version <%.1f>, but at most version <%.1f> allowed";
1007fe9
+    pdf_major_version_found = pdf_doc->doc->getPDFMajorVersion();
1007fe9
+    pdf_minor_version_found = pdf_doc->doc->getPDFMinorVersion();
1007fe9
+    if ((pdf_major_version_found > major_pdf_version_wanted)
1007fe9
+     || (pdf_minor_version_found > minor_pdf_version_wanted)) {
1007fe9
+        const char *msg =
1007fe9
+            "PDF inclusion: found PDF version <%d.%d>, but at most version <%d.%d> allowed";
1007fe9
         if (pdf_inclusion_errorlevel > 0) {
1007fe9
-            pdftex_fail(msg, pdf_version_found, pdf_version_wanted);
1007fe9
+            pdftex_fail(msg, pdf_major_version_found, pdf_minor_version_found, major_pdf_version_wanted, minor_pdf_version_wanted);
1007fe9
         } else if (pdf_inclusion_errorlevel < 0) {
1007fe9
             ; /* do nothing */
1007fe9
         } else { /* = 0, give warning */
1007fe9
-            pdftex_warn(msg, pdf_version_found, pdf_version_wanted);
1007fe9
+            pdftex_warn(msg, pdf_major_version_found, pdf_minor_version_found, major_pdf_version_wanted, minor_pdf_version_wanted);
1007fe9
         }
1007fe9
     }
1007fe9
     epdf_num_pages = pdf_doc->doc->getCatalog()->getNumPages();
1007fe9
diff -up texlive-base-20210325/source/texk/web2c/pdftexdir/pdftosrc.cc.poppler-xpdf-fix texlive-base-20210325/source/texk/web2c/pdftexdir/pdftosrc.cc
1007fe9
--- texlive-base-20210325/source/texk/web2c/pdftexdir/pdftosrc.cc.poppler-xpdf-fix	2021-05-10 15:26:43.545060694 -0400
1007fe9
+++ texlive-base-20210325/source/texk/web2c/pdftexdir/pdftosrc.cc	2021-05-10 16:06:58.614896618 -0400
1007fe9
@@ -41,10 +41,15 @@ POPPLER_VERSION should be defined.
1007fe9
 #include <string.h>
1007fe9
 #include <ctype.h>
1007fe9
 
1007fe9
-#include <aconf.h>
1007fe9
-#include <GString.h>
1007fe9
-#include <gmem.h>
1007fe9
-#include <gfile.h>
1007fe9
+#ifdef POPPLER_VERSION
1007fe9
+#define GString GooString
1007fe9
+#include <dirent.h>
1007fe9
+#include <goo/GooString.h>
1007fe9
+#include <goo/gmem.h>
1007fe9
+#include <goo/gfile.h>
1007fe9
+#else
1007fe9
+#error POPPLER_VERSION should be defined.
1007fe9
+#endif
1007fe9
 #include <assert.h>
1007fe9
 
1007fe9
 #include "Object.h"
1007fe9
@@ -183,7 +188,7 @@ int main(int argc, char *argv[])
1007fe9
                     if (n == e->gen)
1007fe9
                         localOffset = obj2.getInt();
1007fe9
                 }
1007fe9
-#if defined(XPDF304)
1007fe9
+#if defined(POPPLER_VERSION) || defined(XPDF304)
1007fe9
                 while (str->getChar() != EOF) ;
1007fe9
 #else /* xpdf 4.00 */
1007fe9
                 lexer->skipToEOF();