From root@newsguy.com  Thu Jan  7 10:50:33 1999
Received: from peach.ocn.ne.jp (peach.ocn.ne.jp [210.145.254.87])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id KAA20612
          for <FreeBSD-gnats-submit@freebsd.org>; Thu, 7 Jan 1999 10:50:29 -0800 (PST)
          (envelope-from root@newsguy.com)
Received: from local.ocn.ne.jp by peach.ocn.ne.jp (8.9.1a/OCN) id DAA11641; Fri, 8 Jan 1999 03:49:56 +0900 (JST)
Received: (from root@localhost)
	by local.ocn.ne.jp (8.9.1/8.8.6) id DAA03169;
	Fri, 8 Jan 1999 03:46:44 +0900 (JST)
Message-Id: <199901071846.DAA03169@local.ocn.ne.jp>
Date: Fri, 8 Jan 1999 03:46:44 +0900 (JST)
From: dcs@newsguy.com
Reply-To: dcs@newsguy.com
To: FreeBSD-gnats-submit@freebsd.org
Cc: dcs@newsguy.com
Subject: Incomplete include file
X-Send-Pr-Version: 3.2

>Number:         9373
>Category:       misc
>Synopsis:       Getopt external variable is not declared
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jan  7 11:00:01 PST 1999
>Closed-Date:    Sun Jan 10 22:01:56 PST 1999
>Last-Modified:  Sun Jan 10 22:02:10 PST 1999
>Originator:     Daniel C. Sobral
>Release:        FreeBSD 3.0-CURRENT i386
>Organization:
>Environment:

	Current and, possibly, stable, though the patches below
also include current's libstand.

>Description:

	POSIX introduced optreset to deal with multiple invocations
of getopt (as in, multiple input lines :). This is documented in the
man page and is used in the code, but unistd.h and stand.h do not
declare it. Incidentally, it prevents me fixing a bug in loader's
code... :-)

>How-To-Repeat:

	If you are using "loader", try:
ls -? /kernel
load /kernel

>Fix:
	
	Apply the following patches (notice that I don't know if
my placement of optreset in unistd is in the appropriate place):

--- include/unistd.h.orig	Fri Jan  8 03:31:10 1999
+++ include/unistd.h	Fri Jan  8 03:31:41 1999
@@ -199,6 +199,7 @@
 void	*valloc __P((size_t));			/* obsoleted by malloc() */
 pid_t	 vfork __P((void));
 
+extern optreset;			/* getopt(3) external variable */
 extern char *suboptarg;			/* getsubopt(3) external variable */
 int	 getsubopt __P((char **, char * const *, char **));
 #endif /* !_POSIX_SOURCE */
--- lib/libstand/stand.h.orig	Fri Jan  8 03:33:45 1999
+++ lib/libstand/stand.h	Fri Jan  8 03:35:04 1999
@@ -220,7 +220,7 @@
 extern long	strtol(const char *, char **, int);
 extern char *	strerror(int err);
 extern char	*optarg;			/* getopt(3) external variables */
-extern int	optind, opterr, optopt;
+extern int	optind, opterr, optopt, optreset;
 extern int	getopt(int, char * const [], const char *);
 
 /* pager.c */
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: msmith 
State-Changed-When: Sun Jan 10 22:01:56 PST 1999 
State-Changed-Why:  
Looks reasonable, committed. 
>Unformatted:
