summaryrefslogtreecommitdiffstats
path: root/sys/libkern/index.c
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1999-11-21 04:26:48 +0000
committerpeter <peter@FreeBSD.org>1999-11-21 04:26:48 +0000
commit216e35006e551f69144762215a7ef9762298fe98 (patch)
tree408c546667ad68d073b739a9fae743a2cc3c218a /sys/libkern/index.c
parentbc517213b48aad16f9ee93b012cb65efddcc204c (diff)
downloadFreeBSD-src-216e35006e551f69144762215a7ef9762298fe98.zip
FreeBSD-src-216e35006e551f69144762215a7ef9762298fe98.tar.gz
Tempt fate and stop index from converting a const char * into a char *.
I've made a seperate version (c_index() etc) that use const/const, but I'm not sure it's worth it considering there is one file in the tree that uses index on const strings (kern_linker.c) and it's easily adjusted to scan the strings directly (and is perhaps more efficient that way).
Diffstat (limited to 'sys/libkern/index.c')
-rw-r--r--sys/libkern/index.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/sys/libkern/index.c b/sys/libkern/index.c
index 6351223..b22341c 100644
--- a/sys/libkern/index.c
+++ b/sys/libkern/index.c
@@ -33,21 +33,33 @@
* $FreeBSD$
*/
-#include <string.h>
+#include <sys/param.h>
+#include <sys/libkern.h>
char *
-#ifdef STRCHR
-strchr(p, ch)
-#else
index(p, ch)
-#endif
- register const char *p, ch;
+ char *p;
+ int ch;
{
for (;; ++p) {
if (*p == ch)
- return((char *)p);
+ return(p);
if (!*p)
- return((char *)NULL);
+ return(NULL);
+ }
+ /* NOTREACHED */
+}
+
+const char *
+c_index(p, ch)
+ const char *p;
+ int ch;
+{
+ for (;; ++p) {
+ if (*p == ch)
+ return(p);
+ if (!*p)
+ return(NULL);
}
/* NOTREACHED */
}
OpenPOWER on IntegriCloud