diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-05-25 10:21:26 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-05-25 10:21:26 -0300 |
commit | e8a7ecb982effdfc1148098b288c6ac7130f756e (patch) | |
tree | 5229dadc11873122ff55042e1d08f545d25bb839 /lauxlib.c | |
parent | 38da9d568a4702a6f9405882db56c2a2aa3189c1 (diff) | |
download | lua-e8a7ecb982effdfc1148098b288c6ac7130f756e.tar.gz lua-e8a7ecb982effdfc1148098b288c6ac7130f756e.tar.bz2 lua-e8a7ecb982effdfc1148098b288c6ac7130f756e.zip |
luaL_findstring -> luaL_checkoption
Diffstat (limited to 'lauxlib.c')
-rw-r--r-- | lauxlib.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lauxlib.c,v 1.132 2005/05/16 21:19:00 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.133 2005/05/17 19:49:15 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 | */ |
@@ -95,12 +95,15 @@ LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) { | |||
95 | /* }====================================================== */ | 95 | /* }====================================================== */ |
96 | 96 | ||
97 | 97 | ||
98 | LUALIB_API int luaL_findstring (const char *name, const char *const list[]) { | 98 | LUALIB_API int luaL_checkoption (lua_State *L, int narg, const char *def, |
99 | const char *const lst[]) { | ||
100 | const char *name = (def) ? luaL_optstring(L, narg, def) : | ||
101 | luaL_checkstring(L, narg); | ||
99 | int i; | 102 | int i; |
100 | for (i=0; list[i]; i++) | 103 | for (i=0; lst[i]; i++) |
101 | if (strcmp(list[i], name) == 0) | 104 | if (strcmp(lst[i], name) == 0) |
102 | return i; | 105 | return i; |
103 | return -1; /* name not found */ | 106 | return luaL_error(L, "invalid option " LUA_QS, name); |
104 | } | 107 | } |
105 | 108 | ||
106 | 109 | ||