diff options
| -rw-r--r-- | ldblib.c | 9 | ||||
| -rw-r--r-- | ldebug.c | 7 |
2 files changed, 11 insertions, 5 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldblib.c,v 1.146 2014/11/10 14:27:16 roberto Exp roberto $ | 2 | ** $Id: ldblib.c,v 1.147 2014/12/08 15:47:25 roberto Exp roberto $ |
| 3 | ** Interface from Lua to its debug API | 3 | ** Interface from Lua to its debug API |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -207,15 +207,20 @@ static int db_getlocal (lua_State *L) { | |||
| 207 | 207 | ||
| 208 | static int db_setlocal (lua_State *L) { | 208 | static int db_setlocal (lua_State *L) { |
| 209 | int arg; | 209 | int arg; |
| 210 | const char *name; | ||
| 210 | lua_State *L1 = getthread(L, &arg); | 211 | lua_State *L1 = getthread(L, &arg); |
| 211 | lua_Debug ar; | 212 | lua_Debug ar; |
| 212 | int level = (int)luaL_checkinteger(L, arg + 1); | 213 | int level = (int)luaL_checkinteger(L, arg + 1); |
| 214 | int nvar = (int)luaL_checkinteger(L, arg + 2); | ||
| 213 | if (!lua_getstack(L1, level, &ar)) /* out of range? */ | 215 | if (!lua_getstack(L1, level, &ar)) /* out of range? */ |
| 214 | return luaL_argerror(L, arg+1, "level out of range"); | 216 | return luaL_argerror(L, arg+1, "level out of range"); |
| 215 | luaL_checkany(L, arg+3); | 217 | luaL_checkany(L, arg+3); |
| 216 | lua_settop(L, arg+3); | 218 | lua_settop(L, arg+3); |
| 217 | lua_xmove(L, L1, 1); | 219 | lua_xmove(L, L1, 1); |
| 218 | lua_pushstring(L, lua_setlocal(L1, &ar, (int)luaL_checkinteger(L, arg+2))); | 220 | name = lua_setlocal(L1, &ar, nvar); |
| 221 | if (name == NULL) | ||
| 222 | lua_pop(L1, 1); /* pop value (if not popped by 'lua_setlocal') */ | ||
| 223 | lua_pushstring(L, name); | ||
| 219 | return 1; | 224 | return 1; |
| 220 | } | 225 | } |
| 221 | 226 | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldebug.c,v 2.108 2014/12/08 15:48:23 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 2.109 2014/12/10 11:30:09 roberto Exp roberto $ |
| 3 | ** Debug Interface | 3 | ** Debug Interface |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -167,9 +167,10 @@ LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { | |||
| 167 | StkId pos = 0; /* to avoid warnings */ | 167 | StkId pos = 0; /* to avoid warnings */ |
| 168 | const char *name = findlocal(L, ar->i_ci, n, &pos); | 168 | const char *name = findlocal(L, ar->i_ci, n, &pos); |
| 169 | lua_lock(L); | 169 | lua_lock(L); |
| 170 | if (name) | 170 | if (name) { |
| 171 | setobjs2s(L, pos, L->top - 1); | 171 | setobjs2s(L, pos, L->top - 1); |
| 172 | L->top--; /* pop value */ | 172 | L->top--; /* pop value */ |
| 173 | } | ||
| 173 | lua_unlock(L); | 174 | lua_unlock(L); |
| 174 | return name; | 175 | return name; |
| 175 | } | 176 | } |
