added 1 changeset to branch 'refs/remotes/HaikuPM-github/package-management' old head: 37cfff1f04388b62c3a7453aa4cc0e81b4c0978c new head: ce76b7e202b1141bdc0a1989bfce9ac27bcbc7aa overview: https://github.com/haiku/HaikuPM/compare/37cfff1...ce76b7e ---------------------------------------------------------------------------- ce76b7e: Fix strrchr() * For the comparison cast the character parameter to char as required by the spec. * Fix broken handling of strrchr(..., 0). It is supposed to return a pointer to the end of the string. It did return a pointer to the start. [ Ingo Weinhold <ingo_weinhold@xxxxxx> ] ---------------------------------------------------------------------------- Commit: ce76b7e202b1141bdc0a1989bfce9ac27bcbc7aa Author: Ingo Weinhold <ingo_weinhold@xxxxxx> Date: Tue Aug 13 19:30:30 2013 UTC ---------------------------------------------------------------------------- 1 file changed, 9 insertions(+), 10 deletions(-) src/system/libroot/posix/string/strrchr.c | 19 +++++++++---------- ---------------------------------------------------------------------------- diff --git a/src/system/libroot/posix/string/strrchr.c b/src/system/libroot/posix/string/strrchr.c index a2abeb8..c975b3a 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 <sys/types.h> #include <string.h> @@ -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;