luaL_findstring -> luaL_checkoption

This commit is contained in:
Roberto Ierusalimschy
2005-05-25 10:21:26 -03:00
parent 38da9d568a
commit e8a7ecb982
5 changed files with 18 additions and 18 deletions

View File

@@ -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);
}