mirror of
https://github.com/sogou/workflow.git
synced 2026-10-25 17:10:05 +08:00
Merge pull request #1028 from Barenboim/master
Allow leading spaces in inline command
This commit is contained in:
+13
-16
@@ -145,8 +145,7 @@ static int __redis_parse_lf(const char ch, redis_parser_t *parser)
|
||||
|
||||
static int __redis_parse_line(redis_parser_t *parser)
|
||||
{
|
||||
char *buf = (char *)parser->msgbuf;
|
||||
char *str = buf + parser->msgidx;
|
||||
char *str = parser->msgbuf + parser->msgidx;
|
||||
size_t slen = parser->findidx - parser->msgidx;
|
||||
char data[32];
|
||||
int i, n;
|
||||
@@ -238,7 +237,7 @@ static int __redis_parse_line(redis_parser_t *parser)
|
||||
|
||||
static int __redis_parse_crlf(redis_parser_t *parser)
|
||||
{
|
||||
char *buf = (char *)parser->msgbuf;
|
||||
char *buf = parser->msgbuf;
|
||||
|
||||
for (; parser->findidx + 1 < parser->msgsize; parser->findidx++)
|
||||
{
|
||||
@@ -251,8 +250,6 @@ static int __redis_parse_crlf(redis_parser_t *parser)
|
||||
|
||||
static int __redis_parse_nchar(redis_parser_t *parser)
|
||||
{
|
||||
//char *buf = (char *)parser->msgbuf;
|
||||
|
||||
if (parser->nchar <= parser->msgsize - parser->msgidx)
|
||||
{
|
||||
redis_reply_set_string((const char *)parser->msgidx, parser->nchar,
|
||||
@@ -269,7 +266,7 @@ static int __redis_parse_nchar(redis_parser_t *parser)
|
||||
//-1 error | 0 continue | 1 finish-one | 2 not-enough
|
||||
static int __redis_parser_forward(redis_parser_t *parser)
|
||||
{
|
||||
char *buf = (char *)parser->msgbuf;
|
||||
char *buf = parser->msgbuf;
|
||||
|
||||
if (parser->msgidx >= parser->msgsize)
|
||||
return 2;
|
||||
@@ -363,11 +360,11 @@ static int __redis_parse_done(redis_reply_t *reply, char *buf, int depth)
|
||||
|
||||
static int __redis_split_inline_command(redis_parser_t *parser)
|
||||
{
|
||||
const char *msg = (const char *)parser->msgbuf;
|
||||
const char *end = msg + parser->msgsize;
|
||||
char *msg = parser->msgbuf;
|
||||
char *end = msg + parser->msgsize;
|
||||
size_t arr_size = 0;
|
||||
redis_reply_t **ele;
|
||||
const char *cur;
|
||||
char *cur;
|
||||
int ret;
|
||||
|
||||
while (msg != end)
|
||||
@@ -396,7 +393,7 @@ static int __redis_split_inline_command(redis_parser_t *parser)
|
||||
return ret;
|
||||
|
||||
ele = parser->reply.element;
|
||||
msg = (const char *)parser->msgbuf;
|
||||
msg = parser->msgbuf;
|
||||
|
||||
while (msg != end)
|
||||
{
|
||||
@@ -443,17 +440,17 @@ int redis_parser_append_message(const void *buf, size_t *size,
|
||||
if (!new_base)
|
||||
return -1;
|
||||
|
||||
parser->msgbuf = new_base;
|
||||
parser->msgbuf = (char *)new_base;
|
||||
parser->bufsize = new_size;
|
||||
}
|
||||
|
||||
memcpy((char *)parser->msgbuf + parser->msgsize, buf, *size);
|
||||
memcpy(parser->msgbuf + parser->msgsize, buf, *size);
|
||||
parser->msgsize += *size;
|
||||
|
||||
if (parser->msgsize && isalpha(*(const char *)parser->msgbuf))
|
||||
if (parser->msgsize > 0 && (isalpha(*parser->msgbuf) ||
|
||||
isspace(*parser->msgbuf)))
|
||||
{
|
||||
while (parser->msgidx < parser->msgsize &&
|
||||
*((const char *)parser->msgbuf + parser->msgidx) != '\n')
|
||||
*(parser->msgbuf + parser->msgidx) != '\n')
|
||||
{
|
||||
parser->msgidx++;
|
||||
}
|
||||
@@ -503,6 +500,6 @@ int redis_parser_append_message(const void *buf, size_t *size,
|
||||
} while (parser->status != REDIS_PARSE_END);
|
||||
|
||||
*size = parser->msgidx - msgsize_bak;
|
||||
return __redis_parse_done(&parser->reply, (char *)parser->msgbuf, 0);
|
||||
return __redis_parse_done(&parser->reply, parser->msgbuf, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ typedef struct __redis_parser
|
||||
{
|
||||
int parse_succ;//check first
|
||||
int status;
|
||||
void *msgbuf;
|
||||
char *msgbuf;
|
||||
size_t msgsize;
|
||||
size_t bufsize;
|
||||
redis_reply_t *cur;
|
||||
|
||||
Reference in New Issue
Block a user