MCPcopy Index your code
hub / github.com/NetHack/NetHack / get_table_boolean

Function get_table_boolean

src/nhlua.c:1078–1104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1076}
1077
1078int
1079get_table_boolean(lua_State *L, const char *name)
1080{
1081 static const char *const boolstr[] = {
1082 "true", "false", "yes", "no", NULL
1083 };
1084 /* static const int boolstr2i[] = { TRUE, FALSE, TRUE, FALSE, -1 }; */
1085 int ltyp;
1086 int ret = -1;
1087
1088 lua_getfield(L, -1, name);
1089 ltyp = lua_type(L, -1);
1090 if (ltyp == LUA_TSTRING) {
1091 ret = luaL_checkoption(L, -1, NULL, boolstr);
1092 /* nhUse(boolstr2i[0]); */
1093 } else if (ltyp == LUA_TBOOLEAN) {
1094 ret = lua_toboolean(L, -1);
1095 } else if (ltyp == LUA_TNUMBER) {
1096 ret = (int) luaL_checkinteger(L, -1);
1097 if (ret < 0 || ret > 1)
1098 ret = -1;
1099 }
1100 lua_pop(L, 1);
1101 if (ret == -1)
1102 nhl_error(L, "Expected a boolean");
1103 return ret;
1104}
1105
1106int
1107get_table_boolean_opt(lua_State *L, const char *name, int defval)

Callers 1

get_table_boolean_optFunction · 0.85

Calls 1

nhl_errorFunction · 0.85

Tested by

no test coverage detected