Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
cacab3b1
Commit
cacab3b1
authored
Oct 28, 2011
by
antirez
Browse files
sds.c single quotes support
parent
072a9052
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/sds.c
View file @
cacab3b1
...
...
@@ -474,7 +474,8 @@ sds *sdssplitargs(char *line, int *argc) {
while
(
*
p
&&
isspace
(
*
p
))
p
++
;
if
(
*
p
)
{
/* 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
;
if
(
current
==
NULL
)
current
=
sdsempty
();
...
...
@@ -504,7 +505,23 @@ sds *sdssplitargs(char *line, int *argc) {
}
current
=
sdscatlen
(
current
,
&
c
,
1
);
}
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
;
done
=
1
;
}
else
if
(
!*
p
)
{
...
...
@@ -525,6 +542,9 @@ sds *sdssplitargs(char *line, int *argc) {
case
'"'
:
inq
=
1
;
break
;
case
'\''
:
insq
=
1
;
break
;
default:
current
=
sdscatlen
(
current
,
p
,
1
);
break
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment