lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi list,

In lua 5.1 luaL_checkudata no longer support negative indices because
it pushes something on the stack before evaluating its argument. I
noticed that because lua-tcc use it that way and it was not working
with 5.1. Here is a unified patch to bring back old behaviour of
luaL_checkudata (also in attached file) :

###
--- lauxlib.c    Mon Jan 16 12:42:22 2006
+++ lauxlib.c    Sun Apr  9 06:51:00 2006
@@ -123,8 +123,10 @@

 LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) {
  void *p = lua_touserdata(L, ud);
+  if (p == NULL || !lua_getmetatable(L, ud))
+    luaL_typerror(L, ud, tname);
  lua_getfield(L, LUA_REGISTRYINDEX, tname);  /* get correct metatable */
-  if (p == NULL || !lua_getmetatable(L, ud) || !lua_rawequal(L, -1, -2))
+  if (!lua_rawequal(L, -1, -2))
    luaL_typerror(L, ud, tname);
  lua_pop(L, 2);  /* remove both metatables */
  return p;
###

It would be nice to put it back into lua source code.

Doub.