Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
2d869952
Commit
2d869952
authored
Jun 15, 2016
by
antirez
Browse files
GETRANGE: return empty string with negative, inverted start/end.
parent
eb45e114
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/bitops.c
View file @
2d869952
...
@@ -773,12 +773,12 @@ void bitcountCommand(client *c) {
...
@@ -773,12 +773,12 @@ void bitcountCommand(client *c) {
if
(
getLongFromObjectOrReply
(
c
,
c
->
argv
[
3
],
&
end
,
NULL
)
!=
C_OK
)
if
(
getLongFromObjectOrReply
(
c
,
c
->
argv
[
3
],
&
end
,
NULL
)
!=
C_OK
)
return
;
return
;
/* Convert negative indexes */
/* Convert negative indexes */
if
(
start
<
0
)
start
=
strlen
+
start
;
if
(
end
<
0
)
end
=
strlen
+
end
;
if
(
start
<
0
&&
end
<
0
&&
start
>
end
)
{
if
(
start
<
0
&&
end
<
0
&&
start
>
end
)
{
addReply
(
c
,
shared
.
czero
);
addReply
(
c
,
shared
.
czero
);
return
;
return
;
}
}
if
(
start
<
0
)
start
=
strlen
+
start
;
if
(
end
<
0
)
end
=
strlen
+
end
;
if
(
start
<
0
)
start
=
0
;
if
(
start
<
0
)
start
=
0
;
if
(
end
<
0
)
end
=
0
;
if
(
end
<
0
)
end
=
0
;
if
(
end
>=
strlen
)
end
=
strlen
-
1
;
if
(
end
>=
strlen
)
end
=
strlen
-
1
;
...
...
src/t_string.c
View file @
2d869952
...
@@ -263,6 +263,10 @@ void getrangeCommand(client *c) {
...
@@ -263,6 +263,10 @@ void getrangeCommand(client *c) {
}
}
/* Convert negative indexes */
/* Convert negative indexes */
if
(
start
<
0
&&
end
<
0
&&
start
>
end
)
{
addReply
(
c
,
shared
.
emptybulk
);
return
;
}
if
(
start
<
0
)
start
=
strlen
+
start
;
if
(
start
<
0
)
start
=
strlen
+
start
;
if
(
end
<
0
)
end
=
strlen
+
end
;
if
(
end
<
0
)
end
=
strlen
+
end
;
if
(
start
<
0
)
start
=
0
;
if
(
start
<
0
)
start
=
0
;
...
...
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