Blame texlive-base-20190410-poppler-0.84.patch

b9d1eda
--- texlive-base-20190410/source/texk/web2c/pdftexdir/pdftoepdf.cc
b9d1eda
+++ texlive-base-20190410/source/texk/web2c/pdftexdir/pdftoepdf.cc
b9d1eda
@@ -26,6 +26,15 @@ The poppler should be 0.59.0 or newer ve
b9d1eda
 POPPLER_VERSION should be defined.
b9d1eda
 */
b9d1eda
 
b9d1eda
+#ifdef POPPLER_VERSION
b9d1eda
+#include <poppler-config.h>
b9d1eda
+#define xpdfVersion POPPLER_VERSION
b9d1eda
+#define xpdfString "poppler"
b9d1eda
+#else
b9d1eda
+#include <xpdf/config.h>        /* just to get the xpdf version */
b9d1eda
+#define xpdfString "xpdf"
b9d1eda
+#endif
b9d1eda
+
b9d1eda
 /* Do this early in order to avoid a conflict between
b9d1eda
    MINGW32 <rpcndr.h> defining 'boolean' as 'unsigned char' and
b9d1eda
    <kpathsea/types.h> defining Pascal's boolean as 'int'.
b9d1eda
@@ -292,7 +292,7 @@ static void copyDictEntry(Object * obj,
b9d1eda
     Object obj1;
b9d1eda
     copyName(obj->dictGetKey(i));
b9d1eda
     pdf_puts(" ");
b9d1eda
-    obj1 = obj->dictGetValNF(i);
b9d1eda
+    obj1 = obj->dictGetValNF(i).copy();
b9d1eda
     copyObject(&obj1);
b9d1eda
     pdf_puts("\n");
b9d1eda
 }
b9d1eda
@@ -351,7 +351,7 @@ static void copyProcSet(Object * obj)
b9d1eda
                     obj->getTypeName());
b9d1eda
     pdf_puts("/ProcSet [ ");
b9d1eda
     for (i = 0, l = obj->arrayGetLength(); i < l; ++i) {
b9d1eda
-        procset = obj->arrayGetNF(i);
b9d1eda
+        procset = obj->arrayGetNF(i).copy();
b9d1eda
         if (!procset.isName())
b9d1eda
             pdftex_fail("PDF inclusion: invalid ProcSet entry type <%s>",
b9d1eda
                         procset.getTypeName());
b9d1eda
@@ -406,7 +406,7 @@ static void copyFont(const char *tag, Ob
b9d1eda
     if (fontdict.isDict()) {
b9d1eda
         subtype = fontdict.dictLookup("Subtype");
b9d1eda
         basefont = fontdict.dictLookup("BaseFont");
b9d1eda
-        fontdescRef = fontdict.dictLookupNF("FontDescriptor");
b9d1eda
+        fontdescRef = fontdict.dictLookupNF("FontDescriptor").copy();
b9d1eda
         if (fontdescRef.isRef()) {
b9d1eda
             fontdesc = fontdescRef.fetch(xref);
b9d1eda
         }
b9d1eda
@@ -452,7 +452,7 @@ static void copyFontResources(Object * o
b9d1eda
                     obj->getTypeName());
b9d1eda
     pdf_puts("/Font << ");
b9d1eda
     for (i = 0, l = obj->dictGetLength(); i < l; ++i) {
b9d1eda
-        fontRef = obj->dictGetValNF(i);
b9d1eda
+        fontRef = obj->dictGetValNF(i).copy();
b9d1eda
         if (fontRef.isRef())
b9d1eda
             copyFont(obj->dictGetKey(i), &fontRef);
b9d1eda
         else if (fontRef.isDict()) {   // some programs generate pdf with embedded font object
b9d1eda
@@ -595,7 +595,7 @@ static void copyObject(Object * obj)
b9d1eda
     } else if (obj->isArray()) {
b9d1eda
         pdf_puts("[");
b9d1eda
         for (i = 0, l = obj->arrayGetLength(); i < l; ++i) {
b9d1eda
-            obj1 = obj->arrayGetNF(i);
b9d1eda
+            obj1 = obj->arrayGetNF(i).copy();
b9d1eda
             if (!obj1.isName())
b9d1eda
                 pdf_puts(" ");
b9d1eda
             copyObject(&obj1);
b9d1eda
@@ -723,7 +723,7 @@ read_pdf_info(char *image_name, char *pa
b9d1eda
 #endif
b9d1eda
     // initialize
b9d1eda
     if (!isInit) {
b9d1eda
-        globalParams = new GlobalParams();
b9d1eda
+        globalParams = std::unique_ptr<GlobalParams>(new GlobalParams());
b9d1eda
         globalParams->setErrQuiet(false);
b9d1eda
         isInit = true;
b9d1eda
     }
b9d1eda
@@ -761,7 +761,7 @@ read_pdf_info(char *image_name, char *pa
b9d1eda
         if (link == 0 || !link->isOk())
b9d1eda
             pdftex_fail("PDF inclusion: invalid destination <%s>", page_name);
b9d1eda
         Ref ref = link->getPageRef();
b9d1eda
-        page_num = pdf_doc->doc->getCatalog()->findPage(ref.num, ref.gen);
b9d1eda
+        page_num = pdf_doc->doc->getCatalog()->findPage(ref);
b9d1eda
         if (page_num == 0)
b9d1eda
             pdftex_fail("PDF inclusion: destination is not a page <%s>",
b9d1eda
                         page_name);
b9d1eda
@@ -921,13 +921,13 @@ void write_epdf(void)
b9d1eda
     pdf_puts(stripzeros(s));
b9d1eda
 
b9d1eda
     // Metadata validity check (as a stream it must be indirect)
b9d1eda
-    dictObj = pageDict->lookupNF("Metadata");
b9d1eda
+    dictObj = pageDict->lookupNF("Metadata").copy();
b9d1eda
     if (!dictObj.isNull() && !dictObj.isRef())
b9d1eda
         pdftex_warn("PDF inclusion: /Metadata must be indirect object");
b9d1eda
 
b9d1eda
     // copy selected items in Page dictionary except Resources & Group
b9d1eda
     for (i = 0; pageDictKeys[i] != NULL; i++) {
b9d1eda
-        dictObj = pageDict->lookupNF(pageDictKeys[i]);
b9d1eda
+        dictObj = pageDict->lookupNF(pageDictKeys[i]).copy();
b9d1eda
         if (!dictObj.isNull()) {
b9d1eda
             pdf_newline();
b9d1eda
             pdf_printf("/%s ", pageDictKeys[i]);
b9d1eda
@@ -936,7 +936,7 @@ void write_epdf(void)
b9d1eda
     } 
b9d1eda
 
b9d1eda
     // handle page group
b9d1eda
-    dictObj = pageDict->lookupNF("Group");
b9d1eda
+    dictObj = pageDict->lookupNF("Group").copy();
b9d1eda
     if (!dictObj.isNull()) {
b9d1eda
         if (pdfpagegroupval == 0) { 
b9d1eda
             // another pdf with page group was included earlier on the
b9d1eda
@@ -978,7 +978,7 @@ The changes below seem to work fine.
b9d1eda
             l = dic1.getLength();
b9d1eda
             for (i = 0; i < l; i++) {
b9d1eda
                 groupDict.dictAdd(dic1.getKey(i),
b9d1eda
-                                  dic1.getValNF(i));
b9d1eda
+                                  dic1.getValNF(i).copy());
b9d1eda
             }
b9d1eda
 // end modification
b9d1eda
             pdf_printf("/Group %ld 0 R\n", (long)pdfpagegroupval);
b9d1eda
@@ -1108,6 +1108,6 @@ void epdf_check_mem()
b9d1eda
             delete_document(p);
b9d1eda
         }
b9d1eda
         // see above for globalParams
b9d1eda
-        delete globalParams;
b9d1eda
+        globalParams.reset();
b9d1eda
     }
b9d1eda
 }
b9d1eda
--- texlive-base-20190410/source/texk/web2c/pdftexdir/pdftosrc.cc
b9d1eda
+++ texlive-base-20190410/source/texk/web2c/pdftexdir/pdftosrc.cc
b9d1eda
@@ -24,6 +24,15 @@ by Arch Linux. The poppler should be 0.5
b9d1eda
 POPPLER_VERSION should be defined.
b9d1eda
 */
b9d1eda
 
b9d1eda
+#ifdef POPPLER_VERSION
b9d1eda
+#include <poppler-config.h>
b9d1eda
+#define xpdfVersion POPPLER_VERSION
b9d1eda
+#define xpdfString "poppler"
b9d1eda
+#else
b9d1eda
+#include <xpdf/config.h>        /* just to get the xpdf version */
b9d1eda
+#define xpdfString "xpdf"
b9d1eda
+#endif
b9d1eda
+
b9d1eda
 #include <w2c/config.h>
b9d1eda
 
b9d1eda
 #include <stdlib.h>
b9d1eda
@@ -79,7 +79,7 @@ int main(int argc, char *argv[])
b9d1eda
         exit(1);
b9d1eda
     }
b9d1eda
     fileName = new GString(argv[1]);
b9d1eda
-    globalParams = new GlobalParams();
b9d1eda
+    globalParams = std::unique_ptr<GlobalParams>(new GlobalParams());
b9d1eda
     doc = new PDFDoc(fileName);
b9d1eda
     if (!doc->isOk()) {
b9d1eda
         fprintf(stderr, "Invalid PDF file\n");
b9d1eda
@@ -100,7 +100,7 @@ int main(int argc, char *argv[])
b9d1eda
     if (objnum == 0) {
b9d1eda
         srcStream = catalogDict.dictLookup("SourceObject");
b9d1eda
         static char const_SourceFile[] = "SourceFile";
b9d1eda
-        if (!srcStream.isStream(const_SourceFile)) {
b9d1eda
+        if (!(srcStream.isStream() && srcStream.getDict()->is(const_SourceFile))) {
b9d1eda
             fprintf(stderr, "No SourceObject found\n");
b9d1eda
             exit(1);
b9d1eda
         }
b9d1eda
@@ -156,7 +156,6 @@ int main(int argc, char *argv[])
b9d1eda
                         (e->type == xrefEntryFree ? "f" : "n"));
b9d1eda
             else {              // e->offset is the object number of the object stream
b9d1eda
                 Stream *str;
b9d1eda
-                Lexer *lexer;
b9d1eda
                 Parser *parser;
b9d1eda
                 Object objStr, obj1, obj2;
b9d1eda
                 int nObjects, first, n;
b9d1eda
@@ -174,8 +173,7 @@ int main(int argc, char *argv[])
b9d1eda
                 // parse the header: object numbers and offsets
b9d1eda
                 objStr.streamReset();
b9d1eda
                 str = new EmbedStream(objStr.getStream(), Object(objNull), true, first);
b9d1eda
-                lexer = new Lexer(xref, str);
b9d1eda
-                parser = new Parser(xref, lexer, false);
b9d1eda
+                parser = new Parser(xref, str, false);
b9d1eda
                 for (n = 0; n < nObjects; ++n) {
b9d1eda
                     obj1 = parser->getObj();
b9d1eda
                     obj2 = parser->getObj();
b9d1eda
@@ -207,5 +207,5 @@ int main(int argc, char *argv[])
b9d1eda
         fprintf(stderr, "Cross-reference table extracted to %s\n", outname);
b9d1eda
     fclose(outfile);
b9d1eda
     delete doc;
b9d1eda
-    delete globalParams;
b9d1eda
+    globalParams.reset();
b9d1eda
 }
b9d1eda
--- texlive-base-20190410/source/texk/web2c/pdftexdir/utils.c
b9d1eda
+++ texlive-base-20190410/source/texk/web2c/pdftexdir/utils.c
b9d1eda
@@ -32,14 +32,6 @@ with this program.  If not, see 
b9d1eda
 #include <zlib.h>
b9d1eda
 #include "ptexlib.h"
b9d1eda
 #include <png.h>
b9d1eda
-#ifdef POPPLER_VERSION
b9d1eda
-#include <poppler-config.h>
b9d1eda
-#define xpdfVersion POPPLER_VERSION
b9d1eda
-#define xpdfString "poppler"
b9d1eda
-#else
b9d1eda
-#include <xpdf/config.h>        /* just to get the xpdf version */
b9d1eda
-#define xpdfString "xpdf"
b9d1eda
-#endif
b9d1eda
 
b9d1eda
 #define check_nprintf(size_get, size_want) \
b9d1eda
     if ((unsigned)(size_get) >= (unsigned)(size_want)) \
b9d1eda
@@ -977,12 +969,10 @@ void initversionstring(char **versions)
b9d1eda
 {
b9d1eda
     const_string fmt =
b9d1eda
                     "Compiled with libpng %s; using libpng %s\n"
b9d1eda
-                    "Compiled with zlib %s; using zlib %s\n"
b9d1eda
-                    "Compiled with %s version %s\n";
b9d1eda
+                    "Compiled with zlib %s; using zlib %s\n";
b9d1eda
     size_t len = strlen(fmt)
b9d1eda
                     + strlen(PNG_LIBPNG_VER_STRING) + strlen(png_libpng_ver)
b9d1eda
                     + strlen(ZLIB_VERSION) + strlen(zlib_version)
b9d1eda
-                    + strlen(xpdfString) + strlen(xpdfVersion)
b9d1eda
                     + 1;
b9d1eda
 
b9d1eda
     /* len will be more than enough, because of the placeholder chars in fmt
b9d1eda
@@ -990,7 +980,7 @@ void initversionstring(char **versions)
b9d1eda
     *versions = xmalloc(len);
b9d1eda
     sprintf(*versions, fmt,
b9d1eda
                     PNG_LIBPNG_VER_STRING, png_libpng_ver,
b9d1eda
-                    ZLIB_VERSION, zlib_version, xpdfString, xpdfVersion);
b9d1eda
+                    ZLIB_VERSION, zlib_version);
b9d1eda
 }
b9d1eda
 
b9d1eda
 
b9d1eda
--- texlive-base-20190410/source/texk/web2c/xetexdir/XeTeX_ext.c
b9d1eda
+++ texlive-base-20190410/source/texk/web2c/xetexdir/XeTeX_ext.c
b9d1eda
@@ -38,7 +38,6 @@ authorization from the copyright holders
b9d1eda
 
b9d1eda
 #include <w2c/config.h>
b9d1eda
 
b9d1eda
-#include <poppler-config.h>
b9d1eda
 #include <png.h>
b9d1eda
 #include <zlib.h>
b9d1eda
 #include <graphite2/Font.h>
b9d1eda
@@ -167,7 +166,6 @@ void initversionstring(char **versions)
b9d1eda
         "Compiled with Graphite2 version %d.%d.%d; using %d.%d.%d\n"
b9d1eda
         "Compiled with HarfBuzz version %s; using %s\n"
b9d1eda
         "Compiled with libpng version %s; using %s\n"
b9d1eda
-        "Compiled with poppler version %s\n"
b9d1eda
 #ifdef XETEX_MAC
b9d1eda
         "Using Mac OS X Core Text and Cocoa frameworks\n"
b9d1eda
 #else
b9d1eda
@@ -184,7 +182,6 @@ void initversionstring(char **versions)
b9d1eda
             + strlen(hb_version_string())
b9d1eda
             + strlen(PNG_LIBPNG_VER_STRING)
b9d1eda
             + strlen(png_libpng_ver)
b9d1eda
-            + strlen(POPPLER_VERSION)
b9d1eda
 #ifndef XETEX_MAC
b9d1eda
             + 6 * 3 /* for fontconfig version #s (won't really need 3 digits per field!) */
b9d1eda
 #endif
b9d1eda
@@ -214,7 +211,7 @@ void initversionstring(char **versions)
b9d1eda
         GR2_VERSION_MAJOR, GR2_VERSION_MINOR, GR2_VERSION_BUGFIX,
b9d1eda
         grMajor, grMinor, grBugfix,
b9d1eda
         HB_VERSION_STRING, hb_version_string(),
b9d1eda
-        PNG_LIBPNG_VER_STRING, png_libpng_ver, POPPLER_VERSION
b9d1eda
+        PNG_LIBPNG_VER_STRING, png_libpng_ver
b9d1eda
 #ifndef XETEX_MAC
b9d1eda
         ,
b9d1eda
         FC_VERSION / 10000, (FC_VERSION % 10000) / 100, FC_VERSION % 100,