From e6a467814a642185e3aa2fce5dc28807f37b55d9 Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 21 Nov 2018 12:49:39 +0100 Subject: [PATCH] RESP3: addReply*Len() support for RESP2 backward comp. --- src/networking.c | 16 ++++++++-------- src/server.h | 1 - 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/networking.c b/src/networking.c index f1ccdaf17..533df2f22 100644 --- a/src/networking.c +++ b/src/networking.c @@ -562,23 +562,23 @@ void addReplyArrayLen(client *c, long length) { } void addReplyMapLen(client *c, long length) { - addReplyAggregateLen(c,length,'%'); + int prefix = c->resp == 2 ? '*' : '%'; + addReplyAggregateLen(c,length,prefix); } void addReplySetLen(client *c, long length) { - addReplyAggregateLen(c,length,'~'); + int prefix = c->resp == 2 ? '*' : '~'; + addReplyAggregateLen(c,length,prefix); } void addReplyAttributeLen(client *c, long length) { - addReplyAggregateLen(c,length,'|'); + int prefix = c->resp == 2 ? '*' : '|'; + addReplyAggregateLen(c,length,prefix); } void addReplyPushLen(client *c, long length) { - addReplyAggregateLen(c,length,'>'); -} - -void addReplyHelloLen(client *c, long length) { - addReplyAggregateLen(c,length,'@'); + int prefix = c->resp == 2 ? '*' : '>'; + addReplyAggregateLen(c,length,prefix); } /* Create the length prefix of a bulk reply, example: $2234 */ diff --git a/src/server.h b/src/server.h index 603bbd2e3..4b8655006 100644 --- a/src/server.h +++ b/src/server.h @@ -1456,7 +1456,6 @@ void addReplyMapLen(client *c, long length); void addReplySetLen(client *c, long length); void addReplyAttributeLen(client *c, long length); void addReplyPushLen(client *c, long length); -void addReplyHelloLen(client *c, long length); void addReplyHelp(client *c, const char **help); void addReplySubcommandSyntaxError(client *c); void copyClientOutputBuffer(client *dst, client *src);