From 4a818f068aef5c598c7af9ed5a834dee5d9a9eb6 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 18 Jun 2009 15:59:58 -0300 Subject: 'checkversion' implemented in the auxiliary library --- lauxlib.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'lauxlib.c') diff --git a/lauxlib.c b/lauxlib.c index 7f7075e8..72cfe04a 100644 --- a/lauxlib.c +++ b/lauxlib.c @@ -1,5 +1,5 @@ /* -** $Id: lauxlib.c,v 1.185 2009/03/31 17:25:08 roberto Exp roberto $ +** $Id: lauxlib.c,v 1.186 2009/04/02 19:54:06 roberto Exp roberto $ ** Auxiliary functions for building Lua libraries ** See Copyright Notice in lua.h */ @@ -649,7 +649,7 @@ static int libsize (const luaL_Reg *l) { LUALIB_API void luaL_register (lua_State *L, const char *libname, const luaL_Reg *l) { - lua_checkversion(L); + luaL_checkversion(L); if (libname) { /* check whether lib already exists */ luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1); @@ -740,3 +740,12 @@ LUALIB_API lua_State *luaL_newstate (void) { return L; } + +LUALIB_API void luaL_checkversion_ (lua_State *L, lua_Number ver) { + const lua_Number *v = lua_version(L); + if (v != lua_version(NULL)) + luaL_error(L, "application using two incompatible Lua VMs"); + else if (*v != ver) + luaL_error(L, "application and Lua core using different Lua versions" + "(%d x %d)", (int)*v, (int)ver); +} -- cgit v1.2.3-55-g6feb