diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-06-05 16:41:31 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-06-05 16:41:31 -0300 |
| commit | 323da725778e1642caae85c66472e36729fdc3c6 (patch) | |
| tree | d13b7f99cdcce92e95ba199e971b383990405dab | |
| parent | 943b8f5b1801c72fee8bf1050919cf1acb600555 (diff) | |
| download | lua-323da725778e1642caae85c66472e36729fdc3c6.tar.gz lua-323da725778e1642caae85c66472e36729fdc3c6.tar.bz2 lua-323da725778e1642caae85c66472e36729fdc3c6.zip | |
`weakmode' queries must have an explicit `?'
Diffstat (limited to '')
| -rw-r--r-- | lbaselib.c | 10 |
1 files changed, 5 insertions, 5 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lbaselib.c,v 1.34 2001/04/11 18:39:37 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.35 2001/04/23 16:35:45 roberto Exp roberto $ |
| 3 | ** Basic library | 3 | ** Basic library |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -170,9 +170,9 @@ static int luaB_settag (lua_State *L) { | |||
| 170 | } | 170 | } |
| 171 | 171 | ||
| 172 | static int luaB_weakmode (lua_State *L) { | 172 | static int luaB_weakmode (lua_State *L) { |
| 173 | const char *mode = luaL_opt_string(L, 2, NULL); | 173 | const char *mode = luaL_check_string(L, 2); |
| 174 | luaL_checktype(L, 1, LUA_TTABLE); | 174 | luaL_checktype(L, 1, LUA_TTABLE); |
| 175 | if (mode == NULL) { | 175 | if (*mode == l_c('?')) { |
| 176 | char buff[3]; | 176 | char buff[3]; |
| 177 | char *s = buff; | 177 | char *s = buff; |
| 178 | int imode = lua_getweakmode(L, 1); | 178 | int imode = lua_getweakmode(L, 1); |
| @@ -184,11 +184,11 @@ static int luaB_weakmode (lua_State *L) { | |||
| 184 | } | 184 | } |
| 185 | else { | 185 | else { |
| 186 | int imode = 0; | 186 | int imode = 0; |
| 187 | lua_pushvalue(L, 1); /* push table */ | ||
| 188 | if (strchr(mode, l_c('k'))) imode |= LUA_WEAK_KEY; | 187 | if (strchr(mode, l_c('k'))) imode |= LUA_WEAK_KEY; |
| 189 | if (strchr(mode, l_c('v'))) imode |= LUA_WEAK_VALUE; | 188 | if (strchr(mode, l_c('v'))) imode |= LUA_WEAK_VALUE; |
| 189 | lua_pushvalue(L, 1); /* push table */ | ||
| 190 | lua_setweakmode(L, imode); | 190 | lua_setweakmode(L, imode); |
| 191 | return 1; | 191 | return 1; /* return the table */ |
| 192 | } | 192 | } |
| 193 | } | 193 | } |
| 194 | 194 | ||
