FreeBSD/usr.bin/whereis/whereis.c
/*
 * Split string `s' at colons, and pass it to the string list pointed
 * to by `cppp' (which has `*ip' elements).  Note that the original
 * string is modified by replacing the colon with a NUL byte.  The
 * partial string is only added if it has a length greater than 0, and
 * if it's not already contained in the string list.
 */
Split string `s' at colons, and pass it to the string list pointed
to by `cppp' (which has `*ip' elements).  Note that the original
string is modified by replacing the colon with a NUL byte.  The
partial string is only added if it has a length greater than 0, and
if it's not already contained in the string list.
Split string ` s ' at colons and pass it to the string list pointed to by ` cppp ' ( which has ` * ip ' elements ) . Note that the original string is modified by replacing the colon with a NUL byte . The partial string is only added if it has a length greater than 0 and if it ' s not already contained in the string list .
static void
decolonify(char *s, ccharp **cppp, int *ip)
{
	char *cp;
	while ((cp = strchr(s, ':')), *s != '\0') {
		if (cp)
			*cp = '\0';
		if (strlen(s) && !contains(*cppp, s)) {
			*cppp = realloc(*cppp, (*ip + 2) * sizeof(char *));
			if (*cppp == NULL)
				abort();
			(*cppp)[*ip] = s;
			(*cppp)[*ip + 1] = NULL;
			(*ip)++;
		}
		if (cp)
			s = cp + 1;
		else
			break;
	}
}
static void decolonify ( char * s , ccharp * * cppp , int * ip ) { char * cp ; while ( ( cp = strchr ( s , ' ' ) ) , * s != ' \0 ' ) { if ( cp ) * cp = ' \0 ' ; if ( strlen ( s ) && ! contains ( * cppp , s ) ) { * cppp = realloc ( * cppp , ( * ip + 2 ) * sizeof ( char * ) ) ; if ( * cppp == NULL ) abort ( ) ; ( * cppp ) [ * ip ] = s ; ( * cppp ) [ * ip + 1 ] = NULL ; ( * ip ) ++ ; } if ( cp ) s = cp + 1 ; else break ; } }
Split string `s' at colons, and pass it to the string list pointed
 to by `cppp' (which has `*ip' elements).
Split string ` s ' at colons and pass it to the string list pointed to by ` cppp ' ( which has ` * ip ' elements ) .