forked from pool/gnuplot
aae35d918e
Fix building with newer LUA versions (i.e. fix "openSUSE Factory" build failures) Changed since last request: Re-diffed gnuplot.changes. (For some reason, there was a gnuplot.changes merge failure despite osc pull - and there was some spurious change in that file. Try again ...) Builds successfully on oS 12.1 and Factory. 11.4 is unresolvable (texlive issue). SLES 11 fails as texlive-2007 clashes with texlive-bin-2010 (i386) or because of different tex.fmt (mixing different TeX versions, x86-64). SLES 10 fails for epstopdf in ghostscript. All those issues are unrelated to the patch. OBS-URL: https://build.opensuse.org/request/show/104758 OBS-URL: https://build.opensuse.org/package/show/Publishing/gnuplot?expand=0&rev=28
109 lines
2.5 KiB
Diff
109 lines
2.5 KiB
Diff
Support lua 5.2, based on Rev. 1.17.2.1 from the
|
|
gnuplot branch-4-6-stable.
|
|
Cf. http://gnuplot.cvs.sourceforge.net/viewvc/gnuplot/gnuplot/term/lua.trm?view=log
|
|
|
|
--- term/lua.trm.orig 2012-02-09 20:16:56.000000000 +0100
|
|
+++ term/lua.trm 2012-02-09 20:17:07.000000000 +0100
|
|
@@ -113,6 +113,41 @@
|
|
*/
|
|
static char last_error_msg[MAX_LINE_LEN+1] = "";
|
|
|
|
+#if LUA_VERSION_NUM > 501
|
|
+/*
|
|
+ * two helper functions to ease transitioning to lua 5.2
|
|
+ */
|
|
+
|
|
+/*
|
|
+ * same as lua_getfield(L, LUA_GLOBALINDEXS, f) in lua 5.1
|
|
+ */
|
|
+static void LUA_getfield_global(lua_State *L, const char *f)
|
|
+{
|
|
+ lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS);
|
|
+ lua_getfield(L, -1, f);
|
|
+ lua_replace(L, -2);
|
|
+}
|
|
+/*
|
|
+ * approximately the same as luaL_register(L, libname, l) in lua 5.1
|
|
+ */
|
|
+static void LUA_register(lua_State *L, const char *libname, const luaL_Reg *l)
|
|
+{
|
|
+ if (!libname)
|
|
+ luaL_setfuncs(L, l, 0);
|
|
+ else {
|
|
+ LUA_getfield_global(L, "package");
|
|
+ lua_getfield(L, -1, "loaded");
|
|
+ lua_newtable(L);
|
|
+ luaL_setfuncs(L, l, 0);
|
|
+ lua_pushvalue(L, -1);
|
|
+ lua_setglobal(L, libname);
|
|
+ lua_setfield(L, -2, libname);
|
|
+ lua_pop(L, 2);
|
|
+ lua_getglobal(L, libname);
|
|
+ }
|
|
+}
|
|
+#endif /* LUA_VERSION_NUM > 501 */
|
|
+
|
|
/*
|
|
* Handle Lua functions
|
|
*/
|
|
@@ -378,8 +413,11 @@
|
|
return(1);
|
|
}
|
|
|
|
-
|
|
+#if LUA_VERSION_NUM > 500
|
|
+static const luaL_Reg gp_methods[] = {
|
|
+#else
|
|
static const luaL_reg gp_methods[] = {
|
|
+#endif
|
|
{"write", LUA_GP_write},
|
|
{"int_error", LUA_GP_int_error},
|
|
{"int_warn", LUA_GP_int_warn},
|
|
@@ -395,7 +433,11 @@
|
|
static void
|
|
LUA_register_gp_fnc ()
|
|
{
|
|
+#if LUA_VERSION_NUM > 501
|
|
+ LUA_register(L, LUA_GP_FNC, gp_methods);
|
|
+#else
|
|
luaL_register(L, LUA_GP_FNC, gp_methods);
|
|
+#endif
|
|
}
|
|
|
|
|
|
@@ -524,7 +566,11 @@
|
|
*/
|
|
if (L)
|
|
lua_close(L);
|
|
+#if LUA_VERSION_NUM > 500
|
|
+ L = luaL_newstate();
|
|
+#else
|
|
L = lua_open();
|
|
+#endif
|
|
|
|
luaL_openlibs(L); /* Load Lua libraries */
|
|
luaopen_debug(L);
|
|
@@ -571,14 +617,22 @@
|
|
sf = lua_gettop(L);
|
|
|
|
/* lua_settop(L, 0);*/ /* clear stack */
|
|
+#if LUA_VERSION_NUM > 501
|
|
+ LUA_getfield_global(L, "debug");
|
|
+#else
|
|
lua_getfield(L, LUA_GLOBALSINDEX, "debug");
|
|
+#endif
|
|
lua_getfield(L, -1, "traceback");
|
|
lua_remove(L, -2); /* rm debug */
|
|
tb = lua_gettop(L); /* store "traceback" */
|
|
/* create table `term' */
|
|
lua_newtable(L);
|
|
lua_setglobal(L, "term");
|
|
+#if LUA_VERSION_NUM > 501
|
|
+ LUA_getfield_global(L, "term");
|
|
+#else
|
|
lua_getfield(L, LUA_GLOBALSINDEX, "term");
|
|
+#endif
|
|
luaterm = lua_gettop(L); /* store `term' */
|
|
|
|
/* register gp functions */
|