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