Changeset 12b29f3 in mainline
- Timestamp:
- 2014-08-29T07:50:09Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 293703e
- Parents:
- 69c664e
- Location:
- uspace/lib/posix
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/posix/include/posix/string.h
r69c664e r12b29f3 64 64 * forward declarations ought to be enough. 65 65 */ 66 /* From str.h. */67 extern char * strtok_r(char *, const char *, char **);68 extern char * strtok(char *, const char *);69 66 70 67 /* From mem.h */ … … 101 98 extern char *__POSIX_DEF__(strstr)(const char *haystack, const char *needle); 102 99 100 /* Tokenization functions. */ 101 extern char *__POSIX_DEF__(strtok_r)(char *, const char *, char **); 102 extern char *__POSIX_DEF__(strtok)(char *, const char *); 103 104 103 105 /* Collation Functions */ 104 106 extern int __POSIX_DEF__(strcoll)(const char *s1, const char *s2); -
uspace/lib/posix/source/string.c
r69c664e r12b29f3 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.