diff options
Diffstat (limited to 'kern')
-rw-r--r-- | kern/string.c | 18 | ||||
-rw-r--r-- | kern/string.h | 3 |
2 files changed, 19 insertions, 2 deletions
diff --git a/kern/string.c b/kern/string.c index 05218e01..b77aa2f3 100644 --- a/kern/string.c +++ b/kern/string.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2014 Richard Braun. + * Copyright (c) 2012-2017 Richard Braun. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -176,3 +176,19 @@ strcmp(const char *s1, const char *s2) return (int)c1 - (int)c2; } #endif /* ARCH_STRING_STRCMP */ + +#ifndef ARCH_STRING_STRCHR +char * +strchr(const char *s, int c) +{ + for (;;) { + if (*s == c) { + return (char *)s; + } else if (*s == '\0') { + return NULL; + } + + s++; + } +} +#endif /* ARCH_STRING_STRCHR */ diff --git a/kern/string.h b/kern/string.h index 7ce4ab8f..86786c2b 100644 --- a/kern/string.h +++ b/kern/string.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012 Richard Braun. + * Copyright (c) 2012-2017 Richard Braun. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,5 +28,6 @@ size_t strlen(const char *s); char * strcpy(char *dest, const char *src); size_t strlcpy(char *dest, const char *src, size_t n); int strcmp(const char *s1, const char *s2); +char * strchr(const char *s, int c); #endif /* _KERN_STRING_H */ |