mirror of https://github.com/rusefi/lua.git
'checkversion' implemented in the auxiliary library
This commit is contained in:
parent
1d6ebce296
commit
4a818f068a
13
lauxlib.c
13
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);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lauxlib.h,v 1.94 2008/01/03 17:07:59 roberto Exp roberto $
|
||||
** $Id: lauxlib.h,v 1.95 2009/02/13 19:39:34 roberto Exp roberto $
|
||||
** Auxiliary functions for building Lua libraries
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -26,6 +26,8 @@ typedef struct luaL_Reg {
|
|||
} luaL_Reg;
|
||||
|
||||
|
||||
LUALIB_API void (luaL_checkversion_) (lua_State *L, lua_Number ver);
|
||||
#define luaL_checkversion(L) luaL_checkversion_(L, LUA_VERSION_NUM)
|
||||
|
||||
LUALIB_API void (luaI_openlib) (lua_State *L, const char *libname,
|
||||
const luaL_Reg *l, int nup);
|
||||
|
|
4
lua.c
4
lua.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lua.c,v 1.171 2008/07/11 17:51:01 roberto Exp roberto $
|
||||
** $Id: lua.c,v 1.172 2009/02/19 17:15:35 roberto Exp roberto $
|
||||
** Lua stand-alone interpreter
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -343,7 +343,7 @@ static int pmain (lua_State *L) {
|
|||
lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */
|
||||
luaL_openlibs(L); /* open libraries */
|
||||
lua_gc(L, LUA_GCRESTART, 0);
|
||||
lua_checkversion(L);
|
||||
luaL_checkversion(L);
|
||||
s->ok = (handle_luainit(L) == LUA_OK);
|
||||
if (!s->ok) return 0;
|
||||
script = collectargs(argv, &has_i, &has_v, &has_e);
|
||||
|
|
Loading…
Reference in New Issue