MCPcopy Create free account
hub / github.com/coreboot/coreboot / strtok_r

Function strtok_r

payloads/libpayload/libc/string.c:516–535  ·  view source on GitHub ↗

* Extract first token in string str that is delimited by a character in tokens. * Destroys str and eliminates the token delimiter. * @param str A pointer to the string to tokenize. * @param delim A pointer to an array of characters that delimit the token * @param ptr A pointer to a string pointer to keep state of the tokenizer * @return Pointer to token */

Source from the content-addressed store, hash-verified

514 * @return Pointer to token
515 */
516char *strtok_r(char *str, const char *delim, char **ptr)
517{
518 /* start new tokenizing job or continue existing one? */
519 if (str == NULL)
520 str = *ptr;
521
522 /* skip over prefix delimiters */
523 char *start = str + strspn(str, delim);
524
525 if (start[0] == '\0')
526 return NULL;
527
528 /* find first delimiter character */
529 char *end = start + strcspn(start, delim);
530 *ptr = end;
531 if (end[0] != '\0')
532 *(*ptr)++ = '\0';
533
534 return start;
535}
536
537/**
538 * Extract first token in string str that is delimited by a character in tokens.

Callers 1

strtokFunction · 0.70

Calls 2

strspnFunction · 0.70
strcspnFunction · 0.70

Tested by

no test coverage detected