Skip to content
This repository was archived by the owner on Jan 19, 2021. It is now read-only.

strtok function? #47

Open
janus opened this issue May 3, 2015 · 1 comment
Open

strtok function? #47

janus opened this issue May 3, 2015 · 1 comment

Comments

@janus
Copy link

janus commented May 3, 2015

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;
    }
@tekknolagi
Copy link
Owner

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants