o make first arg const since we don't modify it
o use strsep() instead of strtok() as strtok() changes internal state
o add some bounds checking and use strlcat() instead of pointer arithmetic
o ANSI function headers
Originally based on a patch from Lars J. Buitinck but much modified.