| 222 | |
| 223 | |
| 224 | static int db_setlocal (lua_State *L) { |
| 225 | int arg; |
| 226 | const char *name; |
| 227 | lua_State *L1 = getthread(L, &arg); |
| 228 | lua_Debug ar; |
| 229 | int level = (int)luaL_checkinteger(L, arg + 1); |
| 230 | int nvar = (int)luaL_checkinteger(L, arg + 2); |
| 231 | if (!lua_getstack(L1, level, &ar)) /* out of range? */ |
| 232 | return luaL_argerror(L, arg+1, "level out of range"); |
| 233 | luaL_checkany(L, arg+3); |
| 234 | lua_settop(L, arg+3); |
| 235 | checkstack(L, L1, 1); |
| 236 | lua_xmove(L, L1, 1); |
| 237 | name = lua_setlocal(L1, &ar, nvar); |
| 238 | if (name == NULL) |
| 239 | lua_pop(L1, 1); /* pop value (if not popped by 'lua_setlocal') */ |
| 240 | lua_pushstring(L, name); |
| 241 | return 1; |
| 242 | } |
| 243 | |
| 244 | |
| 245 | /* |
nothing calls this directly
no test coverage detected