Changeset 7afb4a5 in mainline for uspace/lib/libc/generic/string.c
- Timestamp:
- 2009-04-09T21:28:50Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 095003a8
- Parents:
- 92fd52d7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libc/generic/string.c
r92fd52d7 r7afb4a5 536 536 * 537 537 * @return Pointer to character in @a str or NULL if not found. 538 *539 538 */ 540 539 const char *str_chr(const char *str, wchar_t ch) … … 549 548 550 549 return NULL; 550 } 551 552 /** Find last occurence of character in string. 553 * 554 * @param str String to search. 555 * @param ch Character to look for. 556 * 557 * @return Pointer to character in @a str or NULL if not found. 558 */ 559 const char *str_rchr(const char *str, wchar_t ch) 560 { 561 wchar_t acc; 562 size_t off = 0; 563 char *res; 564 565 res = NULL; 566 while ((acc = str_decode(str, &off, STR_NO_LIMIT)) != 0) { 567 if (acc == ch) 568 res = (str + off); 569 } 570 571 return res; 551 572 } 552 573 … … 626 647 627 648 return (tolower(a[c]) - tolower(b[c])); 628 }629 630 /** Return pointer to the first occurence of character c in string.631 *632 * @param str Scanned string.633 * @param c Searched character (taken as one byte).634 * @return Pointer to the matched character or NULL if it is not635 * found in given string.636 */637 char *strchr(const char *str, int c)638 {639 while (*str != '\0') {640 if (*str == (char) c)641 return (char *) str;642 str++;643 }644 645 return NULL;646 }647 648 /** Return pointer to the last occurence of character c in string.649 *650 * @param str Scanned string.651 * @param c Searched character (taken as one byte).652 * @return Pointer to the matched character or NULL if it is not653 * found in given string.654 */655 char *strrchr(const char *str, int c)656 {657 char *retval = NULL;658 659 while (*str != '\0') {660 if (*str == (char) c)661 retval = (char *) str;662 str++;663 }664 665 return (char *) retval;666 649 } 667 650 … … 870 853 871 854 /* Skip over leading delimiters. */ 872 while (*s && (str chr(delim, *s) != NULL)) ++s;855 while (*s && (str_chr(delim, *s) != NULL)) ++s; 873 856 start = s; 874 857 875 858 /* Skip over token characters. */ 876 while (*s && (str chr(delim, *s) == NULL)) ++s;859 while (*s && (str_chr(delim, *s) == NULL)) ++s; 877 860 end = s; 878 861 *next = (*s ? s + 1 : s);
Note:
See TracChangeset
for help on using the changeset viewer.