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
8ce0b322
You need to sign in or sign up before continuing.
Commit
8ce0b322
authored
Nov 04, 2010
by
Pieter Noordhuis
Browse files
Finding \r\n without strstr is a little harder
parent
8b616d35
Changes
2
Hide whitespace changes
Inline
Side-by-side
hiredis.c
View file @
8ce0b322
...
@@ -164,8 +164,17 @@ static char *readBytes(redisReader *r, unsigned int bytes) {
...
@@ -164,8 +164,17 @@ static char *readBytes(redisReader *r, unsigned int bytes) {
static
char
*
seekNewline
(
char
*
s
)
{
static
char
*
seekNewline
(
char
*
s
)
{
/* Find pointer to \r\n without strstr */
/* Find pointer to \r\n without strstr */
while
(
s
!=
NULL
&&
s
[
0
]
!=
'\r'
&&
s
[
1
]
!=
'\n'
)
while
(
s
!=
NULL
)
{
s
=
strchr
(
s
,
'\r'
);
s
=
strchr
(
s
,
'\r'
);
if
(
s
!=
NULL
)
{
if
(
s
[
1
]
==
'\n'
)
break
;
else
s
++
;
}
else
{
break
;
}
}
return
s
;
return
s
;
}
}
...
...
test.c
View file @
8ce0b322
...
@@ -219,6 +219,17 @@ static void test_reply_reader() {
...
@@ -219,6 +219,17 @@ static void test_reply_reader() {
ret
=
redisReplyReaderGetReply
(
reader
,
&
reply
);
ret
=
redisReplyReaderGetReply
(
reader
,
&
reply
);
test_cond
(
ret
==
REDIS_OK
&&
reply
==
(
void
*
)
REDIS_REPLY_STATUS
);
test_cond
(
ret
==
REDIS_OK
&&
reply
==
(
void
*
)
REDIS_REPLY_STATUS
);
redisReplyReaderFree
(
reader
);
redisReplyReaderFree
(
reader
);
test
(
"Works when a single newline (
\\
r
\\
n) covers two calls to feed: "
);
reader
=
redisReplyReaderCreate
();
redisReplyReaderSetReplyObjectFunctions
(
reader
,
NULL
);
redisReplyReaderFeed
(
reader
,(
char
*
)
"+OK
\r
"
,
4
);
ret
=
redisReplyReaderGetReply
(
reader
,
&
reply
);
assert
(
ret
==
REDIS_OK
&&
reply
==
NULL
);
redisReplyReaderFeed
(
reader
,(
char
*
)
"
\n
"
,
1
);
ret
=
redisReplyReaderGetReply
(
reader
,
&
reply
);
test_cond
(
ret
==
REDIS_OK
&&
reply
==
(
void
*
)
REDIS_REPLY_STATUS
);
redisReplyReaderFree
(
reader
);
}
}
static
void
test_throughput
()
{
static
void
test_throughput
()
{
...
...
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