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