| 132 | */ |
| 133 | |
| 134 | char *redisProtocolToLuaType(lua_State *lua, char* reply) { |
| 135 | |
| 136 | if (!lua_checkstack(lua, 5)) { |
| 137 | /* |
| 138 | * Increase the Lua stack if needed, to make sure there is enough room |
| 139 | * to push 5 elements to the stack. On failure, exit with panic. |
| 140 | * Notice that we need, in the worst case, 5 elements because redisProtocolToLuaType_Aggregate |
| 141 | * might push 5 elements to the Lua stack.*/ |
| 142 | serverPanic("lua stack limit reach when parsing redis.call reply"); |
| 143 | } |
| 144 | |
| 145 | char *p = reply; |
| 146 | |
| 147 | switch(*p) { |
| 148 | case ':': p = redisProtocolToLuaType_Int(lua,reply); break; |
| 149 | case '$': p = redisProtocolToLuaType_Bulk(lua,reply); break; |
| 150 | case '+': p = redisProtocolToLuaType_Status(lua,reply); break; |
| 151 | case '-': p = redisProtocolToLuaType_Error(lua,reply); break; |
| 152 | case '*': p = redisProtocolToLuaType_Aggregate(lua,reply,*p); break; |
| 153 | case '%': p = redisProtocolToLuaType_Aggregate(lua,reply,*p); break; |
| 154 | case '~': p = redisProtocolToLuaType_Aggregate(lua,reply,*p); break; |
| 155 | case '_': p = redisProtocolToLuaType_Null(lua,reply); break; |
| 156 | case '#': p = redisProtocolToLuaType_Bool(lua,reply,p[1]); break; |
| 157 | case ',': p = redisProtocolToLuaType_Double(lua,reply); break; |
| 158 | } |
| 159 | return p; |
| 160 | } |
| 161 | |
| 162 | char *redisProtocolToLuaType_Int(lua_State *lua, char *reply) { |
| 163 | char *p = strchr(reply+1,'\r'); |
no test coverage detected