Bug 32054

Summary: inconsistency between index.3 and rindex.3
Product: Documentation Reporter: koich <koich>
Component: Books & ArticlesAssignee: Simon L. B. Nielsen <simon>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff
none
index.3.diff none

Description koich 2001-11-17 03:50:01 UTC
I found some inconsistency between index.3 and rindex.3.
Comment 1 Dima Dorfman 2001-11-18 00:36:09 UTC
SUZUKI Koichi <koich@cac.co.jp> wrote:
> I found some inconsistency between index.3 and rindex.3.

Is there a reason both of these shouldn't be described in one file?  I
know some people complained about man pages being overcrowded, but
this seems pretty natural to me.
Comment 2 metal 2001-11-18 07:30:13 UTC
Dima Dorfman wrote:

> SUZUKI Koichi <koich@cac.co.jp> wrote:
>>I found some inconsistency between index.3 and rindex.3.
> 
> Is there a reason both of these shouldn't be described in one file.  I

> know some people complained about man pages being overcrowded, but
> this seems pretty natural to me.

I don't know why these man pages are separated.

I agree with you.
I think these shoud be described together.

I made a patch to index.3 rev.1.6.
How about this one.
You know, I'm not native.
Please correct if you feel strange.

-- 
This is my STYLE.
SUZUKI Koichi
Comment 3 Giorgos Keramidas freebsd_committer freebsd_triage 2002-07-11 19:46:49 UTC
On 2001-11-16 19:41 +0000, SUZUKI Koichi wrote:
> I found some inconsistency between index.3 and rindex.3.

On 2001-11-18 00:36 +0000, Dima Dorfman wrote:
> Is there a reason both of these shouldn't be described in one file?
> I know some people complained about man pages being overcrowded, but
> this seems pretty natural to me.

On 2001-11-17 23:30 +0000, SUZUKI Koichi wrote:
> I agree with you.
> I think these shoud be described together.
>
> I made a patch to index.3 rev.1.6.
> How about this one.
> You know, I'm not native.
> Please correct if you feel strange.

How about this patch to src/lib/libc/string/ to make a link from
rindex.3 -> index.3, merge the text of rindex.3 and index.3 and then
`cvs remove' of rindex.3?

%%%
Index: Makefile.inc
===================================================================
RCS file: /home/ncvs/src/lib/libc/string/Makefile.inc,v
retrieving revision 1.26
diff -u -r1.26 Makefile.inc
--- Makefile.inc	27 Nov 2001 07:57:31 -0000	1.26
+++ Makefile.inc	11 Jul 2002 18:34:04 -0000
@@ -30,6 +30,7 @@
 	string.3 strlcpy.3 strlen.3 strmode.3 strpbrk.3 strrchr.3 strsep.3 \
 	strspn.3 strstr.3 strtok.3 strxfrm.3 swab.3 wmemchr.3
 
+MLINKS+=index.3 rindex.3
 MLINKS+=strcasecmp.3 strncasecmp.3
 MLINKS+=strcat.3 strncat.3
 MLINKS+=strcmp.3 strncmp.3
Index: index.3
===================================================================
RCS file: /home/ncvs/src/lib/libc/string/index.3,v
retrieving revision 1.6
diff -u -r1.6 index.3
--- index.3	1 Oct 2001 16:09:00 -0000	1.6
+++ index.3	11 Jul 2002 18:45:47 -0000
@@ -46,6 +46,9 @@
 .In string.h
 .Ft char *
 .Fn index "const char *s" "int c"
+.Lp
+.Ft char *
+.Fn rindex "const char *s" "int c"
 .Sh DESCRIPTION
 The
 .Fn index
@@ -56,18 +59,25 @@
 .Em char )
 in the null-terminated string
 .Fa s .
+The
+.Fn rindex
+function locates the last character matching
+.Fa c .
 .Sh RETURN VALUES
 A pointer to the character is returned if it is found; otherwise
 .Dv NULL
 is returned.
 If
 .Fa c
-is '\e0',
+is
+.Ql \e0 ,
 .Fn index
-locates the terminating '\e0'.
+and
+.Fn
+locate the terminating
+.Ql \e0 .
 .Sh SEE ALSO
 .Xr memchr 3 ,
-.Xr rindex 3 ,
 .Xr strchr 3 ,
 .Xr strcspn 3 ,
 .Xr strpbrk 3 ,
%%%
Comment 4 simon 2003-04-30 23:55:08 UTC
On 2003.04.30 15:30:09 -0700, Simon L. Nielsen wrote:
>  It seems very logical to merge the two man pages like suggested in the
>  PR.  I have a few minor changed to the patch that Giorgos Keramidas
>  <keramida@freebsd.org> added to the PR :


Having sent this I of course went to look if this was a generel issue
and found that actually strchr / strrchr are identical to index / rindex
and are in fact implemented from the same .c files.

Wouldn't it make sense to merge the man pages for all for pages since
all of them are very short and basically identical ?

Unless somebody tells me this is a bad idea I think I will do a new
patch to merge all four man pages...

-- 
Simon L. Nielsen
Comment 5 simon 2003-05-04 23:25:58 UTC
Hello

Resubmit of the previous patch inline as per request of Giorgos
Keramidas. At least I hope it will be inline when I don't sign
the mail...

The patch is also at
http://simon.nitro.dk/freebsd/files/work/man-index.3-sln2.patch in case
that is a simpler way to extract it.

%%%
Index: Makefile.inc
===================================================================
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
 
 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
Index: index.3
===================================================================
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
===================================================================
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 .
%%%

-- 
Simon L. Nielsen
Comment 6 Simon L. B. Nielsen freebsd_committer freebsd_triage 2003-07-25 17:15:52 UTC
Responsible Changed
From-To: freebsd-doc->simon

I already worked on this, so I will handle it.
Comment 7 Simon L. B. Nielsen freebsd_committer freebsd_triage 2003-07-28 23:51:45 UTC
State Changed
From-To: open->closed

Committed, thanks!