Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4264 → Rev 4265

/trunk/uspace/lib/libc/include/string.h
73,6 → 73,7
extern void wstr_nstr(char *dst, const wchar_t *src, size_t size);
 
extern const char *str_chr(const char *str, wchar_t ch);
extern const char *str_rchr(const char *str, wchar_t ch);
 
extern bool wstr_linsert(wchar_t *str, wchar_t ch, count_t pos, count_t max_pos);
extern bool wstr_remove(wchar_t *str, count_t pos);
91,9 → 92,6
 
extern char *strdup(const char *);
 
extern char *strchr(const char *, int);
extern char *strrchr(const char *, int);
 
extern long int strtol(const char *, char **, int);
extern unsigned long strtoul(const char *, char **, int);
 
/trunk/uspace/lib/libc/generic/getopt.c
241,7 → 241,7
}
}
if ((optchar = (int)*place++) == (int)':' ||
(oli = strchr(options + (IGNORE_FIRST ? 1 : 0), optchar)) == NULL) {
(oli = str_chr(options + (IGNORE_FIRST ? 1 : 0), optchar)) == NULL) {
/* option letter unknown or ':' */
if (!*place)
++optind;
377,7 → 377,7
nonopt_start = nonopt_end = -1;
return -1;
}
if ((has_equal = strchr(current_argv, '=')) != NULL) {
if ((has_equal = str_chr(current_argv, '=')) != NULL) {
/* argument found (--option=arg) */
current_argv_len = has_equal - current_argv;
has_equal++;
/trunk/uspace/lib/libc/generic/string.c
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);
 
/trunk/uspace/srv/loader/main.c
275,7 → 275,7
const char *cp;
/* Set the task name. */
cp = strrchr(pathname, '/');
cp = str_rchr(pathname, '/');
cp = (cp == NULL) ? pathname : (cp + 1);
task_set_name(cp);
/trunk/uspace/srv/fs/fat/fat_dentry.c
66,7 → 66,7
 
if (!(rc = stricmp(name, component)))
return rc;
if (!strchr(name, '.')) {
if (!str_chr(name, '.')) {
/*
* There is no '.' in the name, so we know that there is enough
* space for appending an extra '.' to name.