docs/32054: inconsistency between index.3 and rindex.3
Simon L. Nielsen
simon at nitro.dk
Thu May 1 22:40:12 UTC 2003
The following reply was made to PR docs/32054; it has been noted by GNATS.
From: "Simon L. Nielsen" <simon at nitro.dk>
To: freebsd-gnats-submit at freebsd.org, SUZUKI Koichi <koich at cac.co.jp>
Cc:
Subject: Re: docs/32054: inconsistency between index.3 and rindex.3
Date: Fri, 2 May 2003 00:35:59 +0200
--brEuL7wsLY8+TuWz
Content-Type: multipart/mixed; boundary="sgneBHv3152wZ8jf"
Content-Disposition: inline
--sgneBHv3152wZ8jf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Hello
After some more research...
index / strchr are located in different header files so to avoid
confusion I think it is simpler to keep them as seperate man pages.
The attached patch differes from the pr previous patch I added to this
PR by :
Minor fixes found from comparing with other similar man pages
documenting multiple functions.
Include the documentation of strrchr in strchr(3).
Minimze the diff between strchr(3) and index(3) mainly overriding from
strchr(3) to index(3) since the former is the "standard" one and
strchr(3) matches mostly with the Open Group Unix Specification
description.
If this patch is used rindex.3 and strrchr.3 should be deleted from the
tree.
--=20
Simon L. Nielsen
--sgneBHv3152wZ8jf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="man-index.3-sln2.patch"
Content-Transfer-Encoding: quoted-printable
Index: Makefile.inc
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/ncvs/src/lib/libc/string/Makefile.inc,v
retrieving revision 1.32
diff -u -d -r1.32 Makefile.inc
--- Makefile.inc 18 Nov 2002 09:50:56 -0000 1.32
+++ Makefile.inc 1 May 2003 22:13:19 -0000
@@ -26,14 +26,16 @@
.endif
=20
MAN+=3D 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
=20
+MLINKS+=3Dindex.3 rindex.3
MLINKS+=3Dstrcasecmp.3 strncasecmp.3
MLINKS+=3Dstrcat.3 strncat.3
+MLINKS+=3Dstrchr.3 strrchr.3
MLINKS+=3Dstrcmp.3 strncmp.3
MLINKS+=3Dstrcpy.3 stpcpy.3
MLINKS+=3Dstrcpy.3 strncpy.3
Index: index.3
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/ncvs/src/lib/libc/string/index.3,v
retrieving revision 1.8
diff -u -d -r1.8 index.3
--- index.3 18 Dec 2002 13:33:03 -0000 1.8
+++ index.3 1 May 2003 22:02:15 -0000
@@ -38,7 +38,8 @@
.Dt INDEX 3
.Os
.Sh NAME
-.Nm index
+.Nm index ,
+.Nm rindex
.Nd locate character in string
.Sh LIBRARY
.Lb libc
@@ -46,28 +47,44 @@
.In strings.h
.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
+.Dv 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
+returns 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 locates the terminating
+.Ql \e0 .
.Sh SEE ALSO
.Xr memchr 3 ,
-.Xr rindex 3 ,
.Xr strchr 3 ,
.Xr strcspn 3 ,
.Xr strpbrk 3 ,
@@ -79,11 +96,13 @@
.Sh HISTORY
A
.Fn index
+and a
+.Fn rindex
function 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
Index: strchr.3
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/ncvs/src/lib/libc/string/strchr.3,v
retrieving revision 1.9
diff -u -d -r1.9 strchr.3
--- strchr.3 18 Dec 2002 13:33:03 -0000 1.9
+++ strchr.3 1 May 2003 21:40:59 -0000
@@ -40,7 +40,8 @@
.Dt STRCHR 3
.Os
.Sh NAME
-.Nm strchr
+.Nm strchr ,
+.Nm strrchr
.Nd locate character in string
.Sh LIBRARY
.Lb libc
@@ -48,41 +49,53 @@
.In string.h
.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
+.Dv NULL
character is considered part of the string.
-If
-.Fa c
-is
-.Ql \e0 ,
+.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
+and
+.Fn strrchr
returns 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 locates 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
+and
+.Fn strrchr
conforms to
.St -isoC .
--sgneBHv3152wZ8jf--
--brEuL7wsLY8+TuWz
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (FreeBSD)
iD8DBQE+saFN8kocFXgPTRwRAohJAJ0Yg6Ge9jhzTdcdTPdYKicQpbmCXQCgxwPy
m13i6mqQqOLtQYq3o0HsWds=
=Uhep
-----END PGP SIGNATURE-----
--brEuL7wsLY8+TuWz--
More information about the freebsd-doc
mailing list