summaryrefslogtreecommitdiffstats
path: root/sys
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
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')
-rw-r--r--sys/kern/kern_linker.c4
-rw-r--r--sys/libkern/index.c28
-rw-r--r--sys/libkern/rindex.c31
-rw-r--r--sys/sys/libkern.h6
4 files changed, 24 insertions, 45 deletions
diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c
index f8054ca..9262e54 100644
--- a/sys/kern/kern_linker.c
+++ b/sys/kern/kern_linker.c
@@ -345,7 +345,7 @@ linker_make_file(const char* pathname, void* priv, struct linker_file_ops* ops)
int namelen;
const char *filename;
- filename = c_rindex(pathname, '/');
+ filename = rindex(pathname, '/');
if (filename && filename[1])
filename++;
else
@@ -993,7 +993,7 @@ linker_search_path(const char *name)
enum vtype type;
/* qualified at all? */
- if (c_index(name, '/'))
+ if (index(name, '/'))
return(linker_strdup(name));
/* traverse the linker path */
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 */
diff --git a/sys/sys/libkern.h b/sys/sys/libkern.h
index 71947a0..340bc68 100644
--- a/sys/sys/libkern.h
+++ b/sys/sys/libkern.h
@@ -73,10 +73,8 @@ int locc __P((int, char *, u_int));
void qsort __P((void *base, size_t nmemb, size_t size,
int (*compar)(const void *, const void *)));
u_long random __P((void));
-char *index __P((char *, int));
-char *rindex __P((char *, int));
-const char *c_index __P((const char *, int));
-const char *c_rindex __P((const char *, int));
+char *index __P((const char *, int));
+char *rindex __P((const char *, int));
int scanc __P((u_int, const u_char *, const u_char *, int));
int skpc __P((int, int, char *));
void srandom __P((u_long));
OpenPOWER on IntegriCloud