From 7cd6c4d188847b8167e9a9e05ad034f5d51a13df Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 10 Dec 1999 17:38:41 +0000 Subject: 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. --- sys/libkern/rindex.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) (limited to 'sys/libkern/rindex.c') 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 */ -- cgit v1.1