| 261 | } |
| 262 | |
| 263 | char *redisProtocolToLuaType_Double(lua_State *lua, char *reply) { |
| 264 | char *p = strchr(reply+1,'\r'); |
| 265 | char buf[MAX_LONG_DOUBLE_CHARS+1]; |
| 266 | size_t len = p-reply-1; |
| 267 | double d; |
| 268 | |
| 269 | if (len <= MAX_LONG_DOUBLE_CHARS) { |
| 270 | memcpy(buf,reply+1,len); |
| 271 | buf[len] = '\0'; |
| 272 | d = strtod(buf,NULL); /* We expect a valid representation. */ |
| 273 | } else { |
| 274 | d = 0; |
| 275 | } |
| 276 | |
| 277 | lua_newtable(lua); |
| 278 | lua_pushstring(lua,"double"); |
| 279 | lua_pushnumber(lua,d); |
| 280 | lua_settable(lua,-3); |
| 281 | return p+2; |
| 282 | } |
| 283 | |
| 284 | /* This function is used in order to push an error on the Lua stack in the |
| 285 | * format used by redis.pcall to return errors, which is a lua table |
no test coverage detected