summaryrefslogtreecommitdiff
path: root/libc/string/string.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-06-15 20:02:37 +0000
committerEric Andersen <andersen@codepoet.org>2001-06-15 20:02:37 +0000
commit3632e2fabdbfe3a279e2464088af05fbe2956e1d (patch)
treed1d2a3d5fd3a65ffdf821a1a049aa50ad6c1b5bd /libc/string/string.c
parent1a5c8c4765bd07f9503282b9db75aa4466016660 (diff)
Make strrchr not call other string functions. Hopefully
speeding it a bit.
Diffstat (limited to 'libc/string/string.c')
-rw-r--r--libc/string/string.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/libc/string/string.c b/libc/string/string.c
index bb524eeac..27649b43b 100644
--- a/libc/string/string.c
+++ b/libc/string/string.c
@@ -197,21 +197,20 @@ weak_alias(strchr, index);
/********************** Function strrchr ************************************/
#ifdef L_strrchr
+
char *strrchr(const char *str, int c)
{
register char *prev = 0;
register char *ptr = (char *) str;
- /* For null it's just like strlen */
- if (c == '\0')
- return ptr + strlen(ptr);
-
- /* everything else just step along the string. */
- while ((ptr = strchr(ptr, c)) != 0) {
- prev = ptr;
+ while (*ptr != '\0') {
+ if (*ptr == c)
+ prev = ptr;
ptr++;
}
- return prev;
+ if (c == '\0')
+ return(ptr);
+ return(prev);
}
weak_alias(strrchr, rindex);