mirror of
https://github.com/fluencelabs/redis
synced 2025-04-01 23:31:03 +00:00
sds.c single quotes support
This commit is contained in:
parent
d8ba159b6c
commit
e1cf460cf1
24
src/sds.c
24
src/sds.c
@ -477,7 +477,8 @@ sds *sdssplitargs(char *line, int *argc) {
|
|||||||
while(*p && isspace(*p)) p++;
|
while(*p && isspace(*p)) p++;
|
||||||
if (*p) {
|
if (*p) {
|
||||||
/* get a token */
|
/* get a token */
|
||||||
int inq=0; /* set to 1 if we are in "quotes" */
|
int inq=0; /* set to 1 if we are in "quotes" */
|
||||||
|
int insq=0; /* set to 1 if we are in 'single quotes' */
|
||||||
int done=0;
|
int done=0;
|
||||||
|
|
||||||
if (current == NULL) current = sdsempty();
|
if (current == NULL) current = sdsempty();
|
||||||
@ -507,7 +508,23 @@ sds *sdssplitargs(char *line, int *argc) {
|
|||||||
}
|
}
|
||||||
current = sdscatlen(current,&c,1);
|
current = sdscatlen(current,&c,1);
|
||||||
} else if (*p == '"') {
|
} else if (*p == '"') {
|
||||||
/* closing quote must be followed by a space */
|
/* closing quote must be followed by a space or
|
||||||
|
* nothing at all. */
|
||||||
|
if (*(p+1) && !isspace(*(p+1))) goto err;
|
||||||
|
done=1;
|
||||||
|
} else if (!*p) {
|
||||||
|
/* unterminated quotes */
|
||||||
|
goto err;
|
||||||
|
} else {
|
||||||
|
current = sdscatlen(current,p,1);
|
||||||
|
}
|
||||||
|
} else if (insq) {
|
||||||
|
if (*p == '\\' && *(p+1) == '\'') {
|
||||||
|
p++;
|
||||||
|
current = sdscatlen(current,"'",1);
|
||||||
|
} else if (*p == '\'') {
|
||||||
|
/* closing quote must be followed by a space or
|
||||||
|
* nothing at all. */
|
||||||
if (*(p+1) && !isspace(*(p+1))) goto err;
|
if (*(p+1) && !isspace(*(p+1))) goto err;
|
||||||
done=1;
|
done=1;
|
||||||
} else if (!*p) {
|
} else if (!*p) {
|
||||||
@ -528,6 +545,9 @@ sds *sdssplitargs(char *line, int *argc) {
|
|||||||
case '"':
|
case '"':
|
||||||
inq=1;
|
inq=1;
|
||||||
break;
|
break;
|
||||||
|
case '\'':
|
||||||
|
insq=1;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
current = sdscatlen(current,p,1);
|
current = sdscatlen(current,p,1);
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user