summaryrefslogtreecommitdiff
path: root/deps/hiredis
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2018-12-06 11:23:23 +0100
committerantirez <antirez@gmail.com>2019-01-09 17:00:30 +0100
commita2b2d88f384c4ad3e812cceccd4720a9c650207c (patch)
treee27a7235441111e10817f56d260425fea95a37a5 /deps/hiredis
parent005915b5c3ed1fcb79e3e0ed6b5d41c057ef5a3b (diff)
downloadredis-a2b2d88f384c4ad3e812cceccd4720a9c650207c.tar.gz
RESP3: hiredis: initial double implementation.
Diffstat (limited to 'deps/hiredis')
-rw-r--r--deps/hiredis/.travis.yml6
-rw-r--r--deps/hiredis/hiredis.c21
-rw-r--r--deps/hiredis/hiredis.h1
-rw-r--r--deps/hiredis/read.c36
-rw-r--r--deps/hiredis/read.h1
5 files changed, 64 insertions, 1 deletions
diff --git a/deps/hiredis/.travis.yml b/deps/hiredis/.travis.yml
index ad08076d8..faf2ce684 100644
--- a/deps/hiredis/.travis.yml
+++ b/deps/hiredis/.travis.yml
@@ -8,6 +8,12 @@ os:
- linux
- osx
+branches:
+ only:
+ - staging
+ - trying
+ - master
+
before_script:
- if [ "$TRAVIS_OS_NAME" == "osx" ] ; then brew update; brew install redis; fi
diff --git a/deps/hiredis/hiredis.c b/deps/hiredis/hiredis.c
index 42d0f8dd1..13b961871 100644
--- a/deps/hiredis/hiredis.c
+++ b/deps/hiredis/hiredis.c
@@ -47,6 +47,7 @@ static redisReply *createReplyObject(int type);
static void *createStringObject(const redisReadTask *task, char *str, size_t len);
static void *createArrayObject(const redisReadTask *task, int elements);
static void *createIntegerObject(const redisReadTask *task, long long value);
+static void *createDoubleObject(const redisReadTask *task, double value);
static void *createNilObject(const redisReadTask *task);
/* Default set of functions to build the reply. Keep in mind that such a
@@ -55,6 +56,7 @@ static redisReplyObjectFunctions defaultFunctions = {
createStringObject,
createArrayObject,
createIntegerObject,
+ createDoubleObject,
createNilObject,
freeReplyObject
};
@@ -179,6 +181,25 @@ static void *createIntegerObject(const redisReadTask *task, long long value) {
return r;
}
+static void *createDoubleObject(const redisReadTask *task, double value) {
+ redisReply *r, *parent;
+
+ r = createReplyObject(REDIS_REPLY_DOUBLE);
+ if (r == NULL)
+ return NULL;
+
+ r->dval = value;
+
+ if (task->parent) {
+ parent = task->parent->obj;
+ assert(parent->type == REDIS_REPLY_ARRAY ||
+ parent->type == REDIS_REPLY_MAP ||
+ parent->type == REDIS_REPLY_SET);
+ parent->element[task->idx] = r;
+ }
+ return r;
+}
+
static void *createNilObject(const redisReadTask *task) {
redisReply *r, *parent;
diff --git a/deps/hiredis/hiredis.h b/deps/hiredis/hiredis.h
index 1b0d5e659..40719fe2d 100644
--- a/deps/hiredis/hiredis.h
+++ b/deps/hiredis/hiredis.h
@@ -88,6 +88,7 @@ extern "C" {
typedef struct redisReply {
int type; /* REDIS_REPLY_* */
long long integer; /* The integer when type is REDIS_REPLY_INTEGER */
+ double dval; /* The double when type is REDIS_REPLY_DOUBLE */
size_t len; /* Length of string */
char *str; /* Used for both REDIS_REPLY_ERROR and REDIS_REPLY_STRING */
size_t elements; /* number of elements, for REDIS_REPLY_ARRAY */
diff --git a/deps/hiredis/read.c b/deps/hiredis/read.c
index 221438883..d6a479741 100644
--- a/deps/hiredis/read.c
+++ b/deps/hiredis/read.c
@@ -29,7 +29,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-
#include "fmacros.h"
#include <string.h>
#include <stdlib.h>
@@ -40,6 +39,7 @@
#include <errno.h>
#include <ctype.h>
#include <limits.h>
+#include <math.h>
#include "read.h"
#include "sds.h"
@@ -278,6 +278,36 @@ static int processLineItem(redisReader *r) {
} else {
obj = (void*)REDIS_REPLY_INTEGER;
}
+ } else if (cur->type == REDIS_REPLY_DOUBLE) {
+ if (r->fn && r->fn->createDouble) {
+ char buf[326], *eptr;
+ double d;
+
+ if ((size_t)len-1 >= sizeof(buf)) {
+ __redisReaderSetError(r,REDIS_ERR_PROTOCOL,
+ "Double value is too large");
+ return REDIS_ERR;
+ }
+
+ memcpy(buf,p+1,len-1);
+ buf[len-1] = '\0';
+
+ if (strcasecmp(buf,",inf") == 0) {
+ d = 1.0/0.0; /* Positive infinite. */
+ } else if (strcasecmp(buf,",-inf") == 0) {
+ d = -1.0/0.0; /* Nevative infinite. */
+ } else {
+ d = strtod((char*)buf,&eptr);
+ if (eptr[0] != '\0' || isnan(d)) {
+ __redisReaderSetError(r,REDIS_ERR_PROTOCOL,
+ "Bad double value");
+ return REDIS_ERR;
+ }
+ }
+ obj = r->fn->createDouble(cur,d);
+ } else {
+ obj = (void*)REDIS_REPLY_DOUBLE;
+ }
} else {
/* Type will be error or status. */
if (r->fn && r->fn->createString)
@@ -460,6 +490,9 @@ static int processItem(redisReader *r) {
case ':':
cur->type = REDIS_REPLY_INTEGER;
break;
+ case ',':
+ cur->type = REDIS_REPLY_DOUBLE;
+ break;
case '$':
cur->type = REDIS_REPLY_STRING;
break;
@@ -487,6 +520,7 @@ static int processItem(redisReader *r) {
case REDIS_REPLY_ERROR:
case REDIS_REPLY_STATUS:
case REDIS_REPLY_INTEGER:
+ case REDIS_REPLY_DOUBLE:
return processLineItem(r);
case REDIS_REPLY_STRING:
return processBulkItem(r);
diff --git a/deps/hiredis/read.h b/deps/hiredis/read.h
index 84ee15cb6..e7c4bd308 100644
--- a/deps/hiredis/read.h
+++ b/deps/hiredis/read.h
@@ -81,6 +81,7 @@ typedef struct redisReplyObjectFunctions {
void *(*createString)(const redisReadTask*, char*, size_t);
void *(*createArray)(const redisReadTask*, int);
void *(*createInteger)(const redisReadTask*, long long);
+ void *(*createDouble)(const redisReadTask*, double);
void *(*createNil)(const redisReadTask*);
void (*freeObject)(void*);
} redisReplyObjectFunctions;