diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2010-01-25 12:30:04 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2010-01-25 12:30:04 +0000 |
commit | 65c37b17f39210ff32ba3ec1415d5f5a3f8e86ff (patch) | |
tree | a23710d061b8695f9eec30cbf5591e6016432089 /Build/source/texk/web2c/mplibdir | |
parent | a6ff9d2b253991c7c8eb94f2977abb10ad466480 (diff) |
texk/web2c/luatexdir: compiler warnings
git-svn-id: svn://tug.org/texlive/trunk@16817 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/mplibdir')
-rw-r--r-- | Build/source/texk/web2c/mplibdir/ChangeLog | 8 | ||||
-rw-r--r-- | Build/source/texk/web2c/mplibdir/lmplib.c | 22 | ||||
-rw-r--r-- | Build/source/texk/web2c/mplibdir/mp.w | 8 |
3 files changed, 24 insertions, 14 deletions
diff --git a/Build/source/texk/web2c/mplibdir/ChangeLog b/Build/source/texk/web2c/mplibdir/ChangeLog index 1d749252e49..11d1b25e872 100644 --- a/Build/source/texk/web2c/mplibdir/ChangeLog +++ b/Build/source/texk/web2c/mplibdir/ChangeLog @@ -1,3 +1,11 @@ +2010-01-24 Peter Breitenlohner <peb@mppmu.mpg.de> + + * mp.w (mp_execute, mp_get_char_dimension): Declare string params + as const. + * lmplib.c: #include "../luatex-api.h". + Remove 'char *' casts of Lua strings. + Declare various string variables as const. + 2009-12-05 Peter Breitenlohner <peb@mppmu.mpg.de> * mpxout.w: Convert CRLF to native line endings. diff --git a/Build/source/texk/web2c/mplibdir/lmplib.c b/Build/source/texk/web2c/mplibdir/lmplib.c index 40ca908448b..a4fe02dcee8 100644 --- a/Build/source/texk/web2c/mplibdir/lmplib.c +++ b/Build/source/texk/web2c/mplibdir/lmplib.c @@ -32,6 +32,7 @@ # include <../lua51/lauxlib.h> # include <../lua51/lualib.h> #endif +#include "../luatex-api.h" #include "mplib.h" #include "mplibps.h" @@ -54,7 +55,7 @@ #define mplib_init_S(a) do { \ lua_pushliteral(L,#a); \ - mplib_##a##_ptr = (char *)lua_tostring(L,-1); \ + mplib_##a##_ptr = lua_tostring(L,-1); \ mplib_##a##_index = luaL_ref (L,LUA_REGISTRYINDEX); \ } while (0) @@ -62,11 +63,11 @@ lua_rawgeti(L,LUA_REGISTRYINDEX,mplib_##a##_index); \ } while (0) -#define mplib_is_S(a,i) (mplib_##a##_ptr==(char *)lua_tostring(L,i)) +#define mplib_is_S(a,i) (mplib_##a##_ptr==lua_tostring(L,i)) #define mplib_make_S(a) \ static int mplib_##a##_index = 0; \ - static char *mplib_##a##_ptr = NULL + static const char *mplib_##a##_ptr = NULL static int mplib_type_Ses[mp_special_code + 1] = { 0 }; /* [0] is not used */ @@ -235,7 +236,8 @@ static char *mplib_find_file(MP mp, const char *fname, const char *fmode, int ft lua_checkstack(L, 4); lua_getfield(L, LUA_REGISTRYINDEX, "mplib_file_finder"); if (lua_isfunction(L, -1)) { - char *s = NULL, *x = NULL; + char *s = NULL; + const char *x = NULL; lua_pushstring(L, fname); lua_pushstring(L, fmode); if (ftype >= mp_filetype_text) { @@ -245,10 +247,10 @@ static char *mplib_find_file(MP mp, const char *fname, const char *fmode, int ft } if (lua_pcall(L, 3, 1, 0) != 0) { fprintf(stdout, "Error in mp.find_file: %s\n", - (char *) lua_tostring(L, -1)); + lua_tostring(L, -1)); return NULL; } - x = (char *) lua_tostring(L, -1); + x = lua_tostring(L, -1); if (x != NULL) s = strdup(x); lua_pop(L, 1); /* pop the string */ @@ -328,10 +330,10 @@ static int mplib_new(lua_State * L) options->ini_version = lua_toboolean(L, -1); break; case P_MEM_NAME: - options->mem_name = strdup((char *) lua_tostring(L, -1)); + options->mem_name = strdup(lua_tostring(L, -1)); break; case P_JOB_NAME: - options->job_name = strdup((char *) lua_tostring(L, -1)); + options->job_name = strdup(lua_tostring(L, -1)); break; case P_FIND_FILE: if (mplib_find_file_function(L)) { /* error here */ @@ -422,7 +424,7 @@ static int mplib_execute(lua_State * L) MP *mp_ptr = is_mp(L, 1); if (*mp_ptr != NULL && lua_isstring(L, 2)) { size_t l; - char *s = (char *) lua_tolstring(L, 2, &l); + const char *s = lua_tolstring(L, 2, &l); int h = mp_execute(*mp_ptr, s, l); mp_run_data *res = mp_rundata(*mp_ptr); return mplib_wrapresults(L, res, h); @@ -453,7 +455,7 @@ static int mplib_char_dimension(lua_State * L, int t) { MP *mp_ptr = is_mp(L, 1); if (*mp_ptr != NULL) { - char *fname = (char *)luaL_checkstring(L,2); + const char *fname = luaL_checkstring(L,2); int charnum = (int)luaL_checkinteger(L,3); if (charnum<0 || charnum>255) { lua_pushnumber(L, (lua_Number)0); diff --git a/Build/source/texk/web2c/mplibdir/mp.w b/Build/source/texk/web2c/mplibdir/mp.w index fd3a06b1fef..ab6f770aaf3 100644 --- a/Build/source/texk/web2c/mplibdir/mp.w +++ b/Build/source/texk/web2c/mplibdir/mp.w @@ -22882,7 +22882,7 @@ if ( mp->start_sym>0 ) { /* insert the `\&{everyjob}' symbol */ } @ @c -int mp_execute (MP mp, char *s, size_t l) { +int mp_execute (MP mp, const char *s, size_t l) { mp_reset_stream(&(mp->run_data.term_out)); mp_reset_stream(&(mp->run_data.log_out)); mp_reset_stream(&(mp->run_data.error_out)); @@ -22963,7 +22963,7 @@ char * mp_metapost_version (void) { @ @<Exported function headers@>= int mp_run (MP mp); -int mp_execute (MP mp, char *s, size_t l); +int mp_execute (MP mp, const char *s, size_t l); int mp_finish (MP mp); char * mp_metapost_version (void); @@ -25723,7 +25723,7 @@ font_number mp_find_font (MP mp, char *f) { @ This is an interface function for getting the width of character, as a double in ps units -@c double mp_get_char_dimension (MP mp, char *fname, int c, int t) { +@c double mp_get_char_dimension (MP mp, const char *fname, int c, int t) { unsigned n; four_quarters cc; font_number f = 0; @@ -25749,7 +25749,7 @@ as a double in ps units } @ @<Exported function ...@>= -double mp_get_char_dimension (MP mp, char *fname, int n, int t); +double mp_get_char_dimension (MP mp, const char *fname, int n, int t); @ One simple application of |find_font| is the implementation of the |font_size| |