* getopt.c: Replace with latest NetBSD version 1.16. Keep Cygwin
specific changes as minimal as possible.
This commit is contained in:
parent
e92be2201a
commit
968bdf96b1
@ -1,3 +1,8 @@
|
|||||||
|
2004-02-14 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* getopt.c: Replace with latest NetBSD version 1.16. Keep Cygwin
|
||||||
|
specific changes as minimal as possible.
|
||||||
|
|
||||||
2004-02-13 Christopher Faylor <cgf@redhat.com>
|
2004-02-13 Christopher Faylor <cgf@redhat.com>
|
||||||
|
|
||||||
* sigproc.cc (proc_subproc): Change warning back to silent debug
|
* sigproc.cc (proc_subproc): Change warning back to silent debug
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $ */
|
/* $NetBSD: getopt_long.c,v 1.16 2003/10/27 00:12:42 lukem Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||||
@ -36,46 +36,55 @@
|
|||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "winsup.h"
|
#include <sys/cdefs.h>
|
||||||
|
#if defined(LIBC_SCCS) && !defined(lint)
|
||||||
|
__RCSID("$NetBSD: getopt_long.c,v 1.16 2003/10/27 00:12:42 lukem Exp $");
|
||||||
|
#endif /* LIBC_SCCS and not lint */
|
||||||
|
|
||||||
|
#ifndef __CYGWIN__
|
||||||
|
#include "namespace.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <err.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <getopt.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <getopt.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#define REPLACE_GETOPT
|
|
||||||
|
|
||||||
|
#ifdef __CYGWIN__
|
||||||
#define _DIAGASSERT(x) do {} while (0)
|
#define _DIAGASSERT(x) do {} while (0)
|
||||||
|
#define HAVE_NBTOOL_CONFIG_H 1
|
||||||
|
#define HAVE_GETOPT_LONG 0
|
||||||
|
#define HAVE_DECL_OPTIND 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if HAVE_NBTOOL_CONFIG_H && !HAVE_GETOPT_LONG && !HAVE_DECL_OPTIND
|
||||||
|
#define REPLACE_GETOPT
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef REPLACE_GETOPT
|
#ifdef REPLACE_GETOPT
|
||||||
#ifdef __weak_alias
|
#ifdef __weak_alias
|
||||||
__weak_alias(getopt,_getopt)
|
__weak_alias(getopt,_getopt)
|
||||||
#endif
|
#endif
|
||||||
int __declspec(dllexport) opterr = 1; /* if error message should be printed */
|
int opterr = 1; /* if error message should be printed */
|
||||||
int __declspec(dllexport) optind = 1; /* index into parent argv vector */
|
int optind = 1; /* index into parent argv vector */
|
||||||
int __declspec(dllexport) optopt = '?'; /* character checked for validity */
|
int optopt = '?'; /* character checked for validity */
|
||||||
int __declspec(dllexport) optreset; /* reset getopt */
|
int optreset; /* reset getopt */
|
||||||
char __declspec(dllexport) *optarg; /* argument associated with option */
|
char *optarg; /* argument associated with option */
|
||||||
|
#elif HAVE_NBTOOL_CONFIG_H && !HAVE_DECL_OPTRESET
|
||||||
|
static int optreset;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __weak_alias
|
#ifdef __weak_alias
|
||||||
__weak_alias(getopt_long,_getopt_long)
|
__weak_alias(getopt_long,_getopt_long)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __CYGWIN__
|
#if !HAVE_GETOPT_LONG
|
||||||
#define __progname __argv[0]
|
|
||||||
#else
|
|
||||||
extern char *__progname;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define IGNORE_FIRST (*options == '-' || *options == '+')
|
#define IGNORE_FIRST (*options == '-' || *options == '+')
|
||||||
#define PRINT_ERROR ((opterr) && ((*options != ':') \
|
#define PRINT_ERROR ((opterr) && ((*options != ':') \
|
||||||
|| (IGNORE_FIRST && options[1] != ':')))
|
|| (IGNORE_FIRST && options[1] != ':')))
|
||||||
|
#define IS_POSIXLY_CORRECT (getenv("POSIXLY_CORRECT") != NULL)
|
||||||
#define IS_POSIXLY_CORRECT (getenv("POSIXLY_INCORRECT_GETOPT") == NULL)
|
|
||||||
|
|
||||||
#define PERMUTE (!IS_POSIXLY_CORRECT && !IGNORE_FIRST)
|
#define PERMUTE (!IS_POSIXLY_CORRECT && !IGNORE_FIRST)
|
||||||
/* XXX: GNU ignores PC if *options == '-' */
|
/* XXX: GNU ignores PC if *options == '-' */
|
||||||
#define IN_ORDER (!IS_POSIXLY_CORRECT && *options == '-')
|
#define IN_ORDER (!IS_POSIXLY_CORRECT && *options == '-')
|
||||||
@ -86,11 +95,15 @@ extern char *__progname;
|
|||||||
|| (*options == ':') ? (int)':' : (int)'?')
|
|| (*options == ':') ? (int)':' : (int)'?')
|
||||||
#define INORDER (int)1
|
#define INORDER (int)1
|
||||||
|
|
||||||
|
#ifdef __CYGWIN__
|
||||||
static char EMSG[1];
|
static char EMSG[1];
|
||||||
|
#else
|
||||||
|
#define EMSG ""
|
||||||
|
#endif
|
||||||
|
|
||||||
static int getopt_internal (int, char * const *, const char *);
|
static int getopt_internal __P((int, char * const *, const char *));
|
||||||
static int gcd (int, int);
|
static int gcd __P((int, int));
|
||||||
static void permute_args (int, int, int, char * const *);
|
static void permute_args __P((int, int, int, char * const *));
|
||||||
|
|
||||||
static char *place = EMSG; /* option letter processing */
|
static char *place = EMSG; /* option letter processing */
|
||||||
|
|
||||||
@ -106,23 +119,6 @@ static const char noarg[] = "option doesn't take an argument -- %.*s";
|
|||||||
static const char illoptchar[] = "unknown option -- %c";
|
static const char illoptchar[] = "unknown option -- %c";
|
||||||
static const char illoptstring[] = "unknown option -- %s";
|
static const char illoptstring[] = "unknown option -- %s";
|
||||||
|
|
||||||
static void
|
|
||||||
_vwarnx(const char *fmt, va_list ap)
|
|
||||||
{
|
|
||||||
(void)fprintf(stderr, "%s: ", __progname);
|
|
||||||
if (fmt != NULL)
|
|
||||||
(void)vfprintf(stderr, fmt, ap);
|
|
||||||
(void)fprintf(stderr, "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
warnx(const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
va_start(ap, fmt);
|
|
||||||
_vwarnx(fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Compute the greatest common divisor of a and b.
|
* Compute the greatest common divisor of a and b.
|
||||||
@ -502,3 +498,4 @@ getopt_long(nargc, nargv, options, long_options, idx)
|
|||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
#endif /* !GETOPT_LONG */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user