6 * split a string into an array of strings,
7 * separated by any chars in the fs string
8 * strings may contain chars from fs if quoted
9 * quotes may be escaped or quoted
15 strsplit(char *s, char *fs)
17 char *sp, *sp2, *delim, **ssp, *ns;
19 static char quote[] = "'";
21 if((ns = malloc((unsigned) strlen(s) + 1)) == NULL)
28 while(*sp && strchr(fs, *sp))
37 while(*sp && !strchr(delim, *sp))
51 if(sp[1] == '\'' || sp[1] == '"')
57 if(delim == quote && *sp)
60 while(delim == quote && *sp);
64 if((ssp = (char **) malloc(sizeof(char *) * (num + 2))) == NULL)
68 for(i = 1; i <= num; i++)