diff options
Diffstat (limited to 'userland/libc/string/strrchr.c')
-rw-r--r-- | userland/libc/string/strrchr.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/userland/libc/string/strrchr.c b/userland/libc/string/strrchr.c index a44199a..30b625d 100644 --- a/userland/libc/string/strrchr.c +++ b/userland/libc/string/strrchr.c @@ -3,10 +3,12 @@ char *strrchr(const char *s, int c) { char *last = NULL; for (; *s; s++) { - if (*s == (char)c) + if (*s == (char)c) { last = (char *)s; + } + } + if ((char)c == '\0') { + last = (char *)s; } - if ((char)c == '\0') - last = (char*)s; return last; } |