diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-11-12 11:32:27 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-11-12 11:32:27 -0200 |
| commit | cb59019f580ae0cb863cbf903efae28cf67c33af (patch) | |
| tree | 8d602c2b6cb4a6a2e3399e5c1e7d855e6f416b9b | |
| parent | 52c0f9575b4253a8f3064158529dcedec3c9bffe (diff) | |
| download | lua-cb59019f580ae0cb863cbf903efae28cf67c33af.tar.gz lua-cb59019f580ae0cb863cbf903efae28cf67c33af.tar.bz2 lua-cb59019f580ae0cb863cbf903efae28cf67c33af.zip | |
uses return value from luaL_getmetatable
| -rw-r--r-- | lauxlib.c | 5 |
1 files changed, 2 insertions, 3 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lauxlib.c,v 1.272 2014/10/29 16:11:17 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.273 2014/11/02 19:19:04 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 | */ |
| @@ -279,8 +279,7 @@ LUALIB_API int luaL_execresult (lua_State *L, int stat) { | |||
| 279 | */ | 279 | */ |
| 280 | 280 | ||
| 281 | LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) { | 281 | LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) { |
| 282 | luaL_getmetatable(L, tname); /* try to get metatable */ | 282 | if (luaL_getmetatable(L, tname)) /* name already in use? */ |
| 283 | if (!lua_isnil(L, -1)) /* name already in use? */ | ||
| 284 | return 0; /* leave previous value on top, but return 0 */ | 283 | return 0; /* leave previous value on top, but return 0 */ |
| 285 | lua_pop(L, 1); | 284 | lua_pop(L, 1); |
| 286 | lua_newtable(L); /* create metatable */ | 285 | lua_newtable(L); /* create metatable */ |
