]> granicus.if.org Git - libevent/commitdiff
Fix implementation of strsep.
authorNick Mathewson <nickm@torproject.org>
Wed, 3 Oct 2007 04:14:54 +0000 (04:14 +0000)
committerNick Mathewson <nickm@torproject.org>
Wed, 3 Oct 2007 04:14:54 +0000 (04:14 +0000)
svn:r457

ChangeLog
http.c

index 96880842f8ec1d728a4fa38030bd83e90454556d..c36ce72c0d4854e8a3c17be0f8d863223c87a0e5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -25,4 +25,5 @@ Changes in current version:
  o Make test subdirectory compile under mingw.
  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 entire evdns.h header enclosed in "extern C" as appropriate.
\ No newline at end of file
+ o Make the entire evdns.h header enclosed in "extern C" as appropriate.
+ o Fix implementation of strsep on platforms that lack it
diff --git a/http.c b/http.c
index 098680dd561c7f8fe42f4909cbbe588cc0da41be..d0e458e488d33fac6f482290a61d902b39d6c39a 100644 (file)
--- a/http.c
+++ b/http.c
@@ -138,17 +138,21 @@ void evhttp_read(int, short, void *);
 void evhttp_write(int, short, void *);
 
 #ifndef HAVE_STRSEP
+/* strsep replacement for platforms that lack it.  Only works if
+ * del is one character long. */
 static char *
 strsep(char **s, const char *del)
 {
        char *d, *tok;
+        assert(strlen(del) == 1);
        if (!s || !*s)
                return NULL;
        tok = *s;
        d = strstr(tok, del);
-       if (d)
-               *s = d + strlen(del);
-       else
+       if (d) {
+               *d = '\0';
+               *s = d + 1;
+       } else
                *s = NULL;
        return tok;
 }