535,7 → 535,6 |
* @param ch Character to look for. |
* |
* @return Pointer to character in @a str or NULL if not found. |
* |
*/ |
const char *str_chr(const char *str, wchar_t ch) |
{ |
550,6 → 549,28 |
return NULL; |
} |
|
/** Find last occurence of character in string. |
* |
* @param str String to search. |
* @param ch Character to look for. |
* |
* @return Pointer to character in @a str or NULL if not found. |
*/ |
const char *str_rchr(const char *str, wchar_t ch) |
{ |
wchar_t acc; |
size_t off = 0; |
char *res; |
|
res = NULL; |
while ((acc = str_decode(str, &off, STR_NO_LIMIT)) != 0) { |
if (acc == ch) |
res = (str + off); |
} |
|
return res; |
} |
|
/** Insert a wide character into a wide string. |
* |
* Insert a wide character into a wide string at position |
627,44 → 648,6 |
return (tolower(a[c]) - tolower(b[c])); |
} |
|
/** Return pointer to the first occurence of character c in string. |
* |
* @param str Scanned string. |
* @param c Searched character (taken as one byte). |
* @return Pointer to the matched character or NULL if it is not |
* found in given string. |
*/ |
char *strchr(const char *str, int c) |
{ |
while (*str != '\0') { |
if (*str == (char) c) |
return (char *) str; |
str++; |
} |
|
return NULL; |
} |
|
/** Return pointer to the last occurence of character c in string. |
* |
* @param str Scanned string. |
* @param c Searched character (taken as one byte). |
* @return Pointer to the matched character or NULL if it is not |
* found in given string. |
*/ |
char *strrchr(const char *str, int c) |
{ |
char *retval = NULL; |
|
while (*str != '\0') { |
if (*str == (char) c) |
retval = (char *) str; |
str++; |
} |
|
return (char *) retval; |
} |
|
/** Convert string to a number. |
* Core of strtol and strtoul functions. |
* |
869,11 → 852,11 |
s = *next; |
|
/* Skip over leading delimiters. */ |
while (*s && (strchr(delim, *s) != NULL)) ++s; |
while (*s && (str_chr(delim, *s) != NULL)) ++s; |
start = s; |
|
/* Skip over token characters. */ |
while (*s && (strchr(delim, *s) == NULL)) ++s; |
while (*s && (str_chr(delim, *s) == NULL)) ++s; |
end = s; |
*next = (*s ? s + 1 : s); |
|