diff options
author | antirez <antirez@gmail.com> | 2019-09-16 18:36:16 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2019-09-16 18:36:16 +0200 |
commit | f01f0c02d14149e826532ba20f084244fdf29d20 (patch) | |
tree | 46a98b831eff73ac01c9751ae01c7563d697de64 /src/scripting.c | |
parent | 6931004969d23dc6233a94e422090f35ebec143d (diff) | |
download | redis-f01f0c02d14149e826532ba20f084244fdf29d20.tar.gz |
RESP3: convert RESP3 null as Lua nil. Implement RESP3->Lua bools.
Diffstat (limited to 'src/scripting.c')
-rw-r--r-- | src/scripting.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/scripting.c b/src/scripting.c index 3ad228a67..9ab1e7ab3 100644 --- a/src/scripting.c +++ b/src/scripting.c @@ -44,6 +44,7 @@ char *redisProtocolToLuaType_Status(lua_State *lua, char *reply); char *redisProtocolToLuaType_Error(lua_State *lua, char *reply); char *redisProtocolToLuaType_Aggregate(lua_State *lua, char *reply, int atype); char *redisProtocolToLuaType_Null(lua_State *lua, char *reply); +char *redisProtocolToLuaType_Bool(lua_State *lua, char *reply, int tf); int redis_math_random (lua_State *L); int redis_math_randomseed (lua_State *L); void ldbInit(void); @@ -137,6 +138,7 @@ char *redisProtocolToLuaType(lua_State *lua, char* reply) { case '%': p = redisProtocolToLuaType_Aggregate(lua,reply,*p); break; case '~': p = redisProtocolToLuaType_Aggregate(lua,reply,*p); break; case '_': p = redisProtocolToLuaType_Null(lua,reply); break; + case '#': p = redisProtocolToLuaType_Bool(lua,reply,p[1]); } return p; } @@ -227,7 +229,13 @@ char *redisProtocolToLuaType_Aggregate(lua_State *lua, char *reply, int atype) { char *redisProtocolToLuaType_Null(lua_State *lua, char *reply) { char *p = strchr(reply+1,'\r'); - lua_pushboolean(lua,0); + lua_pushnil(lua); + return p+2; +} + +char *redisProtocolToLuaType_Bool(lua_State *lua, char *reply, int tf) { + char *p = strchr(reply+1,'\r'); + lua_pushboolean(lua,tf == 't'); return p+2; } |