From facbc3fa3a478c87282c3f95ba056c6711e5e96d Mon Sep 17 00:00:00 2001 From: Peter Breitenlohner Date: Fri, 28 Aug 2015 11:36:12 +0000 Subject: luaTeX: Enable g++ warnings and avoid most of them git-svn-id: svn://tug.org/texlive/trunk@38228 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/web2c/Makefile.in | 4 ++-- Build/source/texk/web2c/luatexdir/ChangeLog | 6 +++++ Build/source/texk/web2c/luatexdir/am/libluatex.am | 6 ++--- Build/source/texk/web2c/luatexdir/image/epdf.h | 2 +- .../source/texk/web2c/luatexdir/image/pdftoepdf.w | 9 +++---- Build/source/texk/web2c/luatexdir/lua/lepdflib.cc | 28 +++++++++++----------- 6 files changed, 31 insertions(+), 24 deletions(-) diff --git a/Build/source/texk/web2c/Makefile.in b/Build/source/texk/web2c/Makefile.in index abfa6a10611..181d9bcb24e 100644 --- a/Build/source/texk/web2c/Makefile.in +++ b/Build/source/texk/web2c/Makefile.in @@ -3382,8 +3382,8 @@ libluatex_a_preflags = $(AM_CPPFLAGS) $(ZLIB_INCLUDES) \ libluatex_a_CPPFLAGS = $(libluatex_a_preflags) $(LUA_INCLUDES) libluajittex_a_CPPFLAGS = $(libluatex_a_preflags) $(LUAJIT_INCLUDES) \ $(LUAJIT_DEFINES) -DLuajitTeX -libluatex_a_CXXFLAGS = # $(WARNING_CXXFLAGS) -libluajittex_a_CXXFLAGS = # $(WARNING_CXXFLAGS) +libluatex_a_CXXFLAGS = $(WARNING_CXXFLAGS) +libluajittex_a_CXXFLAGS = $(WARNING_CXXFLAGS) dist_libluatex_a_SOURCES = \ luatexdir/lua/lstrlibext.c diff --git a/Build/source/texk/web2c/luatexdir/ChangeLog b/Build/source/texk/web2c/luatexdir/ChangeLog index 5b7f3f4bb0a..6daa5d94ac8 100644 --- a/Build/source/texk/web2c/luatexdir/ChangeLog +++ b/Build/source/texk/web2c/luatexdir/ChangeLog @@ -1,3 +1,9 @@ +2015-08-27 Peter Breitenlohner + + * am/libluatex.am: Enable g++ warnings. + * image/epdf.h, image/pdftoepdf.w, lua/lepdflib.cc: Avoid most + g++ warnings. + 2015-08-27 Peter Breitenlohner * image/pdftoepdf.w: Drop useless casts to avoid warnings. diff --git a/Build/source/texk/web2c/luatexdir/am/libluatex.am b/Build/source/texk/web2c/luatexdir/am/libluatex.am index 4d66fefc67e..19fc671a3fe 100644 --- a/Build/source/texk/web2c/luatexdir/am/libluatex.am +++ b/Build/source/texk/web2c/luatexdir/am/libluatex.am @@ -1,6 +1,6 @@ ## texk/web2c/luatexdir/am/libluatex.am: Makefile fragment for libluatex. ## -## Copyright (C) 2009-2014 Peter Breitenlohner +## Copyright (C) 2009-2015 Peter Breitenlohner ## You may freely use, modify and/or distribute this file. ## liblua52 @@ -25,8 +25,8 @@ libluatex_a_CPPFLAGS = $(libluatex_a_preflags) $(LUA_INCLUDES) libluajittex_a_CPPFLAGS = $(libluatex_a_preflags) $(LUAJIT_INCLUDES) $(LUAJIT_DEFINES) libluajittex_a_CPPFLAGS += -DLuajitTeX -libluatex_a_CXXFLAGS = # $(WARNING_CXXFLAGS) -libluajittex_a_CXXFLAGS = # $(WARNING_CXXFLAGS) +libluatex_a_CXXFLAGS = $(WARNING_CXXFLAGS) +libluajittex_a_CXXFLAGS = $(WARNING_CXXFLAGS) dist_libluatex_a_SOURCES = \ luatexdir/lua/lstrlibext.c diff --git a/Build/source/texk/web2c/luatexdir/image/epdf.h b/Build/source/texk/web2c/luatexdir/image/epdf.h index c0d17b29778..c7f475eaa95 100644 --- a/Build/source/texk/web2c/luatexdir/image/epdf.h +++ b/Build/source/texk/web2c/luatexdir/image/epdf.h @@ -194,6 +194,6 @@ struct PdfDocument { unsigned int pc; // counter to track PDFDoc generation or deletion }; -PdfDocument *refPdfDocument(char *file_path, file_error_mode fe); +PdfDocument *refPdfDocument(const char *file_path, file_error_mode fe); #endif /* EPDF_H */ diff --git a/Build/source/texk/web2c/luatexdir/image/pdftoepdf.w b/Build/source/texk/web2c/luatexdir/image/pdftoepdf.w index 82da2a2b012..6e214c13cc7 100644 --- a/Build/source/texk/web2c/luatexdir/image/pdftoepdf.w +++ b/Build/source/texk/web2c/luatexdir/image/pdftoepdf.w @@ -46,20 +46,21 @@ static int CompPdfDocument(const void *pa, const void *pb, void * /*p */ ) // Returns pointer to PdfDocument structure for PDF file. -static PdfDocument *findPdfDocument(char *file_path) +static PdfDocument *findPdfDocument(const char *file_path) { PdfDocument *pdf_doc, tmp; assert(file_path != NULL); if (PdfDocumentTree == NULL) return NULL; - tmp.file_path = file_path; + tmp.file_path = xstrdup(file_path); pdf_doc = (PdfDocument *) avl_find(PdfDocumentTree, &tmp); + free(tmp.file_path); return pdf_doc; } #define PDF_CHECKSUM_SIZE 32 -static char *get_file_checksum(char *a, file_error_mode fe) +static char *get_file_checksum(const char *a, file_error_mode fe) { struct stat finfo; char *ck = NULL; @@ -93,7 +94,7 @@ static char *get_file_checksum(char *a, file_error_mode fe) // Creates a new PdfDocument structure if it doesn't exist yet. // When fe = FE_RETURN_NULL, the function returns NULL in error case. -PdfDocument *refPdfDocument(char *file_path, file_error_mode fe) +PdfDocument *refPdfDocument(const char *file_path, file_error_mode fe) { char *checksum; PdfDocument *pdf_doc; diff --git a/Build/source/texk/web2c/luatexdir/lua/lepdflib.cc b/Build/source/texk/web2c/luatexdir/lua/lepdflib.cc index 621717635fe..1616dad3c76 100644 --- a/Build/source/texk/web2c/luatexdir/lua/lepdflib.cc +++ b/Build/source/texk/web2c/luatexdir/lua/lepdflib.cc @@ -129,7 +129,7 @@ static int l_open_PDFDoc(lua_State * L) udstruct *uout; PdfDocument *d; file_path = luaL_checkstring(L, 1); // path - d = refPdfDocument((char *) file_path, FE_RETURN_NULL); + d = refPdfDocument(file_path, FE_RETURN_NULL); if (d == NULL) lua_pushnil(L); else { @@ -525,7 +525,7 @@ static int m_##in##_##function(lua_State * L) \ 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)) \ + if (((in *) uin->d)->function(s)) \ lua_pushboolean(L, 1); \ else \ lua_pushboolean(L, 0); \ @@ -937,7 +937,7 @@ static int m_Dict_add(lua_State * L) uin = (udstruct *) luaL_checkudata(L, 1, M_Dict); if (uin->pd != NULL && uin->pd->pc != uin->pc) pdfdoc_changed_error(L); - s = copyString((char *) luaL_checkstring(L, 2)); + s = copyString(luaL_checkstring(L, 2)); uobj = (udstruct *) luaL_checkudata(L, 3, M_Object); ((Dict *) uin->d)->add(s, ((Object *) uobj->d)); return 0; @@ -945,12 +945,12 @@ static int m_Dict_add(lua_State * L) static int m_Dict_set(lua_State * L) { - char *s; + const char *s; udstruct *uin, *uobj; uin = (udstruct *) luaL_checkudata(L, 1, M_Dict); if (uin->pd != NULL && uin->pd->pc != uin->pc) pdfdoc_changed_error(L); - s = (char *) luaL_checkstring(L, 2); + s = luaL_checkstring(L, 2); uobj = (udstruct *) luaL_checkudata(L, 3, M_Object); ((Dict *) uin->d)->set(s, ((Object *) uobj->d)); return 0; @@ -958,12 +958,12 @@ static int m_Dict_set(lua_State * L) static int m_Dict_remove(lua_State * L) { - char *s; + 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 = (char *) luaL_checkstring(L, 2); + s = luaL_checkstring(L, 2); ((Dict *) uin->d)->remove(s); return 0; } @@ -1294,7 +1294,7 @@ static const struct luaL_Reg Links_m[] = { // Object // Special type checking. -#define m_Object_isType(function) \ +#define m_Object_isType(function, cast) \ static int m_Object_##function(lua_State * L) \ { \ udstruct *uin; \ @@ -1303,7 +1303,7 @@ static int m_Object_##function(lua_State * L) \ pdfdoc_changed_error(L); \ if (lua_gettop(L) >= 2) { \ if (lua_isstring(L, 2) \ - && ((Object *) uin->d)->function((char *) lua_tostring(L, 2))) \ + && ((Object *) uin->d)->function(cast lua_tostring(L, 2))) \ lua_pushboolean(L, 1); \ else \ lua_pushboolean(L, 0); \ @@ -1377,7 +1377,7 @@ static int m_Object_initName(lua_State * L) if (uin->pd != NULL && uin->pd->pc != uin->pc) pdfdoc_changed_error(L); s = luaL_checkstring(L, 2); - ((Object *) uin->d)->initName((char *) s); + ((Object *) uin->d)->initName(s); return 0; } @@ -1528,13 +1528,13 @@ m_poppler_get_BOOL(Object, isInt); m_poppler_get_BOOL(Object, isReal); m_poppler_get_BOOL(Object, isNum); m_poppler_get_BOOL(Object, isString); -m_Object_isType(isName); +m_Object_isType(isName, ); m_poppler_get_BOOL(Object, isNull); m_poppler_get_BOOL(Object, isArray); -m_Object_isType(isDict); -m_Object_isType(isStream); +m_Object_isType(isDict, ); +m_Object_isType(isStream, (char *)); m_poppler_get_BOOL(Object, isRef); -m_Object_isType(isCmd); +m_Object_isType(isCmd, ); m_poppler_get_BOOL(Object, isError); m_poppler_get_BOOL(Object, isEOF); m_poppler_get_BOOL(Object, isNone); -- cgit v1.2.3