diff options
author | Peter Wemm <peter@FreeBSD.org> | 1999-12-10 17:38:41 +0000 |
---|---|---|
committer | Peter Wemm <peter@FreeBSD.org> | 1999-12-10 17:38:41 +0000 |
commit | 453713898148aa3c05ff75238db3402a6ad1a1de (patch) | |
tree | 372c0b9a0a8fb4511957c386b9aadaf9291915bd /sys/libkern/rindex.c | |
parent | aa6be122fdbf570c204351ebe746fbf562a709b0 (diff) | |
download | src-453713898148aa3c05ff75238db3402a6ad1a1de.tar.gz src-453713898148aa3c05ff75238db3402a6ad1a1de.zip |
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.
Notes
Notes:
svn path=/head/; revision=54411
Diffstat (limited to 'sys/libkern/rindex.c')
-rw-r--r-- | sys/libkern/rindex.c | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/sys/libkern/rindex.c b/sys/libkern/rindex.c index b73031c35123..29c01a793866 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 */ |