From b90f71ca2ab1b2eea7ca992b1e51a4b39afe0728 Mon Sep 17 00:00:00 2001 From: Scott Perry Date: Mon, 26 May 2008 12:38:15 +0200 Subject: Use strtok_r instead of strchr in IRC_JOIN. This patch does significant cleanup on the join code by using strtok_r instead of mangling strchr to parse channel names and keys in parallel when a JOIN command contains a list of channels and keys. Also adds an strtok_r implementation to libportab. --- src/portab/strtok_r.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/portab/strtok_r.c (limited to 'src/portab/strtok_r.c') diff --git a/src/portab/strtok_r.c b/src/portab/strtok_r.c new file mode 100644 index 00000000..852c8f70 --- /dev/null +++ b/src/portab/strtok_r.c @@ -0,0 +1,27 @@ +#include "portab.h" +#include + +#ifndef HAVE_STRTOK_R + +char * +strtok_r(char *str, const char *delim, char **saveptr) +{ + char *tmp; + + if (!str) + str = *saveptr; + str += strspn(str, delim); + if (*str == 0) + return NULL; + + tmp = str + strcspn(str, delim); /* get end of token */ + if (*tmp) { /* another delimiter */ + *tmp = 0; + tmp++; + } + *saveptr = tmp; + return str; +} + +#endif + -- cgit 1.4.1