diff options
Diffstat (limited to 'lauxlib.c')
-rw-r--r-- | lauxlib.c | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lauxlib.c,v 1.185 2009/03/31 17:25:08 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.186 2009/04/02 19:54:06 roberto Exp roberto $ |
3 | ** Auxiliary functions for building Lua libraries | 3 | ** Auxiliary functions for building Lua libraries |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -649,7 +649,7 @@ static int libsize (const luaL_Reg *l) { | |||
649 | 649 | ||
650 | LUALIB_API void luaL_register (lua_State *L, const char *libname, | 650 | LUALIB_API void luaL_register (lua_State *L, const char *libname, |
651 | const luaL_Reg *l) { | 651 | const luaL_Reg *l) { |
652 | lua_checkversion(L); | 652 | luaL_checkversion(L); |
653 | if (libname) { | 653 | if (libname) { |
654 | /* check whether lib already exists */ | 654 | /* check whether lib already exists */ |
655 | luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1); | 655 | luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1); |
@@ -740,3 +740,12 @@ LUALIB_API lua_State *luaL_newstate (void) { | |||
740 | return L; | 740 | return L; |
741 | } | 741 | } |
742 | 742 | ||
743 | |||
744 | LUALIB_API void luaL_checkversion_ (lua_State *L, lua_Number ver) { | ||
745 | const lua_Number *v = lua_version(L); | ||
746 | if (v != lua_version(NULL)) | ||
747 | luaL_error(L, "application using two incompatible Lua VMs"); | ||
748 | else if (*v != ver) | ||
749 | luaL_error(L, "application and Lua core using different Lua versions" | ||
750 | "(%d x %d)", (int)*v, (int)ver); | ||
751 | } | ||