From c8eed367881350a5485903fd1bf2ed0292ac17cc Mon Sep 17 00:00:00 2001 From: Liam Devine Date: Mon, 4 Jul 2011 23:35:16 +0100 Subject: [PATCH] This is a replacement for luaL_typerror , removed from Lua 5.2, which corrects the spelling. NOTE: There is one failing test in.the /test/testsrvr.lua and /test/testclnt.lua combination which was present in the repo I cloned from. --- src/lua_typeerror.c | 10 ++++++++++ src/lua_typeerror.h | 7 +++++++ 2 files changed, 17 insertions(+) create mode 100644 src/lua_typeerror.c create mode 100644 src/lua_typeerror.h diff --git a/src/lua_typeerror.c b/src/lua_typeerror.c new file mode 100644 index 0000000..d6a3d76 --- /dev/null +++ b/src/lua_typeerror.c @@ -0,0 +1,10 @@ +#include "lua_typeerror.h" +#include "lua.h" +#include "lauxlib.h" + +int luaL_typeerror (lua_State *L, int narg, const char *tname) +{ + const char *msg = lua_pushfstring(L, "%s expected, got %s",tname, luaL_typename(L, narg)); + return luaL_argerror(L, narg, msg); +} + diff --git a/src/lua_typeerror.h b/src/lua_typeerror.h new file mode 100644 index 0000000..4f2aafd --- /dev/null +++ b/src/lua_typeerror.h @@ -0,0 +1,7 @@ +#ifndef LUA_TYPEERROR_H_ +#define LUA_TYPEERROR_H_ + +struct lua_State; +int luaL_typeerror (struct lua_State *L, int narg, const char *tname); + +#endif