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 | |
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')
-rw-r--r-- | lib/libc/string/Makefile.inc | 6 | ||||
-rw-r--r-- | lib/libc/string/index.3 | 44 | ||||
-rw-r--r-- | lib/libc/string/rindex.3 | 92 | ||||
-rw-r--r-- | lib/libc/string/strchr.3 | 44 | ||||
-rw-r--r-- | lib/libc/string/strrchr.3 | 91 |
5 files changed, 61 insertions, 216 deletions
diff --git a/lib/libc/string/Makefile.inc b/lib/libc/string/Makefile.inc index 8621f26..a1cc7d4 100644 --- a/lib/libc/string/Makefile.inc +++ b/lib/libc/string/Makefile.inc @@ -26,14 +26,16 @@ MISRCS+=bcmp.c bcopy.c bzero.c ffs.c index.c memccpy.c memchr.c memcmp.c \ .endif MAN+= bcmp.3 bcopy.3 bstring.3 bzero.3 ffs.3 index.3 memccpy.3 memchr.3 \ - memcmp.3 memcpy.3 memmove.3 memset.3 rindex.3 strcasecmp.3 strcat.3 \ + memcmp.3 memcpy.3 memmove.3 memset.3 strcasecmp.3 strcat.3 \ strchr.3 strcmp.3 strcoll.3 strcpy.3 strcspn.3 strdup.3 strerror.3 \ - string.3 strlcpy.3 strlen.3 strmode.3 strpbrk.3 strrchr.3 strsep.3 \ + string.3 strlcpy.3 strlen.3 strmode.3 strpbrk.3 strsep.3 \ strspn.3 strstr.3 strtok.3 strxfrm.3 swab.3 wcscoll.3 wcstok.3 \ wcswidth.3 wcsxfrm.3 wmemchr.3 +MLINKS+=index.3 rindex.3 MLINKS+=strcasecmp.3 strncasecmp.3 MLINKS+=strcat.3 strncat.3 +MLINKS+=strchr.3 strrchr.3 MLINKS+=strcmp.3 strncmp.3 MLINKS+=strcpy.3 stpcpy.3 MLINKS+=strcpy.3 strncpy.3 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 diff --git a/lib/libc/string/rindex.3 b/lib/libc/string/rindex.3 deleted file mode 100644 index ddef319..0000000 --- a/lib/libc/string/rindex.3 +++ /dev/null @@ -1,92 +0,0 @@ -.\" Copyright (c) 1990, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek. -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)rindex.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt RINDEX 3 -.Os -.Sh NAME -.Nm rindex -.Nd locate character in string -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In strings.h -.Ft char * -.Fn rindex "const char *s" "int c" -.Sh DESCRIPTION -The -.Fn rindex -function -locates the last character -matching -.Fa c -(converted to a -.Vt char ) -in the null-terminated string -.Fa s . -.Sh RETURN VALUES -A pointer to the character is returned if it is found; otherwise -NULL is returned. -If -.Fa c -is -.Ql \e0 , -.Fn rindex -locates the terminating -.Ql \e0 . -.Sh SEE ALSO -.Xr index 3 , -.Xr memchr 3 , -.Xr strchr 3 , -.Xr strcspn 3 , -.Xr strpbrk 3 , -.Xr strrchr 3 , -.Xr strsep 3 , -.Xr strspn 3 , -.Xr strstr 3 , -.Xr strtok 3 -.Sh HISTORY -A -.Fn rindex -function appeared in -.At v6 . -Its prototype existed previously in -.Aq Pa string.h -before it was moved to -.Aq Pa strings.h -for -.St -p1003.1-2001 -compliance. diff --git a/lib/libc/string/strchr.3 b/lib/libc/string/strchr.3 index 5bbc739..09b8414 100644 --- a/lib/libc/string/strchr.3 +++ b/lib/libc/string/strchr.3 @@ -40,49 +40,59 @@ .Dt STRCHR 3 .Os .Sh NAME -.Nm strchr +.Nm strchr , strrchr .Nd locate character in string .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In string.h -.Ft char * +.Ft "char *" .Fn strchr "const char *s" "int c" +.Ft "char *" +.Fn strrchr "const char *s" "int c" .Sh DESCRIPTION The .Fn strchr function locates the first occurrence of .Fa c +(converted to a +.Vt char ) in the string pointed to by .Fa s . -The terminating -.Dv NUL -character is considered part of the string. -If -.Fa c -is -.Ql \e0 , +The terminating null character is considered part of the string. +.Pp +The +.Fn strrchr +function is identical to .Fn strchr -locates the terminating -.Ql \e0 . +except it locates the last occurrence of +.Fa c . .Sh RETURN VALUES -The function +The functions .Fn strchr -returns a pointer to the located character, or +and +.Fn strrchr +return a pointer to the located character, or .Dv NULL if the character does not appear in the string. +If +.Fa c +is +.Ql \e0 , +the functions locate the terminating +.Ql \e0 . .Sh SEE ALSO .Xr memchr 3 , .Xr strcspn 3 , .Xr strpbrk 3 , -.Xr strrchr 3 , .Xr strsep 3 , .Xr strspn 3 , .Xr strstr 3 , .Xr strtok 3 .Sh STANDARDS -The +The functions .Fn strchr -function -conforms to +and +.Fn strrchr +conform to .St -isoC . diff --git a/lib/libc/string/strrchr.3 b/lib/libc/string/strrchr.3 deleted file mode 100644 index a930313..0000000 --- a/lib/libc/string/strrchr.3 +++ /dev/null @@ -1,91 +0,0 @@ -.\" Copyright (c) 1990, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek and the American National Standards Committee X3, -.\" on Information Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)strrchr.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 4, 1993 -.Dt STRRCHR 3 -.Os -.Sh NAME -.Nm strrchr -.Nd locate character in string -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In string.h -.Ft char * -.Fn strrchr "const char *s" "int c" -.Sh DESCRIPTION -The -.Fn strrchr -function -locates the last occurrence of -.Fa c -(converted to a char) -in the string -.Fa s . -If -.Fa c -is -.Ql \e0 , -.Fn strrchr -locates the terminating -.Ql \e0 . -.Sh RETURN VALUES -The -.Fn strrchr -function -returns a pointer to the character, -or a null -pointer if -.Fa c -does not occur anywhere in -.Fa s . -.Sh SEE ALSO -.Xr memchr 3 , -.Xr strchr 3 , -.Xr strcspn 3 , -.Xr strpbrk 3 , -.Xr strsep 3 , -.Xr strspn 3 , -.Xr strstr 3 , -.Xr strtok 3 -.Sh STANDARDS -The -.Fn strrchr -function -conforms to -.St -isoC . |