| 1209 | } |
| 1210 | |
| 1211 | const char *RedisProtocolToLuaTypeDouble(lua_State *lua, const char *reply) { |
| 1212 | const char *p = strchr(reply + 1, '\r'); |
| 1213 | char buf[MAX_LONG_DOUBLE_CHARS + 1]; |
| 1214 | size_t len = p - reply - 1; |
| 1215 | double d = NAN; |
| 1216 | |
| 1217 | if (len <= MAX_LONG_DOUBLE_CHARS) { |
| 1218 | memcpy(buf, reply + 1, len); |
| 1219 | buf[len] = '\0'; |
| 1220 | d = strtod(buf, nullptr); /* We expect a valid representation. */ |
| 1221 | } else { |
| 1222 | d = 0; |
| 1223 | } |
| 1224 | |
| 1225 | lua_newtable(lua); |
| 1226 | lua_pushstring(lua, "double"); |
| 1227 | lua_pushnumber(lua, d); |
| 1228 | lua_settable(lua, -3); |
| 1229 | return p + 2; |
| 1230 | } |
| 1231 | |
| 1232 | const char *RedisProtocolToLuaTypeBigNumber(lua_State *lua, const char *reply) { |
| 1233 | const char *p = strchr(reply + 1, '\r'); |
no outgoing calls
no test coverage detected