mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-09 20:41:27 -04:00
Fix implementation of strsep.
svn:r457
This commit is contained in:
parent
4ed4867375
commit
bc7b7c249c
@ -26,3 +26,4 @@ Changes in current version:
|
|||||||
o Fix win32 buffer.c behavior so that it is correct for sockets (which do not like ReadFile and WriteFile).
|
o Fix win32 buffer.c behavior so that it is correct for sockets (which do not like ReadFile and WriteFile).
|
||||||
o Make the test.sh script run unit tests for the evpoll method.
|
o Make the test.sh script run unit tests for the evpoll method.
|
||||||
o Make the entire evdns.h header enclosed in "extern C" as appropriate.
|
o Make the entire evdns.h header enclosed in "extern C" as appropriate.
|
||||||
|
o Fix implementation of strsep on platforms that lack it
|
||||||
|
10
http.c
10
http.c
@ -138,17 +138,21 @@ void evhttp_read(int, short, void *);
|
|||||||
void evhttp_write(int, short, void *);
|
void evhttp_write(int, short, void *);
|
||||||
|
|
||||||
#ifndef HAVE_STRSEP
|
#ifndef HAVE_STRSEP
|
||||||
|
/* strsep replacement for platforms that lack it. Only works if
|
||||||
|
* del is one character long. */
|
||||||
static char *
|
static char *
|
||||||
strsep(char **s, const char *del)
|
strsep(char **s, const char *del)
|
||||||
{
|
{
|
||||||
char *d, *tok;
|
char *d, *tok;
|
||||||
|
assert(strlen(del) == 1);
|
||||||
if (!s || !*s)
|
if (!s || !*s)
|
||||||
return NULL;
|
return NULL;
|
||||||
tok = *s;
|
tok = *s;
|
||||||
d = strstr(tok, del);
|
d = strstr(tok, del);
|
||||||
if (d)
|
if (d) {
|
||||||
*s = d + strlen(del);
|
*d = '\0';
|
||||||
else
|
*s = d + 1;
|
||||||
|
} else
|
||||||
*s = NULL;
|
*s = NULL;
|
||||||
return tok;
|
return tok;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user