summaryrefslogtreecommitdiffstats
path: root/sys/libkern/rindex.c
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1999-12-10 17:38:41 +0000
committerpeter <peter@FreeBSD.org>1999-12-10 17:38:41 +0000
commit7cd6c4d188847b8167e9a9e05ad034f5d51a13df (patch)
tree163f9248d3dedff4434849e33fd82e432ddbc804 /sys/libkern/rindex.c
parent108333f0a453421722555eb52a232a10bd5c4c77 (diff)
downloadFreeBSD-src-7cd6c4d188847b8167e9a9e05ad034f5d51a13df.zip
FreeBSD-src-7cd6c4d188847b8167e9a9e05ad034f5d51a13df.tar.gz
Zap c_index() and c_rindex(). Bruce prefers these to implicitly convert
a const into a non-const as they do in libc. I feel that defeating the type checking like that quite evil, but that's the way it is.
Diffstat (limited to 'sys/libkern/rindex.c')
-rw-r--r--sys/libkern/rindex.c31
1 files changed, 10 insertions, 21 deletions
diff --git a/sys/libkern/rindex.c b/sys/libkern/rindex.c
index b73031c..29c01a7 100644
--- a/sys/libkern/rindex.c
+++ b/sys/libkern/rindex.c
@@ -38,31 +38,20 @@
char *
rindex(p, ch)
- char *p;
- int ch;
-{
- char *save;
-
- for (save = NULL;; ++p) {
- if (*p == ch)
- save = p;
- if (!*p)
- return(save);
- }
- /* NOTREACHED */
-}
-
-const char *
-c_rindex(p, ch)
const char *p;
int ch;
{
- const char *save;
+ union {
+ const char *cp;
+ char *p;
+ } u;
+ char *save;
- for (save = NULL;; ++p) {
- if (*p == ch)
- save = p;
- if (!*p)
+ u.cp = p;
+ for (save = NULL;; ++u.p) {
+ if (*u.p == ch)
+ save = u.p;
+ if (!*u.p)
return(save);
}
/* NOTREACHED */
OpenPOWER on IntegriCloud