On 13 Feb 2011, at 5:22 PM, Ruediger Pluem wrote:
+ /* skip characters in sep (will terminate at '\0') */ + while (*str && strchr(sep, *str)) { + ++str; + } + + if (!*str) { /* no more tokens */ + return NULL; + } + + token = str; + + /* skip valid token characters to terminate token and + * prepare for the next call (will terminate at '\0) + * on the way, ignore all quoted strings, and within + * quoted strings, escaped characters. + */ + *last = token + 1;What happens if str is supplied as "a, b"? I mean why token + 1 and not token?
I guess it's because we know *token isn't a separator, so there is no point checking if it is one a second time.
The same pattern exists in apr_strtok.c: https://svn.apache.org/repos/asf/apr/apr/trunk/strings/apr_strtok.c Regards, Graham --
