diff --git a/sys/cddl/compat/opensolaris/kern/opensolaris_string.c b/sys/cddl/compat/opensolaris/kern/opensolaris_string.c index cae984fbbff9..4448f3485ccf 100644 --- a/sys/cddl/compat/opensolaris/kern/opensolaris_string.c +++ b/sys/cddl/compat/opensolaris/kern/opensolaris_string.c @@ -31,37 +31,6 @@ #define IS_ALPHA(c) \ (((c) >= 'a' && (c) <= 'z') || ((c) >= 'A' && (c) <= 'Z')) -char * -strchr(const char *s, int c) -{ - char ch; - - ch = c; - for (;; ++s) { - if (*s == ch) - return ((char *)s); - if (*s == '\0') - return (NULL); - } - /* NOTREACHED */ -} - -char * -strrchr(const char *s, int c) -{ - char *save; - char ch; - - ch = c; - for (save = NULL;; ++s) { - if (*s == ch) - save = (char *)s; - if (*s == '\0') - return (save); - } - /* NOTREACHED */ -} - char * strpbrk(const char *s, const char *b) { diff --git a/sys/cddl/compat/opensolaris/sys/string.h b/sys/cddl/compat/opensolaris/sys/string.h index c802c0f4cd39..aeec929610ed 100644 --- a/sys/cddl/compat/opensolaris/sys/string.h +++ b/sys/cddl/compat/opensolaris/sys/string.h @@ -29,8 +29,8 @@ #ifndef _OPENSOLARIS_SYS_STRING_H_ #define _OPENSOLARIS_SYS_STRING_H_ -char *strchr(const char *, int); -char *strrchr(const char *p, int c); +#include + char *strpbrk(const char *, const char *); void strident_canon(char *s, size_t n); diff --git a/sys/compat/opensolaris/kern/opensolaris_string.c b/sys/compat/opensolaris/kern/opensolaris_string.c index cae984fbbff9..4448f3485ccf 100644 --- a/sys/compat/opensolaris/kern/opensolaris_string.c +++ b/sys/compat/opensolaris/kern/opensolaris_string.c @@ -31,37 +31,6 @@ #define IS_ALPHA(c) \ (((c) >= 'a' && (c) <= 'z') || ((c) >= 'A' && (c) <= 'Z')) -char * -strchr(const char *s, int c) -{ - char ch; - - ch = c; - for (;; ++s) { - if (*s == ch) - return ((char *)s); - if (*s == '\0') - return (NULL); - } - /* NOTREACHED */ -} - -char * -strrchr(const char *s, int c) -{ - char *save; - char ch; - - ch = c; - for (save = NULL;; ++s) { - if (*s == ch) - save = (char *)s; - if (*s == '\0') - return (save); - } - /* NOTREACHED */ -} - char * strpbrk(const char *s, const char *b) { diff --git a/sys/compat/opensolaris/sys/string.h b/sys/compat/opensolaris/sys/string.h index c802c0f4cd39..aeec929610ed 100644 --- a/sys/compat/opensolaris/sys/string.h +++ b/sys/compat/opensolaris/sys/string.h @@ -29,8 +29,8 @@ #ifndef _OPENSOLARIS_SYS_STRING_H_ #define _OPENSOLARIS_SYS_STRING_H_ -char *strchr(const char *, int); -char *strrchr(const char *p, int c); +#include + char *strpbrk(const char *, const char *); void strident_canon(char *s, size_t n); diff --git a/sys/libkern/index.c b/sys/libkern/index.c index d9f470945550..a12d70616c43 100644 --- a/sys/libkern/index.c +++ b/sys/libkern/index.c @@ -33,6 +33,10 @@ __FBSDID("$FreeBSD$"); #include #include +/* + * index() is also present as the strchr() in the kernel; it does exactly the + * same thing as it's userland equivalent. + */ char * index(p, ch) const char *p; diff --git a/sys/libkern/rindex.c b/sys/libkern/rindex.c index b1669f82c2b9..19bed70344f9 100644 --- a/sys/libkern/rindex.c +++ b/sys/libkern/rindex.c @@ -33,6 +33,10 @@ __FBSDID("$FreeBSD$"); #include #include +/* + * rindex() is also present as the strrchr() in the kernel; it does exactly the + * same thing as it's userland equivalent. + */ char * rindex(p, ch) const char *p; diff --git a/sys/sys/libkern.h b/sys/sys/libkern.h index 9d5ba5c293fe..e3deb2db35bb 100644 --- a/sys/sys/libkern.h +++ b/sys/sys/libkern.h @@ -153,6 +153,18 @@ memset(void *b, int c, size_t len) return (b); } +static __inline char * +strchr(const char *p, int ch) +{ + return (index(p, ch)); +} + +static __inline char * +strrchr(const char *p, int ch) +{ + return (rindex(p, ch)); +} + /* fnmatch() return values. */ #define FNM_NOMATCH 1 /* Match failed. */