mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-22 18:53:04 +00:00
* src/getopt1.c: Updated from textutils 2.0e
* src/getopt.c: Likewise. * src/getopt.h: Likewise.
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
2000-03-17 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
|
* src/getopt1.c: Updated from textutils 2.0e
|
||||||
|
* src/getopt.c: Likewise.
|
||||||
|
* src/getopt.h: Likewise.
|
||||||
|
|
||||||
2000-03-17 Akim Demaille <akim@epita.fr>
|
2000-03-17 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
* src/Makefile.am (bison.simple): Fix the awk program: quote only
|
* src/Makefile.am (bison.simple): Fix the awk program: quote only
|
||||||
|
|||||||
51
src/getopt.c
51
src/getopt.c
@@ -1,14 +1,10 @@
|
|||||||
/* Getopt for GNU.
|
/* Getopt for GNU.
|
||||||
NOTE: getopt is now part of the C library, so if you don't know what
|
NOTE: The canonical source of this file is maintained with the GNU
|
||||||
"Keep this file name-space clean" means, talk to drepper@gnu.org
|
C Library. Bugs can be reported to bug-glibc@gnu.org.
|
||||||
before changing it!
|
|
||||||
|
|
||||||
Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98
|
Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99
|
||||||
Free Software Foundation, Inc.
|
Free Software Foundation, Inc.
|
||||||
|
|
||||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
|
||||||
Bugs can be reported to bug-glibc@gnu.org.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it
|
This program is free software; you can redistribute it and/or modify it
|
||||||
under the terms of the GNU General Public License as published by the
|
under the terms of the GNU General Public License as published by the
|
||||||
Free Software Foundation; either version 2, or (at your option) any
|
Free Software Foundation; either version 2, or (at your option) any
|
||||||
@@ -20,9 +16,8 @@
|
|||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software Foundation,
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
USA. */
|
|
||||||
|
|
||||||
/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>.
|
/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>.
|
||||||
Ditto for AIX 3.2 and <stdlib.h>. */
|
Ditto for AIX 3.2 and <stdlib.h>. */
|
||||||
@@ -32,13 +27,13 @@
|
|||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
#endif
|
#else
|
||||||
|
# if !defined __STDC__ || !__STDC__
|
||||||
#if !defined __STDC__ || !__STDC__
|
|
||||||
/* This is a separate conditional since some stdc systems
|
/* This is a separate conditional since some stdc systems
|
||||||
reject `defined (const)'. */
|
reject `defined (const)'. */
|
||||||
# ifndef const
|
# ifndef const
|
||||||
# define const
|
# define const
|
||||||
|
# endif
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -112,7 +107,7 @@
|
|||||||
Also, when `ordering' is RETURN_IN_ORDER,
|
Also, when `ordering' is RETURN_IN_ORDER,
|
||||||
each non-option ARGV-element is returned here. */
|
each non-option ARGV-element is returned here. */
|
||||||
|
|
||||||
char *optarg = NULL;
|
char *optarg;
|
||||||
|
|
||||||
/* Index in ARGV of the next element to be scanned.
|
/* Index in ARGV of the next element to be scanned.
|
||||||
This is used for communication to and from the caller
|
This is used for communication to and from the caller
|
||||||
@@ -133,7 +128,7 @@ int optind = 1;
|
|||||||
causes problems with re-calling getopt as programs generally don't
|
causes problems with re-calling getopt as programs generally don't
|
||||||
know that. */
|
know that. */
|
||||||
|
|
||||||
int __getopt_initialized = 0;
|
int __getopt_initialized;
|
||||||
|
|
||||||
/* The next char to be scanned in the option-element
|
/* The next char to be scanned in the option-element
|
||||||
in which the last option character we returned was found.
|
in which the last option character we returned was found.
|
||||||
@@ -698,16 +693,18 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (opterr)
|
if (opterr)
|
||||||
if (argv[optind - 1][1] == '-')
|
{
|
||||||
/* --option */
|
if (argv[optind - 1][1] == '-')
|
||||||
fprintf (stderr,
|
/* --option */
|
||||||
_("%s: option `--%s' doesn't allow an argument\n"),
|
fprintf (stderr,
|
||||||
argv[0], pfound->name);
|
_("%s: option `--%s' doesn't allow an argument\n"),
|
||||||
else
|
argv[0], pfound->name);
|
||||||
/* +option or -option */
|
else
|
||||||
fprintf (stderr,
|
/* +option or -option */
|
||||||
_("%s: option `%c%s' doesn't allow an argument\n"),
|
fprintf (stderr,
|
||||||
argv[0], argv[optind - 1][0], pfound->name);
|
_("%s: option `%c%s' doesn't allow an argument\n"),
|
||||||
|
argv[0], argv[optind - 1][0], pfound->name);
|
||||||
|
}
|
||||||
|
|
||||||
nextchar += strlen (nextchar);
|
nextchar += strlen (nextchar);
|
||||||
|
|
||||||
|
|||||||
84
src/getopt.h
84
src/getopt.h
@@ -1,9 +1,7 @@
|
|||||||
/* Declarations for getopt.
|
/* Declarations for getopt.
|
||||||
Copyright (C) 1989,90,91,92,93,94,96,97 Free Software Foundation, Inc.
|
Copyright (C) 1989,90,91,92,93,94,96,97,98 Free Software Foundation, Inc.
|
||||||
|
|
||||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||||
Bugs can be reported to bug-glibc@gnu.org.
|
Bugs can be reported to bug-glibc@gnu.org.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it
|
This program is free software; you can redistribute it and/or modify it
|
||||||
under the terms of the GNU General Public License as published by the
|
under the terms of the GNU General Public License as published by the
|
||||||
Free Software Foundation; either version 2, or (at your option) any
|
Free Software Foundation; either version 2, or (at your option) any
|
||||||
@@ -20,7 +18,10 @@
|
|||||||
USA. */
|
USA. */
|
||||||
|
|
||||||
#ifndef _GETOPT_H
|
#ifndef _GETOPT_H
|
||||||
#define _GETOPT_H 1
|
|
||||||
|
#ifndef __need_getopt
|
||||||
|
# define _GETOPT_H 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -57,6 +58,7 @@ extern int opterr;
|
|||||||
|
|
||||||
extern int optopt;
|
extern int optopt;
|
||||||
|
|
||||||
|
#ifndef __need_getopt
|
||||||
/* Describe the long-named options requested by the application.
|
/* Describe the long-named options requested by the application.
|
||||||
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
|
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
|
||||||
of `struct option' terminated by an element containing a name which is
|
of `struct option' terminated by an element containing a name which is
|
||||||
@@ -80,11 +82,11 @@ extern int optopt;
|
|||||||
|
|
||||||
struct option
|
struct option
|
||||||
{
|
{
|
||||||
#if defined (__STDC__) && __STDC__
|
# if defined __STDC__ && __STDC__
|
||||||
const char *name;
|
const char *name;
|
||||||
#else
|
# else
|
||||||
char *name;
|
char *name;
|
||||||
#endif
|
# endif
|
||||||
/* has_arg can't be an enum because some compilers complain about
|
/* has_arg can't be an enum because some compilers complain about
|
||||||
type mismatches in all the code that assumes it is an int. */
|
type mismatches in all the code that assumes it is an int. */
|
||||||
int has_arg;
|
int has_arg;
|
||||||
@@ -94,40 +96,74 @@ struct option
|
|||||||
|
|
||||||
/* Names for the values of the `has_arg' field of `struct option'. */
|
/* Names for the values of the `has_arg' field of `struct option'. */
|
||||||
|
|
||||||
#define no_argument 0
|
# define no_argument 0
|
||||||
#define required_argument 1
|
# define required_argument 1
|
||||||
#define optional_argument 2
|
# define optional_argument 2
|
||||||
|
#endif /* need getopt */
|
||||||
|
|
||||||
#if defined (__STDC__) && __STDC__
|
|
||||||
#ifdef __GNU_LIBRARY__
|
/* Get definitions and prototypes for functions to process the
|
||||||
|
arguments in ARGV (ARGC of them, minus the program name) for
|
||||||
|
options given in OPTS.
|
||||||
|
|
||||||
|
Return the option character from OPTS just read. Return -1 when
|
||||||
|
there are no more options. For unrecognized options, or options
|
||||||
|
missing arguments, `optopt' is set to the option letter, and '?' is
|
||||||
|
returned.
|
||||||
|
|
||||||
|
The OPTS string is a list of characters which are recognized option
|
||||||
|
letters, optionally followed by colons, specifying that that letter
|
||||||
|
takes an argument, to be placed in `optarg'.
|
||||||
|
|
||||||
|
If a letter in OPTS is followed by two colons, its argument is
|
||||||
|
optional. This behavior is specific to the GNU `getopt'.
|
||||||
|
|
||||||
|
The argument `--' causes premature termination of argument
|
||||||
|
scanning, explicitly telling `getopt' that there are no more
|
||||||
|
options.
|
||||||
|
|
||||||
|
If OPTS begins with `--', then non-option arguments are treated as
|
||||||
|
arguments to the option '\0'. This behavior is specific to the GNU
|
||||||
|
`getopt'. */
|
||||||
|
|
||||||
|
#if defined __STDC__ && __STDC__
|
||||||
|
# ifdef __GNU_LIBRARY__
|
||||||
/* Many other libraries have conflicting prototypes for getopt, with
|
/* Many other libraries have conflicting prototypes for getopt, with
|
||||||
differences in the consts, in stdlib.h. To avoid compilation
|
differences in the consts, in stdlib.h. To avoid compilation
|
||||||
errors, only prototype getopt for the GNU C library. */
|
errors, only prototype getopt for the GNU C library. */
|
||||||
extern int getopt (int argc, char *const *argv, const char *shortopts);
|
extern int getopt (int __argc, char *const *__argv, const char *__shortopts);
|
||||||
#else /* not __GNU_LIBRARY__ */
|
# else /* not __GNU_LIBRARY__ */
|
||||||
extern int getopt ();
|
extern int getopt ();
|
||||||
#endif /* __GNU_LIBRARY__ */
|
# endif /* __GNU_LIBRARY__ */
|
||||||
extern int getopt_long (int argc, char *const *argv, const char *shortopts,
|
|
||||||
const struct option *longopts, int *longind);
|
# ifndef __need_getopt
|
||||||
extern int getopt_long_only (int argc, char *const *argv,
|
extern int getopt_long (int __argc, char *const *__argv, const char *__shortopts,
|
||||||
const char *shortopts,
|
const struct option *__longopts, int *__longind);
|
||||||
const struct option *longopts, int *longind);
|
extern int getopt_long_only (int __argc, char *const *__argv,
|
||||||
|
const char *__shortopts,
|
||||||
|
const struct option *__longopts, int *__longind);
|
||||||
|
|
||||||
/* Internal only. Users should not call this directly. */
|
/* Internal only. Users should not call this directly. */
|
||||||
extern int _getopt_internal (int argc, char *const *argv,
|
extern int _getopt_internal (int __argc, char *const *__argv,
|
||||||
const char *shortopts,
|
const char *__shortopts,
|
||||||
const struct option *longopts, int *longind,
|
const struct option *__longopts, int *__longind,
|
||||||
int long_only);
|
int __long_only);
|
||||||
|
# endif
|
||||||
#else /* not __STDC__ */
|
#else /* not __STDC__ */
|
||||||
extern int getopt ();
|
extern int getopt ();
|
||||||
|
# ifndef __need_getopt
|
||||||
extern int getopt_long ();
|
extern int getopt_long ();
|
||||||
extern int getopt_long_only ();
|
extern int getopt_long_only ();
|
||||||
|
|
||||||
extern int _getopt_internal ();
|
extern int _getopt_internal ();
|
||||||
|
# endif
|
||||||
#endif /* __STDC__ */
|
#endif /* __STDC__ */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Make sure we later can get all the definitions and declarations. */
|
||||||
|
#undef __need_getopt
|
||||||
|
|
||||||
#endif /* getopt.h */
|
#endif /* getopt.h */
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/* getopt_long and getopt_long_only entry points for GNU getopt.
|
/* getopt_long and getopt_long_only entry points for GNU getopt.
|
||||||
Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98
|
Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98
|
||||||
Free Software Foundation, Inc.
|
Free Software Foundation, Inc.
|
||||||
|
|
||||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||||
Bugs can be reported to bug-glibc@gnu.org.
|
Bugs can be reported to bug-glibc@gnu.org.
|
||||||
|
|
||||||
@@ -16,16 +15,12 @@
|
|||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software Foundation,
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
USA. */
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#else
|
||||||
|
|
||||||
#include "getopt.h"
|
|
||||||
|
|
||||||
#if !defined __STDC__ || !__STDC__
|
#if !defined __STDC__ || !__STDC__
|
||||||
/* This is a separate conditional since some stdc systems
|
/* This is a separate conditional since some stdc systems
|
||||||
reject `defined (const)'. */
|
reject `defined (const)'. */
|
||||||
@@ -33,6 +28,9 @@
|
|||||||
#define const
|
#define const
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "getopt.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user