diff options
author | simon <simon@FreeBSD.org> | 2003-07-28 22:50:42 +0000 |
---|---|---|
committer | simon <simon@FreeBSD.org> | 2003-07-28 22:50:42 +0000 |
commit | e669733309fbc4dc64ccfd18e35a59f5075138e7 (patch) | |
tree | 82c3c2f1c097a4d61b843d9a19122e752c9404e1 /lib/libc/string/index.3 | |
parent | 2d36cfc14d602cba258095ac28ae460c653aa450 (diff) | |
download | FreeBSD-src-e669733309fbc4dc64ccfd18e35a59f5075138e7.zip FreeBSD-src-e669733309fbc4dc64ccfd18e35a59f5075138e7.tar.gz |
* Merge index(3) and rindex(3) to index(3) since the two functions are
almost identical.
* Merge strchr(3) and strrchr(3) to strchr(3) since the two functions
are almost identical.
* Make the wording of index(3) and strchr(3) more similar.
* mdoc(7) cleanup.
Submitted by: SUZUKI Koichi <metal@gc5.so-net.ne.jp>, keramida, myself
PR: docs/32054
Reviewed by: ru
Approved by: ceri (mentor)
Diffstat (limited to 'lib/libc/string/index.3')
-rw-r--r-- | lib/libc/string/index.3 | 44 |
1 files changed, 30 insertions, 14 deletions
diff --git a/lib/libc/string/index.3 b/lib/libc/string/index.3 index 149b1af..79eaa45 100644 --- a/lib/libc/string/index.3 +++ b/lib/libc/string/index.3 @@ -38,36 +38,50 @@ .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 . +The terminating null character is considered part of the string. +.Pp +The +.Fn rindex +function is identical to +.Fn index , +except it locates the last occurrence of +.Fa c . .Sh RETURN VALUES -A pointer to the character is returned if it is found; otherwise +The functions +.Fn index +and +.Fn rindex +return a pointer to the located character, or .Dv NULL -is returned. +if the character does not appear in the string. If .Fa c -is '\e0', -.Fn index -locates the terminating '\e0'. +is +.Ql \e0 , +the functions locate the terminating +.Ql \e0 . .Sh SEE ALSO .Xr memchr 3 , -.Xr rindex 3 , .Xr strchr 3 , .Xr strcspn 3 , .Xr strpbrk 3 , @@ -77,13 +91,15 @@ locates the terminating '\e0'. .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 +Their prototypes existed previously in .Aq Pa string.h -before it was moved to +before they were moved to .Aq Pa strings.h for .St -p1003.1-2001 |