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
hiredis
Commits
4eab917a
Commit
4eab917a
authored
Nov 26, 2010
by
Pieter Noordhuis
Browse files
Use custom stroll
parent
f1410836
Changes
1
Hide whitespace changes
Inline
Side-by-side
hiredis.c
View file @
4eab917a
...
@@ -192,6 +192,35 @@ static char *seekNewline(char *s, size_t len) {
...
@@ -192,6 +192,35 @@ static char *seekNewline(char *s, size_t len) {
return
NULL
;
return
NULL
;
}
}
/* Read a long long value starting at *s, under the assumption that it will be
* terminated by \r\n. Ambiguously returns -1 for unexpected input. */
static
long
long
readLongLong
(
char
*
s
)
{
long
long
v
=
0
;
int
dec
,
mult
=
1
;
char
c
;
if
(
*
s
==
'-'
)
{
mult
=
-
1
;
s
++
;
}
else
if
(
*
s
==
'+'
)
{
mult
=
1
;
s
++
;
}
while
((
c
=
*
(
s
++
))
!=
'\r'
)
{
dec
=
c
-
'0'
;
if
(
dec
>=
0
&&
dec
<
10
)
{
v
*=
10
;
v
+=
dec
;
}
else
{
/* Should not happen... */
return
-
1
;
}
}
return
mult
*
v
;
}
static
char
*
readLine
(
redisReader
*
r
,
int
*
_len
)
{
static
char
*
readLine
(
redisReader
*
r
,
int
*
_len
)
{
char
*
p
,
*
s
;
char
*
p
,
*
s
;
int
len
;
int
len
;
...
@@ -241,7 +270,7 @@ static int processLineItem(redisReader *r) {
...
@@ -241,7 +270,7 @@ static int processLineItem(redisReader *r) {
if
((
p
=
readLine
(
r
,
&
len
))
!=
NULL
)
{
if
((
p
=
readLine
(
r
,
&
len
))
!=
NULL
)
{
if
(
r
->
fn
)
{
if
(
r
->
fn
)
{
if
(
cur
->
type
==
REDIS_REPLY_INTEGER
)
{
if
(
cur
->
type
==
REDIS_REPLY_INTEGER
)
{
obj
=
r
->
fn
->
createInteger
(
cur
,
strtoll
(
p
,
NULL
,
10
));
obj
=
r
->
fn
->
createInteger
(
cur
,
readLongLong
(
p
));
}
else
{
}
else
{
obj
=
r
->
fn
->
createString
(
cur
,
p
,
len
);
obj
=
r
->
fn
->
createString
(
cur
,
p
,
len
);
}
}
...
@@ -270,7 +299,7 @@ static int processBulkItem(redisReader *r) {
...
@@ -270,7 +299,7 @@ static int processBulkItem(redisReader *r) {
if
(
s
!=
NULL
)
{
if
(
s
!=
NULL
)
{
p
=
r
->
buf
+
r
->
pos
;
p
=
r
->
buf
+
r
->
pos
;
bytelen
=
s
-
(
r
->
buf
+
r
->
pos
)
+
2
;
/* include \r\n */
bytelen
=
s
-
(
r
->
buf
+
r
->
pos
)
+
2
;
/* include \r\n */
len
=
strtol
(
p
,
NULL
,
10
);
len
=
readLongLong
(
p
);
if
(
len
<
0
)
{
if
(
len
<
0
)
{
/* The nil object can always be created. */
/* The nil object can always be created. */
...
@@ -315,7 +344,7 @@ static int processMultiBulkItem(redisReader *r) {
...
@@ -315,7 +344,7 @@ static int processMultiBulkItem(redisReader *r) {
}
}
if
((
p
=
readLine
(
r
,
NULL
))
!=
NULL
)
{
if
((
p
=
readLine
(
r
,
NULL
))
!=
NULL
)
{
elements
=
strtol
(
p
,
NULL
,
10
);
elements
=
readLongLong
(
p
);
root
=
(
r
->
ridx
==
0
);
root
=
(
r
->
ridx
==
0
);
if
(
elements
==
-
1
)
{
if
(
elements
==
-
1
)
{
...
...
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