Loading...
--- Libc/Libc-1725.40.4/stdlib/FreeBSD/getopt.c
+++ Libc/Libc-825.26/stdlib/FreeBSD/getopt.c
@@ -1,8 +1,6 @@
-/* $NetBSD: getopt.c,v 1.29 2014/06/05 22:00:22 christos Exp $ */
+/* $NetBSD: getopt.c,v 1.26 2003/08/07 16:43:40 agc Exp $ */
-/*-
- * SPDX-License-Identifier: BSD-3-Clause
- *
+/*
* Copyright (c) 1987, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
@@ -14,7 +12,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
+ * 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -35,7 +33,7 @@
static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: src/lib/libc/stdlib/getopt.c,v 1.8 2007/01/09 00:28:10 imp Exp $");
#include "namespace.h"
#include <stdio.h>
@@ -46,15 +44,17 @@
#include "libc_private.h"
+#ifndef BUILDING_VARIANT
int opterr = 1, /* if error message should be printed */
optind = 1, /* index into parent argv vector */
optopt, /* character checked for validity */
optreset; /* reset getopt */
char *optarg; /* argument associated with option */
+#endif /* !BUILDING_VARIANT */
#define BADCH (int)'?'
#define BADARG (int)':'
-static char EMSG[] = "";
+#define EMSG ""
#if __DARWIN_UNIX03
#define PROGNAME nargv[0]
@@ -67,7 +67,10 @@
* Parse argc/argv argument vector.
*/
int
-getopt(int nargc, char * const nargv[], const char *ostr)
+getopt(nargc, nargv, ostr)
+ int nargc;
+ char * const nargv[];
+ const char *ostr;
{
static char *place = EMSG; /* option letter processing */
char *oli; /* option letter list index */
@@ -120,12 +123,6 @@
entire next argument. */
if (*place)
optarg = place;
- else if (oli[2] == ':')
- /*
- * GNU Extension, for optional arguments if the rest of
- * the argument is empty, we return NULL
- */
- optarg = NULL;
else if (nargc > ++optind)
optarg = nargv[optind];
else {