carp icon indicating copy to clipboard operation
carp copied to clipboard

strtok function?

Open janus opened this issue 9 years ago • 1 comments

There is something in the below I don't understand...to me the result of strtok is redundant because its inputs are constants. Is there something I am missing out?

See https://github.com/tekknolagi/carp/blob/master/src/carp_tokenizer.c#L112

toks = strtok(NULL, delim);

    if (toks != NULL) {
      parsed->next = malloc(sizeof *parsed->next);
      lookbehind = parsed;
      parsed = parsed->next;
    }

janus avatar May 03 '15 14:05 janus

As I understand the man page, strtok maintains its own state, and subsequent calls to tokenize a string must call strtok with NULL as the first argument: http://linux.die.net/man/3/strtok

If I have misunderstood, please correct me.

All that being said, I do plan on rewriting this tokenizer entirely.

tekknolagi avatar May 03 '15 17:05 tekknolagi