| 358 | */ |
| 359 | |
| 360 | LUALIB_API int luaL_checkoption (lua_State *L, int arg, const char *def, |
| 361 | const char *const lst[]) { |
| 362 | const char *name = (def) ? luaL_optstring(L, arg, def) : |
| 363 | luaL_checkstring(L, arg); |
| 364 | int i; |
| 365 | for (i=0; lst[i]; i++) |
| 366 | if (strcmp(lst[i], name) == 0) |
| 367 | return i; |
| 368 | return luaL_argerror(L, arg, |
| 369 | lua_pushfstring(L, "invalid option '%s'", name)); |
| 370 | } |
| 371 | |
| 372 | |
| 373 | /* |
no test coverage detected