Skip to content
This repository has been archived by the owner on Mar 6, 2023. It is now read-only.

Commit

Permalink
sync with experimental r7119 -- trunk
Browse files Browse the repository at this point in the history
git-svn-id: https://serveur-svn.lri.fr/svn/modhel/luatex/trunk@7120 0b2b3880-5936-4365-a048-eb17d2e5a6bf
  • Loading branch information
luigiScarso committed Mar 17, 2019
1 parent 905e26c commit f659b81
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 59 deletions.
50 changes: 32 additions & 18 deletions source/texk/web2c/luatexdir/image/pdftoepdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,15 +552,23 @@ static void writeRefs(PDF pdf, PdfDocument * pdf_doc)
ppref * ref ;
ppxref * xref = ppdoc_xref (pdf_doc->pdfe);
for (r = pdf_doc->inObjList; r != NULL;) {
ref = ppxref_find (xref, (ppuint) r->objnum);
obj = ppref_obj(ref);
if (obj->type == PPSTREAM) {
pdf_begin_obj(pdf, r->num, OBJSTM_NEVER);
if (xref != NULL) {
ref = ppxref_find(xref, (ppuint) r->objnum);
if (ref != NULL) {
obj = ppref_obj(ref);
if (obj->type == PPSTREAM) {
pdf_begin_obj(pdf, r->num, OBJSTM_NEVER);
} else {
pdf_begin_obj(pdf, r->num, 2);
}
copyObject(pdf, pdf_doc, obj);
pdf_end_obj(pdf);
} else {
formatted_warning("pdf inclusion","ignoring missing object %i, case 1\n",(int) r->objnum);
}
} else {
pdf_begin_obj(pdf, r->num, 2);
formatted_warning("pdf inclusion","ignoring missing object %i, case 2\n",(int) r->objnum);
}
copyObject(pdf, pdf_doc, obj);
pdf_end_obj(pdf);
n = r->next;
free(r);
r = n;
Expand Down Expand Up @@ -995,19 +1003,25 @@ int write_epdf_object(PDF pdf, image_dict * idict, int n)
} else {
PdfDocument * pdf_doc = refPdfDocument(img_filepath(idict), FE_FAIL, img_userpassword(idict), img_ownerpassword(idict));
ppdoc * pdfe = pdf_doc->pdfe;
ppref * ref = ppxref_find(ppdoc_xref(pdfe), (ppuint) n);
if (ref != NULL) {
ppobj *obj;
num = pdf->obj_count++;
obj = ppref_obj(ref);
if (obj->type == PPSTREAM) {
pdf_begin_obj(pdf, num, OBJSTM_NEVER);
if (ppdoc_xref(pdfe)) {
ppref * ref = ppxref_find(ppdoc_xref(pdfe), (ppuint) n);
if (ref != NULL) {
ppobj *obj;
num = pdf->obj_count++;
obj = ppref_obj(ref);
if (obj->type == PPSTREAM) {
pdf_begin_obj(pdf, num, OBJSTM_NEVER);
} else {
pdf_begin_obj(pdf, num, 2);
}
copyObject(pdf, pdf_doc, obj);
pdf_end_obj(pdf);
writeRefs(pdf, pdf_doc);
} else {
pdf_begin_obj(pdf, num, 2);
formatted_warning("pdf inclusion","ignoring missing image %i, case 1\n",(int) n);
}
copyObject(pdf, pdf_doc, obj);
pdf_end_obj(pdf);
writeRefs(pdf, pdf_doc);
} else {
formatted_warning("pdf inclusion","ignoring missing image %i, case 2\n",(int) n);
}
if (! img_keepopen(idict)) {
unrefPdfDocument(img_filepath(idict));
Expand Down
99 changes: 59 additions & 40 deletions source/texk/web2c/luatexdir/lua/lpdfelib.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ static int pushstreamonly(lua_State * L, ppstream * stream)

static int pushreference(lua_State * L, ppref * reference)
{
if (reference != NULL) {
if (reference != NULL && reference->number != 0) {
pdfe_push_reference;
lua_pushinteger(L,reference->number);
return 2;
Expand Down Expand Up @@ -502,8 +502,10 @@ static int pdfelib_getfromarray(lua_State * L)
int index = luaL_checkint(L, 2) - 1;
if (index < a->array->size) {
ppobj *object = pparray_at(a->array,index);
lua_pushinteger(L,(int) object->type);
return 1 + pushvalue(L,object);
if (object != NULL) {
lua_pushinteger(L,(int) object->type);
return 1 + pushvalue(L,object);
}
}
}
return 0;
Expand All @@ -524,10 +526,12 @@ static int pdfelib_getfromdictionary(lua_State * L)
int index = luaL_checkint(L, 2) - 1;
if (index < d->dictionary->size) {
ppobj *object = ppdict_at(d->dictionary,index);
ppname key = ppdict_key(d->dictionary,index);
lua_pushstring(L,(const char *) key);
lua_pushinteger(L,(int) object->type);
return 2 + pushvalue(L,object);
if (object != NULL) {
ppname key = ppdict_key(d->dictionary,index);
lua_pushstring(L,(const char *) key);
lua_pushinteger(L,(int) object->type);
return 2 + pushvalue(L,object);
}
}
}
}
Expand All @@ -550,10 +554,12 @@ static int pdfelib_getfromstream(lua_State * L)
int index = luaL_checkint(L, 2) - 1;
if (index < d->size) {
ppobj *object = ppdict_at(d,index);
ppname key = ppdict_key(d,index);
lua_pushstring(L,(const char *) key);
lua_pushinteger(L,(int) object->type);
return 2 + pushvalue(L,object);
if (object != NULL) {
ppname key = ppdict_key(d,index);
lua_pushstring(L,(const char *) key);
lua_pushinteger(L,(int) object->type);
return 2 + pushvalue(L,object);
}
}
}
}
Expand Down Expand Up @@ -622,14 +628,17 @@ static int pdfelib_arraytotable(lua_State * L)
if (a != NULL) {
int flat = lua_isboolean(L,2);
int i = 0;
int j = 0;
lua_createtable(L,i,0);
/* table */
for (i=0;i<a->array->size;i++) {
ppobj *object = pparray_at(a->array,i);
pdfelib_totable(L,object,flat);
/* table { type, [value], [extra], [more] } */
lua_rawseti(L,-2,i+1);
/* table[i] = { type, [value], [extra], [more] } */
if (object != NULL) {
pdfelib_totable(L,object,flat);
/* table { type, [value], [extra], [more] } */
lua_rawseti(L,-2,++j);
/* table[i] = { type, [value], [extra], [more] } */
}
}
return 1;
}
Expand All @@ -646,13 +655,15 @@ static int pdfelib_dictionarytotable(lua_State * L)
/* table */
for (i=0;i<d->dictionary->size;i++) {
ppobj *object = ppdict_at(d->dictionary,i);
ppname key = ppdict_key(d->dictionary,i);
lua_pushstring(L,(const char *) key);
/* table key */
pdfelib_totable(L,object,flat);
/* table key { type, [value], [extra], [more] } */
lua_rawset(L,-3);
/* table[key] = { type, [value], [extra] } */
if (object != NULL) {
ppname key = ppdict_key(d->dictionary,i);
lua_pushstring(L,(const char *) key);
/* table key */
pdfelib_totable(L,object,flat);
/* table key { type, [value], [extra], [more] } */
lua_rawset(L,-3);
/* table[key] = { type, [value], [extra] } */
}
}
return 1;
}
Expand All @@ -676,22 +687,25 @@ static int pdfelib_pagestotable(lua_State * L)
ppdoc *d = p->document;
ppref *r = NULL;
int i = 0;
int j = 0;
lua_createtable(L,ppdoc_page_count(d),0);
/* pages[1..n] */
for (r = ppdoc_first_page(d), i = 1; r != NULL; r = ppdoc_next_page(d), ++i) {
lua_createtable(L,3,0);
pushdictionary(L,ppref_obj(r)->dict);
/* table dictionary n */
lua_rawseti(L,-3,2);
/* table dictionary */
lua_rawseti(L,-2,1);
/* table */
lua_pushinteger(L,r->number);
/* table reference */
lua_rawseti(L,-2,3);
/* table */
lua_rawseti(L,-2,i);
/* pages[i] = { dictionary, size, objnum } */
if (ppref_obj(r) != NULL) {
pushdictionary(L,ppref_obj(r)->dict);
/* table dictionary n */
lua_rawseti(L,-3,2);
/* table dictionary */
lua_rawseti(L,-2,1);
/* table */
lua_pushinteger(L,r->number);
/* table reference */
lua_rawseti(L,-2,3);
/* table */
lua_rawseti(L,-2,++j);
/* pages[i] = { dictionary, size, objnum } */
}
}
return 1;
}
Expand Down Expand Up @@ -1158,10 +1172,15 @@ static int pdfelib_getbox(lua_State * L)
static int pdfelib_getfromreference(lua_State * L)
{
pdfe_reference *r = check_isreference(L, 1);
if (r != NULL) {
ppobj *o = ppref_obj(ppxref_find(r->xref, (ppuint) r->onum));
lua_pushinteger(L,o->type);
return 1 + pushvalue(L,o);
if (r != NULL && r->xref != NULL) {
ppref *rr = ppxref_find(r->xref, (ppuint) r->onum);
if (rr != NULL) {
ppobj *o = ppref_obj(rr);
if (o != NULL) {
lua_pushinteger(L,o->type);
return 1 + pushvalue(L,o);
}
}
}
return 0;
}
Expand Down Expand Up @@ -1213,8 +1232,8 @@ static int pdfelib_getfromreference(lua_State * L)
*/

# define pdfelib_get_indirect_o(p) \
ppref *r = ppxref_find(((pdfe_reference *) p)->xref, (ppuint) (((pdfe_reference *) p)->onum)); \
ppobj *o = ppref_obj(r); \
ppref *r = (((pdfe_reference *) p)->xref != NULL) ? ppxref_find(((pdfe_reference *) p)->xref, (ppuint) (((pdfe_reference *) p)->onum)) : NULL; \
ppobj *o = (r != NULL) ? ppref_obj(r) : NULL; \

# define pdfelib_get_value_direct(get_d,get_a) do { \
int t = lua_type(L,2); \
Expand Down
2 changes: 1 addition & 1 deletion source/texk/web2c/luatexdir/luatex_svnversion.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define luatex_svn_revision 7116
#define luatex_svn_revision 7119

0 comments on commit f659b81

Please sign in to comment.