aboutsummaryrefslogtreecommitdiff
path: root/newlib/libc/string/strrchr.c
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc/string/strrchr.c')
-rw-r--r--newlib/libc/string/strrchr.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/newlib/libc/string/strrchr.c b/newlib/libc/string/strrchr.c
index 65160f5..36ef3ef 100644
--- a/newlib/libc/string/strrchr.c
+++ b/newlib/libc/string/strrchr.c
@@ -41,21 +41,19 @@ _DEFUN (strrchr, (s, i),
int i)
{
_CONST char *last = NULL;
- char c = i;
- while (*s)
+ if (i)
{
- if (*s == c)
+ while (s=strchr(s, i))
{
last = s;
+ s++;
}
- s++;
}
-
- if (*s == c)
+ else
{
- last = s;
+ last = strchr(s, i);
}
-
+
return (char *) last;
}