diff --git a/src/system/libroot/posix/string/strrchr.c b/src/system/libroot/posix/string/strrchr.c index a2abeb86f0..c975b3a6c0 100644 --- a/src/system/libroot/posix/string/strrchr.c +++ b/src/system/libroot/posix/string/strrchr.c @@ -1,7 +1,7 @@ -/* -** Copyright 2001, Manuel J. Petit. All rights reserved. -** Distributed under the terms of the NewOS License. -*/ +/* + * Copyright 2001, Manuel J. Petit. All rights reserved. + * Distributed under the terms of the NewOS License. + */ #include #include @@ -10,14 +10,13 @@ char * strrchr(char const *s, int c) { - char const *last = c ? 0 : s; + char const *last = NULL; - - while (*s) { - if (*s == c) + for (;; s++) { + if (*s == (char)c) last = s; - - s += 1; + if (*s == '\0') + break; } return (char *)last;