Changeset 8e7c9fe in mainline for uspace/lib/posix/source/string.c
- Timestamp:
- 2014-09-12T03:45:25Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c53b58e
- Parents:
- 3eb0c85 (diff), 105d8d6 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/posix/source/string.c
r3eb0c85 r8e7c9fe 508 508 509 509 return NULL; 510 } 511 512 /** Split string by delimiters. 513 * 514 * @param s String to be tokenized. May not be NULL. 515 * @param delim String with the delimiters. 516 * @return Pointer to the prefix of @a s before the first 517 * delimiter character. NULL if no such prefix 518 * exists. 519 */ 520 char *posix_strtok(char *s, const char *delim) 521 { 522 static char *next; 523 524 return posix_strtok_r(s, delim, &next); 525 } 526 527 528 /** Split string by delimiters. 529 * 530 * @param s String to be tokenized. May not be NULL. 531 * @param delim String with the delimiters. 532 * @param next Variable which will receive the pointer to the 533 * continuation of the string following the first 534 * occurrence of any of the delimiter characters. 535 * May be NULL. 536 * @return Pointer to the prefix of @a s before the first 537 * delimiter character. NULL if no such prefix 538 * exists. 539 */ 540 char *posix_strtok_r(char *s, const char *delim, char **next) 541 { 542 char *start, *end; 543 544 if (s == NULL) 545 s = *next; 546 547 /* Skip over leading delimiters. */ 548 while (*s && (posix_strchr(delim, *s) != NULL)) ++s; 549 start = s; 550 551 /* Skip over token characters. */ 552 while (*s && (posix_strchr(delim, *s) == NULL)) ++s; 553 end = s; 554 *next = (*s ? s + 1 : s); 555 556 if (start == end) { 557 return NULL; /* No more tokens. */ 558 } 559 560 /* Overwrite delimiter with NULL terminator. */ 561 *end = '\0'; 562 return start; 510 563 } 511 564
Note:
See TracChangeset
for help on using the changeset viewer.