Commits

Anonymous committed 17ebab5

strtoken -> rb_strtok_r (with arguments order changes)

Comments (0)

Files changed (9)

include/irc_string.h

 #define EmptyString(x) ((x) == NULL || *(x) == '\0')
 #define CheckEmpty(x) EmptyString(x) ? "" : x
 
-char *strtoken(char **save, char *str, const char *fs);
-
 /*
  * character macros
  */

modules/core/m_join.c

 	 * this code has a side effect of losing keys, but..
 	 */
 	chanlist = LOCAL_COPY(parv[1]);
-	for(name = strtoken(&p, chanlist, ","); name; name = strtoken(&p, NULL, ","))
+	for(name = rb_strtok_r(chanlist, ",", &p); name; name = rb_strtok_r(NULL, ",", &p))
 	{
 		/* check the length and name of channel is ok */
 		if(!check_channel_name_loc(source_p, name) || (strlen(name) > LOC_CHANNELLEN))
 	if(parc > 2)
 	{
 		mykey = LOCAL_COPY(parv[2]);
-		key = strtoken(&p2, mykey, ",");
+		key = rb_strtok_r(mykey, ",", &p2);
 	}
 
-	for(name = strtoken(&p, jbuf, ","); name;
-	    key = (key) ? strtoken(&p2, NULL, ",") : NULL, name = strtoken(&p, NULL, ","))
+	for(name = rb_strtok_r(jbuf, ",", &p); name;
+	    key = (key) ? rb_strtok_r(NULL, ",", &p2) : NULL, name = rb_strtok_r(NULL, ",", &p))
 	{
 		hook_data_channel_activity hook_info;
 

modules/core/m_message.c

 
 	ntargets = 0;
 
-	for(nick = strtoken(&p, target_list, ","); nick; nick = strtoken(&p, NULL, ","))
+	for(nick = rb_strtok_r(target_list, ",", &p); nick; nick = rb_strtok_r(NULL, ",", &p))
 	{
 		char *with_prefix;
 		/*

modules/core/m_part.c

 	if(parc > 2)
 		rb_strlcpy(reason, parv[2], sizeof(reason));
 
-	name = strtoken(&p, s, ",");
+	name = rb_strtok_r(s, ",", &p);
 
 	/* Finish the flood grace period... */
 	if(MyClient(source_p) && !IsFloodDone(source_p))
 	while(name)
 	{
 		part_one_client(client_p, source_p, name, reason);
-		name = strtoken(&p, NULL, ",");
+		name = rb_strtok_r(NULL, ",", &p);
 	}
 	return 0;
 }

modules/m_accept.c

 	build_nicklist(source_p, addbuf, delbuf, parv[1]);
 
 	/* parse the delete list */
-	for (nick = strtoken(&p, delbuf, ","); nick != NULL; nick = strtoken(&p, NULL, ","))
+	for (nick = rb_strtok_r(delbuf, ",", &p); nick != NULL; nick = rb_strtok_r(NULL, ",", &p))
 	{
 		/* shouldnt happen, but lets be paranoid */
 		if((target_p = find_named_person(nick)) == NULL)
 	accept_num = rb_dlink_list_length(&source_p->localClient->allow_list);
 
 	/* parse the add list */
-	for (nick = strtoken(&p, addbuf, ","); nick; nick = strtoken(&p, NULL, ","))
+	for (nick = rb_strtok_r(addbuf, ",", &p); nick; nick = rb_strtok_r(NULL, ",", &p), accept_num++)
 	{
 		/* shouldnt happen, but lets be paranoid */
 		if((target_p = find_named_person(nick)) == NULL)
 		/* why is this here? */
 		/* del_from accept(target_p, source_p); */
 		add_accept(source_p, target_p);
-		accept_num++;
 	}
 
 	return 0;
 	del = lenadd = lendel = 0;
 
 	/* build list of clients to add into addbuf, clients to remove in delbuf */
-	for (name = strtoken(&p, n, ","); name; name = strtoken(&p, NULL, ","), del = 0)
+	for (name = rb_strtok_r(n, ",", &p); name; name = rb_strtok_r(NULL, ",", &p), del = 0)
 	{
 		if(*name == '-')
 		{

modules/m_capab.c

 	for (i = 1; i < parc; i++)
 	{
 		char *t = LOCAL_COPY(parv[i]);
-		for (s = strtoken(&p, t, " "); s; s = strtoken(&p, NULL, " "))
+		for (s = rb_strtok_r(t, " ", &p); s; s = rb_strtok_r(NULL, " ", &p))
 		{
 			for (cap = captab; cap->name; cap++)
 			{
 
 	source_p->serv->fullcaps = rb_strdup(parv[1]);
 
-	for (s = strtoken(&p, t, " "); s; s = strtoken(&p, NULL, " "))
+	for (s = rb_strtok_r(t, " ", &p); s; s = rb_strtok_r(NULL, " ", &p))
 	{
 		for (cap = captab; cap->name; cap++)
 		{
 	for (i = 1; i < parc; i++)
 	{
 		char *cs = LOCAL_COPY(parv[i]);
-		for (nick = strtoken(&p, cs, " "); nick; nick = strtoken(&p, NULL, " "))
+		for (nick = rb_strtok_r(cs, " ", &p); nick; nick = rb_strtok_r(NULL, " ", &p))
 		{
 			target_p = find_named_client(nick);
 

modules/m_monitor.c

 
 	tmp = LOCAL_COPY(nicks);
 
-	for(name = strtoken(&p, tmp, ","); name; name = strtoken(&p, NULL, ","))
+	for(name = rb_strtok_r(tmp, ",", &p); name; name = rb_strtok_r(NULL, ",", &p))
 	{
 		if(EmptyString(name) || strlen(name) > NICKLEN-1)
 			continue;
 
 	tmp = LOCAL_COPY(nicks);
 
-	for(name = strtoken(&p, tmp, ","); name; name = strtoken(&p, NULL, ","))
+	for(name = rb_strtok_r(tmp, ",", &p); name; name = rb_strtok_r(NULL, ",", &p))
 	{
 		if(EmptyString(name))
 			continue;
 	return dest;
 }
 
-/*
- * strtoken - walk through a string of tokens, using a set of separators
- *   argv 9/90
- *
- */
-char *
-strtoken(char **save, char *str, const char *fs)
-{
-	char *pos = *save;	/* keep last position across calls */
-	char *tmp;
-
-	if(str)
-		pos = str;	/* new string scan */
-
-	while(pos && *pos && strchr(fs, *pos) != NULL)
-		++pos;		/* skip leading separators */
-
-	if(!pos || !*pos)
-		return (pos = *save = NULL);	/* string contains only sep's */
-
-	tmp = pos;		/* now, keep position of the token */
-
-	while(*pos && strchr(fs, *pos) == NULL)
-		++pos;		/* skip content of the token */
-
-	if(*pos)
-		*pos++ = '\0';	/* remove first sep after the token */
-	else
-		pos = NULL;	/* end of string */
-
-	*save = pos;
-	return tmp;
-}
-
 char *
 strip_colour(char *string)
 {