From 2cc4d0286c4d92f5f055c157fcc5673c7f90cff0 Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 16 Sep 2019 17:49:40 +0200 Subject: [PATCH] RESP3: implement new NULL representation parsing in Lua. --- src/scripting.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/scripting.c b/src/scripting.c index 2c90bb7ae..564dad8ca 100644 --- a/src/scripting.c +++ b/src/scripting.c @@ -43,6 +43,7 @@ char *redisProtocolToLuaType_Bulk(lua_State *lua, char *reply); 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); int redis_math_random (lua_State *L); int redis_math_randomseed (lua_State *L); void ldbInit(void); @@ -135,6 +136,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_Aggregate(lua,reply,*p); break; + case '_': p = redisProtocolToLuaType_Null(lua,reply); break; } return p; } @@ -223,6 +225,12 @@ char *redisProtocolToLuaType_Aggregate(lua_State *lua, char *reply, int atype) { return p; } +char *redisProtocolToLuaType_Null(lua_State *lua, char *reply) { + char *p = strchr(reply+1,'\r'); + lua_pushboolean(lua,0); + return p+2; +} + /* This function is used in order to push an error on the Lua stack in the * format used by redis.pcall to return errors, which is a lua table * with a single "err" field set to the error string. Note that this