aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lapi.c14
-rw-r--r--lstate.c4
-rw-r--r--lstate.h4
-rw-r--r--lua.h5
4 files changed, 12 insertions, 15 deletions
diff --git a/lapi.c b/lapi.c
index f6e8b034..dd8a96ac 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 2.81 2009/06/17 18:38:54 roberto Exp roberto $ 2** $Id: lapi.c,v 2.82 2009/06/18 16:36:40 roberto Exp roberto $
3** Lua API 3** Lua API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -129,13 +129,11 @@ LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) {
129} 129}
130 130
131 131
132LUA_API void lua_checkversion_ (lua_State *L, int version) { 132static const lua_Number l_version = LUA_VERSION_NUM;
133 lua_lock(L); 133
134 if (version != LUA_VERSION_NUM) 134LUA_API const lua_Number *lua_version (lua_State *L) {
135 luaG_runerror(L, "app./library not compiled with header " LUA_VERSION); 135 if (L == NULL) return &l_version;
136 if (G(L)->nilobjp != luaO_nilobject) 136 else return G(L)->version;
137 luaG_runerror(L, "application using multiple Lua VMs");
138 lua_unlock(L);
139} 137}
140 138
141 139
diff --git a/lstate.c b/lstate.c
index c6ca5b9b..3268209e 100644
--- a/lstate.c
+++ b/lstate.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstate.c,v 2.54 2009/04/28 19:04:36 roberto Exp roberto $ 2** $Id: lstate.c,v 2.55 2009/06/01 19:09:26 roberto Exp roberto $
3** Global State 3** Global State
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -208,7 +208,7 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
208 setnilvalue(registry(L)); 208 setnilvalue(registry(L));
209 luaZ_initbuffer(L, &g->buff); 209 luaZ_initbuffer(L, &g->buff);
210 g->panic = NULL; 210 g->panic = NULL;
211 g->nilobjp = luaO_nilobject; 211 g->version = lua_version(NULL);
212 g->gcstate = GCSpause; 212 g->gcstate = GCSpause;
213 g->rootgc = obj2gco(L); 213 g->rootgc = obj2gco(L);
214 g->sweepstrgc = 0; 214 g->sweepstrgc = 0;
diff --git a/lstate.h b/lstate.h
index 6751c0a1..783e51cf 100644
--- a/lstate.h
+++ b/lstate.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstate.h,v 2.43 2009/04/17 22:00:01 roberto Exp roberto $ 2** $Id: lstate.h,v 2.44 2009/06/01 19:09:26 roberto Exp roberto $
3** Global State 3** Global State
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -148,9 +148,9 @@ typedef struct global_State {
148 TValue l_registry; 148 TValue l_registry;
149 struct lua_State *mainthread; 149 struct lua_State *mainthread;
150 UpVal uvhead; /* head of double-linked list of all open upvalues */ 150 UpVal uvhead; /* head of double-linked list of all open upvalues */
151 const lua_Number *version; /* pointer to version number */
151 struct Table *mt[NUM_TAGS]; /* metatables for basic types */ 152 struct Table *mt[NUM_TAGS]; /* metatables for basic types */
152 TString *tmname[TM_N]; /* array with tag-method names */ 153 TString *tmname[TM_N]; /* array with tag-method names */
153 const TValue *nilobjp; /* pointer to nil object (to check consistency) */
154} global_State; 154} global_State;
155 155
156 156
diff --git a/lua.h b/lua.h
index aa242e8e..edeafe7a 100644
--- a/lua.h
+++ b/lua.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lua.h,v 1.238 2009/06/15 19:51:31 roberto Exp roberto $ 2** $Id: lua.h,v 1.239 2009/06/17 17:49:44 roberto Exp roberto $
3** Lua - An Extensible Extension Language 3** Lua - An Extensible Extension Language
4** Lua.org, PUC-Rio, Brazil (http://www.lua.org) 4** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
5** See Copyright Notice at the end of this file 5** See Copyright Notice at the end of this file
@@ -118,8 +118,7 @@ LUA_API lua_State *(lua_mainthread) (lua_State *L);
118LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); 118LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf);
119 119
120 120
121LUA_API void lua_checkversion_ (lua_State *L, int version); 121LUA_API const lua_Number *lua_version (lua_State *L);
122#define lua_checkversion(L) (lua_checkversion_(L, LUA_VERSION_NUM))
123 122
124 123
125/* 124/*