Add include files to get prototype declarations, and fix bugs found.
[unix-history] / usr / src / lib / libc / string / index.c
index aa55b60..e734007 100644 (file)
@@ -6,9 +6,10 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)index.c    5.6 (Berkeley) %G%";
+static char sccsid[] = "@(#)index.c    5.7 (Berkeley) %G%";
 #endif /* LIBC_SCCS and not lint */
 
 #endif /* LIBC_SCCS and not lint */
 
+#include <sys/cdefs.h>
 #include <string.h>
 #include <stddef.h>
 
 #include <string.h>
 #include <stddef.h>
 
@@ -18,11 +19,11 @@ strchr(p, ch)
 #else
 index(p, ch)
 #endif
 #else
 index(p, ch)
 #endif
-       register char *p, ch;
+       register const char *p, ch;
 {
        for (;; ++p) {
                if (*p == ch)
 {
        for (;; ++p) {
                if (*p == ch)
-                       return(p);
+                       return((char *)p);
                if (!*p)
                        return((char *)NULL);
        }
                if (!*p)
                        return((char *)NULL);
        }