--- texk/web2c/xetexdir/pdfimage.cpp +++ texk/web2c/xetexdir/pdfimage.cpp 2012-04-13 16:52:54.939126587 +0200 @@ -38,9 +38,18 @@ authorization from the copyright holders #include #include -#include "PDFDoc.h" -#include "Catalog.h" -#include "Page.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "XeTeX_ext.h" --- texk/web2c/xetexdir/xetexextra.h +++ texk/web2c/xetexdir/xetexextra.h 2011-09-13 14:45:00.256426839 +0000 @@ -56,7 +56,11 @@ Foundation, Inc., 675 Mass Ave, Cambridg #include /* for ETEX_VERSION */ #include /* for XETEX_VERSION */ -#define BANNER "This is XeTeX, Version 3.1415926-" ETEX_VERSION "-" XETEX_VERSION +#ifdef POPPLER_VERSION +# define BANNER "This is XeTeX using libpoppler, Version 3.1415926-" ETEX_VERSION "-" XETEX_VERSION +#else +# define BANNER "This is XeTeX, Version 3.1415926-" ETEX_VERSION "-" XETEX_VERSION +#endif #define COPYRIGHT_HOLDER "SIL International and Jonathan Kew" #define AUTHOR "Jonathan Kew" #define PROGRAM_HELP XETEXHELP --- texk/web2c/luatexdir/image/epdf.h +++ texk/web2c/luatexdir/image/epdf.h 2011-09-13 14:49:39.051927771 +0000 @@ -36,20 +36,20 @@ # include # include # include -# include "Object.h" -# include "Stream.h" -# include "Gfx.h" -# include "Annot.h" -# include "Array.h" -# include "Dict.h" -# include "XRef.h" -# include "Catalog.h" -# include "Link.h" -# include "Page.h" -# include "GfxFont.h" -# include "PDFDoc.h" -# include "GlobalParams.h" -# include "Error.h" +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include extern "C" { --- texk/web2c/pdftexdir/pdftexextra.h +++ texk/web2c/pdftexdir/pdftexextra.h 2011-09-13 14:46:22.147926062 +0000 @@ -25,7 +25,11 @@ with this program. If not, see /* for PDFTEX_VERSION */ #include /* for ETEX_VERSION */ -#define BANNER "This is pdfTeX, Version 3.1415926-" ETEX_VERSION "-" PDFTEX_VERSION +#ifdef POPPLER_VERSION +# define BANNER "This is pdfTeX using libpoppler, Version 3.1415926-" ETEX_VERSION "-" PDFTEX_VERSION +#else +# define BANNER "This is pdfTeX, Version 3.1415926-" ETEX_VERSION "-" PDFTEX_VERSION +#endif #define COPYRIGHT_HOLDER "Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX)" #define AUTHOR NULL #define PROGRAM_HELP PDFTEXHELP --- texk/web2c/pdftexdir/pdftoepdf.cc +++ texk/web2c/pdftexdir/pdftoepdf.cc 2012-04-13 16:56:57.780022236 +0200 @@ -21,7 +21,6 @@ with this program. If not, see . */ -#define boolean MINGW32_boolean #include #include @@ -30,6 +29,10 @@ with this program. If not, see #include +extern "C" { +#include +} + #ifdef POPPLER_VERSION #include #include @@ -44,21 +47,18 @@ with this program. If not, see #endif #include - -#include "Object.h" -#include "Stream.h" -#include "Array.h" -#include "Dict.h" -#include "XRef.h" -#include "Catalog.h" -#include "Link.h" -#include "Page.h" -#include "GfxFont.h" -#include "PDFDoc.h" -#include "GlobalParams.h" -#include "Error.h" - -#undef boolean +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // This file is mostly C and not very much C++; it's just used to interface // the functions of xpdf, which happens to be written in C++. --- texk/web2c/pdftexdir/pdftosrc.cc +++ texk/web2c/pdftexdir/pdftosrc.cc 2012-04-13 16:59:10.136510522 +0200 @@ -23,6 +23,10 @@ with this program. If not, see #include +extern "C" { +#include +} + #ifdef POPPLER_VERSION #define GString GooString #define xpdfVersion POPPLER_VERSION @@ -37,20 +41,20 @@ with this program. If not, see #endif #include - -#include "Object.h" -#include "Stream.h" -#include "Lexer.h" -#include "Parser.h" -#include "Array.h" -#include "Dict.h" -#include "XRef.h" -#include "Catalog.h" -#include "Page.h" -#include "GfxFont.h" -#include "PDFDoc.h" -#include "GlobalParams.h" -#include "Error.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include static XRef *xref = 0; @@ -130,7 +134,7 @@ int main(int argc, char *argv[]) exit(1); } if (extract_xref_table) { - int size = xref->getSize(); + int size = xref->getNumObjects(); int i; for (i = 0; i < size; i++) { if (xref->getEntry(i)->offset == 0xffffffff) --- texk/web2c/pdftexdir/utils.c +++ texk/web2c/pdftexdir/utils.c 2009-09-04 08:38:04.000000000 +0000 @@ -42,12 +42,12 @@ with this program. If not, see +# define xpdfVersion POPPLER_VERSION +# define xpdfString "poppler" #else -#include "xpdf/config.h" /* just to get the xpdf version */ -#define xpdfString "xpdf" +# include "xpdf/config.h" /* just to get the xpdf version */ +# define xpdfString "xpdf" #endif #define check_nprintf(size_get, size_want) \ --- texk/web2c/pdftexdir/writefont.c +++ texk/web2c/pdftexdir/writefont.c 2009-09-04 08:39:19.000000000 +0000 @@ -17,6 +17,9 @@ You should have received a copy of the G with this program. If not, see . */ +#ifdef POPPLER_VERSION +# include +#endif #include "ptexlib.h" /**********************************************************************/ --- texk/web2c/luatexdir/lua/lepdflib.cc +++ texk/web2c/luatexdir/lua/lepdflib.cc 2012-05-18 14:56:15.722565710 +0000 @@ -1,7 +1,7 @@ /* lepdflib.cc - Copyright 2009-2011 Taco Hoekwater - Copyright 2009-2011 Hartmut Henkel + Copyright 2009-2012 Taco Hoekwater + Copyright 2009-2012 Hartmut Henkel This file is part of LuaTeX. @@ -49,15 +49,13 @@ static const char *ErrorCodeNames[] = { //********************************************************************** #define M_Annot "Annot" -#define M_AnnotBorder "AnnotBorder" -#define M_AnnotBorderStyle "AnnotBorderStyle" #define M_Annots "Annots" #define M_Array "Array" #define M_Catalog "Catalog" -#define M_EmbFile "EmbFile" #define M_Dict "Dict" #define M_GooString "GooString" #define M_LinkDest "LinkDest" +#define M_Link "Link" #define M_Links "Links" #define M_Object "Object" #define M_Page "Page" @@ -65,8 +63,8 @@ static const char *ErrorCodeNames[] = { #define M_PDFRectangle "PDFRectangle" #define M_Ref "Ref" #define M_Stream "Stream" -#define M_XRef "XRef" #define M_XRefEntry "XRefEntry" +#define M_XRef "XRef" //********************************************************************** @@ -84,16 +82,9 @@ static udstruct *new_##type##_userdata(l new_poppler_userdata(PDFDoc); new_poppler_userdata(Annot); -new_poppler_userdata(AnnotBorder); -//new_poppler_userdata(AnnotBorderStyle); -new_poppler_userdata(Annots); new_poppler_userdata(Array); new_poppler_userdata(Catalog); new_poppler_userdata(Dict); -#ifdef EMBFILE_IN_CATALOG_H -new_poppler_userdata(EmbFile); -#endif -//new_poppler_userdata(GooString); new_poppler_userdata(LinkDest); new_poppler_userdata(Links); new_poppler_userdata(Object); @@ -102,7 +93,6 @@ new_poppler_userdata(PDFRectangle); new_poppler_userdata(Ref); new_poppler_userdata(Stream); new_poppler_userdata(XRef); -//new_poppler_userdata(XRefEntry); //********************************************************************** @@ -137,53 +127,6 @@ static int l_open_PDFDoc(lua_State * L) return 1; // doc path } -static int l_new_Annot(lua_State * L) -{ - udstruct *uxref, *udict, *ucatalog, *uref, *uout; - uxref = (udstruct *) luaL_checkudata(L, 1, M_XRef); - udict = (udstruct *) luaL_checkudata(L, 2, M_Dict); - ucatalog = (udstruct *) luaL_checkudata(L, 3, M_Catalog); - uref = (udstruct *) luaL_checkudata(L, 4, M_Ref); - if (uxref->pd != ucatalog->pd || uxref->pd != udict->pd - || uxref->pd != uref->pd) - pdfdoc_differs_error(L); - if ((uxref->pd != NULL && uxref->pd->pc != uxref->pc) || - (ucatalog->pd != NULL && ucatalog->pd->pc != ucatalog->pc) || - (udict->pd != NULL && udict->pd->pc != udict->pc) || - (uref->pd != NULL && uref->pd->pc != uref->pc)) - pdfdoc_changed_error(L); - uout = new_Annot_userdata(L); - uout->d = - new Annot((XRef *) uxref->d, (Dict *) udict->d, (Catalog *) ucatalog->d, - (Object *) uref->d); - uout->atype = ALLOC_LEPDF; - uout->pc = uxref->pc; - uout->pd = uxref->pd; - return 1; -} - -static int l_new_Annots(lua_State * L) -{ - udstruct *uxref, *ucatalog, *uannotsobj, *uout; - uxref = (udstruct *) luaL_checkudata(L, 1, M_XRef); - ucatalog = (udstruct *) luaL_checkudata(L, 2, M_Catalog); - uannotsobj = (udstruct *) luaL_checkudata(L, 3, M_Object); - if (uxref->pd != ucatalog->pd || uxref->pd != uannotsobj->pd) - pdfdoc_differs_error(L); - if ((uxref->pd != NULL && uxref->pd->pc != uxref->pc) - || (ucatalog->pd != NULL && ucatalog->pd->pc != ucatalog->pc) - || (uannotsobj->pd != NULL && uannotsobj->pd->pc != uannotsobj->pc)) - pdfdoc_changed_error(L); - uout = new_Annots_userdata(L); - uout->d = - new Annots((XRef *) uxref->d, (Catalog *) ucatalog->d, - (Object *) uannotsobj->d); - uout->atype = ALLOC_LEPDF; - uout->pc = uxref->pc; - uout->pd = uxref->pd; - return 1; -} - static int l_new_Array(lua_State * L) { udstruct *uxref, *uout; @@ -238,8 +181,6 @@ static int l_new_PDFRectangle(lua_State static const struct luaL_Reg epdflib[] = { {"open", l_open_PDFDoc}, - {"Annot", l_new_Annot}, - {"Annots", l_new_Annots}, {"Array", l_new_Array}, {"Dict", l_new_Dict}, {"Object", l_new_Object}, @@ -362,12 +303,26 @@ static int m_##type##__tostring(lua_Stat return 1; \ } +#define m_poppler_check_string(in, function) \ +static int m_##in##_##function(lua_State * L) \ +{ \ + const char *s; \ + udstruct *uin; \ + uin = (udstruct *) luaL_checkudata(L, 1, M_##in); \ + if (uin->pd != NULL && uin->pd->pc != uin->pc) \ + pdfdoc_changed_error(L); \ + s = luaL_checkstring(L, 2); \ + if (((in *) uin->d)->function((char *) s)) \ + lua_pushboolean(L, 1); \ + else \ + lua_pushboolean(L, 0); \ + return 1; \ +} + //********************************************************************** // Annot m_poppler_get_BOOL(Annot, isOk); -m_poppler_get_OBJECT(Annot, getAppearance); -m_poppler_get_poppler(Annot, AnnotBorder, getBorder); static int m_Annot_match(lua_State * L) { @@ -405,8 +360,6 @@ static int m_Annot__gc(lua_State * L) static const struct luaL_Reg Annot_m[] = { {"isOk", m_Annot_isOk}, - {"getAppearance", m_Annot_getAppearance}, - {"getBorder", m_Annot_getBorder}, {"match", m_Annot_match}, {"__tostring", m_Annot__tostring}, {"__gc", m_Annot__gc}, @@ -414,38 +367,6 @@ static const struct luaL_Reg Annot_m[] = }; //********************************************************************** -// AnnotBorderStyle - -#ifdef HAVE_ANNOTBORDERSTYLE - -m_poppler_get_DOUBLE(AnnotBorderStyle, getWidth); - -m_poppler__tostring(AnnotBorderStyle); - -static int m_Annots__gc(lua_State * L) -{ - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Annots); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); -#ifdef DEBUG - printf("\n===== Annots GC ===== uin=<%p>\n", uin); -#endif - if (uin->atype == ALLOC_LEPDF) - delete(Annots *) uin->d; - return 0; -} - -static const struct luaL_Reg AnnotBorderStyle_m[] = { - {"getWidth", m_AnnotBorderStyle_getWidth}, - {"__tostring", m_AnnotBorderStyle__tostring}, - {"__gc", m_Annots__gc}, - {NULL, NULL} // sentinel -}; - -#endif - -//********************************************************************** // Annots m_poppler_get_INT(Annots, getNumAnnots); @@ -694,34 +615,6 @@ static int m_Catalog_findDest(lua_State m_poppler_get_poppler(Catalog, Object, getDests); m_poppler_get_INT(Catalog, numEmbeddedFiles); -#ifdef EMBFILE_IN_CATALOG_H - -static int m_Catalog_embeddedFile(lua_State * L) -{ - EmbFile *ef; - int i, len; - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_Catalog); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - i = luaL_checkint(L, 2); - len = ((Catalog *) uin->d)->numEmbeddedFiles(); - if (i > 0 && i <= len) { - ef = ((Catalog *) uin->d)->embeddedFile(i - 1); - if (ef != NULL) { - uout = new_EmbFile_userdata(L); - uout->d = ef; - uout->pc = uin->pc; - uout->pd = uin->pd; - } else - lua_pushnil(L); - } else - lua_pushnil(L); - return 1; -} - -#endif - m_poppler_get_INT(Catalog, numJS); static int m_Catalog_getJS(lua_State * L) @@ -763,9 +656,6 @@ static const struct luaL_Reg Catalog_m[] {"findDest", m_Catalog_findDest}, {"getDests", m_Catalog_getDests}, {"numEmbeddedFiles", m_Catalog_numEmbeddedFiles}, -#ifdef EMBFILE_IN_CATALOG_H - {"embeddedFile", m_Catalog_embeddedFile}, -#endif {"numJS", m_Catalog_numJS}, {"getJS", m_Catalog_getJS}, {"getOutline", m_Catalog_getOutline}, @@ -775,53 +665,6 @@ static const struct luaL_Reg Catalog_m[] }; //********************************************************************** -// EmbFile - -#ifdef EMBFILE_IN_CATALOG_H - -m_poppler_get_GOOSTRING(EmbFile, name); -m_poppler_get_GOOSTRING(EmbFile, description); -m_poppler_get_INT(EmbFile, size); -m_poppler_get_GOOSTRING(EmbFile, modDate); -m_poppler_get_GOOSTRING(EmbFile, createDate); -m_poppler_get_GOOSTRING(EmbFile, checksum); -m_poppler_get_GOOSTRING(EmbFile, mimeType); - -static int m_EmbFile_streamObject(lua_State * L) -{ - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_EmbFile); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - uout = new_Object_userdata(L); - uout->d = new Object(); // automatic init to type "none" - ((EmbFile *) uin->d)->streamObject().copy((Object *) uout->d); - uout->pc = uin->pc; - uout->pd = uin->pd; - return 1; -} - -m_poppler_get_BOOL(EmbFile, isOk); - -m_poppler__tostring(EmbFile); - -static const struct luaL_Reg EmbFile_m[] = { - {"name", m_EmbFile_name}, - {"description", m_EmbFile_description}, - {"size", m_EmbFile_size}, - {"modDate", m_EmbFile_modDate}, - {"createDate", m_EmbFile_createDate}, - {"checksum", m_EmbFile_checksum}, - {"mimeType", m_EmbFile_mimeType}, - {"streamObject", m_EmbFile_streamObject}, - {"isOk", m_EmbFile_isOk}, - {"__tostring", m_EmbFile__tostring}, - {NULL, NULL} // sentinel -}; - -#endif - -//********************************************************************** // Dict static int m_Dict_incRef(lua_State * L) @@ -888,20 +731,7 @@ static int m_Dict_remove(lua_State * L) return 0; } -static int m_Dict_is(lua_State * L) -{ - const char *s; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Dict); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - s = luaL_checkstring(L, 2); - if (((Dict *) uin->d)->is((char *) s)) - lua_pushboolean(L, 1); - else - lua_pushboolean(L, 0); - return 1; -} +m_poppler_check_string(Dict, is); static int m_Dict_lookup(lua_State * L) { @@ -1012,6 +842,8 @@ static int m_Dict_getValNF(lua_State * L return 1; } +m_poppler_check_string(Dict, hasKey); + m_poppler__tostring(Dict); static const struct luaL_Reg Dict_m[] = { @@ -1028,6 +860,7 @@ static const struct luaL_Reg Dict_m[] = {"getKey", m_Dict_getKey}, {"getVal", m_Dict_getVal}, {"getValNF", m_Dict_getValNF}, + {"hasKey", m_Dict_hasKey}, {"__tostring", m_Dict__tostring}, {NULL, NULL} // sentinel }; @@ -1135,9 +968,13 @@ static const struct luaL_Reg LinkDest_m[ //********************************************************************** // Links +m_poppler_get_INT(Links, getNumLinks); + m_poppler__tostring(Links); static const struct luaL_Reg Links_m[] = { + {"getNumLinks", m_Links_getNumLinks}, + //{"getLink", m_Links_getLink}, {"__tostring", m_Links__tostring}, {NULL, NULL} // sentinel }; @@ -1367,13 +1204,11 @@ static int m_Object_getType(lua_State * static int m_Object_getTypeName(lua_State * L) { - char *s; udstruct *uin; uin = (udstruct *) luaL_checkudata(L, 1, M_Object); if (uin->pd != NULL && uin->pd->pc != uin->pc) pdfdoc_changed_error(L); - s = ((Object *) uin->d)->getTypeName(); - lua_pushstring(L, s); + lua_pushstring(L, ((Object *) uin->d)->getTypeName()); return 1; } @@ -1465,15 +1300,13 @@ static int m_Object_getString(lua_State static int m_Object_getName(lua_State * L) { - char *s; udstruct *uin; uin = (udstruct *) luaL_checkudata(L, 1, M_Object); if (uin->pd != NULL && uin->pd->pc != uin->pc) pdfdoc_changed_error(L); - if (((Object *) uin->d)->isName()) { - s = ((Object *) uin->d)->getName(); - lua_pushstring(L, s); - } else + if (((Object *) uin->d)->isName()) + lua_pushstring(L, ((Object *) uin->d)->getName()); + else lua_pushnil(L); return 1; } @@ -1582,10 +1415,9 @@ static int m_Object_getCmd(lua_State * L uin = (udstruct *) luaL_checkudata(L, 1, M_Object); if (uin->pd != NULL && uin->pd->pc != uin->pc) pdfdoc_changed_error(L); - if (((Object *) uin->d)->isCmd()) { - s = ((Object *) uin->d)->getCmd(); - lua_pushstring(L, s); - } else + if (((Object *) uin->d)->isCmd()) + lua_pushstring(L, ((Object *) uin->d)->getCmd()); + else lua_pushnil(L); return 1; } @@ -2043,28 +1875,6 @@ m_poppler_get_poppler(Page, Dict, getSep m_poppler_get_poppler(Page, Dict, getResourceDict); m_poppler_get_OBJECT(Page, getAnnots); -static int m_Page_getLinks(lua_State * L) -{ - Links *links; - udstruct *uin, *ucat, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_Page); - ucat = (udstruct *) luaL_checkudata(L, 2, M_Catalog); - if (uin->pd != NULL && ucat->pd != NULL && uin->pd != ucat->pd) - pdfdoc_differs_error(L); - if ((uin->pd != NULL && uin->pd->pc != uin->pc) - || (ucat->pd != NULL && ucat->pd->pc != ucat->pd->pc)) - pdfdoc_changed_error(L); - links = ((Page *) uin->d)->getLinks((Catalog *) ucat->d); - if (links != NULL) { - uout = new_Links_userdata(L); - uout->d = links; - uout->pc = uin->pc; - uout->pd = uin->pd; - } else - lua_pushnil(L); - return 1; -} - m_poppler_get_OBJECT(Page, getContents); m_poppler__tostring(Page); @@ -2091,7 +1901,6 @@ static const struct luaL_Reg Page_m[] = {"getSeparationInfo", m_Page_getSeparationInfo}, {"getResourceDict", m_Page_getResourceDict}, {"getAnnots", m_Page_getAnnots}, - {"getLinks", m_Page_getLinks}, {"getContents", m_Page_getContents}, {"__tostring", m_Page__tostring}, {NULL, NULL} // sentinel @@ -2276,19 +2085,23 @@ static int m_PDFDoc_findPage(lua_State * static int m_PDFDoc_getLinks(lua_State * L) { - int i; + int i, pages; Links *links; udstruct *uin, *uout; uin = (udstruct *) luaL_checkudata(L, 1, M_PDFDoc); if (uin->pd != NULL && uin->pd->pc != uin->pc) pdfdoc_changed_error(L); i = luaL_checkint(L, 2); - links = ((PdfDocument *) uin->d)->doc->getLinks(i); - if (links != NULL) { - uout = new_Links_userdata(L); - uout->d = links; - uout->pc = uin->pc; - uout->pd = uin->pd; + pages = ((PdfDocument *) uin->d)->doc->getNumPages(); + if (i > 0 && i <= pages) { + links = ((PdfDocument *) uin->d)->doc->getLinks(i); + if (links != NULL) { + uout = new_Links_userdata(L); + uout->d = links; + uout->pc = uin->pc; + uout->pd = uin->pd; + } else + lua_pushnil(L); } else lua_pushnil(L); return 1; @@ -2367,6 +2180,8 @@ static int m_PDFDoc_getDocInfoNF(lua_Sta m_PDFDoc_INT(getPDFMajorVersion); m_PDFDoc_INT(getPDFMinorVersion); +m_poppler__tostring(PDFDoc); + static int m_PDFDoc__gc(lua_State * L) { udstruct *uin; @@ -2410,6 +2225,7 @@ static const struct luaL_Reg PDFDoc_m[] {"getDocInfoNF", m_PDFDoc_getDocInfoNF}, {"getPDFMajorVersion", m_PDFDoc_getPDFMajorVersion}, {"getPDFMinorVersion", m_PDFDoc_getPDFMinorVersion}, + {"__tostring", m_PDFDoc__tostring}, {"__gc", m_PDFDoc__gc}, // finalizer {NULL, NULL} // sentinel }; @@ -2555,11 +2371,6 @@ static const char *StreamKindNames[] = "Flate", "JBIG2", "JPX", "Weird", NULL }; -#if 0 -static const char *StreamColorSpaceModeNames[] = - { "CSNone", "CSDeviceGray", "CSDeviceRGB", "CSDeviceCMYK", NULL }; -#endif - m_poppler_get_INT(Stream, getKind); static int m_Stream_getKindName(lua_State * L) @@ -2645,12 +2456,26 @@ static int m_XRef_fetch(lua_State * L) m_poppler_get_OBJECT(XRef, getDocInfo); m_poppler_get_OBJECT(XRef, getDocInfoNF); m_poppler_get_INT(XRef, getNumObjects); -// getLastXRefPos m_poppler_get_INT(XRef, getRootNum); m_poppler_get_INT(XRef, getRootGen); // getStreamEnd -m_poppler_get_INT(XRef, getSize); -// getEntry + +static int m_XRef_getNumEntry(lua_State * L) +{ + int i, offset; + udstruct *uin; + uin = (udstruct *) luaL_checkudata(L, 1, M_XRef); + if (uin->pd != NULL && uin->pd->pc != uin->pc) + pdfdoc_changed_error(L); + offset = luaL_checkint(L, 2); + i = ((XRef *) uin->d)->getNumEntry(offset); + if (i >= 0) + lua_pushinteger(L, i); + else + lua_pushnil(L); + return 1; +} + m_poppler_get_poppler(XRef, Object, getTrailerDict); m_poppler__tostring(XRef); @@ -2672,11 +2497,10 @@ static const struct luaL_Reg XRef_m[] = {"getDocInfo", m_XRef_getDocInfo}, {"getDocInfoNF", m_XRef_getDocInfoNF}, {"getNumObjects", m_XRef_getNumObjects}, - // {"getRootNum", m_XRef_getRootNum}, {"getRootGen", m_XRef_getRootGen}, - // - {"getSize", m_XRef_getSize}, + // {"getStreamEnd", m_XRef_getStreamEnd}, + {"getNumEntry", m_XRef_getNumEntry}, {"getTrailerDict", m_XRef_getTrailerDict}, {"__tostring", m_XRef__tostring}, {NULL, NULL} // sentinel @@ -2685,7 +2509,10 @@ static const struct luaL_Reg XRef_m[] = //********************************************************************** // XRefEntry +m_poppler__tostring(XRefEntry); + static const struct luaL_Reg XRefEntry_m[] = { + {"__tostring", m_XRefEntry__tostring}, {NULL, NULL} // sentinel }; @@ -2702,17 +2529,10 @@ static const struct luaL_Reg XRefEntry_m int luaopen_epdf(lua_State * L) { register_meta(Annot); - // TODO register_meta(AnnotBorder); -#ifdef HAVE_ANNOTBORDERSTYLE - register_meta(AnnotBorderStyle); -#endif register_meta(Annots); register_meta(Array); register_meta(Catalog); register_meta(Dict); -#ifdef EMBFILE_IN_CATALOG_H - register_meta(EmbFile); -#endif register_meta(GooString); register_meta(LinkDest); register_meta(Links); --- texk/web2c/luatexdir/lua/ltexlib.c +++ texk/web2c/luatexdir/lua/ltexlib.c 2012-05-18 14:51:48.448218000 +0000 @@ -261,6 +261,9 @@ void luacstring_close(int n) free(next->text); t = next; next = next->next; + if (t==read_spindle.tail) { + read_spindle.tail = NULL; /* prevent double free */ + } free(t); } read_spindle.head = NULL; --- texk/web2c/luatexdir/lua/luainit.w +++ texk/web2c/luatexdir/lua/luainit.w 2012-05-18 14:52:02.703975000 +0000 @@ -1,6 +1,6 @@ % luainit.w % -% Copyright 2006-2011 Taco Hoekwater +% Copyright 2006-2012 Taco Hoekwater % This file is part of LuaTeX. @@ -328,7 +328,7 @@ static void parse_options(int argc, char "the terms of the GNU General Public License, version 2. For more\n" "information about these matters, see the file named COPYING and\n" "the LuaTeX source.\n\n" - "Copyright 2011 Taco Hoekwater, the LuaTeX Team.\n"); + "Copyright 2012 Taco Hoekwater, the LuaTeX Team.\n"); /* *INDENT-ON* */ uexit(0); } else if (ARGUMENT_IS("credits")) { @@ -738,7 +738,7 @@ void lua_initialize(int ac, char **av) argc = ac; argv = av; - if (asprintf(&banner, "This is LuaTeX, Version %s-%d (TeX Live 2012)", + if (asprintf(&banner, "This is LuaTeX, Version %s-%d" WEB2CVERSION, luatex_version_string, luatex_date_info) < 0) { exit(EXIT_FAILURE); }