diff options
Diffstat (limited to 'lauxlib.c')
-rw-r--r-- | lauxlib.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lauxlib.c,v 1.165 2007/02/07 17:51:21 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.166 2007/04/19 20:21:53 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 | */ |
@@ -125,7 +125,7 @@ LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) { | |||
125 | } | 125 | } |
126 | 126 | ||
127 | 127 | ||
128 | LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) { | 128 | LUALIB_API void *luaL_testudata (lua_State *L, int ud, const char *tname) { |
129 | void *p = lua_touserdata(L, ud); | 129 | void *p = lua_touserdata(L, ud); |
130 | if (p != NULL) { /* value is a userdata? */ | 130 | if (p != NULL) { /* value is a userdata? */ |
131 | if (lua_getmetatable(L, ud)) { /* does it have a metatable? */ | 131 | if (lua_getmetatable(L, ud)) { /* does it have a metatable? */ |
@@ -136,8 +136,14 @@ LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) { | |||
136 | } | 136 | } |
137 | } | 137 | } |
138 | } | 138 | } |
139 | luaL_typerror(L, ud, tname); /* else error */ | 139 | return NULL; /* value is not a userdata of the proper type */ |
140 | return NULL; /* to avoid warnings */ | 140 | } |
141 | |||
142 | |||
143 | LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) { | ||
144 | void *p = luaL_testudata(L, ud, tname); | ||
145 | if (p == NULL) luaL_typerror(L, ud, tname); | ||
146 | return p; | ||
141 | } | 147 | } |
142 | 148 | ||
143 | 149 | ||