Gentoo Archives: gentoo-commits

From: "Alexis Ballier (aballier)" <aballier@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo commit in src/patchsets/texlive/2017/texlive-core: 090_all_poppler-0.59.patch series
Date: Sun, 07 Jan 2018 05:13:29
Message-Id: 20180107051325.0DC3C1A2@oystercatcher.gentoo.org
1 aballier 18/01/07 05:13:25
2
3 Modified: series
4 Added: 090_all_poppler-0.59.patch
5 Log:
6 add texlive 2017 patch for latest poppler; bug #629710
7
8 Revision Changes Path
9 1.4 src/patchsets/texlive/2017/texlive-core/series
10
11 file : http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/texlive/2017/texlive-core/series?rev=1.4&view=markup
12 plain: http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/texlive/2017/texlive-core/series?rev=1.4&content-type=text/plain
13 diff : http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/texlive/2017/texlive-core/series?r1=1.3&r2=1.4
14
15 Index: series
16 ===================================================================
17 RCS file: /var/cvsroot/gentoo/src/patchsets/texlive/2017/texlive-core/series,v
18 retrieving revision 1.3
19 retrieving revision 1.4
20 diff -u -r1.3 -r1.4
21 --- series 20 Jun 2017 13:04:41 -0000 1.3
22 +++ series 7 Jan 2018 05:13:24 -0000 1.4
23 @@ -6,3 +6,4 @@
24 060_all_luatex_zlib.patch
25 070_all_luatex_ggc7_align.patch
26 080_all_pdftoepdf-c++11.patch
27 +090_all_poppler-0.59.patch
28
29
30
31 1.1 src/patchsets/texlive/2017/texlive-core/090_all_poppler-0.59.patch
32
33 file : http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/texlive/2017/texlive-core/090_all_poppler-0.59.patch?rev=1.1&view=markup
34 plain: http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/texlive/2017/texlive-core/090_all_poppler-0.59.patch?rev=1.1&content-type=text/plain
35
36 Index: 090_all_poppler-0.59.patch
37 ===================================================================
38 https://bugs.gentoo.org/629710
39
40 Index: texlive-20170524-source/texk/web2c/luatexdir/image/pdftoepdf.w
41 ===================================================================
42 --- texlive-20170524-source.orig/texk/web2c/luatexdir/image/pdftoepdf.w
43 +++ texlive-20170524-source/texk/web2c/luatexdir/image/pdftoepdf.w
44 @@ -228,7 +228,7 @@ PdfDocument *refMemStreamPdfDocument(cha
45 free(checksum);
46 }
47 if (pdf_doc->doc == NULL) {
48 - docmemstream = new MemStream( docstream,0,streamsize, obj.initNull() );
49 + docmemstream = new MemStream( docstream,0,streamsize, Object(objNull) );
50 doc = new PDFDoc(docmemstream); /* takes ownership of docmemstream */
51 pdf_doc->pc++;
52 if (!doc->isOk() || !doc->okToPrint()) {
53 @@ -412,9 +412,8 @@ static void copyArray(PDF pdf, PdfDocume
54 Object obj1;
55 pdf_begin_array(pdf);
56 for (i = 0, l = array->getLength(); i < l; ++i) {
57 - array->getNF(i, &obj1);
58 + obj1 = array->getNF(i);
59 copyObject(pdf, pdf_doc, &obj1);
60 - obj1.free();
61 }
62 pdf_end_array(pdf);
63 }
64 @@ -426,9 +425,8 @@ static void copyDict(PDF pdf, PdfDocumen
65 pdf_begin_dict(pdf);
66 for (i = 0, l = dict->getLength(); i < l; ++i) {
67 copyName(pdf, dict->getKey(i));
68 - dict->getValNF(i, &obj1);
69 + obj1 = dict->getValNF(i);
70 copyObject(pdf, pdf_doc, &obj1);
71 - obj1.free();
72 }
73 pdf_end_dict(pdf);
74 }
75 @@ -514,13 +512,12 @@ static void writeRefs(PDF pdf, PdfDocume
76 PDFDoc *doc = pdf_doc->doc;
77 xref = doc->getXRef();
78 for (r = pdf_doc->inObjList; r != NULL;) {
79 - xref->fetch(r->ref.num, r->ref.gen, &obj1);
80 + obj1 = xref->fetch(r->ref.num, r->ref.gen);
81 if (obj1.isStream())
82 pdf_begin_obj(pdf, r->num, OBJSTM_NEVER);
83 else
84 pdf_begin_obj(pdf, r->num, 2);
85 copyObject(pdf, pdf_doc, &obj1);
86 - obj1.free();
87 pdf_end_obj(pdf);
88 n = r->next;
89 delete r;
90 @@ -744,7 +741,7 @@ void write_epdf(PDF pdf, image_dict * id
91 catalog = doc->getCatalog();
92 page = catalog->getPage(img_pagenum(idict));
93 pageref = catalog->getPageRef(img_pagenum(idict));
94 - doc->getXRef()->fetch(pageref->num, pageref->gen, &pageobj);
95 + pageobj = doc->getXRef()->fetch(pageref->num, pageref->gen);
96 pageDict = pageobj.getDict();
97 /* write the Page header */
98 pdf_begin_obj(pdf, img_objnum(idict), OBJSTM_NEVER);
99 @@ -761,12 +758,11 @@ void write_epdf(PDF pdf, image_dict * id
100 pdf_dict_add_int(pdf, "PTEX.PageNumber", (int) img_pagenum(idict));
101 }
102 if ((suppress_optional_info & 8) == 0) {
103 - doc->getDocInfoNF(&obj1);
104 + obj1 = doc->getDocInfoNF();
105 if (obj1.isRef()) {
106 /* the info dict must be indirect (PDF Ref p. 61) */
107 pdf_dict_add_ref(pdf, "PTEX.InfoDict", addInObj(pdf, pdf_doc, obj1.getRef()));
108 }
109 - obj1.free();
110 }
111 if (img_is_bbox(idict)) {
112 bbox[0] = sp2bp(img_bbox(idict)[0]);
113 @@ -792,19 +788,17 @@ void write_epdf(PDF pdf, image_dict * id
114 Now all relevant parts of the Page dictionary are copied. Metadata validity
115 check is needed(as a stream it must be indirect).
116 */
117 - pageDict->lookupNF("Metadata", &obj1);
118 + obj1 = pageDict->lookupNF("Metadata");
119 if (!obj1.isNull() && !obj1.isRef())
120 formatted_warning("pdf inclusion","/Metadata must be indirect object");
121 - obj1.free();
122 /* copy selected items in Page dictionary */
123 for (i = 0; pagedictkeys[i] != NULL; i++) {
124 - pageDict->lookupNF(pagedictkeys[i], &obj1);
125 + obj1 = pageDict->lookupNF(pagedictkeys[i]);
126 if (!obj1.isNull()) {
127 pdf_add_name(pdf, pagedictkeys[i]);
128 /* preserves indirection */
129 copyObject(pdf, pdf_doc, &obj1);
130 }
131 - obj1.free();
132 }
133 /*
134 If there are no Resources in the Page dict of the embedded page,
135 @@ -812,32 +806,28 @@ void write_epdf(PDF pdf, image_dict * id
136 PDF file, climbing up the tree until the Resources are found.
137 (This fixes a problem with Scribus 1.3.3.14.)
138 */
139 - pageDict->lookupNF("Resources", &obj1);
140 + obj1 = pageDict->lookupNF("Resources");
141 if (obj1.isNull()) {
142 op1 = &pagesobj1;
143 op2 = &pagesobj2;
144 - pageDict->lookup("Parent", op1);
145 + *op1 = pageDict->lookup("Parent");
146 while (op1->isDict()) {
147 - obj1.free();
148 - op1->dictLookupNF("Resources", &obj1);
149 + obj1 = op1->dictLookupNF("Resources");
150 if (!obj1.isNull()) {
151 pdf_add_name(pdf, "Resources");
152 copyObject(pdf, pdf_doc, &obj1);
153 break;
154 }
155 - op1->dictLookup("Parent", op2);
156 + *op2 = op1->dictLookup("Parent");
157 optmp = op1;
158 op1 = op2;
159 op2 = optmp;
160 - op2->free();
161 };
162 if (!op1->isDict())
163 formatted_warning("pdf inclusion","Page /Resources missing");
164 - op1->free();
165 }
166 - obj1.free();
167 /* Write the Page contents. */
168 - page->getContents(&contents);
169 + contents = page->getContents();
170 if (contents.isStream()) {
171 /*
172 Variant A: get stream and recompress under control of \pdfcompresslevel
173 @@ -848,27 +838,23 @@ void write_epdf(PDF pdf, image_dict * id
174
175 Variant B: copy stream without recompressing
176 */
177 - contents.streamGetDict()->lookup("F", &obj1);
178 + obj1 = contents.streamGetDict()->lookup("F");
179 if (!obj1.isNull()) {
180 normal_error("pdf inclusion","unsupported external stream");
181 }
182 - obj1.free();
183 - contents.streamGetDict()->lookup("Length", &obj1);
184 + obj1 = contents.streamGetDict()->lookup("Length");
185 pdf_add_name(pdf, "Length");
186 copyObject(pdf, pdf_doc, &obj1);
187 - obj1.free();
188 - contents.streamGetDict()->lookup("Filter", &obj1);
189 + obj1 = contents.streamGetDict()->lookup("Filter");
190 if (!obj1.isNull()) {
191 pdf_add_name(pdf, "Filter");
192 copyObject(pdf, pdf_doc, &obj1);
193 - obj1.free();
194 - contents.streamGetDict()->lookup("DecodeParms", &obj1);
195 + obj1 = contents.streamGetDict()->lookup("DecodeParms");
196 if (!obj1.isNull()) {
197 pdf_add_name(pdf, "DecodeParms");
198 copyObject(pdf, pdf_doc, &obj1);
199 }
200 }
201 - obj1.free();
202 pdf_end_dict(pdf);
203 pdf_begin_stream(pdf);
204 copyStreamStream(pdf, contents.getStream()->getUndecodedStream());
205 @@ -879,8 +865,8 @@ void write_epdf(PDF pdf, image_dict * id
206 pdf_end_dict(pdf);
207 pdf_begin_stream(pdf);
208 for (i = 0, l = contents.arrayGetLength(); i < l; ++i) {
209 - copyStreamStream(pdf, (contents.arrayGet(i, &obj1))->getStream());
210 - obj1.free();
211 + obj1 = contents.arrayGet(i);
212 + copyStreamStream(pdf, obj1.getStream());
213 if (i < (l - 1)) {
214 /*
215 Put a space between streams to be on the safe side (streams
216 @@ -901,8 +887,6 @@ void write_epdf(PDF pdf, image_dict * id
217 }
218 /* write out all indirect objects */
219 writeRefs(pdf, pdf_doc);
220 - contents.free();
221 - pageobj.free();
222 /*
223 unrefPdfDocument() must come after contents.free() and pageobj.free()!
224 TH: The next line makes repeated pdf inclusion unacceptably slow
225 Index: texlive-20170524-source/texk/web2c/luatexdir/lua/lepdflib.cc
226 ===================================================================
227 --- texlive-20170524-source.orig/texk/web2c/luatexdir/lua/lepdflib.cc
228 +++ texlive-20170524-source/texk/web2c/luatexdir/lua/lepdflib.cc
229 @@ -538,7 +538,7 @@ static int m_##in##_##function(lua_State
230 pdfdoc_changed_error(L); \
231 uout = new_Object_userdata(L); \
232 uout->d = new Object(); \
233 - ((in *) uin->d)->function((Object *) uout->d); \
234 + *((Object *)uout->d) = ((in *) uin->d)->function(); \
235 uout->atype = ALLOC_LEPDF; \
236 uout->pc = uin->pc; \
237 uout->pd = uin->pd; \
238 @@ -668,13 +668,11 @@ static const struct luaL_Reg Annots_m[]
239
240 static int m_Array_incRef(lua_State * L)
241 {
242 - int i;
243 udstruct *uin;
244 uin = (udstruct *) luaL_checkudata(L, 1, M_Array);
245 if (uin->pd != NULL && uin->pd->pc != uin->pc)
246 pdfdoc_changed_error(L);
247 - i = ((Array *) uin->d)->incRef();
248 - lua_pushinteger(L, i);
249 + lua_pushinteger(L, 1);
250 return 1;
251 }
252
253 @@ -685,8 +683,7 @@ static int m_Array_decRef(lua_State * L)
254 uin = (udstruct *) luaL_checkudata(L, 1, M_Array);
255 if (uin->pd != NULL && uin->pd->pc != uin->pc)
256 pdfdoc_changed_error(L);
257 - i = ((Array *) uin->d)->decRef();
258 - lua_pushinteger(L, i);
259 + lua_pushinteger(L, 1);
260 return 1;
261 }
262
263 @@ -702,7 +699,7 @@ static int m_Array_add(lua_State * L)
264 if ((uin->pd != NULL && uin->pd->pc != uin->pc)
265 || (uobj->pd != NULL && uobj->pd->pc != uobj->pc))
266 pdfdoc_changed_error(L);
267 - ((Array *) uin->d)->add(((Object *) uobj->d));
268 + ((Array *) uin->d)->add(std::move(*((Object *) uobj->d)));
269 return 0;
270 }
271
272 @@ -718,7 +715,7 @@ static int m_Array_get(lua_State * L)
273 if (i > 0 && i <= len) {
274 uout = new_Object_userdata(L);
275 uout->d = new Object();
276 - ((Array *) uin->d)->get(i - 1, (Object *) uout->d);
277 + *((Object *) uout->d) = ((Array *) uin->d)->get(i - 1);
278 uout->atype = ALLOC_LEPDF;
279 uout->pc = uin->pc;
280 uout->pd = uin->pd;
281 @@ -739,7 +736,7 @@ static int m_Array_getNF(lua_State * L)
282 if (i > 0 && i <= len) {
283 uout = new_Object_userdata(L);
284 uout->d = new Object();
285 - ((Array *) uin->d)->getNF(i - 1, (Object *) uout->d);
286 + *((Object *) uout->d) = ((Array *) uin->d)->getNF(i - 1);
287 uout->atype = ALLOC_LEPDF;
288 uout->pc = uin->pc;
289 uout->pd = uin->pd;
290 @@ -953,25 +950,21 @@ static const struct luaL_Reg Catalog_m[]
291
292 static int m_Dict_incRef(lua_State * L)
293 {
294 - int i;
295 udstruct *uin;
296 uin = (udstruct *) luaL_checkudata(L, 1, M_Dict);
297 if (uin->pd != NULL && uin->pd->pc != uin->pc)
298 pdfdoc_changed_error(L);
299 - i = ((Dict *) uin->d)->incRef();
300 - lua_pushinteger(L, i);
301 + lua_pushinteger(L, 1);
302 return 1;
303 }
304
305 static int m_Dict_decRef(lua_State * L)
306 {
307 - int i;
308 udstruct *uin;
309 uin = (udstruct *) luaL_checkudata(L, 1, M_Dict);
310 if (uin->pd != NULL && uin->pd->pc != uin->pc)
311 pdfdoc_changed_error(L);
312 - i = ((Dict *) uin->d)->decRef();
313 - lua_pushinteger(L, i);
314 + lua_pushinteger(L, 1);
315 return 1;
316 }
317
318 @@ -986,7 +979,7 @@ static int m_Dict_add(lua_State * L)
319 pdfdoc_changed_error(L);
320 s = copyString(luaL_checkstring(L, 2));
321 uobj = (udstruct *) luaL_checkudata(L, 3, M_Object);
322 - ((Dict *) uin->d)->add(s, ((Object *) uobj->d));
323 + ((Dict *) uin->d)->add(s, std::move(*((Object *) uobj->d)));
324 return 0;
325 }
326
327 @@ -999,7 +992,7 @@ static int m_Dict_set(lua_State * L)
328 pdfdoc_changed_error(L);
329 s = luaL_checkstring(L, 2);
330 uobj = (udstruct *) luaL_checkudata(L, 3, M_Object);
331 - ((Dict *) uin->d)->set(s, ((Object *) uobj->d));
332 + ((Dict *) uin->d)->set(s, std::move(*((Object *) uobj->d)));
333 return 0;
334 }
335
336 @@ -1027,7 +1020,7 @@ static int m_Dict_lookup(lua_State * L)
337 s = luaL_checkstring(L, 2);
338 uout = new_Object_userdata(L);
339 uout->d = new Object();
340 - ((Dict *) uin->d)->lookup(s, (Object *) uout->d);
341 + *((Object *) uout->d) = ((Dict *) uin->d)->lookup(s);
342 uout->atype = ALLOC_LEPDF;
343 uout->pc = uin->pc;
344 uout->pd = uin->pd;
345 @@ -1044,7 +1037,7 @@ static int m_Dict_lookupNF(lua_State * L
346 s = luaL_checkstring(L, 2);
347 uout = new_Object_userdata(L);
348 uout->d = new Object();
349 - ((Dict *) uin->d)->lookupNF(s, (Object *) uout->d);
350 + *((Object *) uout->d) = ((Dict *) uin->d)->lookupNF(s);
351 uout->atype = ALLOC_LEPDF;
352 uout->pc = uin->pc;
353 uout->pd = uin->pd;
354 @@ -1096,7 +1089,7 @@ static int m_Dict_getVal(lua_State * L)
355 if (i > 0 && i <= len) {
356 uout = new_Object_userdata(L);
357 uout->d = new Object();
358 - ((Dict *) uin->d)->getVal(i - 1, (Object *) uout->d);
359 + *((Object *) uout->d) = ((Dict *) uin->d)->getVal(i - 1);
360 uout->atype = ALLOC_LEPDF;
361 uout->pc = uin->pc;
362 uout->pd = uin->pd;
363 @@ -1117,7 +1110,7 @@ static int m_Dict_getValNF(lua_State * L
364 if (i > 0 && i <= len) {
365 uout = new_Object_userdata(L);
366 uout->d = new Object();
367 - ((Dict *) uin->d)->getValNF(i - 1, (Object *) uout->d);
368 + *((Object *) uout->d) = ((Dict *) uin->d)->getValNF(i - 1);
369 uout->atype = ALLOC_LEPDF;
370 uout->pc = uin->pc;
371 uout->pd = uin->pd;
372 @@ -1381,9 +1374,9 @@ static int m_Object_initBool(lua_State *
373 pdfdoc_changed_error(L);
374 luaL_checktype(L, 2, LUA_TBOOLEAN);
375 if (lua_toboolean(L, 2) != 0)
376 - ((Object *) uin->d)->initBool(gTrue);
377 + *((Object *) uin->d) = Object(gTrue);
378 else
379 - ((Object *) uin->d)->initBool(gFalse);
380 + *((Object *) uin->d) = Object(gFalse);
381 return 0;
382 }
383
384 @@ -1395,7 +1388,7 @@ static int m_Object_initInt(lua_State *
385 if (uin->pd != NULL && uin->pd->pc != uin->pc)
386 pdfdoc_changed_error(L);
387 i = luaL_checkint(L, 2);
388 - ((Object *) uin->d)->initInt(i);
389 + *((Object *) uin->d) = Object(i);
390 return 0;
391 }
392
393 @@ -1407,7 +1400,7 @@ static int m_Object_initReal(lua_State *
394 if (uin->pd != NULL && uin->pd->pc != uin->pc)
395 pdfdoc_changed_error(L);
396 d = luaL_checknumber(L, 2);
397 - ((Object *) uin->d)->initReal(d);
398 + *((Object *) uin->d) = Object(d);
399 return 0;
400 }
401
402 @@ -1422,7 +1415,7 @@ static int m_Object_initString(lua_State
403 pdfdoc_changed_error(L);
404 s = luaL_checklstring(L, 2, &len);
405 gs = new GooString(s, len);
406 - ((Object *) uin->d)->initString(gs);
407 + *((Object *) uin->d) = Object(gs);
408 return 0;
409 }
410
411 @@ -1434,7 +1427,7 @@ static int m_Object_initName(lua_State *
412 if (uin->pd != NULL && uin->pd->pc != uin->pc)
413 pdfdoc_changed_error(L);
414 s = luaL_checkstring(L, 2);
415 - ((Object *) uin->d)->initName(s);
416 + *((Object *) uin->d) = Object(objName, s);
417 return 0;
418 }
419
420 @@ -1444,13 +1437,14 @@ static int m_Object_initNull(lua_State *
421 uin = (udstruct *) luaL_checkudata(L, 1, M_Object);
422 if (uin->pd != NULL && uin->pd->pc != uin->pc)
423 pdfdoc_changed_error(L);
424 - ((Object *) uin->d)->initNull();
425 + *((Object *) uin->d) = Object(objNull);
426 return 0;
427 }
428
429 static int m_Object_initArray(lua_State * L)
430 {
431 udstruct *uin, *uxref;
432 + Array *a;
433 uin = (udstruct *) luaL_checkudata(L, 1, M_Object);
434 uxref = (udstruct *) luaL_checkudata(L, 2, M_XRef);
435 if (uin->pd != NULL && uxref->pd != NULL && uin->pd != uxref->pd)
436 @@ -1458,7 +1452,8 @@ static int m_Object_initArray(lua_State
437 if ((uin->pd != NULL && uin->pd->pc != uin->pc)
438 || (uxref->pd != NULL && uxref->pd->pc != uxref->pc))
439 pdfdoc_changed_error(L);
440 - ((Object *) uin->d)->initArray((XRef *) uxref->d);
441 + a = new Array((XRef *) uxref->d);
442 + *((Object *) uin->d) = Object(a);
443 return 0;
444 }
445
446 @@ -1469,6 +1464,7 @@ static int m_Object_initArray(lua_State
447 static int m_Object_initDict(lua_State * L)
448 {
449 udstruct *uin, *uxref;
450 + Dict *d;
451 uin = (udstruct *) luaL_checkudata(L, 1, M_Object);
452 uxref = (udstruct *) luaL_checkudata(L, 2, M_XRef);
453 if (uin->pd != NULL && uxref->pd != NULL && uin->pd != uxref->pd)
454 @@ -1476,7 +1472,8 @@ static int m_Object_initDict(lua_State *
455 if ((uin->pd != NULL && uin->pd->pc != uin->pc)
456 || (uxref->pd != NULL && uxref->pd->pc != uxref->pc))
457 pdfdoc_changed_error(L);
458 - ((Object *) uin->d)->initDict((XRef *) uxref->d);
459 + d = new Dict((XRef *) uxref->d);
460 + *((Object *) uin->d) = Object(d);
461 return 0;
462 }
463
464 @@ -1490,7 +1487,7 @@ static int m_Object_initStream(lua_State
465 if ((uin->pd != NULL && uin->pd->pc != uin->pc)
466 || (ustream->pd != NULL && ustream->pd->pc != ustream->pc))
467 pdfdoc_changed_error(L);
468 - ((Object *) uin->d)->initStream((Stream *) ustream->d);
469 + *((Object *) uin->d) = Object((Stream *) ustream->d);
470 return 0;
471 }
472
473 @@ -1503,7 +1500,7 @@ static int m_Object_initRef(lua_State *
474 pdfdoc_changed_error(L);
475 num = luaL_checkint(L, 2);
476 gen = luaL_checkint(L, 3);
477 - ((Object *) uin->d)->initRef(num, gen);
478 + *((Object *) uin->d) = Object(num, gen);
479 return 0;
480 }
481
482 @@ -1515,7 +1512,7 @@ static int m_Object_initCmd(lua_State *
483 if (uin->pd != NULL && uin->pd->pc != uin->pc)
484 pdfdoc_changed_error(L);
485 s = luaL_checkstring(L, 2);
486 - ((Object *) uin->d)->initCmd(CHARP_CAST s);
487 + *((Object *) uin->d) = Object(objCmd, CHARP_CAST s);
488 return 0;
489 }
490
491 @@ -1525,7 +1522,7 @@ static int m_Object_initError(lua_State
492 uin = (udstruct *) luaL_checkudata(L, 1, M_Object);
493 if (uin->pd != NULL && uin->pd->pc != uin->pc)
494 pdfdoc_changed_error(L);
495 - ((Object *) uin->d)->initError();
496 + *((Object *) uin->d) = Object(objError);
497 return 0;
498 }
499
500 @@ -1535,7 +1532,7 @@ static int m_Object_initEOF(lua_State *
501 uin = (udstruct *) luaL_checkudata(L, 1, M_Object);
502 if (uin->pd != NULL && uin->pd->pc != uin->pc)
503 pdfdoc_changed_error(L);
504 - ((Object *) uin->d)->initEOF();
505 + *((Object *) uin->d) = Object(objEOF);
506 return 0;
507 }
508
509 @@ -1551,7 +1548,7 @@ static int m_Object_fetch(lua_State * L)
510 pdfdoc_changed_error(L);
511 uout = new_Object_userdata(L);
512 uout->d = new Object();
513 - ((Object *) uin->d)->fetch((XRef *) uxref->d, (Object *) uout->d);
514 + *((Object *) uout->d) = ((Object *) uin->d)->fetch((XRef *) uxref->d);
515 uout->atype = ALLOC_LEPDF;
516 uout->pc = uin->pc;
517 uout->pd = uin->pd;
518 @@ -1816,7 +1813,7 @@ static int m_Object_arrayAdd(lua_State *
519 pdfdoc_changed_error(L);
520 if (!((Object *) uin->d)->isArray())
521 luaL_error(L, "Object is not an Array");
522 - ((Object *) uin->d)->arrayAdd((Object *) uobj->d);
523 + ((Object *) uin->d)->arrayAdd(std::move(*((Object *) uobj->d)));
524 return 0;
525 }
526
527 @@ -1833,7 +1830,7 @@ static int m_Object_arrayGet(lua_State *
528 if (i > 0 && i <= len) {
529 uout = new_Object_userdata(L);
530 uout->d = new Object();
531 - ((Object *) uin->d)->arrayGet(i - 1, (Object *) uout->d);
532 + *((Object *) uout->d) = ((Object *) uin->d)->arrayGet(i - 1);
533 uout->atype = ALLOC_LEPDF;
534 uout->pc = uin->pc;
535 uout->pd = uin->pd;
536 @@ -1857,7 +1854,7 @@ static int m_Object_arrayGetNF(lua_State
537 if (i > 0 && i <= len) {
538 uout = new_Object_userdata(L);
539 uout->d = new Object();
540 - ((Object *) uin->d)->arrayGetNF(i - 1, (Object *) uout->d);
541 + *((Object *) uout->d) = ((Object *) uin->d)->arrayGetNF(i - 1);
542 uout->atype = ALLOC_LEPDF;
543 uout->pc = uin->pc;
544 uout->pd = uin->pd;
545 @@ -1897,7 +1894,7 @@ static int m_Object_dictAdd(lua_State *
546 pdfdoc_changed_error(L);
547 if (!((Object *) uin->d)->isDict())
548 luaL_error(L, "Object is not a Dict");
549 - ((Object *) uin->d)->dictAdd(copyString(s), (Object *) uobj->d);
550 + ((Object *) uin->d)->dictAdd(copyString(s), std::move(*((Object *) uobj->d)));
551 return 0;
552 }
553
554 @@ -1915,7 +1912,7 @@ static int m_Object_dictSet(lua_State *
555 pdfdoc_changed_error(L);
556 if (!((Object *) uin->d)->isDict())
557 luaL_error(L, "Object is not a Dict");
558 - ((Object *) uin->d)->dictSet(s, (Object *) uobj->d);
559 + ((Object *) uin->d)->dictSet(s, std::move(*((Object *) uobj->d)));
560 return 0;
561 }
562
563 @@ -1930,7 +1927,7 @@ static int m_Object_dictLookup(lua_State
564 if (((Object *) uin->d)->isDict()) {
565 uout = new_Object_userdata(L);
566 uout->d = new Object();
567 - ((Object *) uin->d)->dictLookup(s, (Object *) uout->d);
568 + *((Object *) uout->d) = ((Object *) uin->d)->dictLookup(s);
569 uout->atype = ALLOC_LEPDF;
570 uout->pc = uin->pc;
571 uout->pd = uin->pd;
572 @@ -1950,7 +1947,7 @@ static int m_Object_dictLookupNF(lua_Sta
573 if (((Object *) uin->d)->isDict()) {
574 uout = new_Object_userdata(L);
575 uout->d = new Object();
576 - ((Object *) uin->d)->dictLookupNF(s, (Object *) uout->d);
577 + *((Object *) uout->d) = ((Object *) uin->d)->dictLookupNF(s);
578 uout->atype = ALLOC_LEPDF;
579 uout->pc = uin->pc;
580 uout->pd = uin->pd;
581 @@ -1991,7 +1988,7 @@ static int m_Object_dictGetVal(lua_State
582 if (i > 0 && i <= len) {
583 uout = new_Object_userdata(L);
584 uout->d = new Object();
585 - ((Object *) uin->d)->dictGetVal(i - 1, (Object *) uout->d);
586 + *((Object *) uout->d) = ((Object *) uin->d)->dictGetVal(i - 1);
587 uout->atype = ALLOC_LEPDF;
588 uout->pc = uin->pc;
589 uout->pd = uin->pd;
590 @@ -2015,7 +2012,7 @@ static int m_Object_dictGetValNF(lua_Sta
591 if (i > 0 && i <= len) {
592 uout = new_Object_userdata(L);
593 uout->d = new Object();
594 - ((Object *) uin->d)->dictGetValNF(i - 1, (Object *) uout->d);
595 + *((Object *) uout->d) = ((Object *) uin->d)->dictGetValNF(i - 1);
596 uout->atype = ALLOC_LEPDF;
597 uout->pc = uin->pc;
598 uout->pd = uin->pd;
599 @@ -2243,7 +2240,7 @@ m_poppler_get_poppler(Page, Stream, getM
600 m_poppler_get_poppler(Page, Dict, getPieceInfo);
601 m_poppler_get_poppler(Page, Dict, getSeparationInfo);
602 m_poppler_get_poppler(Page, Dict, getResourceDict);
603 -m_poppler_get_OBJECT(Page, getAnnots);
604 +m_poppler_get_OBJECT(Page, getAnnotsObject);
605
606 m_poppler_get_OBJECT(Page, getContents);
607
608 @@ -2270,7 +2267,7 @@ static const struct luaL_Reg Page_m[] =
609 {"getPieceInfo", m_Page_getPieceInfo},
610 {"getSeparationInfo", m_Page_getSeparationInfo},
611 {"getResourceDict", m_Page_getResourceDict},
612 - {"getAnnots", m_Page_getAnnots},
613 + {"getAnnots", m_Page_getAnnotsObject},
614 {"getContents", m_Page_getContents},
615 {"__tostring", m_Page__tostring},
616 {NULL, NULL} // sentinel
617 @@ -2520,7 +2517,7 @@ static int m_PDFDoc_getDocInfo(lua_State
618 if (((PdfDocument *) uin->d)->doc->getXRef()->isOk()) {
619 uout = new_Object_userdata(L);
620 uout->d = new Object();
621 - ((PdfDocument *) uin->d)->doc->getDocInfo((Object *) uout->d);
622 + *((Object *) uout->d) = ((PdfDocument *) uin->d)->doc->getDocInfo();
623 uout->atype = ALLOC_LEPDF;
624 uout->pc = uin->pc;
625 uout->pd = uin->pd;
626 @@ -2538,7 +2535,7 @@ static int m_PDFDoc_getDocInfoNF(lua_Sta
627 if (((PdfDocument *) uin->d)->doc->getXRef()->isOk()) {
628 uout = new_Object_userdata(L);
629 uout->d = new Object();
630 - ((PdfDocument *) uin->d)->doc->getDocInfoNF((Object *) uout->d);
631 + *((Object *) uout->d) = ((PdfDocument *) uin->d)->doc->getDocInfoNF();
632 uout->atype = ALLOC_LEPDF;
633 uout->pc = uin->pc;
634 uout->pd = uin->pd;
635 @@ -2841,7 +2838,7 @@ static int m_Attribute_getValue(lua_Stat
636 uout = new_Object_userdata(L);
637 uout->d = new Object();
638 origin = (Object *) (((Attribute *) uin->d)->getValue());
639 - origin->copy ( ((Object *)uout->d) );
640 + *((Object *) uout->d) = origin->copy();
641 uout->atype = ALLOC_LEPDF;
642 uout->pc = uin->pc;
643 uout->pd = uin->pd;
644 @@ -3320,7 +3317,7 @@ static int m_StructTreeRoot_findParentEl
645 parent = root->findParentElement(i-1);
646 if (parent != NULL) {
647 uout = new_StructElement_userdata(L);
648 - uout->d = new StructElement( *parent );
649 + uout->d = (StructElement *) parent;
650 uout->atype = ALLOC_LEPDF;
651 uout->pc = uin->pc;
652 uout->pd = uin->pd;
653 @@ -3370,7 +3367,7 @@ static int m_XRef_fetch(lua_State * L)
654 gen = luaL_checkint(L, 3);
655 uout = new_Object_userdata(L);
656 uout->d = new Object();
657 - ((XRef *) uin->d)->fetch(num, gen, (Object *) uout->d);
658 + *((Object *) uout->d) = ((XRef *) uin->d)->fetch(num, gen);
659 uout->atype = ALLOC_LEPDF;
660 uout->pc = uin->pc;
661 uout->pd = uin->pd;
662 Index: texlive-20170524-source/texk/web2c/luatexdir/lua/lpdfscannerlib.cc
663 ===================================================================
664 --- texlive-20170524-source.orig/texk/web2c/luatexdir/lua/lpdfscannerlib.cc
665 +++ texlive-20170524-source/texk/web2c/luatexdir/lua/lpdfscannerlib.cc
666 @@ -634,7 +634,7 @@ static int scanner_scan(lua_State * L)
667 int i;
668 for (i=0;i<count;i++) {
669 Object *val = new Object();
670 - arrayref->get(i, val);
671 + *val = arrayref->get(i);
672 if (val->isStream()) {
673 ObjectList *rover = self->_streams;
674 ObjectList *item = (ObjectList *)priv_xmalloc (sizeof(ObjectList));
675 Index: texlive-20170524-source/texk/web2c/pdftexdir/pdftoepdf.cc
676 ===================================================================
677 --- texlive-20170524-source.orig/texk/web2c/pdftexdir/pdftoepdf.cc
678 +++ texlive-20170524-source/texk/web2c/pdftexdir/pdftoepdf.cc
679 @@ -84,31 +84,6 @@ extern integer zround(double);
680 #define MASK_SUPPRESS_PTEX_PAGENUMBER 0x04
681 #define MASK_SUPPRESS_PTEX_INFODICT 0x08
682
683 -// PdfObject encapsulates the xpdf Object type,
684 -// and properly frees its resources on destruction.
685 -// Use obj-> to access members of the Object,
686 -// and &obj to get a pointer to the object.
687 -// It is no longer necessary to call Object::free explicitely.
688 -
689 -class PdfObject {
690 - public:
691 - PdfObject() { // nothing
692 - } ~PdfObject() {
693 - iObject.free();
694 - }
695 - Object *operator->() {
696 - return &iObject;
697 - }
698 - Object *operator&() {
699 - return &iObject;
700 - }
701 - private: // no copying or assigning
702 - PdfObject(const PdfObject &);
703 - void operator=(const PdfObject &);
704 - public:
705 - Object iObject;
706 -};
707 -
708 // When copying the Resources of the selected page, all objects are copied
709 // recusively top-down. Indirect objects however are not fetched during
710 // copying, but get a new object number from pdfTeX and then will be
711 @@ -212,18 +187,6 @@ static void delete_document(PdfDocument
712 delete pdf_doc;
713 }
714
715 -// Replacement for
716 -// Object *initDict(Dict *dict1){ initObj(objDict); dict = dict1; return this; }
717 -
718 -static void initDictFromDict(PdfObject & obj, Dict * dict)
719 -{
720 - obj->initDict(xref);
721 - for (int i = 0, l = dict->getLength(); i < l; i++) {
722 - Object obj1;
723 - obj->dictAdd(copyString(dict->getKey(i)), dict->getValNF(i, &obj1));
724 - }
725 -}
726 -
727 // --------------------------------------------------------------------
728
729 static int addEncoding(GfxFont * gfont)
730 @@ -320,10 +283,10 @@ static void copyName(char *s)
731
732 static void copyDictEntry(Object * obj, int i)
733 {
734 - PdfObject obj1;
735 + Object obj1;
736 copyName(obj->dictGetKey(i));
737 pdf_puts(" ");
738 - obj->dictGetValNF(i, &obj1);
739 + obj1 = obj->dictGetValNF(i);
740 copyObject(&obj1);
741 pdf_puts("\n");
742 }
743 @@ -376,17 +339,17 @@ static void copyStream(Stream * str)
744 static void copyProcSet(Object * obj)
745 {
746 int i, l;
747 - PdfObject procset;
748 + Object procset;
749 if (!obj->isArray())
750 pdftex_fail("PDF inclusion: invalid ProcSet array type <%s>",
751 obj->getTypeName());
752 pdf_puts("/ProcSet [ ");
753 for (i = 0, l = obj->arrayGetLength(); i < l; ++i) {
754 - obj->arrayGetNF(i, &procset);
755 - if (!procset->isName())
756 + procset = obj->arrayGetNF(i);
757 + if (!procset.isName())
758 pdftex_fail("PDF inclusion: invalid ProcSet entry type <%s>",
759 - procset->getTypeName());
760 - copyName(procset->getName());
761 + procset.getTypeName());
762 + copyName(procset.getName());
763 pdf_puts(" ");
764 }
765 pdf_puts("]\n");
766 @@ -394,10 +357,29 @@ static void copyProcSet(Object * obj)
767
768 #define REPLACE_TYPE1C true
769
770 +static bool embeddableFont(Object * fontdesc)
771 +{
772 + Object fontfile, ffsubtype;
773 +
774 + if (!fontdesc->isDict())
775 + return false;
776 + fontfile = fontdesc->dictLookup("FontFile");
777 + if (fontfile.isStream())
778 + return true;
779 + if (REPLACE_TYPE1C) {
780 + fontfile = fontdesc->dictLookup("FontFile3");
781 + if (!fontfile.isStream())
782 + return false;
783 + ffsubtype = fontfile.streamGetDict()->lookup("Subtype");
784 + return ffsubtype.isName() && !strcmp(ffsubtype.getName(), "Type1C");
785 + }
786 + return false;
787 +}
788 +
789 static void copyFont(char *tag, Object * fontRef)
790 {
791 - PdfObject fontdict, subtype, basefont, fontdescRef, fontdesc, charset,
792 - fontfile, ffsubtype, stemV;
793 + Object fontdict, subtype, basefont, fontdescRef, fontdesc, charset,
794 + stemV;
795 GfxFont *gfont;
796 fd_entry *fd;
797 fm_entry *fontmap;
798 @@ -413,33 +395,39 @@ static void copyFont(char *tag, Object *
799 }
800 // Only handle included Type1 (and Type1C) fonts; anything else will be copied.
801 // Type1C fonts are replaced by Type1 fonts, if REPLACE_TYPE1C is true.
802 - if (!fixedinclusioncopyfont && fontRef->fetch(xref, &fontdict)->isDict()
803 - && fontdict->dictLookup("Subtype", &subtype)->isName()
804 - && !strcmp(subtype->getName(), "Type1")
805 - && fontdict->dictLookup("BaseFont", &basefont)->isName()
806 - && fontdict->dictLookupNF("FontDescriptor", &fontdescRef)->isRef()
807 - && fontdescRef->fetch(xref, &fontdesc)->isDict()
808 - && (fontdesc->dictLookup("FontFile", &fontfile)->isStream()
809 - || (REPLACE_TYPE1C
810 - && fontdesc->dictLookup("FontFile3", &fontfile)->isStream()
811 - && fontfile->streamGetDict()->lookup("Subtype",
812 - &ffsubtype)->isName()
813 - && !strcmp(ffsubtype->getName(), "Type1C")))
814 - && (fontmap = lookup_fontmap(basefont->getName())) != NULL) {
815 + fontdict = fontRef->fetch(xref);
816 + fontdesc = Object(objNull);
817 + if (fontdict.isDict()) {
818 + subtype = fontdict.dictLookup("Subtype");
819 + basefont = fontdict.dictLookup("BaseFont");
820 + fontdescRef = fontdict.dictLookupNF("FontDescriptor");
821 + if (fontdescRef.isRef()) {
822 + fontdesc = fontdescRef.fetch(xref);
823 + }
824 + }
825 + if (!fixedinclusioncopyfont && fontdict.isDict()
826 + && subtype.isName()
827 + && !strcmp(subtype.getName(), "Type1")
828 + && basefont.isName()
829 + && fontdescRef.isRef()
830 + && fontdesc.isDict()
831 + && embeddableFont(&fontdesc)
832 + && (fontmap = lookup_fontmap(basefont.getName())) != NULL) {
833 // round /StemV value, since the PDF input is a float
834 // (see Font Descriptors in PDF reference), but we only store an
835 // integer, since we don't want to change the struct.
836 - fontdesc->dictLookup("StemV", &stemV);
837 - fd = epdf_create_fontdescriptor(fontmap, zround(stemV->getNum()));
838 - if (fontdesc->dictLookup("CharSet", &charset) &&
839 - charset->isString() && is_subsetable(fontmap))
840 - epdf_mark_glyphs(fd, charset->getString()->getCString());
841 + stemV = fontdesc.dictLookup("StemV");
842 + fd = epdf_create_fontdescriptor(fontmap, zround(stemV.getNum()));
843 + charset = fontdesc.dictLookup("CharSet");
844 + if (!charset.isNull() &&
845 + charset.isString() && is_subsetable(fontmap))
846 + epdf_mark_glyphs(fd, charset.getString()->getCString());
847 else
848 embed_whole_font(fd);
849 - addFontDesc(fontdescRef->getRef(), fd);
850 + addFontDesc(fontdescRef.getRef(), fd);
851 copyName(tag);
852 gfont = GfxFont::makeFont(xref, tag, fontRef->getRef(),
853 - fontdict->getDict());
854 + fontdict.getDict());
855 pdf_printf(" %d 0 R ", addFont(fontRef->getRef(), fd,
856 addEncoding(gfont)));
857 } else {
858 @@ -451,24 +439,24 @@ static void copyFont(char *tag, Object *
859
860 static void copyFontResources(Object * obj)
861 {
862 - PdfObject fontRef;
863 + Object fontRef;
864 int i, l;
865 if (!obj->isDict())
866 pdftex_fail("PDF inclusion: invalid font resources dict type <%s>",
867 obj->getTypeName());
868 pdf_puts("/Font << ");
869 for (i = 0, l = obj->dictGetLength(); i < l; ++i) {
870 - obj->dictGetValNF(i, &fontRef);
871 - if (fontRef->isRef())
872 + fontRef = obj->dictGetValNF(i);
873 + if (fontRef.isRef())
874 copyFont(obj->dictGetKey(i), &fontRef);
875 - else if (fontRef->isDict()) { // some programs generate pdf with embedded font object
876 + else if (fontRef.isDict()) { // some programs generate pdf with embedded font object
877 copyName(obj->dictGetKey(i));
878 pdf_puts(" ");
879 copyObject(&fontRef);
880 }
881 else
882 pdftex_fail("PDF inclusion: invalid font in reference type <%s>",
883 - fontRef->getTypeName());
884 + fontRef.getTypeName());
885 }
886 pdf_puts(">>\n");
887 }
888 @@ -557,7 +545,7 @@ static char *convertNumToPDF(double n)
889
890 static void copyObject(Object * obj)
891 {
892 - PdfObject obj1;
893 + Object obj1;
894 int i, l, c;
895 Ref ref;
896 char *p;
897 @@ -601,8 +589,8 @@ static void copyObject(Object * obj)
898 } else if (obj->isArray()) {
899 pdf_puts("[");
900 for (i = 0, l = obj->arrayGetLength(); i < l; ++i) {
901 - obj->arrayGetNF(i, &obj1);
902 - if (!obj1->isName())
903 + obj1 = obj->arrayGetNF(i);
904 + if (!obj1.isName())
905 pdf_puts(" ");
906 copyObject(&obj1);
907 }
908 @@ -612,9 +600,8 @@ static void copyObject(Object * obj)
909 copyDict(obj);
910 pdf_puts(">>");
911 } else if (obj->isStream()) {
912 - initDictFromDict(obj1, obj->streamGetDict());
913 pdf_puts("<<\n");
914 - copyDict(&obj1);
915 + copyDict(obj->getStream()->getDictObject());
916 pdf_puts(">>\n");
917 pdf_puts("stream\n");
918 copyStream(obj->getStream()->getUndecodedStream());
919 @@ -638,9 +625,8 @@ static void writeRefs()
920 InObj *r;
921 for (r = inObjList; r != 0; r = r->next) {
922 if (!r->written) {
923 - Object obj1;
924 r->written = 1;
925 - xref->fetch(r->ref.num, r->ref.gen, &obj1);
926 + Object obj1 = xref->fetch(r->ref.num, r->ref.gen);
927 if (r->type == objFont) {
928 assert(!obj1.isStream());
929 pdfbeginobj(r->num, 2); // \pdfobjcompresslevel = 2 is for this
930 @@ -656,7 +642,6 @@ static void writeRefs()
931 pdf_puts("\n");
932 pdfendobj();
933 }
934 - obj1.free();
935 }
936 }
937 }
938 @@ -839,8 +824,8 @@ void write_epdf(void)
939 Page *page;
940 Ref *pageRef;
941 Dict *pageDict;
942 - PdfObject contents, obj1, obj2, pageObj, dictObj;
943 - PdfObject groupDict;
944 + Object contents, obj1, obj2, pageObj, dictObj;
945 + Object groupDict;
946 bool writeSepGroup = false;
947 Object info;
948 char *key;
949 @@ -867,8 +852,8 @@ void write_epdf(void)
950 encodingList = 0;
951 page = pdf_doc->doc->getCatalog()->getPage(epdf_selected_page);
952 pageRef = pdf_doc->doc->getCatalog()->getPageRef(epdf_selected_page);
953 - xref->fetch(pageRef->num, pageRef->gen, &pageObj);
954 - pageDict = pageObj->getDict();
955 + pageObj = xref->fetch(pageRef->num, pageRef->gen);
956 + pageDict = pageObj.getDict();
957 rotate = page->getRotate();
958 PDFRectangle *pagebox;
959 // write the Page header
960 @@ -886,7 +871,7 @@ void write_epdf(void)
961 pdf_printf("/%s.PageNumber %i\n", pdfkeyprefix, (int) epdf_selected_page);
962 }
963 if ((suppress_ptex_info & MASK_SUPPRESS_PTEX_INFODICT) == 0) {
964 - pdf_doc->doc->getDocInfoNF(&info);
965 + info = pdf_doc->doc->getDocInfoNF();
966 if (info.isRef()) {
967 // the info dict must be indirect (PDF Ref p. 61)
968 pdf_printf("/%s.InfoDict ", pdfkeyprefix);
969 @@ -942,14 +927,14 @@ void write_epdf(void)
970 pdf_puts(stripzeros(s));
971
972 // Metadata validity check (as a stream it must be indirect)
973 - pageDict->lookupNF("Metadata", &dictObj);
974 - if (!dictObj->isNull() && !dictObj->isRef())
975 + dictObj = pageDict->lookupNF("Metadata");
976 + if (!dictObj.isNull() && !dictObj.isRef())
977 pdftex_warn("PDF inclusion: /Metadata must be indirect object");
978
979 // copy selected items in Page dictionary except Resources & Group
980 for (i = 0; pageDictKeys[i] != NULL; i++) {
981 - pageDict->lookupNF(pageDictKeys[i], &dictObj);
982 - if (!dictObj->isNull()) {
983 + dictObj = pageDict->lookupNF(pageDictKeys[i]);
984 + if (!dictObj.isNull()) {
985 pdf_newline();
986 pdf_printf("/%s ", pageDictKeys[i]);
987 copyObject(&dictObj); // preserves indirection
988 @@ -957,8 +942,8 @@ void write_epdf(void)
989 }
990
991 // handle page group
992 - pageDict->lookupNF("Group", &dictObj);
993 - if (!dictObj->isNull()) {
994 + dictObj = pageDict->lookupNF("Group");
995 + if (!dictObj.isNull()) {
996 if (pdfpagegroupval == 0) {
997 // another pdf with page group was included earlier on the
998 // same page; copy the Group entry as is. See manual for
999 @@ -972,11 +957,11 @@ void write_epdf(void)
1000 copyObject(&dictObj);
1001 } else {
1002 // write Group dict as a separate object, since the Page dict also refers to it
1003 - pageDict->lookup("Group", &dictObj);
1004 - if (!dictObj->isDict())
1005 + dictObj = pageDict->lookup("Group");
1006 + if (!dictObj.isDict())
1007 pdftex_fail("PDF inclusion: /Group dict missing");
1008 writeSepGroup = true;
1009 - initDictFromDict(groupDict, page->getGroup());
1010 + groupDict = Object(page->getGroup());
1011 pdf_printf("/Group %ld 0 R\n", (long)pdfpagegroupval);
1012 }
1013 }
1014 @@ -989,14 +974,14 @@ void write_epdf(void)
1015 pdftex_warn
1016 ("PDF inclusion: /Resources missing. 'This practice is not recommended' (PDF Ref)");
1017 } else {
1018 - initDictFromDict(obj1, page->getResourceDict());
1019 + Object *obj1 = page->getResourceDictObject();
1020 if (!obj1->isDict())
1021 pdftex_fail("PDF inclusion: invalid resources dict type <%s>",
1022 obj1->getTypeName());
1023 pdf_newline();
1024 pdf_puts("/Resources <<\n");
1025 for (i = 0, l = obj1->dictGetLength(); i < l; ++i) {
1026 - obj1->dictGetVal(i, &obj2);
1027 + obj2 = obj1->dictGetVal(i);
1028 key = obj1->dictGetKey(i);
1029 if (strcmp("Font", key) == 0)
1030 copyFontResources(&obj2);
1031 @@ -1009,8 +994,8 @@ void write_epdf(void)
1032 }
1033
1034 // write the page contents
1035 - page->getContents(&contents);
1036 - if (contents->isStream()) {
1037 + contents = page->getContents();
1038 + if (contents.isStream()) {
1039
1040 // Variant A: get stream and recompress under control
1041 // of \pdfcompresslevel
1042 @@ -1021,36 +1006,35 @@ void write_epdf(void)
1043
1044 // Variant B: copy stream without recompressing
1045 //
1046 - contents->streamGetDict()->lookup("F", &obj1);
1047 - if (!obj1->isNull()) {
1048 + obj1 = contents.streamGetDict()->lookup("F");
1049 + if (!obj1.isNull()) {
1050 pdftex_fail("PDF inclusion: Unsupported external stream");
1051 }
1052 - contents->streamGetDict()->lookup("Length", &obj1);
1053 - assert(!obj1->isNull());
1054 + obj1 = contents.streamGetDict()->lookup("Length");
1055 + assert(!obj1.isNull());
1056 pdf_puts("/Length ");
1057 copyObject(&obj1);
1058 pdf_puts("\n");
1059 - contents->streamGetDict()->lookup("Filter", &obj1);
1060 - if (!obj1->isNull()) {
1061 + obj1 = contents.streamGetDict()->lookup("Filter");
1062 + if (!obj1.isNull()) {
1063 pdf_puts("/Filter ");
1064 copyObject(&obj1);
1065 pdf_puts("\n");
1066 - contents->streamGetDict()->lookup("DecodeParms", &obj1);
1067 - if (!obj1->isNull()) {
1068 + obj1 = contents.streamGetDict()->lookup("DecodeParms");
1069 + if (!obj1.isNull()) {
1070 pdf_puts("/DecodeParms ");
1071 copyObject(&obj1);
1072 pdf_puts("\n");
1073 }
1074 }
1075 pdf_puts(">>\nstream\n");
1076 - copyStream(contents->getStream()->getUndecodedStream());
1077 + copyStream(contents.getStream()->getUndecodedStream());
1078 pdfendstream();
1079 - } else if (contents->isArray()) {
1080 + } else if (contents.isArray()) {
1081 pdfbeginstream();
1082 - for (i = 0, l = contents->arrayGetLength(); i < l; ++i) {
1083 - Object contentsobj;
1084 - copyStream((contents->arrayGet(i, &contentsobj))->getStream());
1085 - contentsobj.free();
1086 + for (i = 0, l = contents.arrayGetLength(); i < l; ++i) {
1087 + Object contentsobj = contents.arrayGet(i);
1088 + copyStream(contentsobj.getStream());
1089 if (i < l - 1)
1090 pdf_newline(); // add a newline after each stream except the last
1091 }
1092 Index: texlive-20170524-source/texk/web2c/pdftexdir/pdftosrc.cc
1093 ===================================================================
1094 --- texlive-20170524-source.orig/texk/web2c/pdftexdir/pdftosrc.cc
1095 +++ texlive-20170524-source/texk/web2c/pdftexdir/pdftosrc.cc
1096 @@ -86,22 +86,20 @@ int main(int argc, char *argv[])
1097 objgen = atoi(argv[3]);
1098 }
1099 xref = doc->getXRef();
1100 - catalogDict.initNull();
1101 - xref->getCatalog(&catalogDict);
1102 + catalogDict = xref->getCatalog();
1103 if (!catalogDict.isDict("Catalog")) {
1104 fprintf(stderr, "No Catalog found\n");
1105 exit(1);
1106 }
1107 - srcStream.initNull();
1108 + srcStream = Object(objNull);
1109 if (objnum == 0) {
1110 - catalogDict.dictLookup("SourceObject", &srcStream);
1111 + srcStream = catalogDict.dictLookup("SourceObject");
1112 static char const_SourceFile[] = "SourceFile";
1113 if (!srcStream.isStream(const_SourceFile)) {
1114 fprintf(stderr, "No SourceObject found\n");
1115 exit(1);
1116 }
1117 - srcName.initNull();
1118 - srcStream.getStream()->getDict()->lookup("SourceName", &srcName);
1119 + srcName = srcStream.getStream()->getDict()->lookup("SourceName");
1120 if (!srcName.isString()) {
1121 fprintf(stderr, "No SourceName found\n");
1122 exit(1);
1123 @@ -110,7 +108,7 @@ int main(int argc, char *argv[])
1124 // We cannot free srcName, as objname shares its string.
1125 // srcName.free();
1126 } else if (objnum > 0) {
1127 - xref->fetch(objnum, objgen, &srcStream);
1128 + srcStream = xref->fetch(objnum, objgen);
1129 if (!srcStream.isStream()) {
1130 fprintf(stderr, "Not a Stream object\n");
1131 exit(1);
1132 @@ -159,29 +157,26 @@ int main(int argc, char *argv[])
1133 int localOffset = 0;
1134 Guint firstOffset;
1135
1136 - assert(xref->fetch(e->offset, 0, &objStr)->isStream());
1137 - nObjects = objStr.streamGetDict()->lookup("N", &obj1)->getInt();
1138 - obj1.free();
1139 - first = objStr.streamGetDict()->lookup("First", &obj1)->getInt();
1140 - obj1.free();
1141 + objStr = xref->fetch(e->offset, 0);
1142 + assert(objStr.isStream());
1143 + obj1 = objStr.streamGetDict()->lookup("N");
1144 + nObjects = obj1.getInt();
1145 + obj1 = objStr.streamGetDict()->lookup("First");
1146 + first = obj1.getInt();
1147 firstOffset = objStr.getStream()->getBaseStream()->getStart() + first;
1148
1149 // parse the header: object numbers and offsets
1150 objStr.streamReset();
1151 - obj1.initNull();
1152 - str = new EmbedStream(objStr.getStream(), &obj1, gTrue, first);
1153 + str = new EmbedStream(objStr.getStream(), Object(objNull), gTrue, first);
1154 parser = new Parser(xref, new Lexer(xref, str), gFalse);
1155 for (n = 0; n < nObjects; ++n) {
1156 - parser->getObj(&obj1);
1157 - parser->getObj(&obj2);
1158 + obj1 = parser->getObj();
1159 + obj2 = parser->getObj();
1160 if (n == e->gen)
1161 localOffset = obj2.getInt();
1162 - obj1.free();
1163 - obj2.free();
1164 }
1165 while (str->getChar() != EOF) ;
1166 delete parser;
1167 - objStr.free();
1168
1169 fprintf(outfile, "%.10lu 00000 n\n",
1170 (long unsigned)(firstOffset + localOffset));
1171 @@ -192,7 +187,6 @@ int main(int argc, char *argv[])
1172 s->reset();
1173 while ((c = s->getChar()) != EOF)
1174 fputc(c, outfile);
1175 - srcStream.free();
1176 }
1177 if (objnum == 0)
1178 fprintf(stderr, "Source file extracted to %s\n", outname);
1179 @@ -201,7 +195,6 @@ int main(int argc, char *argv[])
1180 else
1181 fprintf(stderr, "Cross-reference table extracted to %s\n", outname);
1182 fclose(outfile);
1183 - catalogDict.free();
1184 delete doc;
1185 delete globalParams;
1186 }