aboutsummaryrefslogtreecommitdiff
path: root/sys/libkern
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>1999-12-10 17:38:41 +0000
committerPeter Wemm <peter@FreeBSD.org>1999-12-10 17:38:41 +0000
commit453713898148aa3c05ff75238db3402a6ad1a1de (patch)
tree372c0b9a0a8fb4511957c386b9aadaf9291915bd /sys/libkern
parentaa6be122fdbf570c204351ebe746fbf562a709b0 (diff)
downloadsrc-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')
-rw-r--r--sys/libkern/index.c28
-rw-r--r--sys/libkern/rindex.c31
2 files changed, 20 insertions, 39 deletions
diff --git a/sys/libkern/index.c b/sys/libkern/index.c
index b22341cd2253..5c592bfd56af 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 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 */