From e8a7ecb982effdfc1148098b288c6ac7130f756e Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 25 May 2005 10:21:26 -0300 Subject: luaL_findstring -> luaL_checkoption --- lauxlib.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'lauxlib.c') diff --git a/lauxlib.c b/lauxlib.c index 0c64f9e5..b8205191 100644 --- a/lauxlib.c +++ b/lauxlib.c @@ -1,5 +1,5 @@ /* -** $Id: lauxlib.c,v 1.132 2005/05/16 21:19:00 roberto Exp roberto $ +** $Id: lauxlib.c,v 1.133 2005/05/17 19:49:15 roberto Exp roberto $ ** Auxiliary functions for building Lua libraries ** See Copyright Notice in lua.h */ @@ -95,12 +95,15 @@ LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) { /* }====================================================== */ -LUALIB_API int luaL_findstring (const char *name, const char *const list[]) { +LUALIB_API int luaL_checkoption (lua_State *L, int narg, const char *def, + const char *const lst[]) { + const char *name = (def) ? luaL_optstring(L, narg, def) : + luaL_checkstring(L, narg); int i; - for (i=0; list[i]; i++) - if (strcmp(list[i], name) == 0) + for (i=0; lst[i]; i++) + if (strcmp(lst[i], name) == 0) return i; - return -1; /* name not found */ + return luaL_error(L, "invalid option " LUA_QS, name); } -- cgit v1.2.3-55-g6feb