mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
Sync with gnulib.
This commit is contained in:
46
lib/alloca.c
46
lib/alloca.c
@@ -33,7 +33,15 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef emacs
|
#ifdef emacs
|
||||||
|
# include "lisp.h"
|
||||||
# include "blockinput.h"
|
# include "blockinput.h"
|
||||||
|
# define xalloc_die() memory_full ()
|
||||||
|
# ifdef EMACS_FREE
|
||||||
|
# undef free
|
||||||
|
# define free EMACS_FREE
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# include <xalloc.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* If compiling with GCC 2, this file's not needed. */
|
/* If compiling with GCC 2, this file's not needed. */
|
||||||
@@ -53,6 +61,8 @@
|
|||||||
you
|
you
|
||||||
lose
|
lose
|
||||||
-- must know STACK_DIRECTION at compile-time
|
-- must know STACK_DIRECTION at compile-time
|
||||||
|
/* Using #error here is not wise since this file should work for
|
||||||
|
old and obscure compilers. */
|
||||||
# endif /* STACK_DIRECTION undefined */
|
# endif /* STACK_DIRECTION undefined */
|
||||||
# endif /* static */
|
# endif /* static */
|
||||||
# endif /* emacs */
|
# endif /* emacs */
|
||||||
@@ -67,32 +77,19 @@ long i00afunc ();
|
|||||||
# define ADDRESS_FUNCTION(arg) &(arg)
|
# define ADDRESS_FUNCTION(arg) &(arg)
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if __STDC__
|
# ifndef POINTER_TYPE
|
||||||
typedef void *pointer;
|
# ifdef __STDC__
|
||||||
|
# define POINTER_TYPE void
|
||||||
# else
|
# else
|
||||||
typedef char *pointer;
|
# define POINTER_TYPE char
|
||||||
# endif
|
# endif
|
||||||
|
# endif
|
||||||
|
typedef POINTER_TYPE *pointer;
|
||||||
|
|
||||||
# ifndef NULL
|
# ifndef NULL
|
||||||
# define NULL 0
|
# define NULL 0
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
/* Different portions of Emacs need to call different versions of
|
|
||||||
malloc. The Emacs executable needs alloca to call xmalloc, because
|
|
||||||
ordinary malloc isn't protected from input signals. On the other
|
|
||||||
hand, the utilities in lib-src need alloca to call malloc; some of
|
|
||||||
them are very simple, and don't have an xmalloc routine.
|
|
||||||
|
|
||||||
Non-Emacs programs expect this to call xmalloc.
|
|
||||||
|
|
||||||
Callers below should use malloc. */
|
|
||||||
|
|
||||||
# ifndef emacs
|
|
||||||
# undef malloc
|
|
||||||
# define malloc xmalloc
|
|
||||||
# endif
|
|
||||||
extern pointer malloc ();
|
|
||||||
|
|
||||||
/* Define STACK_DIRECTION if you know the direction of stack
|
/* Define STACK_DIRECTION if you know the direction of stack
|
||||||
growth for your system; otherwise it will be automatically
|
growth for your system; otherwise it will be automatically
|
||||||
deduced at run-time.
|
deduced at run-time.
|
||||||
@@ -169,7 +166,8 @@ static header *last_alloca_header = NULL; /* -> last alloca header. */
|
|||||||
implementations of C, for example under Gould's UTX/32. */
|
implementations of C, for example under Gould's UTX/32. */
|
||||||
|
|
||||||
pointer
|
pointer
|
||||||
alloca (size_t size)
|
alloca (size)
|
||||||
|
size_t size;
|
||||||
{
|
{
|
||||||
auto char probe; /* Probes stack depth: */
|
auto char probe; /* Probes stack depth: */
|
||||||
register char *depth = ADDRESS_FUNCTION (probe);
|
register char *depth = ADDRESS_FUNCTION (probe);
|
||||||
@@ -215,8 +213,14 @@ alloca (size_t size)
|
|||||||
/* Allocate combined header + user data storage. */
|
/* Allocate combined header + user data storage. */
|
||||||
|
|
||||||
{
|
{
|
||||||
register pointer new = malloc (sizeof (header) + size);
|
|
||||||
/* Address of header. */
|
/* Address of header. */
|
||||||
|
register pointer new;
|
||||||
|
|
||||||
|
size_t combined_size = sizeof (header) + size;
|
||||||
|
if (combined_size < sizeof (header))
|
||||||
|
xalloc_die ();
|
||||||
|
|
||||||
|
new = xmalloc (combined_size);
|
||||||
|
|
||||||
if (new == 0)
|
if (new == 0)
|
||||||
abort();
|
abort();
|
||||||
|
|||||||
13
lib/error.c
13
lib/error.c
@@ -27,7 +27,6 @@
|
|||||||
#else
|
#else
|
||||||
# include "gettext.h"
|
# include "gettext.h"
|
||||||
#endif
|
#endif
|
||||||
#define _(msgid) gettext (msgid)
|
|
||||||
|
|
||||||
#ifdef _LIBC
|
#ifdef _LIBC
|
||||||
# include <wchar.h>
|
# include <wchar.h>
|
||||||
@@ -55,7 +54,14 @@ void exit ();
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
|
||||||
|
#if !_LIBC
|
||||||
# include "unlocked-io.h"
|
# include "unlocked-io.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _
|
||||||
|
# define _(String) String
|
||||||
|
#endif
|
||||||
|
|
||||||
/* If NULL, error will flush stdout, then print on stderr the program
|
/* If NULL, error will flush stdout, then print on stderr the program
|
||||||
name, a colon and a space. Otherwise, error will call this
|
name, a colon and a space. Otherwise, error will call this
|
||||||
@@ -74,6 +80,7 @@ unsigned int error_message_count;
|
|||||||
|
|
||||||
# define program_name program_invocation_name
|
# define program_name program_invocation_name
|
||||||
# include <errno.h>
|
# include <errno.h>
|
||||||
|
# include <libio/libioP.h>
|
||||||
|
|
||||||
/* In GNU libc we want do not want to use the common name `error' directly.
|
/* In GNU libc we want do not want to use the common name `error' directly.
|
||||||
Instead make it a weak alias. */
|
Instead make it a weak alias. */
|
||||||
@@ -88,7 +95,9 @@ extern void __error_at_line (int status, int errnum, const char *file_name,
|
|||||||
|
|
||||||
# ifdef USE_IN_LIBIO
|
# ifdef USE_IN_LIBIO
|
||||||
# include <libio/iolibio.h>
|
# include <libio/iolibio.h>
|
||||||
# define fflush(s) _IO_fflush (s)
|
# define fflush(s) INTUSE(_IO_fflush) (s)
|
||||||
|
# undef putc
|
||||||
|
# define putc(c, fp) INTUSE(_IO_putc) (c, fp)
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
#else /* not _LIBC */
|
#else /* not _LIBC */
|
||||||
|
|||||||
341
lib/getopt.c
341
lib/getopt.c
@@ -16,8 +16,8 @@
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
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
|
||||||
along with this program; if not, write to the Free Software Foundation,
|
with this program; if not, write to the Free Software Foundation,
|
||||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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>.
|
||||||
@@ -30,6 +30,14 @@
|
|||||||
# include <config.h>
|
# include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined __STDC__ || !__STDC__
|
||||||
|
/* This is a separate conditional since some stdc systems
|
||||||
|
reject `defined (const)'. */
|
||||||
|
# ifndef const
|
||||||
|
# define const
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
/* Comment out all this code if we are using the GNU C Library, and are not
|
/* Comment out all this code if we are using the GNU C Library, and are not
|
||||||
@@ -51,12 +59,14 @@
|
|||||||
#ifndef ELIDE_CODE
|
#ifndef ELIDE_CODE
|
||||||
|
|
||||||
|
|
||||||
#if HAVE_STDLIB_H || defined __GNU_LIBRARY__
|
/* This needs to come after some library #include
|
||||||
|
to get __GNU_LIBRARY__ defined. */
|
||||||
|
#ifdef __GNU_LIBRARY__
|
||||||
|
/* Don't include stdlib.h for non-GNU C libraries because some of them
|
||||||
|
contain conflicting prototypes for getopt. */
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
#endif
|
|
||||||
#if HAVE_UNISTD_H || defined __GNU_LIBRARY__
|
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
#endif
|
#endif /* GNU C library. */
|
||||||
|
|
||||||
#ifdef VMS
|
#ifdef VMS
|
||||||
# include <unixlib.h>
|
# include <unixlib.h>
|
||||||
@@ -65,16 +75,20 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _
|
#ifdef _LIBC
|
||||||
/* This is for other GNU distributions with internationalized messages. */
|
|
||||||
# if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC
|
|
||||||
# include <libintl.h>
|
# include <libintl.h>
|
||||||
# ifndef _
|
|
||||||
# define _(msgid) gettext (msgid)
|
|
||||||
# endif
|
|
||||||
#else
|
#else
|
||||||
# define _(msgid) (msgid)
|
/* This is for other GNU distributions with internationalized messages. */
|
||||||
|
# include "gettext.h"
|
||||||
#endif
|
#endif
|
||||||
|
#define _(msgid) gettext (msgid)
|
||||||
|
|
||||||
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
# include <wchar.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef attribute_hidden
|
||||||
|
# define attribute_hidden
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* This version of `getopt' appears to the caller like standard Unix `getopt'
|
/* This version of `getopt' appears to the caller like standard Unix `getopt'
|
||||||
@@ -120,7 +134,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;
|
int __getopt_initialized attribute_hidden;
|
||||||
|
|
||||||
/* 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.
|
||||||
@@ -179,18 +193,30 @@ static enum
|
|||||||
/* Value of POSIXLY_CORRECT environment variable. */
|
/* Value of POSIXLY_CORRECT environment variable. */
|
||||||
static char *posixly_correct;
|
static char *posixly_correct;
|
||||||
|
|
||||||
#if HAVE_STRING_H || defined __GNU_LIBRARY__
|
#ifdef __GNU_LIBRARY__
|
||||||
|
/* We want to avoid inclusion of string.h with non-GNU libraries
|
||||||
|
because there are many ways it can cause trouble.
|
||||||
|
On some systems, it contains special magic macros that don't work
|
||||||
|
in GCC. */
|
||||||
|
# include <string.h>
|
||||||
|
# define my_index strchr
|
||||||
|
#else
|
||||||
|
|
||||||
|
# if HAVE_STRING_H
|
||||||
# include <string.h>
|
# include <string.h>
|
||||||
# else
|
# else
|
||||||
# if HAVE_STRINGS_H
|
|
||||||
# include <strings.h>
|
# include <strings.h>
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
/* Avoid depending on library functions or files
|
||||||
|
whose names are inconsistent. */
|
||||||
|
|
||||||
|
#ifndef getenv
|
||||||
|
extern char *getenv ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !HAVE_STRCHR && !defined strchr && !defined __GNU_LIBRARY__
|
|
||||||
# define strchr my_strchr
|
|
||||||
static char *
|
static char *
|
||||||
strchr (str, chr)
|
my_index (str, chr)
|
||||||
const char *str;
|
const char *str;
|
||||||
int chr;
|
int chr;
|
||||||
{
|
{
|
||||||
@@ -202,11 +228,20 @@ strchr (str, chr)
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !HAVE_DECL_GETENV && !defined getenv && !defined __GNU_LIBRARY__
|
/* If using GCC, we can safely declare strlen this way.
|
||||||
char *getenv ();
|
If not using GCC, it is ok not to declare it. */
|
||||||
#endif
|
#ifdef __GNUC__
|
||||||
|
/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h.
|
||||||
|
That was relevant to code that was here before. */
|
||||||
|
# if (!defined __STDC__ || !__STDC__) && !defined strlen
|
||||||
|
/* gcc with -traditional declares the built-in strlen to return int,
|
||||||
|
and has done so at least since version 2.4.5. -- rms. */
|
||||||
|
extern int strlen (const char *);
|
||||||
|
# endif /* not __STDC__ */
|
||||||
|
#endif /* __GNUC__ */
|
||||||
|
|
||||||
|
#endif /* not __GNU_LIBRARY__ */
|
||||||
|
|
||||||
/* Handle permutation of arguments. */
|
/* Handle permutation of arguments. */
|
||||||
|
|
||||||
@@ -218,6 +253,12 @@ static int first_nonopt;
|
|||||||
static int last_nonopt;
|
static int last_nonopt;
|
||||||
|
|
||||||
#ifdef _LIBC
|
#ifdef _LIBC
|
||||||
|
/* Stored original parameters.
|
||||||
|
XXX This is no good solution. We should rather copy the args so
|
||||||
|
that we can compare them later. But we must not use malloc(3). */
|
||||||
|
extern int __libc_argc;
|
||||||
|
extern char **__libc_argv;
|
||||||
|
|
||||||
/* Bash 2.0 gives us an environment variable containing flags
|
/* Bash 2.0 gives us an environment variable containing flags
|
||||||
indicating ARGV elements that should not be considered arguments. */
|
indicating ARGV elements that should not be considered arguments. */
|
||||||
|
|
||||||
@@ -229,25 +270,6 @@ static int nonoption_flags_max_len;
|
|||||||
static int nonoption_flags_len;
|
static int nonoption_flags_len;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
static int original_argc;
|
|
||||||
static char *const *original_argv;
|
|
||||||
|
|
||||||
/* Make sure the environment variable bash 2.0 puts in the environment
|
|
||||||
is valid for the getopt call we must make sure that the ARGV passed
|
|
||||||
to getopt is that one passed to the process. */
|
|
||||||
static void
|
|
||||||
__attribute__ ((unused))
|
|
||||||
store_args_and_env (int argc, char *const *argv)
|
|
||||||
{
|
|
||||||
/* XXX This is no good solution. We should rather copy the args so
|
|
||||||
that we can compare them later. But we must not use malloc(3). */
|
|
||||||
original_argc = argc;
|
|
||||||
original_argv = argv;
|
|
||||||
}
|
|
||||||
# ifdef text_set_element
|
|
||||||
text_set_element (__libc_subinit, store_args_and_env);
|
|
||||||
# endif /* text_set_element */
|
|
||||||
|
|
||||||
# ifdef USE_NONOPTION_FLAGS
|
# ifdef USE_NONOPTION_FLAGS
|
||||||
# define SWAP_FLAGS(ch1, ch2) \
|
# define SWAP_FLAGS(ch1, ch2) \
|
||||||
if (nonoption_flags_len > 0) \
|
if (nonoption_flags_len > 0) \
|
||||||
@@ -396,7 +418,7 @@ _getopt_initialize (argc, argv, optstring)
|
|||||||
|
|
||||||
#if defined _LIBC && defined USE_NONOPTION_FLAGS
|
#if defined _LIBC && defined USE_NONOPTION_FLAGS
|
||||||
if (posixly_correct == NULL
|
if (posixly_correct == NULL
|
||||||
&& argc == original_argc && argv == original_argv)
|
&& argc == __libc_argc && argv == __libc_argv)
|
||||||
{
|
{
|
||||||
if (nonoption_flags_max_len == 0)
|
if (nonoption_flags_max_len == 0)
|
||||||
{
|
{
|
||||||
@@ -615,7 +637,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
|
|
||||||
if (longopts != NULL
|
if (longopts != NULL
|
||||||
&& (argv[optind][1] == '-'
|
&& (argv[optind][1] == '-'
|
||||||
|| (long_only && (argv[optind][2] || !strchr (optstring, argv[optind][1])))))
|
|| (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1])))))
|
||||||
{
|
{
|
||||||
char *nameend;
|
char *nameend;
|
||||||
const struct option *p;
|
const struct option *p;
|
||||||
@@ -659,8 +681,26 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
if (ambig && !exact)
|
if (ambig && !exact)
|
||||||
{
|
{
|
||||||
if (print_errors)
|
if (print_errors)
|
||||||
|
{
|
||||||
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
char *buf;
|
||||||
|
|
||||||
|
if (__asprintf (&buf, _("%s: option `%s' is ambiguous\n"),
|
||||||
|
argv[0], argv[optind]) >= 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (_IO_fwide (stderr, 0) > 0)
|
||||||
|
__fwprintf (stderr, L"%s", buf);
|
||||||
|
else
|
||||||
|
fputs (buf, stderr);
|
||||||
|
|
||||||
|
free (buf);
|
||||||
|
}
|
||||||
|
#else
|
||||||
fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
|
fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
|
||||||
argv[0], argv[optind]);
|
argv[0], argv[optind]);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
nextchar += strlen (nextchar);
|
nextchar += strlen (nextchar);
|
||||||
optind++;
|
optind++;
|
||||||
optopt = 0;
|
optopt = 0;
|
||||||
@@ -681,16 +721,50 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
{
|
{
|
||||||
if (print_errors)
|
if (print_errors)
|
||||||
{
|
{
|
||||||
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
char *buf;
|
||||||
|
int n;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (argv[optind - 1][1] == '-')
|
if (argv[optind - 1][1] == '-')
|
||||||
|
{
|
||||||
/* --option */
|
/* --option */
|
||||||
fprintf (stderr,
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
_("%s: option `--%s' doesn't allow an argument\n"),
|
n = __asprintf (&buf, _("\
|
||||||
|
%s: option `--%s' doesn't allow an argument\n"),
|
||||||
argv[0], pfound->name);
|
argv[0], pfound->name);
|
||||||
|
#else
|
||||||
|
fprintf (stderr, _("\
|
||||||
|
%s: option `--%s' doesn't allow an argument\n"),
|
||||||
|
argv[0], pfound->name);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
/* +option or -option */
|
/* +option or -option */
|
||||||
fprintf (stderr,
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
_("%s: option `%c%s' doesn't allow an argument\n"),
|
n = __asprintf (&buf, _("\
|
||||||
|
%s: option `%c%s' doesn't allow an argument\n"),
|
||||||
|
argv[0], argv[optind - 1][0],
|
||||||
|
pfound->name);
|
||||||
|
#else
|
||||||
|
fprintf (stderr, _("\
|
||||||
|
%s: option `%c%s' doesn't allow an argument\n"),
|
||||||
argv[0], argv[optind - 1][0], pfound->name);
|
argv[0], argv[optind - 1][0], pfound->name);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
if (n >= 0)
|
||||||
|
{
|
||||||
|
if (_IO_fwide (stderr, 0) > 0)
|
||||||
|
__fwprintf (stderr, L"%s", buf);
|
||||||
|
else
|
||||||
|
fputs (buf, stderr);
|
||||||
|
|
||||||
|
free (buf);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
nextchar += strlen (nextchar);
|
nextchar += strlen (nextchar);
|
||||||
@@ -706,9 +780,27 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (print_errors)
|
if (print_errors)
|
||||||
|
{
|
||||||
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
char *buf;
|
||||||
|
|
||||||
|
if (__asprintf (&buf, _("\
|
||||||
|
%s: option `%s' requires an argument\n"),
|
||||||
|
argv[0], argv[optind - 1]) >= 0)
|
||||||
|
{
|
||||||
|
if (_IO_fwide (stderr, 0) > 0)
|
||||||
|
__fwprintf (stderr, L"%s", buf);
|
||||||
|
else
|
||||||
|
fputs (buf, stderr);
|
||||||
|
|
||||||
|
free (buf);
|
||||||
|
}
|
||||||
|
#else
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: option `%s' requires an argument\n"),
|
_("%s: option `%s' requires an argument\n"),
|
||||||
argv[0], argv[optind - 1]);
|
argv[0], argv[optind - 1]);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
nextchar += strlen (nextchar);
|
nextchar += strlen (nextchar);
|
||||||
optopt = pfound->val;
|
optopt = pfound->val;
|
||||||
return optstring[0] == ':' ? ':' : '?';
|
return optstring[0] == ':' ? ':' : '?';
|
||||||
@@ -730,18 +822,49 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
option, then it's an error.
|
option, then it's an error.
|
||||||
Otherwise interpret it as a short option. */
|
Otherwise interpret it as a short option. */
|
||||||
if (!long_only || argv[optind][1] == '-'
|
if (!long_only || argv[optind][1] == '-'
|
||||||
|| strchr (optstring, *nextchar) == NULL)
|
|| my_index (optstring, *nextchar) == NULL)
|
||||||
{
|
{
|
||||||
if (print_errors)
|
if (print_errors)
|
||||||
{
|
{
|
||||||
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
char *buf;
|
||||||
|
int n;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (argv[optind][1] == '-')
|
if (argv[optind][1] == '-')
|
||||||
|
{
|
||||||
/* --option */
|
/* --option */
|
||||||
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
n = __asprintf (&buf, _("%s: unrecognized option `--%s'\n"),
|
||||||
|
argv[0], nextchar);
|
||||||
|
#else
|
||||||
fprintf (stderr, _("%s: unrecognized option `--%s'\n"),
|
fprintf (stderr, _("%s: unrecognized option `--%s'\n"),
|
||||||
argv[0], nextchar);
|
argv[0], nextchar);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
/* +option or -option */
|
/* +option or -option */
|
||||||
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
n = __asprintf (&buf, _("%s: unrecognized option `%c%s'\n"),
|
||||||
|
argv[0], argv[optind][0], nextchar);
|
||||||
|
#else
|
||||||
fprintf (stderr, _("%s: unrecognized option `%c%s'\n"),
|
fprintf (stderr, _("%s: unrecognized option `%c%s'\n"),
|
||||||
argv[0], argv[optind][0], nextchar);
|
argv[0], argv[optind][0], nextchar);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
if (n >= 0)
|
||||||
|
{
|
||||||
|
if (_IO_fwide (stderr, 0) > 0)
|
||||||
|
__fwprintf (stderr, L"%s", buf);
|
||||||
|
else
|
||||||
|
fputs (buf, stderr);
|
||||||
|
|
||||||
|
free (buf);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
nextchar = (char *) "";
|
nextchar = (char *) "";
|
||||||
optind++;
|
optind++;
|
||||||
@@ -754,7 +877,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
|
|
||||||
{
|
{
|
||||||
char c = *nextchar++;
|
char c = *nextchar++;
|
||||||
char *temp = strchr (optstring, c);
|
char *temp = my_index (optstring, c);
|
||||||
|
|
||||||
/* Increment `optind' when we start to process its last character. */
|
/* Increment `optind' when we start to process its last character. */
|
||||||
if (*nextchar == '\0')
|
if (*nextchar == '\0')
|
||||||
@@ -764,13 +887,42 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
{
|
{
|
||||||
if (print_errors)
|
if (print_errors)
|
||||||
{
|
{
|
||||||
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
char *buf;
|
||||||
|
int n;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (posixly_correct)
|
if (posixly_correct)
|
||||||
|
{
|
||||||
/* 1003.2 specifies the format of this message. */
|
/* 1003.2 specifies the format of this message. */
|
||||||
fprintf (stderr, _("%s: illegal option -- %c\n"),
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
n = __asprintf (&buf, _("%s: illegal option -- %c\n"),
|
||||||
argv[0], c);
|
argv[0], c);
|
||||||
|
#else
|
||||||
|
fprintf (stderr, _("%s: illegal option -- %c\n"), argv[0], c);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
else
|
else
|
||||||
fprintf (stderr, _("%s: invalid option -- %c\n"),
|
{
|
||||||
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
n = __asprintf (&buf, _("%s: invalid option -- %c\n"),
|
||||||
argv[0], c);
|
argv[0], c);
|
||||||
|
#else
|
||||||
|
fprintf (stderr, _("%s: invalid option -- %c\n"), argv[0], c);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
if (n >= 0)
|
||||||
|
{
|
||||||
|
if (_IO_fwide (stderr, 0) > 0)
|
||||||
|
__fwprintf (stderr, L"%s", buf);
|
||||||
|
else
|
||||||
|
fputs (buf, stderr);
|
||||||
|
|
||||||
|
free (buf);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
optopt = c;
|
optopt = c;
|
||||||
return '?';
|
return '?';
|
||||||
@@ -799,8 +951,24 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
if (print_errors)
|
if (print_errors)
|
||||||
{
|
{
|
||||||
/* 1003.2 specifies the format of this message. */
|
/* 1003.2 specifies the format of this message. */
|
||||||
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
char *buf;
|
||||||
|
|
||||||
|
if (__asprintf (&buf,
|
||||||
|
_("%s: option requires an argument -- %c\n"),
|
||||||
|
argv[0], c) >= 0)
|
||||||
|
{
|
||||||
|
if (_IO_fwide (stderr, 0) > 0)
|
||||||
|
__fwprintf (stderr, L"%s", buf);
|
||||||
|
else
|
||||||
|
fputs (buf, stderr);
|
||||||
|
|
||||||
|
free (buf);
|
||||||
|
}
|
||||||
|
#else
|
||||||
fprintf (stderr, _("%s: option requires an argument -- %c\n"),
|
fprintf (stderr, _("%s: option requires an argument -- %c\n"),
|
||||||
argv[0], c);
|
argv[0], c);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
optopt = c;
|
optopt = c;
|
||||||
if (optstring[0] == ':')
|
if (optstring[0] == ':')
|
||||||
@@ -846,8 +1014,25 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
if (ambig && !exact)
|
if (ambig && !exact)
|
||||||
{
|
{
|
||||||
if (print_errors)
|
if (print_errors)
|
||||||
|
{
|
||||||
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
char *buf;
|
||||||
|
|
||||||
|
if (__asprintf (&buf, _("%s: option `-W %s' is ambiguous\n"),
|
||||||
|
argv[0], argv[optind]) >= 0)
|
||||||
|
{
|
||||||
|
if (_IO_fwide (stderr, 0) > 0)
|
||||||
|
__fwprintf (stderr, L"%s", buf);
|
||||||
|
else
|
||||||
|
fputs (buf, stderr);
|
||||||
|
|
||||||
|
free (buf);
|
||||||
|
}
|
||||||
|
#else
|
||||||
fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"),
|
fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"),
|
||||||
argv[0], argv[optind]);
|
argv[0], argv[optind]);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
nextchar += strlen (nextchar);
|
nextchar += strlen (nextchar);
|
||||||
optind++;
|
optind++;
|
||||||
return '?';
|
return '?';
|
||||||
@@ -864,9 +1049,27 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (print_errors)
|
if (print_errors)
|
||||||
|
{
|
||||||
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
char *buf;
|
||||||
|
|
||||||
|
if (__asprintf (&buf, _("\
|
||||||
|
%s: option `-W %s' doesn't allow an argument\n"),
|
||||||
|
argv[0], pfound->name) >= 0)
|
||||||
|
{
|
||||||
|
if (_IO_fwide (stderr, 0) > 0)
|
||||||
|
__fwprintf (stderr, L"%s", buf);
|
||||||
|
else
|
||||||
|
fputs (buf, stderr);
|
||||||
|
|
||||||
|
free (buf);
|
||||||
|
}
|
||||||
|
#else
|
||||||
fprintf (stderr, _("\
|
fprintf (stderr, _("\
|
||||||
%s: option `-W %s' doesn't allow an argument\n"),
|
%s: option `-W %s' doesn't allow an argument\n"),
|
||||||
argv[0], pfound->name);
|
argv[0], pfound->name);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
nextchar += strlen (nextchar);
|
nextchar += strlen (nextchar);
|
||||||
return '?';
|
return '?';
|
||||||
@@ -879,9 +1082,27 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (print_errors)
|
if (print_errors)
|
||||||
|
{
|
||||||
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
char *buf;
|
||||||
|
|
||||||
|
if (__asprintf (&buf, _("\
|
||||||
|
%s: option `%s' requires an argument\n"),
|
||||||
|
argv[0], argv[optind - 1]) >= 0)
|
||||||
|
{
|
||||||
|
if (_IO_fwide (stderr, 0) > 0)
|
||||||
|
__fwprintf (stderr, L"%s", buf);
|
||||||
|
else
|
||||||
|
fputs (buf, stderr);
|
||||||
|
|
||||||
|
free (buf);
|
||||||
|
}
|
||||||
|
#else
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: option `%s' requires an argument\n"),
|
_("%s: option `%s' requires an argument\n"),
|
||||||
argv[0], argv[optind - 1]);
|
argv[0], argv[optind - 1]);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
nextchar += strlen (nextchar);
|
nextchar += strlen (nextchar);
|
||||||
return optstring[0] == ':' ? ':' : '?';
|
return optstring[0] == ':' ? ':' : '?';
|
||||||
}
|
}
|
||||||
@@ -928,9 +1149,25 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
if (print_errors)
|
if (print_errors)
|
||||||
{
|
{
|
||||||
/* 1003.2 specifies the format of this message. */
|
/* 1003.2 specifies the format of this message. */
|
||||||
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
char *buf;
|
||||||
|
|
||||||
|
if (__asprintf (&buf, _("\
|
||||||
|
%s: option requires an argument -- %c\n"),
|
||||||
|
argv[0], c) >= 0)
|
||||||
|
{
|
||||||
|
if (_IO_fwide (stderr, 0) > 0)
|
||||||
|
__fwprintf (stderr, L"%s", buf);
|
||||||
|
else
|
||||||
|
fputs (buf, stderr);
|
||||||
|
|
||||||
|
free (buf);
|
||||||
|
}
|
||||||
|
#else
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: option requires an argument -- %c\n"),
|
_("%s: option requires an argument -- %c\n"),
|
||||||
argv[0], c);
|
argv[0], c);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
optopt = c;
|
optopt = c;
|
||||||
if (optstring[0] == ':')
|
if (optstring[0] == ':')
|
||||||
|
|||||||
29
lib/getopt.h
29
lib/getopt.h
@@ -1,8 +1,5 @@
|
|||||||
/* Declarations for getopt.
|
/* Declarations for getopt.
|
||||||
|
Copyright (C) 1989-1994, 1996-1999, 2001 Free Software Foundation, Inc.
|
||||||
Copyright (C) 1989-1994, 1996-1999, 2001, 2002 Free Software Foundation,
|
|
||||||
Inc.
|
|
||||||
|
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
@@ -15,8 +12,8 @@
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
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
|
||||||
along with this program; if not, write to the Free Software Foundation,
|
with this program; if not, write to the Free Software Foundation,
|
||||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
#ifndef _GETOPT_H
|
#ifndef _GETOPT_H
|
||||||
@@ -29,17 +26,12 @@
|
|||||||
standalone, or this is the first header included in the source file.
|
standalone, or this is the first header included in the source file.
|
||||||
If we are being used with glibc, we need to include <features.h>, but
|
If we are being used with glibc, we need to include <features.h>, but
|
||||||
that does not exist if we are standalone. So: if __GNU_LIBRARY__ is
|
that does not exist if we are standalone. So: if __GNU_LIBRARY__ is
|
||||||
not defined, include <stdlib.h>, which will pull in <features.h> for us
|
not defined, include <ctype.h>, which will pull in <features.h> for us
|
||||||
if it's from glibc (and will declare getopt). Fall back on <ctype.h> if
|
if it's from glibc. (Why ctype.h? It's guaranteed to exist and it
|
||||||
<stdlib.h> might not exist. (Why ctype.h? It's guaranteed to exist and it
|
|
||||||
doesn't flood the namespace with stuff the way some other headers do.) */
|
doesn't flood the namespace with stuff the way some other headers do.) */
|
||||||
#if !defined __GNU_LIBRARY__
|
#if !defined __GNU_LIBRARY__
|
||||||
# if HAVE_STDLIB_H || STDC_HEADERS
|
|
||||||
# include <stdlib.h>
|
|
||||||
# else
|
|
||||||
# include <ctype.h>
|
# include <ctype.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -145,26 +137,25 @@ struct option
|
|||||||
`getopt'. */
|
`getopt'. */
|
||||||
|
|
||||||
#if (defined __STDC__ && __STDC__) || defined __cplusplus
|
#if (defined __STDC__ && __STDC__) || defined __cplusplus
|
||||||
# if defined HAVE_DECL_GETOPT && !HAVE_DECL_GETOPT
|
|
||||||
# ifdef __GNU_LIBRARY__
|
# 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__ */
|
||||||
# endif /* defined HAVE_DECL_GETOPT && !HAVE_DECL_GETOPT */
|
|
||||||
|
|
||||||
# ifndef __need_getopt
|
# ifndef __need_getopt
|
||||||
extern int getopt_long (int __argc, char *const *__argv, const char *__shortopts,
|
extern int getopt_long (int ___argc, char *const *___argv,
|
||||||
|
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,
|
extern int getopt_long_only (int ___argc, char *const *___argv,
|
||||||
const char *__shortopts,
|
const char *__shortopts,
|
||||||
const struct option *__longopts, int *__longind);
|
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);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* 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, 2002
|
Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98
|
||||||
Free Software Foundation, Inc.
|
Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
@@ -13,15 +13,28 @@
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
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
|
||||||
along with this program; if not, write to the Free Software Foundation,
|
with this program; if not, write to the Free Software Foundation,
|
||||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef _LIBC
|
||||||
|
# include <getopt.h>
|
||||||
|
#else
|
||||||
# include "getopt.h"
|
# include "getopt.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined __STDC__ || !__STDC__
|
||||||
|
/* This is a separate conditional since some stdc systems
|
||||||
|
reject `defined (const)'. */
|
||||||
|
#ifndef const
|
||||||
|
#define const
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
/* Comment out all this code if we are using the GNU C Library, and are not
|
/* Comment out all this code if we are using the GNU C Library, and are not
|
||||||
@@ -80,6 +93,10 @@ getopt_long_only (argc, argv, options, long_options, opt_index)
|
|||||||
return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
|
return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ifdef _LIBC
|
||||||
|
libc_hidden_def (getopt_long)
|
||||||
|
libc_hidden_def (getopt_long_only)
|
||||||
|
# endif
|
||||||
|
|
||||||
#endif /* Not ELIDE_CODE. */
|
#endif /* Not ELIDE_CODE. */
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,20 @@
|
|||||||
/* Convenience header for conditional use of GNU <libintl.h>.
|
/* Convenience header for conditional use of GNU <libintl.h>.
|
||||||
Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc.
|
Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify it
|
||||||
it under the terms of the GNU General Public License as published by
|
under the terms of the GNU Library General Public License as published
|
||||||
the Free Software Foundation; either version 2, or (at your option)
|
by the Free Software Foundation; either version 2, or (at your option)
|
||||||
any later version.
|
any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
GNU General Public License for more details.
|
Library 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 Library General Public
|
||||||
along with this program; if not, write to the Free Software Foundation,
|
License along with this program; if not, write to the Free Software
|
||||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
USA. */
|
||||||
|
|
||||||
#ifndef _LIBGETTEXT_H
|
#ifndef _LIBGETTEXT_H
|
||||||
#define _LIBGETTEXT_H 1
|
#define _LIBGETTEXT_H 1
|
||||||
|
|||||||
@@ -6,19 +6,20 @@
|
|||||||
adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu),
|
adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu),
|
||||||
and implemented by Roland McGrath (roland@ai.mit.edu).
|
and implemented by Roland McGrath (roland@ai.mit.edu).
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
it under the terms of the GNU General Public License as published by
|
modify it under the terms of the GNU Library General Public License as
|
||||||
the Free Software Foundation; either version 2, or (at your option)
|
published by the Free Software Foundation; either version 2 of the
|
||||||
any later version.
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
The GNU C Library is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
GNU General Public License for more details.
|
Library 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 Library General Public
|
||||||
along with this program; if not, write to the Free Software Foundation,
|
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
|
|||||||
@@ -1,11 +1,5 @@
|
|||||||
/* obstack.c - subroutines used implicitly by object stack macros
|
/* obstack.c - subroutines used implicitly by object stack macros
|
||||||
|
Copyright (C) 1988-1994, 1996-1999, 2000-2002 Free Software Foundation, Inc.
|
||||||
Copyright (C) 1988-1994, 1996, 1997, 1998, 1999, 2000, 2001, 2002
|
|
||||||
Free Software Foundation, Inc.
|
|
||||||
|
|
||||||
This file is part of the GNU C Library. Its master source is NOT part of
|
|
||||||
the C library, however. The master source lives in /gd/gnu/lib.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation; either version 2, or (at your option)
|
the Free Software Foundation; either version 2, or (at your option)
|
||||||
@@ -16,8 +10,8 @@
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
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
|
||||||
along with this program; if not, write to the Free Software Foundation,
|
with this program; if not, write to the Free Software Foundation,
|
||||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
@@ -55,7 +49,7 @@
|
|||||||
#ifndef ELIDE_CODE
|
#ifndef ELIDE_CODE
|
||||||
|
|
||||||
|
|
||||||
# ifdef __STDC__
|
# if defined __STDC__ && __STDC__
|
||||||
# define POINTER void *
|
# define POINTER void *
|
||||||
# else
|
# else
|
||||||
# define POINTER char *
|
# define POINTER char *
|
||||||
@@ -86,7 +80,7 @@ union fooround {long x; double d;};
|
|||||||
abort gracefully or use longjump - but shouldn't return. This
|
abort gracefully or use longjump - but shouldn't return. This
|
||||||
variable by default points to the internal function
|
variable by default points to the internal function
|
||||||
`print_and_abort'. */
|
`print_and_abort'. */
|
||||||
# if PROTOTYPES || (defined __STDC__ && __STDC__)
|
# if defined __STDC__ && __STDC__
|
||||||
static void print_and_abort (void);
|
static void print_and_abort (void);
|
||||||
void (*obstack_alloc_failed_handler) (void) = print_and_abort;
|
void (*obstack_alloc_failed_handler) (void) = print_and_abort;
|
||||||
# else
|
# else
|
||||||
@@ -114,7 +108,7 @@ struct obstack *_obstack;
|
|||||||
For free, do not use ?:, since some compilers, like the MIPS compilers,
|
For free, do not use ?:, since some compilers, like the MIPS compilers,
|
||||||
do not allow (expr) ? void : void. */
|
do not allow (expr) ? void : void. */
|
||||||
|
|
||||||
# if PROTOTYPES || (defined __STDC__ && __STDC__)
|
# if defined __STDC__ && __STDC__
|
||||||
# define CALL_CHUNKFUN(h, size) \
|
# define CALL_CHUNKFUN(h, size) \
|
||||||
(((h) -> use_extra_arg) \
|
(((h) -> use_extra_arg) \
|
||||||
? (*(h)->chunkfun) ((h)->extra_arg, (size)) \
|
? (*(h)->chunkfun) ((h)->extra_arg, (size)) \
|
||||||
@@ -156,7 +150,7 @@ _obstack_begin (h, size, alignment, chunkfun, freefun)
|
|||||||
struct obstack *h;
|
struct obstack *h;
|
||||||
int size;
|
int size;
|
||||||
int alignment;
|
int alignment;
|
||||||
# if PROTOTYPES || (defined __STDC__ && __STDC__)
|
# if defined __STDC__ && __STDC__
|
||||||
POINTER (*chunkfun) (long);
|
POINTER (*chunkfun) (long);
|
||||||
void (*freefun) (void *);
|
void (*freefun) (void *);
|
||||||
# else
|
# else
|
||||||
@@ -185,7 +179,7 @@ _obstack_begin (h, size, alignment, chunkfun, freefun)
|
|||||||
size = 4096 - extra;
|
size = 4096 - extra;
|
||||||
}
|
}
|
||||||
|
|
||||||
# if PROTOTYPES || (defined __STDC__ && __STDC__)
|
# if defined __STDC__ && __STDC__
|
||||||
h->chunkfun = (struct _obstack_chunk * (*)(void *, long)) chunkfun;
|
h->chunkfun = (struct _obstack_chunk * (*)(void *, long)) chunkfun;
|
||||||
h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun;
|
h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun;
|
||||||
# else
|
# else
|
||||||
@@ -214,7 +208,7 @@ _obstack_begin_1 (h, size, alignment, chunkfun, freefun, arg)
|
|||||||
struct obstack *h;
|
struct obstack *h;
|
||||||
int size;
|
int size;
|
||||||
int alignment;
|
int alignment;
|
||||||
# if PROTOTYPES || (defined __STDC__ && __STDC__)
|
# if defined __STDC__ && __STDC__
|
||||||
POINTER (*chunkfun) (POINTER, long);
|
POINTER (*chunkfun) (POINTER, long);
|
||||||
void (*freefun) (POINTER, POINTER);
|
void (*freefun) (POINTER, POINTER);
|
||||||
# else
|
# else
|
||||||
@@ -244,7 +238,7 @@ _obstack_begin_1 (h, size, alignment, chunkfun, freefun, arg)
|
|||||||
size = 4096 - extra;
|
size = 4096 - extra;
|
||||||
}
|
}
|
||||||
|
|
||||||
# if PROTOTYPES || (defined __STDC__ && __STDC__)
|
# if defined __STDC__ && __STDC__
|
||||||
h->chunkfun = (struct _obstack_chunk * (*)(void *,long)) chunkfun;
|
h->chunkfun = (struct _obstack_chunk * (*)(void *,long)) chunkfun;
|
||||||
h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun;
|
h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun;
|
||||||
# else
|
# else
|
||||||
@@ -345,7 +339,7 @@ _obstack_newchunk (h, length)
|
|||||||
This is here for debugging.
|
This is here for debugging.
|
||||||
If you use it in a program, you are probably losing. */
|
If you use it in a program, you are probably losing. */
|
||||||
|
|
||||||
# if PROTOTYPES || (defined __STDC__ && __STDC__)
|
# if defined __STDC__ && __STDC__
|
||||||
/* Suppress -Wmissing-prototypes warning. We don't want to declare this in
|
/* Suppress -Wmissing-prototypes warning. We don't want to declare this in
|
||||||
obstack.h because it is just for debugging. */
|
obstack.h because it is just for debugging. */
|
||||||
int _obstack_allocated_p (struct obstack *h, POINTER obj);
|
int _obstack_allocated_p (struct obstack *h, POINTER obj);
|
||||||
@@ -460,16 +454,13 @@ _obstack_memory_used (h)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Define the error handler. */
|
/* Define the error handler. */
|
||||||
# ifndef _
|
# ifdef _LIBC
|
||||||
# if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC
|
|
||||||
# include <libintl.h>
|
# include <libintl.h>
|
||||||
# ifndef _
|
|
||||||
# define _(Str) gettext (Str)
|
|
||||||
# endif
|
|
||||||
# else
|
# else
|
||||||
# define _(Str) (Str)
|
# include "gettext.h"
|
||||||
# endif
|
|
||||||
# endif
|
# endif
|
||||||
|
# define _(msgid) gettext (msgid)
|
||||||
|
|
||||||
# if defined _LIBC && defined USE_IN_LIBIO
|
# if defined _LIBC && defined USE_IN_LIBIO
|
||||||
# include <libio/iolibio.h>
|
# include <libio/iolibio.h>
|
||||||
# define fputs(s, f) _IO_fputs (s, f)
|
# define fputs(s, f) _IO_fputs (s, f)
|
||||||
@@ -507,7 +498,7 @@ print_and_abort ()
|
|||||||
/* Now define the functional versions of the obstack macros.
|
/* Now define the functional versions of the obstack macros.
|
||||||
Define them to simply use the corresponding macros to do the job. */
|
Define them to simply use the corresponding macros to do the job. */
|
||||||
|
|
||||||
# if PROTOTYPES || (defined __STDC__ && __STDC__)
|
# if defined __STDC__ && __STDC__
|
||||||
/* These function definitions do not work with non-ANSI preprocessors;
|
/* These function definitions do not work with non-ANSI preprocessors;
|
||||||
they won't pass through the macro names in parentheses. */
|
they won't pass through the macro names in parentheses. */
|
||||||
|
|
||||||
@@ -618,7 +609,7 @@ POINTER (obstack_copy0) (obstack, address, length)
|
|||||||
return obstack_copy0 (obstack, address, length);
|
return obstack_copy0 (obstack, address, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
# endif /* PROTOTYPES || (defined __STDC__ && __STDC__) */
|
# endif /* __STDC__ */
|
||||||
|
|
||||||
# endif /* 0 */
|
# endif /* 0 */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
/* obstack.h - object stack macros
|
/* obstack.h - object stack macros
|
||||||
|
Copyright (C) 1988,89,90,91,92,93,94,96,97,98,99 Free Software Foundation, Inc.
|
||||||
Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997,
|
|
||||||
1998, 1999, 2002 Free Software Foundation, Inc.
|
|
||||||
|
|
||||||
This file is part of the GNU C Library. Its master source is NOT part of
|
This file is part of the GNU C Library. Its master source is NOT part of
|
||||||
the C library, however. The master source lives in /gd/gnu/lib.
|
the C library, however. The master source lives in /gd/gnu/lib.
|
||||||
@@ -9,19 +7,20 @@
|
|||||||
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
|
This program is free software; you can redistribute it and/or modify it
|
||||||
it under the terms of the GNU General Public License as published by
|
under the terms of the GNU General Public License as published by the
|
||||||
the Free Software Foundation; either version 2, or (at your option)
|
Free Software Foundation; either version 2, or (at your option) any
|
||||||
any later version.
|
later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
GNU General Public License for more details.
|
Library 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 Library General Public
|
||||||
along with this program; if not, write to the Free Software Foundation,
|
License along with this program; if not, write to the Free Software
|
||||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
USA. */
|
||||||
|
|
||||||
/* Summary:
|
/* Summary:
|
||||||
|
|
||||||
@@ -124,12 +123,8 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __INT_TO_PTR
|
#ifndef __INT_TO_PTR
|
||||||
# ifdef __STDC__
|
|
||||||
# define __INT_TO_PTR(P) ((void *) ((P) + (char *) 0))
|
|
||||||
# else
|
|
||||||
# define __INT_TO_PTR(P) ((P) + (char *) 0)
|
# define __INT_TO_PTR(P) ((P) + (char *) 0)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
/* We need the type of the resulting object. If __PTRDIFF_TYPE__ is
|
/* We need the type of the resulting object. If __PTRDIFF_TYPE__ is
|
||||||
defined, as with GNU C, use that; that way we don't pollute the
|
defined, as with GNU C, use that; that way we don't pollute the
|
||||||
@@ -175,7 +170,7 @@ struct obstack /* control current object in current chunk */
|
|||||||
char *chunk_limit; /* address of char after current chunk */
|
char *chunk_limit; /* address of char after current chunk */
|
||||||
PTR_INT_TYPE temp; /* Temporary for some macros. */
|
PTR_INT_TYPE temp; /* Temporary for some macros. */
|
||||||
int alignment_mask; /* Mask of alignment for each object. */
|
int alignment_mask; /* Mask of alignment for each object. */
|
||||||
#if PROTOTYPES || (defined __STDC__ && __STDC__)
|
#if defined __STDC__ && __STDC__
|
||||||
/* These prototypes vary based on `use_extra_arg', and we use
|
/* These prototypes vary based on `use_extra_arg', and we use
|
||||||
casts to the prototypeless function type in all assignments,
|
casts to the prototypeless function type in all assignments,
|
||||||
but having prototypes here quiets -Wstrict-prototypes. */
|
but having prototypes here quiets -Wstrict-prototypes. */
|
||||||
@@ -199,7 +194,7 @@ struct obstack /* control current object in current chunk */
|
|||||||
|
|
||||||
/* Declare the external functions we use; they are in obstack.c. */
|
/* Declare the external functions we use; they are in obstack.c. */
|
||||||
|
|
||||||
#if PROTOTYPES || (defined __STDC__ && __STDC__)
|
#if defined __STDC__ && __STDC__
|
||||||
extern void _obstack_newchunk (struct obstack *, int);
|
extern void _obstack_newchunk (struct obstack *, int);
|
||||||
extern void _obstack_free (struct obstack *, void *);
|
extern void _obstack_free (struct obstack *, void *);
|
||||||
extern int _obstack_begin (struct obstack *, int, int,
|
extern int _obstack_begin (struct obstack *, int, int,
|
||||||
@@ -216,7 +211,7 @@ extern int _obstack_begin_1 ();
|
|||||||
extern int _obstack_memory_used ();
|
extern int _obstack_memory_used ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if PROTOTYPES || (defined __STDC__ && __STDC__)
|
#if defined __STDC__ && __STDC__
|
||||||
|
|
||||||
/* Do the function-declarations after the structs
|
/* Do the function-declarations after the structs
|
||||||
but before defining the macros. */
|
but before defining the macros. */
|
||||||
@@ -256,7 +251,7 @@ int obstack_alignment_mask (struct obstack *obstack);
|
|||||||
int obstack_chunk_size (struct obstack *obstack);
|
int obstack_chunk_size (struct obstack *obstack);
|
||||||
int obstack_memory_used (struct obstack *obstack);
|
int obstack_memory_used (struct obstack *obstack);
|
||||||
|
|
||||||
#endif /* PROTOTYPES || (defined __STDC__ && __STDC__) */
|
#endif /* __STDC__ */
|
||||||
|
|
||||||
/* Non-ANSI C cannot really support alternative functions for these macros,
|
/* Non-ANSI C cannot really support alternative functions for these macros,
|
||||||
so we do not declare them. */
|
so we do not declare them. */
|
||||||
@@ -265,7 +260,7 @@ int obstack_memory_used (struct obstack *obstack);
|
|||||||
more memory. This can be set to a user defined function which
|
more memory. This can be set to a user defined function which
|
||||||
should either abort gracefully or use longjump - but shouldn't
|
should either abort gracefully or use longjump - but shouldn't
|
||||||
return. The default action is to print a message and abort. */
|
return. The default action is to print a message and abort. */
|
||||||
#if PROTOTYPES || (defined __STDC__ && __STDC__)
|
#if defined __STDC__ && __STDC__
|
||||||
extern void (*obstack_alloc_failed_handler) (void);
|
extern void (*obstack_alloc_failed_handler) (void);
|
||||||
#else
|
#else
|
||||||
extern void (*obstack_alloc_failed_handler) ();
|
extern void (*obstack_alloc_failed_handler) ();
|
||||||
@@ -294,7 +289,7 @@ extern int obstack_exit_failure;
|
|||||||
|
|
||||||
/* To prevent prototype warnings provide complete argument list in
|
/* To prevent prototype warnings provide complete argument list in
|
||||||
standard C version. */
|
standard C version. */
|
||||||
#if PROTOYPES || (defined __STDC__ && __STDC__)
|
#if defined __STDC__ && __STDC__
|
||||||
|
|
||||||
# define obstack_init(h) \
|
# define obstack_init(h) \
|
||||||
_obstack_begin ((h), 0, 0, \
|
_obstack_begin ((h), 0, 0, \
|
||||||
@@ -589,7 +584,7 @@ __extension__ \
|
|||||||
(h)->object_base = (h)->next_free, \
|
(h)->object_base = (h)->next_free, \
|
||||||
__INT_TO_PTR ((h)->temp))
|
__INT_TO_PTR ((h)->temp))
|
||||||
|
|
||||||
# if PROTOTYPES || (defined __STDC__ && __STDC__)
|
# if defined __STDC__ && __STDC__
|
||||||
# define obstack_free(h,obj) \
|
# define obstack_free(h,obj) \
|
||||||
( (h)->temp = (char *) (obj) - (char *) (h)->chunk, \
|
( (h)->temp = (char *) (obj) - (char *) (h)->chunk, \
|
||||||
(((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\
|
(((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\
|
||||||
|
|||||||
@@ -2,19 +2,20 @@
|
|||||||
Copyright (C) 1996, 1997, 1998, 2000-2002 Free Software Foundation, Inc.
|
Copyright (C) 1996, 1997, 1998, 2000-2002 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
it under the terms of the GNU General Public License as published by
|
modify it under the terms of the GNU Library General Public License as
|
||||||
the Free Software Foundation; either version 2, or (at your option)
|
published by the Free Software Foundation; either version 2 of the
|
||||||
any later version.
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
The GNU C Library is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
GNU General Public License for more details.
|
Library 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 Library General Public
|
||||||
along with this program; if not, write to the Free Software Foundation,
|
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
#if HAVE_CONFIG_H
|
#if HAVE_CONFIG_H
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
|
|||||||
@@ -1,3 +1,24 @@
|
|||||||
|
/* Prefer faster, non-thread-safe stdio functions if available.
|
||||||
|
|
||||||
|
Copyright (C) 2001, 2002 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU Library General Public License as published
|
||||||
|
by the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
USA. */
|
||||||
|
|
||||||
|
/* Written by Jim Meyering. */
|
||||||
|
|
||||||
#ifndef UNLOCKED_IO_H
|
#ifndef UNLOCKED_IO_H
|
||||||
# define UNLOCKED_IO_H 1
|
# define UNLOCKED_IO_H 1
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user