Rev 4264 | Rev 4266 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4264 | Rev 4265 | ||
---|---|---|---|
Line 533... | Line 533... | ||
533 | * |
533 | * |
534 | * @param str String to search. |
534 | * @param str String to search. |
535 | * @param ch Character to look for. |
535 | * @param ch Character to look for. |
536 | * |
536 | * |
537 | * @return Pointer to character in @a str or NULL if not found. |
537 | * @return Pointer to character in @a str or NULL if not found. |
538 | * |
- | |
539 | */ |
538 | */ |
540 | const char *str_chr(const char *str, wchar_t ch) |
539 | const char *str_chr(const char *str, wchar_t ch) |
541 | { |
540 | { |
542 | wchar_t acc; |
541 | wchar_t acc; |
543 | size_t off = 0; |
542 | size_t off = 0; |
Line 548... | Line 547... | ||
548 | } |
547 | } |
549 | 548 | ||
550 | return NULL; |
549 | return NULL; |
551 | } |
550 | } |
552 | 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; |
|
- | 572 | } |
|
- | 573 | ||
553 | /** Insert a wide character into a wide string. |
574 | /** Insert a wide character into a wide string. |
554 | * |
575 | * |
555 | * Insert a wide character into a wide string at position |
576 | * Insert a wide character into a wide string at position |
556 | * @a pos. The characters after the position are shifted. |
577 | * @a pos. The characters after the position are shifted. |
557 | * |
578 | * |
Line 625... | Line 646... | ||
625 | c++; |
646 | c++; |
626 | 647 | ||
627 | return (tolower(a[c]) - tolower(b[c])); |
648 | return (tolower(a[c]) - tolower(b[c])); |
628 | } |
649 | } |
629 | 650 | ||
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 not |
- | |
635 | * 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 not |
- | |
653 | * 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 | } |
- | |
667 | - | ||
668 | /** Convert string to a number. |
651 | /** Convert string to a number. |
669 | * Core of strtol and strtoul functions. |
652 | * Core of strtol and strtoul functions. |
670 | * |
653 | * |
671 | * @param nptr Pointer to string. |
654 | * @param nptr Pointer to string. |
672 | * @param endptr If not NULL, function stores here pointer to the first |
655 | * @param endptr If not NULL, function stores here pointer to the first |
Line 867... | Line 850... | ||
867 | 850 | ||
868 | if (s == NULL) |
851 | if (s == NULL) |
869 | s = *next; |
852 | s = *next; |
870 | 853 | ||
871 | /* Skip over leading delimiters. */ |
854 | /* Skip over leading delimiters. */ |
872 | while (*s && (strchr(delim, *s) != NULL)) ++s; |
855 | while (*s && (str_chr(delim, *s) != NULL)) ++s; |
873 | start = s; |
856 | start = s; |
874 | 857 | ||
875 | /* Skip over token characters. */ |
858 | /* Skip over token characters. */ |
876 | while (*s && (strchr(delim, *s) == NULL)) ++s; |
859 | while (*s && (str_chr(delim, *s) == NULL)) ++s; |
877 | end = s; |
860 | end = s; |
878 | *next = (*s ? s + 1 : s); |
861 | *next = (*s ? s + 1 : s); |
879 | 862 | ||
880 | if (start == end) { |
863 | if (start == end) { |
881 | return NULL; /* No more tokens. */ |
864 | return NULL; /* No more tokens. */ |