Blame texlive-20210325-poppler-0.84.patch

1007fe9
diff -up texlive-base-20210325/source/texk/web2c/pdftexdir/pdftoepdf.cc.poppler-0.84 texlive-base-20210325/source/texk/web2c/pdftexdir/pdftoepdf.cc
1007fe9
--- texlive-base-20210325/source/texk/web2c/pdftexdir/pdftoepdf.cc.poppler-0.84	2021-05-06 18:21:18.379430999 -0400
1007fe9
+++ texlive-base-20210325/source/texk/web2c/pdftexdir/pdftoepdf.cc	2021-05-10 11:15:09.572907304 -0400
1007fe9
@@ -26,6 +26,15 @@ The poppler should be 0.59.0 or newer ve
1007fe9
 POPPLER_VERSION should be defined.
1007fe9
 */
1007fe9
 
1007fe9
+#ifdef POPPLER_VERSION
1007fe9
+#include <poppler-config.h>
1007fe9
+#define xpdfVersion POPPLER_VERSION
1007fe9
+#define xpdfString "poppler"
1007fe9
+#else
1007fe9
+#include <xpdf/config.h>        /* just to get the xpdf version */
1007fe9
+#define xpdfString "xpdf"
1007fe9
+#endif
1007fe9
+
1007fe9
 /* Do this early in order to avoid a conflict between
1007fe9
    MINGW32 <rpcndr.h> defining 'boolean' as 'unsigned char' and
1007fe9
    <kpathsea/types.h> defining Pascal's boolean as 'int'.
1007fe9
@@ -286,7 +295,7 @@ static void copyDictEntry(Object * obj,
1007fe9
     Object obj1;
1007fe9
     copyName(obj->dictGetKey(i));
1007fe9
     pdf_puts(" ");
1007fe9
-    obj1 = obj->dictGetValNF(i);
1007fe9
+    obj1 = obj->dictGetValNF(i).copy();
1007fe9
     copyObject(&obj1);
1007fe9
     pdf_puts("\n");
1007fe9
 }
1007fe9
@@ -345,7 +354,7 @@ static void copyProcSet(Object * obj)
1007fe9
                     obj->getTypeName());
1007fe9
     pdf_puts("/ProcSet [ ");
1007fe9
     for (i = 0, l = obj->arrayGetLength(); i < l; ++i) {
1007fe9
-        procset = obj->arrayGetNF(i);
1007fe9
+        procset = obj->arrayGetNF(i).copy();
1007fe9
         if (!procset.isName())
1007fe9
             pdftex_fail("PDF inclusion: invalid ProcSet entry type <%s>",
1007fe9
                         procset.getTypeName());
1007fe9
@@ -400,7 +409,7 @@ static void copyFont(const char *tag, Ob
1007fe9
     if (fontdict.isDict()) {
1007fe9
         subtype = fontdict.dictLookup("Subtype");
1007fe9
         basefont = fontdict.dictLookup("BaseFont");
1007fe9
-        fontdescRef = fontdict.dictLookupNF("FontDescriptor");
1007fe9
+        fontdescRef = fontdict.dictLookupNF("FontDescriptor").copy();
1007fe9
         if (fontdescRef.isRef()) {
1007fe9
             fontdesc = fontdescRef.fetch(xref);
1007fe9
         }
1007fe9
@@ -446,7 +455,7 @@ static void copyFontResources(Object * o
1007fe9
                     obj->getTypeName());
1007fe9
     pdf_puts("/Font << ");
1007fe9
     for (i = 0, l = obj->dictGetLength(); i < l; ++i) {
1007fe9
-        fontRef = obj->dictGetValNF(i);
1007fe9
+        fontRef = obj->dictGetValNF(i).copy();
1007fe9
         if (fontRef.isRef())
1007fe9
             copyFont(obj->dictGetKey(i), &fontRef);
1007fe9
         else if (fontRef.isDict()) {   // some programs generate pdf with embedded font object
1007fe9
@@ -589,7 +598,7 @@ static void copyObject(Object * obj)
1007fe9
     } else if (obj->isArray()) {
1007fe9
         pdf_puts("[");
1007fe9
         for (i = 0, l = obj->arrayGetLength(); i < l; ++i) {
1007fe9
-            obj1 = obj->arrayGetNF(i);
1007fe9
+            obj1 = obj->arrayGetNF(i).copy();
1007fe9
             if (!obj1.isName())
1007fe9
                 pdf_puts(" ");
1007fe9
             copyObject(&obj1);
1007fe9
@@ -709,7 +718,7 @@ read_pdf_info(char *image_name, char *pa
1007fe9
     float pdf_version_found, pdf_version_wanted;
1007fe9
     // initialize
1007fe9
     if (!isInit) {
1007fe9
-        globalParams = new GlobalParams();
1007fe9
+        globalParams = std::unique_ptr<GlobalParams>(new GlobalParams());
1007fe9
         globalParams->setErrQuiet(false);
1007fe9
         isInit = true;
1007fe9
     }
1007fe9
@@ -742,7 +751,7 @@ read_pdf_info(char *image_name, char *pa
1007fe9
         if (link == 0 || !link->isOk())
1007fe9
             pdftex_fail("PDF inclusion: invalid destination <%s>", page_name);
1007fe9
         Ref ref = link->getPageRef();
1007fe9
-        page_num = pdf_doc->doc->getCatalog()->findPage(ref.num, ref.gen);
1007fe9
+        page_num = pdf_doc->doc->getCatalog()->findPage(ref);
1007fe9
         if (page_num == 0)
1007fe9
             pdftex_fail("PDF inclusion: destination is not a page <%s>",
1007fe9
                         page_name);
1007fe9
@@ -902,13 +911,13 @@ void write_epdf(void)
1007fe9
     pdf_puts(stripzeros(s));
1007fe9
 
1007fe9
     // Metadata validity check (as a stream it must be indirect)
1007fe9
-    dictObj = pageDict->lookupNF("Metadata");
1007fe9
+    dictObj = pageDict->lookupNF("Metadata").copy();
1007fe9
     if (!dictObj.isNull() && !dictObj.isRef())
1007fe9
         pdftex_warn("PDF inclusion: /Metadata must be indirect object");
1007fe9
 
1007fe9
     // copy selected items in Page dictionary except Resources & Group
1007fe9
     for (i = 0; pageDictKeys[i] != NULL; i++) {
1007fe9
-        dictObj = pageDict->lookupNF(pageDictKeys[i]);
1007fe9
+        dictObj = pageDict->lookupNF(pageDictKeys[i]).copy();
1007fe9
         if (!dictObj.isNull()) {
1007fe9
             pdf_newline();
1007fe9
             pdf_printf("/%s ", pageDictKeys[i]);
1007fe9
@@ -917,7 +926,7 @@ void write_epdf(void)
1007fe9
     } 
1007fe9
 
1007fe9
     // handle page group
1007fe9
-    dictObj = pageDict->lookupNF("Group");
1007fe9
+    dictObj = pageDict->lookupNF("Group").copy();
1007fe9
     if (!dictObj.isNull()) {
1007fe9
         if (pdfpagegroupval == 0) { 
1007fe9
             // another pdf with page group was included earlier on the
1007fe9
@@ -959,7 +968,7 @@ The changes below seem to work fine.
1007fe9
             l = dic1.getLength();
1007fe9
             for (i = 0; i < l; i++) {
1007fe9
                 groupDict.dictAdd(dic1.getKey(i),
1007fe9
-                                  dic1.getValNF(i));
1007fe9
+                                  dic1.getValNF(i).copy());
1007fe9
             }
1007fe9
 // end modification
1007fe9
             pdf_printf("/Group %ld 0 R\n", (long)pdfpagegroupval);
1007fe9
@@ -1089,6 +1098,6 @@ void epdf_check_mem()
1007fe9
             delete_document(p);
1007fe9
         }
1007fe9
         // see above for globalParams
1007fe9
-        delete globalParams;
1007fe9
+        globalParams.reset();
1007fe9
     }
1007fe9
 }
1007fe9
diff -up texlive-base-20210325/source/texk/web2c/pdftexdir/pdftosrc.cc.poppler-0.84 texlive-base-20210325/source/texk/web2c/pdftexdir/pdftosrc.cc
1007fe9
--- texlive-base-20210325/source/texk/web2c/pdftexdir/pdftosrc.cc.poppler-0.84	2021-05-06 18:21:18.379430999 -0400
1007fe9
+++ texlive-base-20210325/source/texk/web2c/pdftexdir/pdftosrc.cc	2021-05-06 18:21:18.383431058 -0400
1007fe9
@@ -24,6 +24,15 @@ by Arch Linux. The poppler should be 0.5
1007fe9
 POPPLER_VERSION should be defined.
1007fe9
 */
1007fe9
 
1007fe9
+#ifdef POPPLER_VERSION
1007fe9
+#include <poppler-config.h>
1007fe9
+#define xpdfVersion POPPLER_VERSION
1007fe9
+#define xpdfString "poppler"
1007fe9
+#else
1007fe9
+#include <xpdf/config.h>        /* just to get the xpdf version */
1007fe9
+#define xpdfString "xpdf"
1007fe9
+#endif
1007fe9
+
1007fe9
 #include <w2c/config.h>
1007fe9
 
1007fe9
 #include <stdlib.h>
1007fe9
@@ -73,7 +82,7 @@ int main(int argc, char *argv[])
1007fe9
         exit(1);
1007fe9
     }
1007fe9
     fileName = new GString(argv[1]);
1007fe9
-    globalParams = new GlobalParams();
1007fe9
+    globalParams = std::unique_ptr<GlobalParams>(new GlobalParams());
1007fe9
     doc = new PDFDoc(fileName);
1007fe9
     if (!doc->isOk()) {
1007fe9
         fprintf(stderr, "Invalid PDF file\n");
1007fe9
@@ -94,7 +103,7 @@ int main(int argc, char *argv[])
1007fe9
     if (objnum == 0) {
1007fe9
         srcStream = catalogDict.dictLookup("SourceObject");
1007fe9
         static char const_SourceFile[] = "SourceFile";
1007fe9
-        if (!srcStream.isStream(const_SourceFile)) {
1007fe9
+        if (!(srcStream.isStream() && srcStream.getDict()->is(const_SourceFile))) {
1007fe9
             fprintf(stderr, "No SourceObject found\n");
1007fe9
             exit(1);
1007fe9
         }
1007fe9
@@ -150,7 +159,6 @@ int main(int argc, char *argv[])
1007fe9
                         (e->type == xrefEntryFree ? "f" : "n"));
1007fe9
             else {              // e->offset is the object number of the object stream
1007fe9
                 Stream *str;
1007fe9
-                Lexer *lexer;
1007fe9
                 Parser *parser;
1007fe9
                 Object objStr, obj1, obj2;
1007fe9
                 int nObjects, first, n;
1007fe9
@@ -168,8 +176,7 @@ int main(int argc, char *argv[])
1007fe9
                 // parse the header: object numbers and offsets
1007fe9
                 objStr.streamReset();
1007fe9
                 str = new EmbedStream(objStr.getStream(), Object(objNull), true, first);
1007fe9
-                lexer = new Lexer(xref, str);
1007fe9
-                parser = new Parser(xref, lexer, false);
1007fe9
+                parser = new Parser(xref, str, false);
1007fe9
                 for (n = 0; n < nObjects; ++n) {
1007fe9
                     obj1 = parser->getObj();
1007fe9
                     obj2 = parser->getObj();
1007fe9
@@ -201,5 +208,5 @@ int main(int argc, char *argv[])
1007fe9
         fprintf(stderr, "Cross-reference table extracted to %s\n", outname);
1007fe9
     fclose(outfile);
1007fe9
     delete doc;
1007fe9
-    delete globalParams;
1007fe9
+    globalParams.reset();
1007fe9
 }
1007fe9
diff -up texlive-base-20210325/source/texk/web2c/pdftexdir/utils.c.poppler-0.84 texlive-base-20210325/source/texk/web2c/pdftexdir/utils.c
1007fe9
--- texlive-base-20210325/source/texk/web2c/pdftexdir/utils.c.poppler-0.84	2019-12-29 19:37:32.000000000 -0500
1007fe9
+++ texlive-base-20210325/source/texk/web2c/pdftexdir/utils.c	2021-05-06 18:21:18.383431058 -0400
1007fe9
@@ -32,14 +32,6 @@ with this program.  If not, see 
1007fe9
 #include <zlib.h>
1007fe9
 #include "ptexlib.h"
1007fe9
 #include <png.h>
1007fe9
-#ifdef POPPLER_VERSION
1007fe9
-/* POPPLER_VERSION should be a proper version string */
1007fe9
-#define xpdfVersion POPPLER_VERSION
1007fe9
-#define xpdfString "poppler"
1007fe9
-#else
1007fe9
-#include <xpdf/config.h>        /* just to get the xpdf version */
1007fe9
-#define xpdfString "xpdf"
1007fe9
-#endif
1007fe9
 
1007fe9
 #define check_nprintf(size_get, size_want) \
1007fe9
     if ((unsigned)(size_get) >= (unsigned)(size_want)) \
1007fe9
@@ -977,12 +969,10 @@ void initversionstring(char **versions)
1007fe9
 {
1007fe9
     const_string fmt =
1007fe9
                     "Compiled with libpng %s; using libpng %s\n"
1007fe9
-                    "Compiled with zlib %s; using zlib %s\n"
1007fe9
-                    "Compiled with %s version %s\n";
1007fe9
+                    "Compiled with zlib %s; using zlib %s\n";
1007fe9
     size_t len = strlen(fmt)
1007fe9
                     + strlen(PNG_LIBPNG_VER_STRING) + strlen(png_libpng_ver)
1007fe9
                     + strlen(ZLIB_VERSION) + strlen(zlib_version)
1007fe9
-                    + strlen(xpdfString) + strlen(xpdfVersion)
1007fe9
                     + 1;
1007fe9
 
1007fe9
     /* len will be more than enough, because of the placeholder chars in fmt
1007fe9
@@ -990,7 +980,7 @@ void initversionstring(char **versions)
1007fe9
     *versions = xmalloc(len);
1007fe9
     sprintf(*versions, fmt,
1007fe9
                     PNG_LIBPNG_VER_STRING, png_libpng_ver,
1007fe9
-                    ZLIB_VERSION, zlib_version, xpdfString, xpdfVersion);
1007fe9
+                    ZLIB_VERSION, zlib_version);
1007fe9
 }
1007fe9
 
1007fe9
 
1007fe9
diff -up texlive-base-20210325/source/texk/web2c/xetexdir/XeTeX_ext.c.poppler-0.84 texlive-base-20210325/source/texk/web2c/xetexdir/XeTeX_ext.c