.\" SUCH DAMAGE.
.\"
.\" @(#)index.3 8.1 (Berkeley) 6/4/93
-.\" $FreeBSD: src/lib/libc/string/index.3,v 1.8 2002/12/18 13:33:03 ru Exp $
+.\" $FreeBSD: src/lib/libc/string/index.3,v 1.11 2003/09/08 19:57:15 ru Exp $
.\"
.Dd June 4, 1993
.Dt INDEX 3
.Os
.Sh NAME
-.Nm index
+.Nm index , rindex
.Nd locate character in string
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.In strings.h
-.Ft char *
+.Ft "char *"
.Fn index "const char *s" "int c"
+.Ft "char *"
+.Fn rindex "const char *s" "int c"
.Sh DESCRIPTION
The
.Fn index
function
-locates the first character matching
+locates the first occurrence of
.Fa c
(converted to a
.Vt char )
-in the null-terminated string
+in the string pointed to by
.Fa s .
-.Sh RETURN VALUES
-A pointer to the character is returned if it is found; otherwise
-.Dv NULL
-is returned.
-If
+The terminating null character is considered part of the string;
+therefore if
.Fa c
-is '\e0',
+is
+.Ql \e0 ,
+the functions locate the terminating
+.Ql \e0 .
+.Pp
+The
+.Fn rindex
+function is identical to
+.Fn index ,
+except it locates the last occurrence of
+.Fa c .
+.Sh RETURN VALUES
+The functions
.Fn index
-locates the terminating '\e0'.
+and
+.Fn rindex
+return a pointer to the located character, or
+.Dv NULL
+if the character does not appear in the string.
.Sh SEE ALSO
.Xr memchr 3 ,
-.Xr rindex 3 ,
.Xr strchr 3 ,
.Xr strcspn 3 ,
.Xr strpbrk 3 ,
.Xr strstr 3 ,
.Xr strtok 3
.Sh HISTORY
-A
+The
.Fn index
-function appeared in
+and
+.Fn rindex
+functions appeared in
.At v6 .
-Its prototype existed previously in
-.Aq Pa string.h
-before it was moved to
-.Aq Pa strings.h
+Their prototypes existed previously in
+.In string.h
+before they were moved to
+.In strings.h
for
.St -p1003.1-2001
compliance.