From howardjp@wam.umd.edu Thu Aug  5 16:56:37 1999
Return-Path: <howardjp@wam.umd.edu>
Received: from po3.wam.umd.edu (po3.wam.umd.edu [128.8.10.165])
	by hub.freebsd.org (Postfix) with ESMTP id EB75E155F8
	for <FreeBSD-gnats-submit@freebsd.org>; Thu,  5 Aug 1999 16:55:37 -0700 (PDT)
	(envelope-from howardjp@wam.umd.edu)
Received: from rac9.wam.umd.edu (root@rac9.wam.umd.edu [128.8.10.149])
	by po3.wam.umd.edu (8.9.3/8.9.3) with ESMTP id TAA10872
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 5 Aug 1999 19:54:36 -0400 (EDT)
Received: from rac9.wam.umd.edu (sendmail@localhost [127.0.0.1])
	by rac9.wam.umd.edu (8.9.3/8.9.3) with SMTP id TAA17728
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 5 Aug 1999 19:54:36 -0400 (EDT)
Received: (from howardjp@localhost)
	by rac9.wam.umd.edu (8.9.3/8.9.3) id TAA17724
	for FreeBSD-gnats-submit@freebsd.org; Thu, 5 Aug 1999 19:54:35 -0400 (EDT)
Message-Id: <199908052354.TAA17724@rac9.wam.umd.edu>
Date: Thu, 5 Aug 1999 19:54:35 -0400 (EDT)
From: James Howard <howardjp@wam.umd.edu>
Reply-To: howardjp@wam.umd.edu
To: FreeBSD-gnats-submit@freebsd.org
Subject: Update to getopt.3 to agree with style.9
X-Send-Pr-Version: 3.2

>Number:         12994
>Category:       docs
>Synopsis:       Update to getopt.3 to agree with style.9
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    hoek
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          doc-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Aug  5 17:00:06 PDT 1999
>Closed-Date:    Wed Jan 5 17:22:26 PST 2000
>Last-Modified:  Wed Jan  5 17:25:55 PST 2000
>Originator:     James Howard
>Release:        FreeBSD 3.2-STABLE i386
>Organization:
University of Maryland
>Environment:

FreeBSD byzantine.student.umd.edu 3.2-STABLE FreeBSD 3.2-STABLE #4: Thu Jun 17 18:40:41 GMT 1999     howardjp@byzantine.student.umd.edu:/usr/src/sys/compile/BYZANTINE  i386

>Description:

Getopt(3) stated that the proper way to handle converting a number
in a command line to a usable int was via atoi(3).  Style(9) says
you should use strtol(3).  Apply the diff to getopt.3 in 
/usr/src/lib/libc/stdlib/ to synchronise it with style(9).

>How-To-Repeat:

man 3 getopt
man style

>Fix:
	
*** getopt.3.orig	Thu Aug  5 19:31:46 1999
--- getopt.3	Thu Aug  5 19:41:08 1999
***************
*** 245,251 ****
  The following code fragment works in most cases.
  .Bd -literal -offset indent
  int length;
! char *p;
  
  while ((ch = getopt(argc, argv, "0123456789")) != -1)
  	switch (ch) {
--- 245,251 ----
  The following code fragment works in most cases.
  .Bd -literal -offset indent
  int length;
! char *p, *ep;
  
  while ((ch = getopt(argc, argv, "0123456789")) != -1)
  	switch (ch) {
***************
*** 253,261 ****
  	case '5': case '6': case '7': case '8': case '9':
  		p = argv[optind - 1];
  		if (p[0] == '-' && p[1] == ch && !p[2])
! 			length = atoi(++p);
  		else
! 			length = atoi(argv[optind] + 1);
  		break;
  	}
  .Ed
--- 253,263 ----
  	case '5': case '6': case '7': case '8': case '9':
  		p = argv[optind - 1];
  		if (p[0] == '-' && p[1] == ch && !p[2])
! 			length = strtol(++p, &ep, 10);
  		else
! 			length = strtol(argv[optind] + 1, &ep, 10);
! 		if (length <= 0 || *ep != '\e0')
! 			err("illegal number -- %s", optarg);
  		break;
  	}
  .Ed

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-doc->hoek 
Responsible-Changed-By: hoek 
Responsible-Changed-When: Thu Aug 5 23:15:28 PDT 1999 
Responsible-Changed-Why:  
James warned me about this...  :-) 
State-Changed-From-To: open->closed 
State-Changed-By: hoek 
State-Changed-When: Wed Jan 5 17:22:26 PST 2000 
State-Changed-Why:  
Somewhat modified patch applied in r.1.11 of getopt.3. 

Thanks! 
>Unformatted:
