[BACK]Return to strtok_r.c CVS log [TXT][DIR] Up to [local] / ircnowd / src / portab

File: [local] / ircnowd / src / portab / strtok_r.c (download)

Revision 1.1, Thu May 16 11:07:06 2024 UTC (4 months ago) by tomglok
Branch point for: MAIN

Initial revision

/*
 * ngIRCd -- The Next Generation IRC Daemon
 */

#include "portab.h"

/**
 * @file
 * Implementation of strtok_r()
 */

#ifndef HAVE_STRTOK_R

#include <string.h>

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