From mika@dogmatix.cs.caltech.edu Wed Jun 23 18:50:05 1999
Return-Path: <mika@dogmatix.cs.caltech.edu>
Received: from vlsi.cs.caltech.edu (vlsi.cs.caltech.edu [131.215.131.129])
	by hub.freebsd.org (Postfix) with ESMTP id 5AA2614CAB
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 23 Jun 1999 18:50:04 -0700 (PDT)
	(envelope-from mika@dogmatix.cs.caltech.edu)
Received: from dogmatix.cs.caltech.edu (dogmatix.cs.caltech.edu [131.215.78.70])
	by vlsi.cs.caltech.edu (8.9.1/8.9.1) with ESMTP id SAA01081
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 23 Jun 1999 18:50:03 -0700 (PDT)
Received: (from mika@localhost)
	by dogmatix.cs.caltech.edu (8.8.8/8.8.7) id SAA09479;
	Wed, 23 Jun 1999 18:50:01 -0700 (PDT)
Message-Id: <199906240150.SAA09479@dogmatix.cs.caltech.edu>
Date: Wed, 23 Jun 1999 18:50:01 -0700 (PDT)
From: Mika Nystrom <mika@cs.caltech.edu>
Sender: mika@dogmatix.cs.caltech.edu
Reply-To: mika@cs.caltech.edu
To: FreeBSD-gnats-submit@freebsd.org
Subject: man page HISTORY for strdup is wrong
X-Send-Pr-Version: 3.2

>Number:         12372
>Category:       docs
>Synopsis:       man page HISTORY for strdup is wrong
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-doc
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jun 23 19:00:02 PDT 1999
>Closed-Date:    Tue Aug 10 05:59:12 PDT 1999
>Last-Modified:  Tue Aug 10 06:02:17 PDT 1999
>Originator:     Mika Nystrom
>Release:        FreeBSD 3.0-CURRENT i386
>Organization:
  Department of Computer Science
  California Institute of Technology
>Environment:
  3.0-CURRENT
  3.2-RELEASE
  others..?
	

>Description:
  The manual page for strdup(3) claims:
HISTORY
     The strdup() function first appeared in 4.4BSD.

BSD                              June 9, 1993                                1

This is wrong.  strdup() is documented in SunOS 4.1.1 (and earlier),
at least as early as 1987.  

From SunOS 4.1.1/sun3:

.\" @(#)string.3 1.33 90/02/15 SMI; from UCB 4.2 and S5
.TH STRING 3  "6 October 1987"
.SH NAME
strcat, strncat, strdup, strcmp, strncmp, strcasecmp, strncasecmp, strcpy, strnc
py, strlen, strchr, strrchr, strpbrk, strspn, strcspn, strstr, strtok, index, ri
ndex \- string operations

It is not present in Tahoe UNIX though (dated 22 Oct 1987, two weeks after
the SMI man page), so I assume it is actually from AT&T System V.
The only reason I bring this up is that the manual page might lead a 
programmer to believe (such as I did in shock after having used strdup
with abandon for several years) that use of strdup will lead to 
less portable programs than it actually does.

>How-To-Repeat:

freebsd% man 3 strdup
>Fix:
	
Edit the man page to say .. don't know.. "Probably from System V"?


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: sheldonh 
State-Changed-When: Thu Jun 24 07:24:09 PDT 1999 
State-Changed-Why:  
The HISTORY section of a manpage isn't intended for use as a portability 
reference. It's there to indicate how a program or interface came to 
exist in the system. 
State-Changed-From-To: closed->open 
State-Changed-By: billf 
State-Changed-When: Thu Jun 24 10:35:13 PDT 1999 
State-Changed-Why:  
This needs to be investigated further. 

From: Tim Vanderhoek <vanderh@ecf.utoronto.ca>
To: Mike Pritchard <mpp@mpp.pro-ns.net>
Cc: sheldonh@FreeBSD.ORG, mika@cs.caltech.edu,
	freebsd-bugs@FreeBSD.ORG, freebsd-gnats-submit@FreeBSD.ORG
Subject: Re: docs/12372: man page HISTORY for strdup is wrong
Date: Thu, 24 Jun 1999 18:09:46 -0400

 [Cc'd to -bugs instead of -doc]
 [Re: correct HISTORY of strdup(3)]
 
 On Thu, Jun 24, 1999 at 12:28:58PM -0500, Mike Pritchard wrote:
 >
 > states that strdup first appeared in 4.4BSD.  It's been so long
 > since I used a 4.2 system, I can't remember if it had strdup or
 > not.  Either way, it looks like the HISTORY really is incorrect.
 
 Yes, although I think it was listed as "under development" in 43.
 
 References: http://man.he.net/man3/strdup
             http://www.neosoft.com/neosoft/man/strdup.3.html
             http://src.doc.ic.ac.uk/computing/systems/unix/4.3bsd-net2/lib/libc/string/strdup.3.Z
 
 The first reference is a copy of some strdup manpage, I think from
 Linux.  It states that its strdup(3) function is conformant to SVID3
 and BSD43.  The 2nd and 3rd links are references to a BSD/386 manpage
 for strdup and to a manpage that appears to be the 43/net2 strdup manpage.
 Both the 2nd and 3rd links list strdup(3) as "Under development".
 
 If Mika (aka. the PR submitter, but Mika is such a cool-sounding name
 that I needed an excuse to say it twice) is right and it's not in
 4.3-Tahoe, then it probably appeared in SVr3 and was quickly copied
 into 43-Reno (or Net/1).  It's rather curious that it appears
 in SunOS 4.1.1 but not 43BSD, though...
 
 A link to a strdup(3) manpage dated Oct. 6, 1987,
 http://wwwwbs.cs.tu-berlin.de/cgi/rtfm/usr/local/man/man3/string.3
 
 Hmm...  Here's another one...  This HPUX man seems to state that
 strdup appeared in SVr2...
 http://www.informatik.uni-frankfurt.de/doc/man/hpux/strxfrm.3c.html
 
 Anyways, I'm inclined to place it in SVr2.
 
 
 -- 
 This is my .signature which gets appended to the end of my messages.
 

From: Mika Nystrom <mika@cs.caltech.edu>
To: mpp@mpp.pro-ns.net, Tim Vanderhoek <vanderh@ecf.utoronto.ca>
Cc: sheldonh@FreeBSD.ORG, mika@cs.caltech.edu,
	freebsd-bugs@FreeBSD.ORG, freebsd-gnats-submit@FreeBSD.ORG
Subject: Re: docs/12372: man page HISTORY for strdup is wrong 
Date: Thu, 24 Jun 1999 17:16:03 -0700

 Tim Vanderhoek writes:
 ...
 >
 >If Mika (aka. the PR submitter, but Mika is such a cool-sounding name
 >that I needed an excuse to say it twice) is right and it's not in
  
 :)
 
 >4.3-Tahoe, then it probably appeared in SVr3 and was quickly copied
 >into 43-Reno (or Net/1).  It's rather curious that it appears
 >in SunOS 4.1.1 but not 43BSD, though...
 >
 >A link to a strdup(3) manpage dated Oct. 6, 1987,
 >http://wwwwbs.cs.tu-berlin.de/cgi/rtfm/usr/local/man/man3/string.3
 >
 
 This looks just like my SunOS man page (notice the reference to the "Sun
 processor"!)
 
 I don't remember if I included the following in my PR:
 .\" @(#)string.3 1.33 90/02/15 SMI; from UCB 4.2 and S5
 
 The reference to S5 I think ought to account for differences.
 In case anyone is curious, I include the man page off the TAHOE 
 UNIX tape for reference.
 
 This is from a 9-track marked "4.3BSD-tahoe TAHOE UNIX System 
 7/25/88"---sorry but I can't help much with the SysV.. I powered
 up an old UNIX PC we have running "UNIX SYSTEM5 3.51m," but it did
 not have a strdup declared in string.h.
 
    Mika
 
 
 >Hmm...  Here's another one...  This HPUX man seems to state that
 >strdup appeared in SVr2...
 >http://www.informatik.uni-frankfurt.de/doc/man/hpux/strxfrm.3c.html
 >
 >Anyways, I'm inclined to place it in SVr2.
 >
 >
 >-- 
 >This is my .signature which gets appended to the end of my messages.
 
 .\" Copyright (c) 1980 Regents of the University of California.
 .\" All rights reserved.  The Berkeley software License Agreement
 .\" specifies the terms and conditions for redistribution.
 .\"
 .\"	@(#)string.3	6.5 (Berkeley) 10/22/87
 .\"
 .TH STRING 3  "October 22, 1987"
 .UC 4
 .SH NAME
 strcat, strncat, strcmp, strncmp, strcasecmp, strncasecmp, strcpy,
 strncpy, strlen, index, rindex \- string operations
 .SH SYNOPSIS
 .nf
 .B #include <strings.h>
 .PP
 .B char *strcat(s, append)
 .B char *s, *append;
 .PP
 .B char *strncat(s, append, count)
 .B char *s, *append;
 .B int count;
 .PP
 .B strcmp(s1, s2)
 .B char *s1, *s2;
 .PP
 .B strncmp(s1, s2, count)
 .B char *s1, *s2;
 .B int count;
 .PP
 .B strcasecmp(s1, s2)
 .B char *s1, *s2;
 .PP
 .B strncasecmp(s1, s2, count)
 .B char *s1, *s2;
 .B int count;
 .PP
 .B char *strcpy(to, from)
 .B char *to, *from;
 .PP
 .B char *strncpy(to, from, count)
 .B char *to, *from;
 .B int count;
 .PP
 .B strlen(s)
 .B char *s;
 .PP
 .B char *index(s, c)
 .B char *s, c;
 .PP
 .B char *rindex(s, c)
 .B char *s, c;
 .fi
 .SH DESCRIPTION
 These functions operate on null-terminated strings.
 They do not check for overflow of any receiving string.
 .PP
 \fIStrcat\fP appends a copy of string \fIappend\fP to the end of string
 \fIs\fP. \fIStrncat\fP copies at most \fIcount\fP characters.  Both
 return a pointer to the null-terminated result.
 .PP
 \fIStrcmp\fP compares its arguments and returns an integer greater than,
 equal to, or less than 0, according as \fIs1\fP is lexicographically
 greater than, equal to, or less than \fIs2\fP.  \fIStrncmp\fP makes the
 same comparison but looks at at most \fIcount\fP characters.
 \fIStrcasecmp\fP and \fIstrncasecmp\fP are identical in function, but are
 case insensitive.  The returned lexicographic difference reflects a
 conversion to lower-case.
 .PP
 \fIStrcpy\fP copies string \fIfrom\fP to \fIto\fP, stopping after the
 null character has been moved.  \fIStrncpy\fP copies exactly \fIcount\fP
 characters, appending nulls if \fIfrom\fP is less than \fIcount\fP
 characters in length; the target may not be null-terminated if the
 length of \fIfrom\fP is \fIcount\fP or more.  Both return \fIto\fP.
 .PP
 \fIStrlen\fP returns the number of non-null characters in \fIs\fP.
 .PP
 .I Index
 .RI ( rindex )
 returns a pointer to the first (last) occurrence of character 
 \fIc\fP in string \fIs\fP or zero if \fIc\fP does not occur in
 the string.  Setting \fIc\fP to NULL works.
 
 

From: Tim Vanderhoek <vanderh@ecf.utoronto.ca>
To: Mika Nystrom <mika@cs.caltech.edu>
Cc: mpp@mpp.pro-ns.net, sheldonh@FreeBSD.ORG,
	freebsd-bugs@FreeBSD.ORG, freebsd-gnats-submit@FreeBSD.ORG
Subject: Re: docs/12372: man page HISTORY for strdup is wrong
Date: Thu, 24 Jun 1999 21:14:17 -0400

 On Thu, Jun 24, 1999 at 05:16:03PM -0700, Mika Nystrom wrote:
 > 
 > This is from a 9-track marked "4.3BSD-tahoe TAHOE UNIX System 
 > 7/25/88"---sorry but I can't help much with the SysV.. I powered
 > up an old UNIX PC we have running "UNIX SYSTEM5 3.51m," but it did
 > not have a strdup declared in string.h.
 
 Ok, someone will have to tell me what "UNIX SYSTEM5 3.51m," translates
 into.  SVr3?
 
 If not, my guess is still SVr2 for the first appearance of strdup().  :)
 
 I'm not sure when SVr4 was released, but it was about the same time as
 SunOS4, so it's less likely they would've copied from that.
 
 I'm sure there's someone on this list [-bugs] who knows, and they're
 going to have to speak-up sooner or later.  :-)
 
 
 -- 
 This is my .signature which gets appended to the end of my messages.
 

From: Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
To: Tim Vanderhoek <vanderh@ecf.utoronto.ca>
Cc: Mike Pritchard <mpp@mpp.pro-ns.net>, sheldonh@FreeBSD.ORG,
	mika@cs.caltech.edu, freebsd-bugs@FreeBSD.ORG,
	freebsd-gnats-submit@FreeBSD.ORG
Subject: Re: docs/12372: man page HISTORY for strdup is wrong
Date: Fri, 25 Jun 1999 10:20:50 -0400 (EDT)

 <<On Thu, 24 Jun 1999 18:09:46 -0400, Tim Vanderhoek <vanderh@ecf.utoronto.ca> said:
 
 > Hmm...  Here's another one...  This HPUX man seems to state that
 > strdup appeared in SVr2...
 > http://www.informatik.uni-frankfurt.de/doc/man/hpux/strxfrm.3c.html
 
 > Anyways, I'm inclined to place it in SVr2.
 
 It is definitely not in 4.3BSD (I checked our sources here).  All of
 the str* functions, except for str(n)cat, str(n)cmp, str(n)cpy, and
 strlen, have implementations in the lib/libc/compat-sys5 directory.
 That directory also includes a family of str???n functions which
 completely null-fill the remainder of their target buffers.
 
 -GAWollman
 
 --
 Garrett A. Wollman   | O Siem / We are all family / O Siem / We're all the same
 wollman@lcs.mit.edu  | O Siem / The fires of freedom 
 Opinions not those of| Dance in the burning flame
 MIT, LCS, CRS, or NSA|                     - Susan Aglukark and Chad Irschick
 

From: Sheldon Hearn <sheldonh@uunet.co.za>
To: freebsd-gnats-submit@freebsd.org
Cc:  
Subject: Re: docs/12372: man page HISTORY for strdup is wrong
Date: Thu, 29 Jul 1999 20:46:54 +0200

 Style precedent taken from the pipe(2) manpage:
 
 Index: strdup.3
 ===================================================================
 RCS file: /home/ncvs/src/lib/libc/string/strdup.3,v
 retrieving revision 1.6
 diff -u -d -r1.6 strdup.3
 --- strdup.3	1997/02/22 15:03:27	1.6
 +++ strdup.3	1999/07/29 18:44:21
 @@ -61,5 +61,4 @@
  .Sh HISTORY
  The
  .Fn strdup
 -function first appeared in
 -.Bx 4.4 .
 +function first appeared in UNIX System V release 2.
 

From: Sheldon Hearn <sheldonh@uunet.co.za>
To: Tim Vanderhoek <vanderh@ecf.utoronto.ca>
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: docs/12372: man page HISTORY for strdup is wrong 
Date: Fri, 30 Jul 1999 00:40:16 +0200

 On Thu, 29 Jul 1999 18:39:29 -0400, Tim Vanderhoek wrote:
 
 > Might want to say "is believed to have first appeared in..." since no
 > one really seemed certain, if I recall.
 
 Fair enough. I'll do that.
 
 Ciao,
 Sheldon.
 
State-Changed-From-To: open->closed 
State-Changed-By: sheldonh 
State-Changed-When: Tue Aug 10 05:59:12 PDT 1999 
State-Changed-Why:  
After much discussion on the freebsd-doc mailing list, it's been 
decided that we already have the most appropriate entry possible  
in the HISTORY section. 
>Unformatted:
