diff options
author | peter <peter@FreeBSD.org> | 1999-12-10 17:38:41 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1999-12-10 17:38:41 +0000 |
commit | 7cd6c4d188847b8167e9a9e05ad034f5d51a13df (patch) | |
tree | 163f9248d3dedff4434849e33fd82e432ddbc804 /sys/libkern | |
parent | 108333f0a453421722555eb52a232a10bd5c4c77 (diff) | |
download | FreeBSD-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')
-rw-r--r-- | sys/libkern/index.c | 28 | ||||
-rw-r--r-- | sys/libkern/rindex.c | 31 |
2 files changed, 20 insertions, 39 deletions
diff --git a/sys/libkern/index.c b/sys/libkern/index.c index b22341c..5c592bf 100644 --- a/sys/libkern/index.c +++ b/sys/libkern/index.c @@ -38,27 +38,19 @@ char * index(p, ch) - char *p; - int ch; -{ - for (;; ++p) { - if (*p == ch) - return(p); - if (!*p) - return(NULL); - } - /* NOTREACHED */ -} - -const char * -c_index(p, ch) const char *p; int ch; { - for (;; ++p) { - if (*p == ch) - return(p); - if (!*p) + union { + const char *cp; + char *p; + } u; + + u.cp = p; + for (;; ++u.p) { + if (*u.p == ch) + return(u.p); + if (!*u.p) return(NULL); } /* NOTREACHED */ 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 */ |