mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-18 00:33:03 +00:00
Sync with fileutils 4.1.1.
This commit is contained in:
272
lib/error.c
272
lib/error.c
@@ -1,23 +1,22 @@
|
|||||||
/* Error handler for noninteractive utilities
|
/* Error handler for noninteractive utilities
|
||||||
Copyright (C) 1990-1998, 2000 Free Software Foundation, Inc.
|
Copyright (C) 1990-1998, 2000, 2001 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.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Library General Public License as
|
modify it under the terms of the GNU Lesser General Public
|
||||||
published by the Free Software Foundation; either version 2 of the
|
License as published by the Free Software Foundation; either
|
||||||
License, or (at your option) any later version.
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
The GNU C Library 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 GNU
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
Library General Public License for more details.
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public
|
You should have received a copy of the GNU Lesser General Public
|
||||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
License along with the GNU C Library; if not, write to the Free
|
||||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||||
Boston, MA 02111-1307, USA. */
|
02111-1307 USA. */
|
||||||
|
|
||||||
/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */
|
/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */
|
||||||
|
|
||||||
@@ -29,6 +28,10 @@
|
|||||||
#if HAVE_LIBINTL_H
|
#if HAVE_LIBINTL_H
|
||||||
# include <libintl.h>
|
# include <libintl.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef _LIBC
|
||||||
|
# include <wchar.h>
|
||||||
|
# define mbsrtowcs __mbsrtowcs
|
||||||
|
#endif
|
||||||
|
|
||||||
#if HAVE_VPRINTF || HAVE_DOPRNT || _LIBC
|
#if HAVE_VPRINTF || HAVE_DOPRNT || _LIBC
|
||||||
# if __STDC__
|
# if __STDC__
|
||||||
@@ -52,13 +55,6 @@ void exit ();
|
|||||||
|
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
|
||||||
#ifndef HAVE_DECL_STRERROR_R
|
|
||||||
"this configure-time declaration test was not run"
|
|
||||||
#endif
|
|
||||||
#if !HAVE_DECL_STRERROR_R
|
|
||||||
char *strerror_r ();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _
|
#ifndef _
|
||||||
# define _(String) String
|
# define _(String) String
|
||||||
#endif
|
#endif
|
||||||
@@ -83,6 +79,12 @@ unsigned int error_message_count;
|
|||||||
|
|
||||||
/* 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. */
|
||||||
|
extern void __error (int status, int errnum, const char *message, ...)
|
||||||
|
__attribute__ ((__format__ (__printf__, 3, 4)));
|
||||||
|
extern void __error_at_line (int status, int errnum, const char *file_name,
|
||||||
|
unsigned int line_number, const char *message,
|
||||||
|
...)
|
||||||
|
__attribute__ ((__format__ (__printf__, 5, 6)));;
|
||||||
# define error __error
|
# define error __error
|
||||||
# define error_at_line __error_at_line
|
# define error_at_line __error_at_line
|
||||||
|
|
||||||
@@ -93,21 +95,30 @@ unsigned int error_message_count;
|
|||||||
|
|
||||||
#else /* not _LIBC */
|
#else /* not _LIBC */
|
||||||
|
|
||||||
|
# if !HAVE_DECL_STRERROR_R && STRERROR_R_CHAR_P
|
||||||
|
# ifndef HAVE_DECL_STRERROR_R
|
||||||
|
"this configure-time declaration test was not run"
|
||||||
|
# endif
|
||||||
|
char *strerror_r ();
|
||||||
|
# endif
|
||||||
|
|
||||||
/* The calling program should define program_name and set it to the
|
/* The calling program should define program_name and set it to the
|
||||||
name of the executing program. */
|
name of the executing program. */
|
||||||
extern char *program_name;
|
extern char *program_name;
|
||||||
|
|
||||||
# ifdef HAVE_STRERROR_R
|
# if HAVE_STRERROR_R || defined strerror_r
|
||||||
# define __strerror_r strerror_r
|
# define __strerror_r strerror_r
|
||||||
# else
|
# else
|
||||||
# if HAVE_STRERROR
|
# if HAVE_STRERROR
|
||||||
# ifndef strerror /* On some systems, strerror is a macro */
|
# ifndef HAVE_DECL_STRERROR
|
||||||
|
"this configure-time declaration test was not run"
|
||||||
|
# endif
|
||||||
|
# if !HAVE_DECL_STRERROR
|
||||||
char *strerror ();
|
char *strerror ();
|
||||||
# endif
|
# endif
|
||||||
# else
|
# else
|
||||||
static char *
|
static char *
|
||||||
private_strerror (errnum)
|
private_strerror (int errnum)
|
||||||
int errnum;
|
|
||||||
{
|
{
|
||||||
extern char *sys_errlist[];
|
extern char *sys_errlist[];
|
||||||
extern int sys_nerr;
|
extern int sys_nerr;
|
||||||
@@ -118,15 +129,118 @@ private_strerror (errnum)
|
|||||||
}
|
}
|
||||||
# define strerror private_strerror
|
# define strerror private_strerror
|
||||||
# endif /* HAVE_STRERROR */
|
# endif /* HAVE_STRERROR */
|
||||||
# endif /* HAVE_STRERROR_R */
|
# endif /* HAVE_STRERROR_R || defined strerror_r */
|
||||||
#endif /* not _LIBC */
|
#endif /* not _LIBC */
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_errno_message (int errnum)
|
||||||
|
{
|
||||||
|
char const *s;
|
||||||
|
|
||||||
|
#if defined HAVE_STRERROR_R || _LIBC
|
||||||
|
char errbuf[1024];
|
||||||
|
# if STRERROR_R_CHAR_P || _LIBC
|
||||||
|
s = __strerror_r (errnum, errbuf, sizeof errbuf);
|
||||||
|
# else
|
||||||
|
if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0)
|
||||||
|
s = errbuf;
|
||||||
|
else
|
||||||
|
s = 0;
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
s = strerror (errnum);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !_LIBC
|
||||||
|
if (! s)
|
||||||
|
s = _("Unknown system error");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if _LIBC && USE_IN_LIBIO
|
||||||
|
if (_IO_fwide (stderr, 0) > 0)
|
||||||
|
{
|
||||||
|
__fwprintf (stderr, L": %s", s);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
fprintf (stderr, ": %s", s);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef VA_START
|
||||||
|
static void
|
||||||
|
error_tail (int status, int errnum, const char *message, va_list args)
|
||||||
|
{
|
||||||
|
# if HAVE_VPRINTF || _LIBC
|
||||||
|
# if _LIBC && USE_IN_LIBIO
|
||||||
|
if (_IO_fwide (stderr, 0) > 0)
|
||||||
|
{
|
||||||
|
# define ALLOCA_LIMIT 2000
|
||||||
|
size_t len = strlen (message) + 1;
|
||||||
|
wchar_t *wmessage = NULL;
|
||||||
|
mbstate_t st;
|
||||||
|
size_t res;
|
||||||
|
const char *tmp;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (len < ALLOCA_LIMIT)
|
||||||
|
wmessage = (wchar_t *) alloca (len * sizeof (wchar_t));
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (wmessage != NULL && len / 2 < ALLOCA_LIMIT)
|
||||||
|
wmessage = NULL;
|
||||||
|
|
||||||
|
wmessage = (wchar_t *) realloc (wmessage,
|
||||||
|
len * sizeof (wchar_t));
|
||||||
|
|
||||||
|
if (wmessage == NULL)
|
||||||
|
{
|
||||||
|
fputws_unlocked (L"out of memory\n", stderr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
memset (&st, '\0', sizeof (st));
|
||||||
|
tmp =message;
|
||||||
|
}
|
||||||
|
while ((res = mbsrtowcs (wmessage, &tmp, len, &st)) == len);
|
||||||
|
|
||||||
|
if (res == (size_t) -1)
|
||||||
|
/* The string cannot be converted. */
|
||||||
|
wmessage = (wchar_t *) L"???";
|
||||||
|
|
||||||
|
__vfwprintf (stderr, wmessage, args);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
# endif
|
||||||
|
vfprintf (stderr, message, args);
|
||||||
|
# else
|
||||||
|
_doprnt (message, args, stderr);
|
||||||
|
# endif
|
||||||
|
va_end (args);
|
||||||
|
|
||||||
|
++error_message_count;
|
||||||
|
if (errnum)
|
||||||
|
print_errno_message (errnum);
|
||||||
|
# if _LIBC && USE_IN_LIBIO
|
||||||
|
if (_IO_fwide (stderr, 0) > 0)
|
||||||
|
putwc (L'\n', stderr);
|
||||||
|
else
|
||||||
|
# endif
|
||||||
|
putc ('\n', stderr);
|
||||||
|
fflush (stderr);
|
||||||
|
if (status)
|
||||||
|
exit (status);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Print the program name and error message MESSAGE, which is a printf-style
|
/* Print the program name and error message MESSAGE, which is a printf-style
|
||||||
format string with optional args.
|
format string with optional args.
|
||||||
If ERRNUM is nonzero, print its corresponding system error message.
|
If ERRNUM is nonzero, print its corresponding system error message.
|
||||||
Exit with status STATUS if it is nonzero. */
|
Exit with status STATUS if it is nonzero. */
|
||||||
/* VARARGS */
|
/* VARARGS */
|
||||||
|
|
||||||
void
|
void
|
||||||
#if defined VA_START && __STDC__
|
#if defined VA_START && __STDC__
|
||||||
error (int status, int errnum, const char *message, ...)
|
error (int status, int errnum, const char *message, ...)
|
||||||
@@ -142,47 +256,48 @@ error (status, errnum, message, va_alist)
|
|||||||
va_list args;
|
va_list args;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
fflush (stdout);
|
||||||
|
#ifdef _LIBC
|
||||||
|
# ifdef USE_IN_LIBIO
|
||||||
|
_IO_flockfile (stderr);
|
||||||
|
# else
|
||||||
|
__flockfile (stderr);
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
if (error_print_progname)
|
if (error_print_progname)
|
||||||
(*error_print_progname) ();
|
(*error_print_progname) ();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fflush (stdout);
|
#if _LIBC && USE_IN_LIBIO
|
||||||
fprintf (stderr, "%s: ", program_name);
|
if (_IO_fwide (stderr, 0) > 0)
|
||||||
|
__fwprintf (stderr, L"%s: ", program_name);
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
fprintf (stderr, "%s: ", program_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef VA_START
|
#ifdef VA_START
|
||||||
VA_START (args, message);
|
VA_START (args, message);
|
||||||
# if HAVE_VPRINTF || _LIBC
|
error_tail (status, errnum, message, args);
|
||||||
vfprintf (stderr, message, args);
|
|
||||||
# else
|
|
||||||
_doprnt (message, args, stderr);
|
|
||||||
# endif
|
|
||||||
va_end (args);
|
|
||||||
#else
|
#else
|
||||||
fprintf (stderr, message, a1, a2, a3, a4, a5, a6, a7, a8);
|
fprintf (stderr, message, a1, a2, a3, a4, a5, a6, a7, a8);
|
||||||
#endif
|
|
||||||
|
|
||||||
++error_message_count;
|
++error_message_count;
|
||||||
if (errnum)
|
if (errnum)
|
||||||
{
|
print_errno_message (errnum);
|
||||||
#if defined HAVE_STRERROR_R || _LIBC
|
|
||||||
char errbuf[1024];
|
|
||||||
# if HAVE_WORKING_STRERROR_R || _LIBC
|
|
||||||
fprintf (stderr, ": %s", __strerror_r (errnum, errbuf, sizeof errbuf));
|
|
||||||
# else
|
|
||||||
/* Don't use __strerror_r's return value because on some systems
|
|
||||||
(at least DEC UNIX 4.0[A-D]) strerror_r returns `int'. */
|
|
||||||
__strerror_r (errnum, errbuf, sizeof errbuf);
|
|
||||||
fprintf (stderr, ": %s", errbuf);
|
|
||||||
# endif
|
|
||||||
#else
|
|
||||||
fprintf (stderr, ": %s", strerror (errnum));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
putc ('\n', stderr);
|
putc ('\n', stderr);
|
||||||
fflush (stderr);
|
fflush (stderr);
|
||||||
if (status)
|
if (status)
|
||||||
exit (status);
|
exit (status);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _LIBC
|
||||||
|
# ifdef USE_IN_LIBIO
|
||||||
|
_IO_funlockfile (stderr);
|
||||||
|
# else
|
||||||
|
__funlockfile (stderr);
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sometimes we want to have at most one error per line. This
|
/* Sometimes we want to have at most one error per line. This
|
||||||
@@ -212,8 +327,9 @@ error_at_line (status, errnum, file_name, line_number, message, va_alist)
|
|||||||
static const char *old_file_name;
|
static const char *old_file_name;
|
||||||
static unsigned int old_line_number;
|
static unsigned int old_line_number;
|
||||||
|
|
||||||
if (old_line_number == line_number &&
|
if (old_line_number == line_number
|
||||||
(file_name == old_file_name || !strcmp (old_file_name, file_name)))
|
&& (file_name == old_file_name
|
||||||
|
|| strcmp (old_file_name, file_name) == 0))
|
||||||
/* Simply return and print nothing. */
|
/* Simply return and print nothing. */
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -221,50 +337,58 @@ error_at_line (status, errnum, file_name, line_number, message, va_alist)
|
|||||||
old_line_number = line_number;
|
old_line_number = line_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fflush (stdout);
|
||||||
|
#ifdef _LIBC
|
||||||
|
# ifdef USE_IN_LIBIO
|
||||||
|
_IO_flockfile (stderr);
|
||||||
|
# else
|
||||||
|
__flockfile (stderr);
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
if (error_print_progname)
|
if (error_print_progname)
|
||||||
(*error_print_progname) ();
|
(*error_print_progname) ();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fflush (stdout);
|
#if _LIBC && USE_IN_LIBIO
|
||||||
fprintf (stderr, "%s:", program_name);
|
if (_IO_fwide (stderr, 0) > 0)
|
||||||
|
__fwprintf (stderr, L"%s: ", program_name);
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
fprintf (stderr, "%s:", program_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_name != NULL)
|
if (file_name != NULL)
|
||||||
fprintf (stderr, "%s:%d: ", file_name, line_number);
|
{
|
||||||
|
#if _LIBC && USE_IN_LIBIO
|
||||||
|
if (_IO_fwide (stderr, 0) > 0)
|
||||||
|
__fwprintf (stderr, L"%s:%d: ", file_name, line_number);
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
fprintf (stderr, "%s:%d: ", file_name, line_number);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef VA_START
|
#ifdef VA_START
|
||||||
VA_START (args, message);
|
VA_START (args, message);
|
||||||
# if HAVE_VPRINTF || _LIBC
|
error_tail (status, errnum, message, args);
|
||||||
vfprintf (stderr, message, args);
|
|
||||||
# else
|
|
||||||
_doprnt (message, args, stderr);
|
|
||||||
# endif
|
|
||||||
va_end (args);
|
|
||||||
#else
|
#else
|
||||||
fprintf (stderr, message, a1, a2, a3, a4, a5, a6, a7, a8);
|
fprintf (stderr, message, a1, a2, a3, a4, a5, a6, a7, a8);
|
||||||
#endif
|
|
||||||
|
|
||||||
++error_message_count;
|
++error_message_count;
|
||||||
if (errnum)
|
if (errnum)
|
||||||
{
|
print_errno_message (errnum);
|
||||||
#if defined HAVE_STRERROR_R || _LIBC
|
|
||||||
char errbuf[1024];
|
|
||||||
# if HAVE_WORKING_STRERROR_R || _LIBC
|
|
||||||
fprintf (stderr, ": %s", __strerror_r (errnum, errbuf, sizeof errbuf));
|
|
||||||
# else
|
|
||||||
/* Don't use __strerror_r's return value because on some systems
|
|
||||||
(at least DEC UNIX 4.0[A-D]) strerror_r returns `int'. */
|
|
||||||
__strerror_r (errnum, errbuf, sizeof errbuf);
|
|
||||||
fprintf (stderr, ": %s", errbuf);
|
|
||||||
# endif
|
|
||||||
#else
|
|
||||||
fprintf (stderr, ": %s", strerror (errnum));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
putc ('\n', stderr);
|
putc ('\n', stderr);
|
||||||
fflush (stderr);
|
fflush (stderr);
|
||||||
if (status)
|
if (status)
|
||||||
exit (status);
|
exit (status);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _LIBC
|
||||||
|
# ifdef USE_IN_LIBIO
|
||||||
|
_IO_funlockfile (stderr);
|
||||||
|
# else
|
||||||
|
__funlockfile (stderr);
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _LIBC
|
#ifdef _LIBC
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#ifndef __attribute__
|
#ifndef __attribute__
|
||||||
/* This feature is available in gcc versions 2.5 and later. */
|
/* This feature is available in gcc versions 2.5 and later. */
|
||||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
|
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
|
||||||
# define __attribute__(Spec) /* empty */
|
# define __attribute__(Spec) /* empty */
|
||||||
# endif
|
# endif
|
||||||
/* The __-protected variants of `format' and `printf' attributes
|
/* The __-protected variants of `format' and `printf' attributes
|
||||||
|
|||||||
99
lib/getopt.c
99
lib/getopt.c
@@ -1,23 +1,25 @@
|
|||||||
/* Getopt for GNU.
|
/* Getopt for GNU.
|
||||||
NOTE: The canonical source of this file is maintained with the GNU
|
NOTE: getopt is now part of the C library, so if you don't know what
|
||||||
C Library. Bugs can be reported to bug-glibc@gnu.org.
|
"Keep this file name-space clean" means, talk to drepper@gnu.org
|
||||||
|
before changing it!
|
||||||
Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99
|
Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001
|
||||||
Free Software Foundation, Inc.
|
Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
under the terms of the GNU General Public License as published by the
|
modify it under the terms of the GNU Lesser General Public
|
||||||
Free Software Foundation; either version 2, or (at your option) any
|
License as published by the Free Software Foundation; either
|
||||||
later version.
|
version 2.1 of the 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.
|
Lesser 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 Lesser General Public
|
||||||
along with this program; if not, write to the Free Software Foundation,
|
License along with the GNU C Library; if not, write to the Free
|
||||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
Software Foundation, 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>.
|
||||||
Ditto for AIX 3.2 and <stdlib.h>. */
|
Ditto for AIX 3.2 and <stdlib.h>. */
|
||||||
@@ -27,13 +29,13 @@
|
|||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
#else
|
#endif
|
||||||
# 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
|
||||||
|
|
||||||
@@ -75,11 +77,12 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _
|
#ifndef _
|
||||||
/* This is for other GNU distributions with internationalized messages.
|
/* This is for other GNU distributions with internationalized messages. */
|
||||||
When compiling libc, the _ macro is predefined. */
|
# if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC
|
||||||
# ifdef HAVE_LIBINTL_H
|
|
||||||
# include <libintl.h>
|
# include <libintl.h>
|
||||||
# define _(msgid) gettext (msgid)
|
# ifndef _
|
||||||
|
# define _(msgid) gettext (msgid)
|
||||||
|
# endif
|
||||||
# else
|
# else
|
||||||
# define _(msgid) (msgid)
|
# define _(msgid) (msgid)
|
||||||
# endif
|
# endif
|
||||||
@@ -250,11 +253,13 @@ static int last_nonopt;
|
|||||||
/* 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. */
|
||||||
|
|
||||||
|
#ifdef USE_NONOPTION_FLAGS
|
||||||
/* Defined in getopt_init.c */
|
/* Defined in getopt_init.c */
|
||||||
extern char *__getopt_nonoption_flags;
|
extern char *__getopt_nonoption_flags;
|
||||||
|
|
||||||
static int nonoption_flags_max_len;
|
static int nonoption_flags_max_len;
|
||||||
static int nonoption_flags_len;
|
static int nonoption_flags_len;
|
||||||
|
#endif
|
||||||
|
|
||||||
static int original_argc;
|
static int original_argc;
|
||||||
static char *const *original_argv;
|
static char *const *original_argv;
|
||||||
@@ -275,13 +280,17 @@ store_args_and_env (int argc, char *const *argv)
|
|||||||
text_set_element (__libc_subinit, store_args_and_env);
|
text_set_element (__libc_subinit, store_args_and_env);
|
||||||
# endif /* text_set_element */
|
# endif /* text_set_element */
|
||||||
|
|
||||||
# define SWAP_FLAGS(ch1, ch2) \
|
# ifdef USE_NONOPTION_FLAGS
|
||||||
|
# define SWAP_FLAGS(ch1, ch2) \
|
||||||
if (nonoption_flags_len > 0) \
|
if (nonoption_flags_len > 0) \
|
||||||
{ \
|
{ \
|
||||||
char __tmp = __getopt_nonoption_flags[ch1]; \
|
char __tmp = __getopt_nonoption_flags[ch1]; \
|
||||||
__getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \
|
__getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \
|
||||||
__getopt_nonoption_flags[ch2] = __tmp; \
|
__getopt_nonoption_flags[ch2] = __tmp; \
|
||||||
}
|
}
|
||||||
|
# else
|
||||||
|
# define SWAP_FLAGS(ch1, ch2)
|
||||||
|
# endif
|
||||||
#else /* !_LIBC */
|
#else /* !_LIBC */
|
||||||
# define SWAP_FLAGS(ch1, ch2)
|
# define SWAP_FLAGS(ch1, ch2)
|
||||||
#endif /* _LIBC */
|
#endif /* _LIBC */
|
||||||
@@ -313,7 +322,7 @@ exchange (argv)
|
|||||||
It leaves the longer segment in the right place overall,
|
It leaves the longer segment in the right place overall,
|
||||||
but it consists of two parts that need to be swapped next. */
|
but it consists of two parts that need to be swapped next. */
|
||||||
|
|
||||||
#ifdef _LIBC
|
#if defined _LIBC && defined USE_NONOPTION_FLAGS
|
||||||
/* First make sure the handling of the `__getopt_nonoption_flags'
|
/* First make sure the handling of the `__getopt_nonoption_flags'
|
||||||
string can work normally. Our top argument must be in the range
|
string can work normally. Our top argument must be in the range
|
||||||
of the string. */
|
of the string. */
|
||||||
@@ -417,7 +426,7 @@ _getopt_initialize (argc, argv, optstring)
|
|||||||
else
|
else
|
||||||
ordering = PERMUTE;
|
ordering = PERMUTE;
|
||||||
|
|
||||||
#ifdef _LIBC
|
#if defined _LIBC && defined USE_NONOPTION_FLAGS
|
||||||
if (posixly_correct == NULL
|
if (posixly_correct == NULL
|
||||||
&& argc == original_argc && argv == original_argv)
|
&& argc == original_argc && argv == original_argv)
|
||||||
{
|
{
|
||||||
@@ -515,6 +524,13 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
int *longind;
|
int *longind;
|
||||||
int long_only;
|
int long_only;
|
||||||
{
|
{
|
||||||
|
int print_errors = opterr;
|
||||||
|
if (optstring[0] == ':')
|
||||||
|
print_errors = 0;
|
||||||
|
|
||||||
|
if (argc < 1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
optarg = NULL;
|
optarg = NULL;
|
||||||
|
|
||||||
if (optind == 0 || !__getopt_initialized)
|
if (optind == 0 || !__getopt_initialized)
|
||||||
@@ -529,7 +545,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
Either it does not have option syntax, or there is an environment flag
|
Either it does not have option syntax, or there is an environment flag
|
||||||
from the shell indicating it is not an option. The later information
|
from the shell indicating it is not an option. The later information
|
||||||
is only used when the used in the GNU libc. */
|
is only used when the used in the GNU libc. */
|
||||||
#ifdef _LIBC
|
#if defined _LIBC && defined USE_NONOPTION_FLAGS
|
||||||
# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \
|
# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \
|
||||||
|| (optind < nonoption_flags_len \
|
|| (optind < nonoption_flags_len \
|
||||||
&& __getopt_nonoption_flags[optind] == '1'))
|
&& __getopt_nonoption_flags[optind] == '1'))
|
||||||
@@ -664,14 +680,17 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
pfound = p;
|
pfound = p;
|
||||||
indfound = option_index;
|
indfound = option_index;
|
||||||
}
|
}
|
||||||
else
|
else if (long_only
|
||||||
|
|| pfound->has_arg != p->has_arg
|
||||||
|
|| pfound->flag != p->flag
|
||||||
|
|| pfound->val != p->val)
|
||||||
/* Second or later nonexact match found. */
|
/* Second or later nonexact match found. */
|
||||||
ambig = 1;
|
ambig = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ambig && !exact)
|
if (ambig && !exact)
|
||||||
{
|
{
|
||||||
if (opterr)
|
if (print_errors)
|
||||||
fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
|
fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
|
||||||
argv[0], argv[optind]);
|
argv[0], argv[optind]);
|
||||||
nextchar += strlen (nextchar);
|
nextchar += strlen (nextchar);
|
||||||
@@ -692,7 +711,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
optarg = nameend + 1;
|
optarg = nameend + 1;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (opterr)
|
if (print_errors)
|
||||||
{
|
{
|
||||||
if (argv[optind - 1][1] == '-')
|
if (argv[optind - 1][1] == '-')
|
||||||
/* --option */
|
/* --option */
|
||||||
@@ -718,7 +737,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
optarg = argv[optind++];
|
optarg = argv[optind++];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (opterr)
|
if (print_errors)
|
||||||
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]);
|
||||||
@@ -745,7 +764,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
if (!long_only || argv[optind][1] == '-'
|
if (!long_only || argv[optind][1] == '-'
|
||||||
|| my_index (optstring, *nextchar) == NULL)
|
|| my_index (optstring, *nextchar) == NULL)
|
||||||
{
|
{
|
||||||
if (opterr)
|
if (print_errors)
|
||||||
{
|
{
|
||||||
if (argv[optind][1] == '-')
|
if (argv[optind][1] == '-')
|
||||||
/* --option */
|
/* --option */
|
||||||
@@ -775,7 +794,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
|
|
||||||
if (temp == NULL || c == ':')
|
if (temp == NULL || c == ':')
|
||||||
{
|
{
|
||||||
if (opterr)
|
if (print_errors)
|
||||||
{
|
{
|
||||||
if (posixly_correct)
|
if (posixly_correct)
|
||||||
/* 1003.2 specifies the format of this message. */
|
/* 1003.2 specifies the format of this message. */
|
||||||
@@ -809,7 +828,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
}
|
}
|
||||||
else if (optind == argc)
|
else if (optind == argc)
|
||||||
{
|
{
|
||||||
if (opterr)
|
if (print_errors)
|
||||||
{
|
{
|
||||||
/* 1003.2 specifies the format of this message. */
|
/* 1003.2 specifies the format of this message. */
|
||||||
fprintf (stderr, _("%s: option requires an argument -- %c\n"),
|
fprintf (stderr, _("%s: option requires an argument -- %c\n"),
|
||||||
@@ -858,7 +877,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
}
|
}
|
||||||
if (ambig && !exact)
|
if (ambig && !exact)
|
||||||
{
|
{
|
||||||
if (opterr)
|
if (print_errors)
|
||||||
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]);
|
||||||
nextchar += strlen (nextchar);
|
nextchar += strlen (nextchar);
|
||||||
@@ -876,7 +895,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
optarg = nameend + 1;
|
optarg = nameend + 1;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (opterr)
|
if (print_errors)
|
||||||
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);
|
||||||
@@ -891,7 +910,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
optarg = argv[optind++];
|
optarg = argv[optind++];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (opterr)
|
if (print_errors)
|
||||||
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]);
|
||||||
@@ -938,12 +957,12 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
}
|
}
|
||||||
else if (optind == argc)
|
else if (optind == argc)
|
||||||
{
|
{
|
||||||
if (opterr)
|
if (print_errors)
|
||||||
{
|
{
|
||||||
/* 1003.2 specifies the format of this message. */
|
/* 1003.2 specifies the format of this message. */
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: option requires an argument -- %c\n"),
|
_("%s: option requires an argument -- %c\n"),
|
||||||
argv[0], c);
|
argv[0], c);
|
||||||
}
|
}
|
||||||
optopt = c;
|
optopt = c;
|
||||||
if (optstring[0] == ':')
|
if (optstring[0] == ':')
|
||||||
|
|||||||
43
lib/getopt.h
43
lib/getopt.h
@@ -1,21 +1,21 @@
|
|||||||
/* Declarations for getopt.
|
/* Declarations for getopt.
|
||||||
Copyright (C) 1989,90,91,92,93,94,96,97,98 Free Software Foundation, Inc.
|
Copyright (C) 1989-1994, 1996-1999, 2001 Free Software Foundation, Inc.
|
||||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
This file is part of 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
|
|
||||||
under the terms of the GNU 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,
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
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.
|
Lesser 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 Lesser General Public
|
||||||
along with this program; if not, write to the Free Software
|
License along with the GNU C Library; if not, write to the Free
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||||
USA. */
|
02111-1307 USA. */
|
||||||
|
|
||||||
#ifndef _GETOPT_H
|
#ifndef _GETOPT_H
|
||||||
|
|
||||||
@@ -23,6 +23,17 @@
|
|||||||
# define _GETOPT_H 1
|
# define _GETOPT_H 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* If __GNU_LIBRARY__ is not already defined, either we are being used
|
||||||
|
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
|
||||||
|
that does not exist if we are standalone. So: if __GNU_LIBRARY__ is
|
||||||
|
not defined, include <ctype.h>, which will pull in <features.h> for us
|
||||||
|
if it's from glibc. (Why ctype.h? It's guaranteed to exist and it
|
||||||
|
doesn't flood the namespace with stuff the way some other headers do.) */
|
||||||
|
#if !defined __GNU_LIBRARY__
|
||||||
|
# include <ctype.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@@ -82,7 +93,7 @@ extern int optopt;
|
|||||||
|
|
||||||
struct option
|
struct option
|
||||||
{
|
{
|
||||||
# if defined __STDC__ && __STDC__
|
# if (defined __STDC__ && __STDC__) || defined __cplusplus
|
||||||
const char *name;
|
const char *name;
|
||||||
# else
|
# else
|
||||||
char *name;
|
char *name;
|
||||||
@@ -126,7 +137,7 @@ struct option
|
|||||||
arguments to the option '\0'. This behavior is specific to the GNU
|
arguments to the option '\0'. This behavior is specific to the GNU
|
||||||
`getopt'. */
|
`getopt'. */
|
||||||
|
|
||||||
#if defined __STDC__ && __STDC__
|
#if (defined __STDC__ && __STDC__) || defined __cplusplus
|
||||||
# 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
|
||||||
|
|||||||
@@ -1,26 +1,29 @@
|
|||||||
/* 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.
|
This file is part of 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
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
under the terms of the GNU General Public License as published by the
|
modify it under the terms of the GNU Lesser General Public
|
||||||
Free Software Foundation; either version 2, or (at your option) any
|
License as published by the Free Software Foundation; either
|
||||||
later version.
|
version 2.1 of the 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.
|
Lesser 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 Lesser General Public
|
||||||
along with this program; if not, write to the Free Software Foundation,
|
License along with the GNU C Library; if not, write to the Free
|
||||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
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>
|
||||||
#else
|
#endif
|
||||||
|
|
||||||
|
#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)'. */
|
||||||
@@ -28,9 +31,6 @@
|
|||||||
#define const
|
#define const
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "getopt.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|||||||
169
lib/obstack.c
169
lib/obstack.c
@@ -1,26 +1,25 @@
|
|||||||
/* obstack.c - subroutines used implicitly by object stack macros
|
/* obstack.c - subroutines used implicitly by object stack macros
|
||||||
Copyright (C) 1988-1994,96,97,98,99,2000 Free Software Foundation, Inc.
|
Copyright (C) 1988-1994,96,97,98,99,2000,2001 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.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Library General Public License as
|
modify it under the terms of the GNU Lesser General Public
|
||||||
published by the Free Software Foundation; either version 2 of the
|
License as published by the Free Software Foundation; either
|
||||||
License, or (at your option) any later version.
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
The GNU C Library 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 GNU
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
Library General Public License for more details.
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public
|
You should have received a copy of the GNU Lesser General Public
|
||||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
License along with the GNU C Library; if not, write to the Free
|
||||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||||
Boston, MA 02111-1307, USA. */
|
02111-1307 USA. */
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include <config.h>
|
# include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "obstack.h"
|
#include "obstack.h"
|
||||||
@@ -40,40 +39,43 @@
|
|||||||
files, it is simpler to just do this in the source for each such file. */
|
files, it is simpler to just do this in the source for each such file. */
|
||||||
|
|
||||||
#include <stdio.h> /* Random thing to get __GNU_LIBRARY__. */
|
#include <stdio.h> /* Random thing to get __GNU_LIBRARY__. */
|
||||||
#if !defined (_LIBC) && defined (__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1
|
#if !defined _LIBC && defined __GNU_LIBRARY__ && __GNU_LIBRARY__ > 1
|
||||||
#include <gnu-versions.h>
|
# include <gnu-versions.h>
|
||||||
#if _GNU_OBSTACK_INTERFACE_VERSION == OBSTACK_INTERFACE_VERSION
|
# if _GNU_OBSTACK_INTERFACE_VERSION == OBSTACK_INTERFACE_VERSION
|
||||||
#define ELIDE_CODE
|
# define ELIDE_CODE
|
||||||
#endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
# include <wchar.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef ELIDE_CODE
|
#ifndef ELIDE_CODE
|
||||||
|
|
||||||
|
|
||||||
#if defined (__STDC__) && __STDC__
|
# if defined __STDC__ && __STDC__
|
||||||
#define POINTER void *
|
# define POINTER void *
|
||||||
#else
|
# else
|
||||||
#define POINTER char *
|
# define POINTER char *
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
/* Determine default alignment. */
|
/* Determine default alignment. */
|
||||||
struct fooalign {char x; double d;};
|
struct fooalign {char x; double d;};
|
||||||
#define DEFAULT_ALIGNMENT \
|
# define DEFAULT_ALIGNMENT \
|
||||||
((PTR_INT_TYPE) ((char *) &((struct fooalign *) 0)->d - (char *) 0))
|
((PTR_INT_TYPE) ((char *) &((struct fooalign *) 0)->d - (char *) 0))
|
||||||
/* If malloc were really smart, it would round addresses to DEFAULT_ALIGNMENT.
|
/* If malloc were really smart, it would round addresses to DEFAULT_ALIGNMENT.
|
||||||
But in fact it might be less smart and round addresses to as much as
|
But in fact it might be less smart and round addresses to as much as
|
||||||
DEFAULT_ROUNDING. So we prepare for it to do that. */
|
DEFAULT_ROUNDING. So we prepare for it to do that. */
|
||||||
union fooround {long x; double d;};
|
union fooround {long x; double d;};
|
||||||
#define DEFAULT_ROUNDING (sizeof (union fooround))
|
# define DEFAULT_ROUNDING (sizeof (union fooround))
|
||||||
|
|
||||||
/* When we copy a long block of data, this is the unit to do it with.
|
/* When we copy a long block of data, this is the unit to do it with.
|
||||||
On some machines, copying successive ints does not work;
|
On some machines, copying successive ints does not work;
|
||||||
in such a case, redefine COPYING_UNIT to `long' (if that works)
|
in such a case, redefine COPYING_UNIT to `long' (if that works)
|
||||||
or `char' as a last resort. */
|
or `char' as a last resort. */
|
||||||
#ifndef COPYING_UNIT
|
# ifndef COPYING_UNIT
|
||||||
#define COPYING_UNIT int
|
# define COPYING_UNIT int
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
|
|
||||||
/* The functions allocating more room by calling `obstack_chunk_alloc'
|
/* The functions allocating more room by calling `obstack_chunk_alloc'
|
||||||
@@ -82,21 +84,21 @@ 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 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
|
||||||
static void print_and_abort ();
|
static void print_and_abort ();
|
||||||
void (*obstack_alloc_failed_handler) () = print_and_abort;
|
void (*obstack_alloc_failed_handler) () = print_and_abort;
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
/* Exit value used when `print_and_abort' is used. */
|
/* Exit value used when `print_and_abort' is used. */
|
||||||
#if defined __GNU_LIBRARY__ || defined HAVE_STDLIB_H
|
# if defined __GNU_LIBRARY__ || defined HAVE_STDLIB_H
|
||||||
#include <stdlib.h>
|
# include <stdlib.h>
|
||||||
#endif
|
# endif
|
||||||
#ifndef EXIT_FAILURE
|
# ifndef EXIT_FAILURE
|
||||||
#define EXIT_FAILURE 1
|
# define EXIT_FAILURE 1
|
||||||
#endif
|
# endif
|
||||||
int obstack_exit_failure = EXIT_FAILURE;
|
int obstack_exit_failure = EXIT_FAILURE;
|
||||||
|
|
||||||
/* The non-GNU-C macros copy the obstack into this global variable
|
/* The non-GNU-C macros copy the obstack into this global variable
|
||||||
@@ -110,33 +112,33 @@ 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 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)) \
|
||||||
: (*(struct _obstack_chunk *(*) (long)) (h)->chunkfun) ((size)))
|
: (*(struct _obstack_chunk *(*) (long)) (h)->chunkfun) ((size)))
|
||||||
|
|
||||||
#define CALL_FREEFUN(h, old_chunk) \
|
# define CALL_FREEFUN(h, old_chunk) \
|
||||||
do { \
|
do { \
|
||||||
if ((h) -> use_extra_arg) \
|
if ((h) -> use_extra_arg) \
|
||||||
(*(h)->freefun) ((h)->extra_arg, (old_chunk)); \
|
(*(h)->freefun) ((h)->extra_arg, (old_chunk)); \
|
||||||
else \
|
else \
|
||||||
(*(void (*) (void *)) (h)->freefun) ((old_chunk)); \
|
(*(void (*) (void *)) (h)->freefun) ((old_chunk)); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#else
|
# else
|
||||||
#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)) \
|
||||||
: (*(struct _obstack_chunk *(*) ()) (h)->chunkfun) ((size)))
|
: (*(struct _obstack_chunk *(*) ()) (h)->chunkfun) ((size)))
|
||||||
|
|
||||||
#define CALL_FREEFUN(h, old_chunk) \
|
# define CALL_FREEFUN(h, old_chunk) \
|
||||||
do { \
|
do { \
|
||||||
if ((h) -> use_extra_arg) \
|
if ((h) -> use_extra_arg) \
|
||||||
(*(h)->freefun) ((h)->extra_arg, (old_chunk)); \
|
(*(h)->freefun) ((h)->extra_arg, (old_chunk)); \
|
||||||
else \
|
else \
|
||||||
(*(void (*) ()) (h)->freefun) ((old_chunk)); \
|
(*(void (*) ()) (h)->freefun) ((old_chunk)); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
|
|
||||||
/* Initialize an obstack H for use. Specify chunk size SIZE (0 means default).
|
/* Initialize an obstack H for use. Specify chunk size SIZE (0 means default).
|
||||||
@@ -152,13 +154,13 @@ _obstack_begin (h, size, alignment, chunkfun, freefun)
|
|||||||
struct obstack *h;
|
struct obstack *h;
|
||||||
int size;
|
int size;
|
||||||
int alignment;
|
int alignment;
|
||||||
#if defined (__STDC__) && __STDC__
|
# if defined __STDC__ && __STDC__
|
||||||
POINTER (*chunkfun) (long);
|
POINTER (*chunkfun) (long);
|
||||||
void (*freefun) (void *);
|
void (*freefun) (void *);
|
||||||
#else
|
# else
|
||||||
POINTER (*chunkfun) ();
|
POINTER (*chunkfun) ();
|
||||||
void (*freefun) ();
|
void (*freefun) ();
|
||||||
#endif
|
# endif
|
||||||
{
|
{
|
||||||
register struct _obstack_chunk *chunk; /* points to new chunk */
|
register struct _obstack_chunk *chunk; /* points to new chunk */
|
||||||
|
|
||||||
@@ -181,13 +183,13 @@ _obstack_begin (h, size, alignment, chunkfun, freefun)
|
|||||||
size = 4096 - extra;
|
size = 4096 - extra;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 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
|
||||||
h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun;
|
h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun;
|
||||||
h->freefun = freefun;
|
h->freefun = freefun;
|
||||||
#endif
|
# endif
|
||||||
h->chunk_size = size;
|
h->chunk_size = size;
|
||||||
h->alignment_mask = alignment - 1;
|
h->alignment_mask = alignment - 1;
|
||||||
h->use_extra_arg = 0;
|
h->use_extra_arg = 0;
|
||||||
@@ -210,13 +212,13 @@ _obstack_begin_1 (h, size, alignment, chunkfun, freefun, arg)
|
|||||||
struct obstack *h;
|
struct obstack *h;
|
||||||
int size;
|
int size;
|
||||||
int alignment;
|
int alignment;
|
||||||
#if 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
|
||||||
POINTER (*chunkfun) ();
|
POINTER (*chunkfun) ();
|
||||||
void (*freefun) ();
|
void (*freefun) ();
|
||||||
#endif
|
# endif
|
||||||
POINTER arg;
|
POINTER arg;
|
||||||
{
|
{
|
||||||
register struct _obstack_chunk *chunk; /* points to new chunk */
|
register struct _obstack_chunk *chunk; /* points to new chunk */
|
||||||
@@ -240,13 +242,13 @@ _obstack_begin_1 (h, size, alignment, chunkfun, freefun, arg)
|
|||||||
size = 4096 - extra;
|
size = 4096 - extra;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 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
|
||||||
h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun;
|
h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun;
|
||||||
h->freefun = freefun;
|
h->freefun = freefun;
|
||||||
#endif
|
# endif
|
||||||
h->chunk_size = size;
|
h->chunk_size = size;
|
||||||
h->alignment_mask = alignment - 1;
|
h->alignment_mask = alignment - 1;
|
||||||
h->extra_arg = arg;
|
h->extra_arg = arg;
|
||||||
@@ -341,11 +343,11 @@ _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 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);
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
int
|
int
|
||||||
_obstack_allocated_p (h, obj)
|
_obstack_allocated_p (h, obj)
|
||||||
@@ -370,7 +372,7 @@ _obstack_allocated_p (h, obj)
|
|||||||
/* Free objects in obstack H, including OBJ and everything allocate
|
/* Free objects in obstack H, including OBJ and everything allocate
|
||||||
more recently than OBJ. If OBJ is zero, free everything in H. */
|
more recently than OBJ. If OBJ is zero, free everything in H. */
|
||||||
|
|
||||||
#undef obstack_free
|
# undef obstack_free
|
||||||
|
|
||||||
/* This function has two names with identical definitions.
|
/* This function has two names with identical definitions.
|
||||||
This is the first one, called from non-ANSI code. */
|
This is the first one, called from non-ANSI code. */
|
||||||
@@ -456,37 +458,54 @@ _obstack_memory_used (h)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Define the error handler. */
|
/* Define the error handler. */
|
||||||
#ifndef _
|
# ifndef _
|
||||||
# if defined HAVE_LIBINTL_H || defined _LIBC
|
# if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC
|
||||||
# include <libintl.h>
|
# include <libintl.h>
|
||||||
# ifndef _
|
# ifndef _
|
||||||
# define _(Str) gettext (Str)
|
# define _(Str) gettext (Str)
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
# define _(Str) (Str)
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
# if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
# include <libio/iolibio.h>
|
||||||
|
# define fputs(s, f) _IO_fputs (s, f)
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef __attribute__
|
||||||
|
/* This feature is available in gcc versions 2.5 and later. */
|
||||||
|
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
|
||||||
|
# define __attribute__(Spec) /* empty */
|
||||||
# endif
|
# endif
|
||||||
# else
|
|
||||||
# define _(Str) (Str)
|
|
||||||
# endif
|
# endif
|
||||||
#endif
|
|
||||||
#if defined _LIBC && defined USE_IN_LIBIO
|
|
||||||
# include <libio/iolibio.h>
|
|
||||||
# define fputs(s, f) _IO_fputs (s, f)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
__attribute__ ((noreturn))
|
||||||
print_and_abort ()
|
print_and_abort ()
|
||||||
{
|
{
|
||||||
fputs (_("memory exhausted"), stderr);
|
/* Don't change any of these strings. Yes, it would be possible to add
|
||||||
fputc ('\n', stderr);
|
the newline to the string and use fputs or so. But this must not
|
||||||
|
happen because the "memory exhausted" message appears in other places
|
||||||
|
like this and the translation should be reused instead of creating
|
||||||
|
a very similar string which requires a separate translation. */
|
||||||
|
# if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
if (_IO_fwide (stderr, 0) > 0)
|
||||||
|
__fwprintf (stderr, L"%s\n", _("memory exhausted"));
|
||||||
|
else
|
||||||
|
# endif
|
||||||
|
fprintf (stderr, "%s\n", _("memory exhausted"));
|
||||||
exit (obstack_exit_failure);
|
exit (obstack_exit_failure);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
# if 0
|
||||||
/* These are now turned off because the applications do not use it
|
/* These are now turned off because the applications do not use it
|
||||||
and it uses bcopy via obstack_grow, which causes trouble on sysV. */
|
and it uses bcopy via obstack_grow, which causes trouble on sysV. */
|
||||||
|
|
||||||
/* 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 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. */
|
||||||
|
|
||||||
@@ -597,8 +616,8 @@ POINTER (obstack_copy0) (obstack, address, length)
|
|||||||
return obstack_copy0 (obstack, address, length);
|
return obstack_copy0 (obstack, address, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* __STDC__ */
|
# endif /* __STDC__ */
|
||||||
|
|
||||||
#endif /* 0 */
|
# endif /* 0 */
|
||||||
|
|
||||||
#endif /* !ELIDE_CODE */
|
#endif /* !ELIDE_CODE */
|
||||||
|
|||||||
@@ -4,20 +4,23 @@
|
|||||||
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.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||||
modify it under the terms of the GNU Library General Public License as
|
Bugs can be reported to bug-glibc@gnu.org.
|
||||||
published by the Free Software Foundation; either version 2 of the
|
|
||||||
License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library is distributed in the hope that it will be useful,
|
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
|
||||||
|
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
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
Library General Public License for more details.
|
Library General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public
|
You should have received a copy of the GNU Library General Public
|
||||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
License along with this program; if not, write to the Free Software
|
||||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
Boston, MA 02111-1307, USA. */
|
USA. */
|
||||||
|
|
||||||
/* Summary:
|
/* Summary:
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,9 @@
|
|||||||
# include <config.h>
|
# include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if HAVE_STDDEF_H
|
||||||
|
# include <stddef.h> /* For the definition of size_t on windows w/MSVC. */
|
||||||
|
#endif
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <quotearg.h>
|
#include <quotearg.h>
|
||||||
#include <quote.h>
|
#include <quote.h>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Find the length of STRING, but scan at most MAXLEN characters.
|
/* Find the length of STRING, but scan at most MAXLEN characters.
|
||||||
Copyright (C) 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
|
Copyright (C) 1996, 1997, 1998, 2000, 2001 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@@ -51,7 +51,7 @@ size_t
|
|||||||
__strnlen (const char *string, size_t maxlen)
|
__strnlen (const char *string, size_t maxlen)
|
||||||
{
|
{
|
||||||
const char *end = memchr (string, '\0', maxlen);
|
const char *end = memchr (string, '\0', maxlen);
|
||||||
return end ? end - string : maxlen;
|
return end ? (size_t) (end - string) : maxlen;
|
||||||
}
|
}
|
||||||
#ifdef weak_alias
|
#ifdef weak_alias
|
||||||
weak_alias (__strnlen, strnlen)
|
weak_alias (__strnlen, strnlen)
|
||||||
|
|||||||
@@ -47,11 +47,11 @@ void free ();
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_DONE_WORKING_MALLOC_CHECK
|
#ifndef HAVE_DONE_WORKING_MALLOC_CHECK
|
||||||
you must run the autoconf test for a properly working malloc -- see malloc.m4
|
"you must run the autoconf test for a properly working malloc -- see malloc.m4"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_DONE_WORKING_REALLOC_CHECK
|
#ifndef HAVE_DONE_WORKING_REALLOC_CHECK
|
||||||
you must run the autoconf test for a properly working realloc -- see realloc.m4
|
"you must run the autoconf test for a properly working realloc --see realloc.m4"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Exit value when the requested amount of memory is not available.
|
/* Exit value when the requested amount of memory is not available.
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#serial 3
|
#serial 4
|
||||||
|
|
||||||
dnl From Paul Eggert.
|
dnl From Paul Eggert.
|
||||||
|
|
||||||
AC_DEFUN(AC_C_BACKSLASH_A,
|
AC_DEFUN([AC_C_BACKSLASH_A],
|
||||||
[
|
[
|
||||||
AC_CACHE_CHECK([whether backslash-a works in strings], ac_cv_c_backslash_a,
|
AC_CACHE_CHECK([whether backslash-a works in strings], ac_cv_c_backslash_a,
|
||||||
[AC_TRY_COMPILE([],
|
[AC_TRY_COMPILE([],
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
#serial 1
|
#serial 4
|
||||||
|
|
||||||
dnl FIXME: put these prerequisite-only *.m4 files in a separate
|
dnl FIXME: put these prerequisite-only *.m4 files in a separate
|
||||||
dnl directory -- otherwise, they'll conflict with existing files.
|
dnl directory -- otherwise, they'll conflict with existing files.
|
||||||
|
|
||||||
dnl These are the prerequisite macros for GNU's error.c file.
|
dnl These are the prerequisite macros for GNU's error.c file.
|
||||||
AC_DEFUN(jm_PREREQ_ERROR,
|
AC_DEFUN([jm_PREREQ_ERROR],
|
||||||
[
|
[
|
||||||
AC_CHECK_FUNCS(strerror strerror_r vprintf doprnt)
|
AC_CHECK_FUNCS(strerror vprintf doprnt)
|
||||||
AC_HEADER_STDC
|
AC_CHECK_DECLS([strerror])
|
||||||
AC_FUNC_STRERROR_R
|
AC_FUNC_STRERROR_R
|
||||||
|
AC_HEADER_STDC
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -3,10 +3,12 @@
|
|||||||
#
|
#
|
||||||
# This file can be copied and used freely without restrictions. It can
|
# This file can be copied and used freely without restrictions. It can
|
||||||
# be used in projects which are not available under the GNU General Public
|
# be used in projects which are not available under the GNU General Public
|
||||||
# License but which still want to provide support for the GNU gettext
|
# License or the GNU Library General Public License but which still want
|
||||||
# functionality.
|
# to provide support for the GNU gettext functionality.
|
||||||
# Please note that the actual code of GNU gettext is covered by the GNU
|
# Please note that the actual code of the GNU gettext library is covered
|
||||||
# General Public License and is *not* in the public domain.
|
# by the GNU Library General Public License, and the rest of the GNU
|
||||||
|
# gettext package package is covered by the GNU General Public License.
|
||||||
|
# They are *not* in the public domain.
|
||||||
|
|
||||||
# serial 10
|
# serial 10
|
||||||
|
|
||||||
@@ -241,7 +243,7 @@ return (int) gettext ("")]ifelse([$2], need-ngettext, [ + (int) ngettext ("", ""
|
|||||||
dnl Found it, now check the version.
|
dnl Found it, now check the version.
|
||||||
AC_MSG_CHECKING([version of bison])
|
AC_MSG_CHECKING([version of bison])
|
||||||
changequote(<<,>>)dnl
|
changequote(<<,>>)dnl
|
||||||
ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison .* \([0-9]*\.[0-9.]*\).*$/\1/p'`
|
ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
|
||||||
case $ac_prog_version in
|
case $ac_prog_version in
|
||||||
'') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
|
'') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
|
||||||
1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*)
|
1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*)
|
||||||
|
|||||||
@@ -3,10 +3,12 @@
|
|||||||
#
|
#
|
||||||
# This file can be copied and used freely without restrictions. It can
|
# This file can be copied and used freely without restrictions. It can
|
||||||
# be used in projects which are not available under the GNU General Public
|
# be used in projects which are not available under the GNU General Public
|
||||||
# License but which still want to provide support for the GNU gettext
|
# License or the GNU Library General Public License but which still want
|
||||||
# functionality.
|
# to provide support for the GNU gettext functionality.
|
||||||
# Please note that the actual code of GNU gettext is covered by the GNU
|
# Please note that the actual code of the GNU gettext library is covered
|
||||||
# General Public License and is *not* in the public domain.
|
# by the GNU Library General Public License, and the rest of the GNU
|
||||||
|
# gettext package package is covered by the GNU General Public License.
|
||||||
|
# They are *not* in the public domain.
|
||||||
|
|
||||||
# serial 2
|
# serial 2
|
||||||
|
|
||||||
|
|||||||
13
m4/malloc.m4
13
m4/malloc.m4
@@ -1,16 +1,16 @@
|
|||||||
#serial 3
|
#serial 5
|
||||||
|
|
||||||
dnl From Jim Meyering.
|
dnl From Jim Meyering.
|
||||||
dnl Determine whether malloc accepts 0 as its argument.
|
dnl Determine whether malloc accepts 0 as its argument.
|
||||||
dnl If it doesn't, arrange to use the replacement function.
|
dnl If it doesn't, arrange to use the replacement function.
|
||||||
dnl
|
dnl
|
||||||
|
|
||||||
AC_DEFUN(jm_FUNC_MALLOC,
|
AC_DEFUN([jm_FUNC_MALLOC],
|
||||||
[
|
[
|
||||||
dnl xmalloc.c requires that this symbol be defined so it doesn't
|
dnl xmalloc.c requires that this symbol be defined so it doesn't
|
||||||
dnl mistakenly use a broken malloc -- as it might if this test were omitted.
|
dnl mistakenly use a broken malloc -- as it might if this test were omitted.
|
||||||
AC_DEFINE_UNQUOTED(HAVE_DONE_WORKING_MALLOC_CHECK, 1,
|
AC_DEFINE(HAVE_DONE_WORKING_MALLOC_CHECK, 1,
|
||||||
[Define if the malloc check has been performed. ])
|
[Define if the malloc check has been performed. ])
|
||||||
|
|
||||||
AC_CACHE_CHECK([for working malloc], jm_cv_func_working_malloc,
|
AC_CACHE_CHECK([for working malloc], jm_cv_func_working_malloc,
|
||||||
[AC_TRY_RUN([
|
[AC_TRY_RUN([
|
||||||
@@ -27,9 +27,8 @@ AC_DEFUN(jm_FUNC_MALLOC,
|
|||||||
jm_cv_func_working_malloc=no)
|
jm_cv_func_working_malloc=no)
|
||||||
])
|
])
|
||||||
if test $jm_cv_func_working_malloc = no; then
|
if test $jm_cv_func_working_malloc = no; then
|
||||||
AC_SUBST(LIBOBJS)
|
AC_LIBOBJ(malloc)
|
||||||
LIBOBJS="$LIBOBJS malloc.$ac_objext"
|
AC_DEFINE(malloc, rpl_malloc,
|
||||||
AC_DEFINE_UNQUOTED(malloc, rpl_malloc,
|
|
||||||
[Define to rpl_malloc if the replacement function should be used.])
|
[Define to rpl_malloc if the replacement function should be used.])
|
||||||
fi
|
fi
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# serial 8
|
# serial 9
|
||||||
|
|
||||||
# From Paul Eggert.
|
# From Paul Eggert.
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
# (at least glibc-2.1.3) because the "_XOPEN_SOURCE 500" definition elicits
|
# (at least glibc-2.1.3) because the "_XOPEN_SOURCE 500" definition elicits
|
||||||
# a syntax error in wchar.h due to the use of undefined __int32_t.
|
# a syntax error in wchar.h due to the use of undefined __int32_t.
|
||||||
|
|
||||||
AC_DEFUN(AC_MBSTATE_T,
|
AC_DEFUN([AC_MBSTATE_T],
|
||||||
[
|
[
|
||||||
AC_CHECK_HEADERS(stdlib.h)
|
AC_CHECK_HEADERS(stdlib.h)
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,12 @@
|
|||||||
#
|
#
|
||||||
# This file can be copied and used freely without restrictions. It can
|
# This file can be copied and used freely without restrictions. It can
|
||||||
# be used in projects which are not available under the GNU General Public
|
# be used in projects which are not available under the GNU General Public
|
||||||
# License but which still want to provide support for the GNU gettext
|
# License or the GNU Library General Public License but which still want
|
||||||
# functionality.
|
# to provide support for the GNU gettext functionality.
|
||||||
# Please note that the actual code of GNU gettext is covered by the GNU
|
# Please note that the actual code of the GNU gettext library is covered
|
||||||
# General Public License and is *not* in the public domain.
|
# by the GNU Library General Public License, and the rest of the GNU
|
||||||
|
# gettext package package is covered by the GNU General Public License.
|
||||||
|
# They are *not* in the public domain.
|
||||||
|
|
||||||
# serial 2
|
# serial 2
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
#serial 3
|
#serial 5
|
||||||
|
|
||||||
dnl From Jim Meyering.
|
dnl From Jim Meyering.
|
||||||
dnl Determine whether realloc works when both arguments are 0.
|
dnl Determine whether realloc works when both arguments are 0.
|
||||||
dnl If it doesn't, arrange to use the replacement function.
|
dnl If it doesn't, arrange to use the replacement function.
|
||||||
dnl
|
dnl
|
||||||
|
|
||||||
AC_DEFUN(jm_FUNC_REALLOC,
|
AC_DEFUN([jm_FUNC_REALLOC],
|
||||||
[
|
[
|
||||||
dnl xmalloc.c requires that this symbol be defined so it doesn't
|
dnl xmalloc.c requires that this symbol be defined so it doesn't
|
||||||
dnl mistakenly use a broken realloc -- as it might if this test were omitted.
|
dnl mistakenly use a broken realloc -- as it might if this test were omitted.
|
||||||
AC_DEFINE_UNQUOTED(HAVE_DONE_WORKING_REALLOC_CHECK, 1,
|
AC_DEFINE(HAVE_DONE_WORKING_REALLOC_CHECK, 1,
|
||||||
[Define if the realloc check has been performed. ])
|
[Define if the realloc check has been performed. ])
|
||||||
|
|
||||||
AC_CACHE_CHECK([for working realloc], jm_cv_func_working_realloc,
|
AC_CACHE_CHECK([for working realloc], jm_cv_func_working_realloc,
|
||||||
[AC_TRY_RUN([
|
[AC_TRY_RUN([
|
||||||
@@ -27,9 +27,8 @@ AC_DEFUN(jm_FUNC_REALLOC,
|
|||||||
jm_cv_func_working_realloc=no)
|
jm_cv_func_working_realloc=no)
|
||||||
])
|
])
|
||||||
if test $jm_cv_func_working_realloc = no; then
|
if test $jm_cv_func_working_realloc = no; then
|
||||||
AC_SUBST(LIBOBJS)
|
AC_LIBOBJ(realloc)
|
||||||
LIBOBJS="$LIBOBJS realloc.$ac_objext"
|
AC_DEFINE(realloc, rpl_realloc,
|
||||||
AC_DEFINE_UNQUOTED(realloc, rpl_realloc,
|
|
||||||
[Define to rpl_realloc if the replacement function should be used.])
|
[Define to rpl_realloc if the replacement function should be used.])
|
||||||
fi
|
fi
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -1,9 +1,23 @@
|
|||||||
#serial 1002
|
#serial 1003
|
||||||
# Experimental replacement for the function in the latest CVS autoconf.
|
# Experimental replacement for the function in the latest CVS autoconf.
|
||||||
# If the compile-test says strerror_r doesn't work, then resort to a
|
|
||||||
# `run'-test that works on BeOS and segfaults on DEC Unix.
|
|
||||||
# Use with the error.c file in ../lib.
|
# Use with the error.c file in ../lib.
|
||||||
|
|
||||||
|
# Copyright 2001 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
# 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 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 General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU 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. */
|
||||||
|
|
||||||
undefine([AC_FUNC_STRERROR_R])
|
undefine([AC_FUNC_STRERROR_R])
|
||||||
|
|
||||||
# AC_FUNC_STRERROR_R
|
# AC_FUNC_STRERROR_R
|
||||||
@@ -11,56 +25,35 @@ undefine([AC_FUNC_STRERROR_R])
|
|||||||
AC_DEFUN([AC_FUNC_STRERROR_R],
|
AC_DEFUN([AC_FUNC_STRERROR_R],
|
||||||
[AC_CHECK_DECLS([strerror_r])
|
[AC_CHECK_DECLS([strerror_r])
|
||||||
AC_CHECK_FUNCS([strerror_r])
|
AC_CHECK_FUNCS([strerror_r])
|
||||||
if test $ac_cv_func_strerror_r = yes; then
|
AC_CACHE_CHECK([whether strerror_r returns char *],
|
||||||
AC_CHECK_HEADERS(string.h)
|
ac_cv_func_strerror_r_char_p,
|
||||||
AC_CACHE_CHECK([for working strerror_r],
|
|
||||||
ac_cv_func_strerror_r_works,
|
|
||||||
[
|
[
|
||||||
AC_TRY_COMPILE(
|
ac_cv_func_strerror_r_char_p=no
|
||||||
[
|
if test $ac_cv_have_decl_strerror_r = yes; then
|
||||||
# include <stdio.h>
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
|
||||||
# if HAVE_STRING_H
|
[[
|
||||||
# include <string.h>
|
char buf[100];
|
||||||
# endif
|
char x = *strerror_r (0, buf, sizeof buf);
|
||||||
],
|
char *p = strerror_r (0, buf, sizeof buf);
|
||||||
[
|
]])],
|
||||||
char buf[100];
|
ac_cv_func_strerror_r_char_p=yes)
|
||||||
char x = *strerror_r (0, buf, sizeof buf);
|
else
|
||||||
],
|
# strerror_r is not declared. Choose between
|
||||||
ac_cv_func_strerror_r_works=yes,
|
|
||||||
ac_cv_func_strerror_r_works=no
|
|
||||||
)
|
|
||||||
if test $ac_cv_func_strerror_r_works = no; then
|
|
||||||
# strerror_r seems not to work, but now we have to choose between
|
|
||||||
# systems that have relatively inaccessible declarations for the
|
# systems that have relatively inaccessible declarations for the
|
||||||
# function. BeOS and DEC UNIX 4.0 fall in this category, but the
|
# function. BeOS and DEC UNIX 4.0 fall in this category, but the
|
||||||
# former has a strerror_r that returns char*, while the latter
|
# former has a strerror_r that returns char*, while the latter
|
||||||
# has a strerror_r that returns `int'.
|
# has a strerror_r that returns `int'.
|
||||||
# This test should segfault on the DEC system.
|
# This test should segfault on the DEC system.
|
||||||
AC_TRY_RUN(
|
AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
|
||||||
[
|
extern char *strerror_r ();],
|
||||||
# include <stdio.h>
|
[[char buf[100];
|
||||||
# include <string.h>
|
|
||||||
# include <ctype.h>
|
|
||||||
|
|
||||||
extern char *strerror_r ();
|
|
||||||
|
|
||||||
int
|
|
||||||
main ()
|
|
||||||
{
|
|
||||||
char buf[100];
|
|
||||||
char x = *strerror_r (0, buf, sizeof buf);
|
char x = *strerror_r (0, buf, sizeof buf);
|
||||||
exit (!isalpha (x));
|
exit (!isalpha (x));]])],
|
||||||
}
|
ac_cv_func_strerror_r_char_p=yes, , :)
|
||||||
],
|
|
||||||
ac_cv_func_strerror_r_works=yes,
|
|
||||||
ac_cv_func_strerror_r_works=no,
|
|
||||||
ac_cv_func_strerror_r_works=no)
|
|
||||||
fi
|
fi
|
||||||
])
|
])
|
||||||
if test $ac_cv_func_strerror_r_works = yes; then
|
if test $ac_cv_func_strerror_r_char_p = yes; then
|
||||||
AC_DEFINE_UNQUOTED(HAVE_WORKING_STRERROR_R, 1,
|
AC_DEFINE([STRERROR_R_CHAR_P], 1,
|
||||||
[Define to 1 if `strerror_r' returns a string.])
|
[Define to 1 if strerror_r returns char *.])
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
])# AC_FUNC_STRERROR_R
|
])# AC_FUNC_STRERROR_R
|
||||||
|
|||||||
Reference in New Issue
Block a user