summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChet Ramey <chet.ramey@case.edu>2023-03-27 16:38:37 -0400
committerChet Ramey <chet.ramey@case.edu>2023-03-27 16:38:37 -0400
commit57d4dc15ff35895a1c1248f948f59739ffb99fde (patch)
tree150728c1cc4b8d51d19939a64676e4da212bae8c
parent429bd8199cb77a35e18759d7f22164d956b122d1 (diff)
downloadbash-57d4dc15ff35895a1c1248f948f59739ffb99fde.tar.gz
small asan fixes; size_t and other ANSI C changes; restore readline variables in compgen builtin
-rw-r--r--CWRU/CWRU.chlog38
-rw-r--r--aclocal.m425
-rw-r--r--array2.c6
-rw-r--r--bashhist.c2
-rw-r--r--bashline.c2
-rw-r--r--builtins/complete.def12
-rw-r--r--builtins/getopts.def18
-rw-r--r--builtins/mkbuiltins.c2
-rw-r--r--builtins/psize-posix.c3
-rwxr-xr-xconfigure23
-rw-r--r--examples/loadables/asort.c20
-rw-r--r--examples/loadables/pathchk.c5
-rw-r--r--files11
-rw-r--r--include/memalloc.h16
-rw-r--r--input.c63
-rw-r--r--lib/doc-support/Makefile.in53
-rw-r--r--lib/doc-support/getopt.c731
-rw-r--r--lib/doc-support/getopt.h132
-rw-r--r--lib/doc-support/getopt1.c178
-rw-r--r--lib/doc-support/texindex.c1665
-rw-r--r--lib/glob/gm_loop.c11
-rw-r--r--lib/glob/ndir.h50
-rw-r--r--lib/intl/plural.c1684
-rw-r--r--lib/posixheaders.old/ansi_stdlib.h41
-rw-r--r--lib/posixheaders.old/filecntl.h45
-rw-r--r--lib/posixheaders.old/memalloc.h58
-rw-r--r--lib/posixheaders.old/posixdir.h49
-rw-r--r--lib/posixheaders.old/posixjmp.h22
-rw-r--r--lib/posixheaders.old/posixstat.h142
-rw-r--r--lib/posixheaders.old/stdc.h79
-rw-r--r--lib/readline/bind.c4
-rw-r--r--lib/readline/doc/hstech.texi5
-rw-r--r--lib/readline/doc/rltech.texi79
-rw-r--r--lib/readline/doc/version.texi6
-rw-r--r--lib/readline/histexpand.c2
-rw-r--r--lib/readline/rltty.c5
-rw-r--r--lib/readline/text.c3
-rw-r--r--lib/sh/random.c2
-rw-r--r--lib/tilde/shell.c2
-rw-r--r--shell.c2
-rw-r--r--support/bashversion.c8
-rw-r--r--support/endian.c5
-rw-r--r--support/memtest.c1
-rw-r--r--support/mksignames.c11
-rw-r--r--support/printenv.c6
-rw-r--r--support/recho.c11
-rw-r--r--support/rlvers.sh1
-rw-r--r--support/signames.c2
-rw-r--r--support/xcase.c6
-rw-r--r--support/zecho.c4
-rw-r--r--version.c7
51 files changed, 1049 insertions, 4309 deletions
diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog
index f6a14756..89194192 100644
--- a/CWRU/CWRU.chlog
+++ b/CWRU/CWRU.chlog
@@ -5819,3 +5819,41 @@ parse.y
parse.y
- count_all_jobs: add extern definition if JOB_CONTROL is not defined.
From Emanuele Torre <torreemanuele6@gmail.com>
+
+bashhist.c
+ - bash_add_history: make sure the current history line is not empty
+ before checking what ended it.
+ From a report by Grisha Levit <grishalevit@gmail.com>
+
+lib/readline/histexpand.c
+ - history_tokenize_word: break out of loop for incomplete command and
+ process substitution or extended globbing patterns
+ From a report by Grisha Levit <grishalevit@gmail.com>
+
+bashline.c
+ - hostnames_matching: fix size_t issue when checking whether to realloc
+ From a report by Grisha Levit <grishalevit@gmail.com>
+
+lib/sh/random.c
+ - genseed: use uintptr_t instead of u_bits32_t to silence compiler
+ warnings. From Paul Eggert <eggert@cs.ucla.edu>
+
+aclocal.m4
+array2.c
+builtins/mkbuiltins.c,builtins/psize-posix.c,version.c
+builtins/getopts.def
+lib/readline/text.c,lib/readline/bind.c
+support/recho.c,support/mksignames.c,support/zecho.c,support/xcase.c
+support/printenv.c,support/signames.c,support/bashversion.c
+support/memtest.c,support/endian.c
+lib/glob/gm_loop.c
+ - some cleanups for function prototypes and other stdc requirements
+
+lib/readline/doc/{rltech.texi,hstech.texi}
+ - add prototypes and stdc requirements to the examples
+
+builtins/complete.def
+ - compgen_builtin: save and restore readline variables affecting how
+ filename completions are treated in case someone uses compgen in
+ the foreground.
+ From a report by Grisha Levit <grishalevit@gmail.com>
diff --git a/aclocal.m4 b/aclocal.m4
index 93251a76..7ace9c23 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -3,7 +3,7 @@ dnl Bash specific tests
dnl
dnl Some derived from PDKSH 5.1.3 autoconf tests
dnl
-dnl Copyright (C) 1987-2021 Free Software Foundation, Inc.
+dnl Copyright (C) 1987-2023 Free Software Foundation, Inc.
dnl
dnl
@@ -435,6 +435,7 @@ AC_CACHE_VAL(bash_cv_sizeof_rlim_cur,
#endif
#include <stdlib.h>
#include <sys/resource.h>
+int
main()
{
struct rlimit r;
@@ -460,6 +461,7 @@ AC_CACHE_VAL(bash_cv_sizeof_quad_t,
#include <stdint.h>
#endif
+int
main()
{
#if HAVE_QUAD_T
@@ -844,9 +846,7 @@ AC_CACHE_VAL(bash_cv_func_strcoll_broken,
#include <stdlib.h>
int
-main(c, v)
-int c;
-char *v[];
+main(int c, char **v)
{
int r1, r2;
char *deflocale, *defcoll;
@@ -1348,15 +1348,13 @@ AC_CACHE_VAL(bash_cv_must_reinstall_sighandlers,
#endif
#include <stdlib.h>
-typedef void sigfunc();
+typedef void sigfunc(int);
volatile int nsigint;
#ifdef HAVE_POSIX_SIGNALS
sigfunc *
-set_signal_handler(sig, handler)
- int sig;
- sigfunc *handler;
+set_signal_handler(int sig, sigfunc *handler)
{
struct sigaction act, oact;
act.sa_handler = handler;
@@ -1371,8 +1369,7 @@ set_signal_handler(sig, handler)
#endif
void
-sigint(s)
-int s;
+sigint(int s)
{
nsigint++;
}
@@ -1839,9 +1836,7 @@ bash_cv_wcwidth_broken,
#include <wchar.h>
int
-main(c, v)
-int c;
-char **v;
+main(int c, char **v)
{
int w;
@@ -2159,9 +2154,7 @@ AC_CACHE_VAL(bash_cv_wexitstatus_offset,
#include <sys/wait.h>
int
-main(c, v)
- int c;
- char **v;
+main(int c, char **v)
{
pid_t pid, p;
int s, i, n;
diff --git a/array2.c b/array2.c
index 2988f3b1..34cd3440 100644
--- a/array2.c
+++ b/array2.c
@@ -9,7 +9,7 @@
* chet@ins.cwru.edu
*/
-/* Copyright (C) 1997-2021,2022 Free Software Foundation, Inc.
+/* Copyright (C) 1997-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -789,9 +789,7 @@ array_to_kvpair_list (ARRAY *a)
}
ARRAY *
-array_assign_list (array, list)
-ARRAY *array;
-WORD_LIST *list;
+array_assign_list (ARRAY *array, WORD_LIST *list)
{
register WORD_LIST *l;
register arrayind_t i;
diff --git a/bashhist.c b/bashhist.c
index 21c77058..d70d8b74 100644
--- a/bashhist.c
+++ b/bashhist.c
@@ -895,7 +895,7 @@ bash_add_history (char *line)
newline, since that is what happens when the line is parsed. */
curlen = strlen (current->line);
- if (dstack.delimiter_depth == 0 && current->line[curlen - 1] == '\\' &&
+ if (dstack.delimiter_depth == 0 && curlen > 0 && current->line[curlen - 1] == '\\' &&
(curlen < 2 || current->line[curlen - 2] != '\\'))
{
current->line[curlen - 1] = '\0';
diff --git a/bashline.c b/bashline.c
index 0047caef..37cc48a9 100644
--- a/bashline.c
+++ b/bashline.c
@@ -919,7 +919,7 @@ hostnames_matching (const char *text)
continue;
/* OK, it matches. Add it to the list. */
- if (nmatch >= (rsize - 1))
+ if (nmatch + 1 >= rsize)
{
rsize = (rsize + 16) - (rsize % 16);
result = strvec_resize (result, rsize);
diff --git a/builtins/complete.def b/builtins/complete.def
index 0d9b9293..881c4711 100644
--- a/builtins/complete.def
+++ b/builtins/complete.def
@@ -1,7 +1,7 @@
This file is complete.def, from which is created complete.c.
It implements the builtins "complete", "compgen", and "compopt" in Bash.
-Copyright (C) 1999-2022 Free Software Foundation, Inc.
+Copyright (C) 1999-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -650,7 +650,7 @@ compgen_builtin (WORD_LIST *list)
STRINGLIST *sl;
char *word, **matches;
char *old_line;
- int old_ind;
+ int old_ind, old_completion, old_quoting, old_suppress;
if (list == 0)
return (EXECUTION_SUCCESS);
@@ -692,6 +692,10 @@ compgen_builtin (WORD_LIST *list)
rval = EXECUTION_FAILURE;
+ old_completion = rl_filename_completion_desired;
+ old_quoting = rl_filename_quoting_desired;
+ old_suppress = rl_completion_suppress_append;
+
/* probably don't have to save these, just being safe */
old_line = pcomp_line;
old_ind = pcomp_ind;
@@ -720,6 +724,10 @@ compgen_builtin (WORD_LIST *list)
strvec_dispose (matches);
}
+ rl_filename_completion_desired = old_completion;
+ rl_filename_quoting_desired = old_quoting;
+ rl_completion_suppress_append = old_suppress;
+
if (sl)
{
if (sl->list && sl->list_len)
diff --git a/builtins/getopts.def b/builtins/getopts.def
index fc4142b0..b8cbc654 100644
--- a/builtins/getopts.def
+++ b/builtins/getopts.def
@@ -1,7 +1,7 @@
This file is getopts.def, from which is created getopts.c.
It implements the builtin "getopts" in Bash.
-Copyright (C) 1987-2022 Free Software Foundation, Inc.
+Copyright (C) 1987-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -93,16 +93,14 @@ static int dogetopts (int, char **);
/* getopts_reset is magic code for when OPTIND is reset. N is the
value that has just been assigned to OPTIND. */
void
-getopts_reset (newind)
- int newind;
+getopts_reset (int newind)
{
sh_optind = newind;
sh_badopt = 0;
}
static int
-getopts_unbind_variable (name)
- char *name;
+getopts_unbind_variable (char *name)
{
#if 0
return (unbind_variable (name));
@@ -112,8 +110,7 @@ getopts_unbind_variable (name)
}
static int
-getopts_bind_variable (name, value)
- char *name, *value;
+getopts_bind_variable (char *name, char *value)
{
SHELL_VAR *v;
@@ -159,9 +156,7 @@ getopts_bind_variable (name, value)
*/
static int
-dogetopts (argc, argv)
- int argc;
- char **argv;
+dogetopts (int argc, char **argv)
{
int ret, special_error, old_opterr, i, n;
char strval[2], numval[16];
@@ -312,8 +307,7 @@ dogetopts (argc, argv)
/* The getopts builtin. Build an argv, and call dogetopts with it. */
int
-getopts_builtin (list)
- WORD_LIST *list;
+getopts_builtin (WORD_LIST *list)
{
char **av;
int ac, ret;
diff --git a/builtins/mkbuiltins.c b/builtins/mkbuiltins.c
index 2ba37471..7b7f68ce 100644
--- a/builtins/mkbuiltins.c
+++ b/builtins/mkbuiltins.c
@@ -59,7 +59,7 @@
extern int errno;
#endif
-static char *xmalloc (), *xrealloc ();
+static char *xmalloc (size_t), *xrealloc (void *, size_t);
#if !defined (__STDC__) && !defined (strcpy)
extern char *strcpy ();
diff --git a/builtins/psize-posix.c b/builtins/psize-posix.c
index 13abe2ca..260b395a 100644
--- a/builtins/psize-posix.c
+++ b/builtins/psize-posix.c
@@ -1,6 +1,6 @@
/* psize-posix - display the pipe size on a Posix system. */
-/* Copyright 2008,2009,2022 Free Software Foundation, Inc.
+/* Copyright 2008,2009,2022,2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -22,6 +22,7 @@
#include <unistd.h>
#include <stdlib.h>
+int
main(int c, char **v)
{
char *p;
diff --git a/configure b/configure
index f5d1fad2..6714479a 100755
--- a/configure
+++ b/configure
@@ -16609,9 +16609,7 @@ else $as_nop
#include <wchar.h>
int
-main(c, v)
-int c;
-char **v;
+main(int c, char **v)
{
int w;
@@ -18796,6 +18794,7 @@ else $as_nop
#endif
#include <stdlib.h>
#include <sys/resource.h>
+int
main()
{
struct rlimit r;
@@ -18843,6 +18842,7 @@ else $as_nop
#include <stdint.h>
#endif
+int
main()
{
#if HAVE_QUAD_T
@@ -19457,9 +19457,7 @@ else $as_nop
#include <sys/wait.h>
int
-main(c, v)
- int c;
- char **v;
+main(int c, char **v)
{
pid_t pid, p;
int s, i, n;
@@ -20228,9 +20226,7 @@ else $as_nop
#include <stdlib.h>
int
-main(c, v)
-int c;
-char *v[];
+main(int c, char **v)
{
int r1, r2;
char *deflocale, *defcoll;
@@ -20726,15 +20722,13 @@ else $as_nop
#endif
#include <stdlib.h>
-typedef void sigfunc();
+typedef void sigfunc(int);
volatile int nsigint;
#ifdef HAVE_POSIX_SIGNALS
sigfunc *
-set_signal_handler(sig, handler)
- int sig;
- sigfunc *handler;
+set_signal_handler(int sig, sigfunc *handler)
{
struct sigaction act, oact;
act.sa_handler = handler;
@@ -20749,8 +20743,7 @@ set_signal_handler(sig, handler)
#endif
void
-sigint(s)
-int s;
+sigint(int s)
{
nsigint++;
}
diff --git a/examples/loadables/asort.c b/examples/loadables/asort.c
index 6570c9af..bfec70f4 100644
--- a/examples/loadables/asort.c
+++ b/examples/loadables/asort.c
@@ -14,6 +14,8 @@
You should have received a copy of the GNU General Public License
along with Bash. If not, see <http://www.gnu.org/licenses/>.
*/
+/* Contributed by Geir Hauge <geir.hauge@gmail.com> */
+
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
@@ -72,7 +74,7 @@ sort_index(SHELL_VAR *dest, SHELL_VAR *source)
if (assoc_p(source)) {
hash = assoc_cell(source);
n = hash->nentries;
- sa = xmalloc(n * sizeof(sort_element));
+ sa = n ? xmalloc(n * sizeof(sort_element)) : 0;
i = 0;
for ( j = 0; j < hash->nbuckets; ++j ) {
bucket = hash->bucket_array[j];
@@ -91,7 +93,7 @@ sort_index(SHELL_VAR *dest, SHELL_VAR *source)
else {
array = array_cell(source);
n = array_num_elements(array);
- sa = xmalloc(n * sizeof(sort_element));
+ sa = n ? xmalloc(n * sizeof(sort_element)) : 0;
i = 0;
for (ae = element_forw(array->head); ae != array->head; ae = element_forw(ae)) {
@@ -107,12 +109,12 @@ sort_index(SHELL_VAR *dest, SHELL_VAR *source)
// sanity check
if ( i != n ) {
builtin_error("%s: corrupt array", source->name);
+ xfree (sa);
return EXECUTION_FAILURE;
}
- qsort(sa, n, sizeof(sort_element), compare);
-
- array_flush(dest_array);
+ if (n)
+ qsort(sa, n, sizeof(sort_element), compare);
for ( i = 0; i < n; ++i ) {
if ( assoc_p(source) )
@@ -123,6 +125,7 @@ sort_index(SHELL_VAR *dest, SHELL_VAR *source)
array_insert(dest_array, i, key);
}
+ xfree (sa);
return EXECUTION_SUCCESS;
}
@@ -155,6 +158,7 @@ sort_inplace(SHELL_VAR *var)
// sanity check
if ( i != n ) {
builtin_error("%s: corrupt array", var->name);
+ xfree (sa);
return EXECUTION_FAILURE;
}
@@ -220,14 +224,14 @@ asort_builtin(WORD_LIST *list)
sh_invalidid (list->next->word->word);
return EXECUTION_FAILURE;
}
- var = find_or_make_array_variable(list->word->word, 1);
- if (var == 0)
- return EXECUTION_FAILURE;
var2 = find_variable(list->next->word->word);
if ( !var2 || ( !array_p(var2) && !assoc_p(var2) ) ) {
builtin_error("%s: Not an array", list->next->word->word);
return EXECUTION_FAILURE;
}
+ var = builtin_find_indexed_array(list->word->word, 1);
+ if (var == 0)
+ return EXECUTION_FAILURE;
return sort_index(var, var2);
}
diff --git a/examples/loadables/pathchk.c b/examples/loadables/pathchk.c
index 174ba976..01cfc10f 100644
--- a/examples/loadables/pathchk.c
+++ b/examples/loadables/pathchk.c
@@ -23,7 +23,7 @@
/* See Makefile for compilation details. */
/*
- Copyright (C) 1999-2009,2022 Free Software Foundation, Inc.
+ Copyright (C) 1999-2009,2022,2023 Free Software Foundation, Inc.
This file is part of GNU Bash.
Bash is free software: you can redistribute it and/or modify
@@ -99,8 +99,7 @@ extern char *strerror (int);
static int validate_path (char *, int);
int
-pathchk_builtin (list)
- WORD_LIST *list;
+pathchk_builtin (WORD_LIST *list)
{
int retval, pflag, opt;
diff --git a/files b/files
deleted file mode 100644
index e033fa3f..00000000
--- a/files
+++ /dev/null
@@ -1,11 +0,0 @@
-./CWRU/CWRU.chlog
-./tests/shopt.right
-./doc/bashref.info
-./doc/bashref.texi
-./doc/version.texi
-./doc/bash.1
-./parse.y
-./externs.h
-./builtins/shopt.def
-./locale.c
-./subst.c
diff --git a/include/memalloc.h b/include/memalloc.h
index 57318b9d..6a08ac9a 100644
--- a/include/memalloc.h
+++ b/include/memalloc.h
@@ -1,7 +1,7 @@
/* memalloc.h -- consolidate code for including alloca.h or malloc.h and
defining alloca. */
-/* Copyright (C) 1993 Free Software Foundation, Inc.
+/* Copyright (C) 1993,2003 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -45,17 +45,13 @@
# include <alloca.h>
# endif /* !IBMESA */
# else /* !HAVE_ALLOCA_H || C_ALLOCA */
-# if defined (__hpux) && defined (__STDC__) && !defined (alloca)
-extern void *alloca ();
-# else
-# if !defined (alloca)
-# if defined (__STDC__)
+# if !defined (alloca)
+# if defined (__STDC__)
extern void *alloca (size_t);
-# else
+# else
extern char *alloca ();
-# endif /* !__STDC__ */
-# endif /* !alloca */
-# endif /* !__hpux || !__STDC__ && !alloca */
+# endif /* !__STDC__ */
+# endif /* !alloca */
# endif /* !HAVE_ALLOCA_H || C_ALLOCA */
#endif /* !__GNUC__ || C_ALLOCA */
diff --git a/input.c b/input.c
index f739de18..6eab9909 100644
--- a/input.c
+++ b/input.c
@@ -597,66 +597,3 @@ with_input_from_buffered_stream (int bfd, char *name)
init_yy_io (bp == 0 ? return_EOF : buffered_getchar,
buffered_ungetchar, st_bstream, name, location);
}
-
-#if defined (TEST)
-void *
-xmalloc(size_t s)
-{
- return (malloc (s));
-}
-
-void *
-xrealloc(char *s, size_t size)
-{
- if (!s)
- return(malloc (size));
- else
- return(realloc (s, size));
-}
-
-void
-init_yy_io (void)
-{
-}
-
-process(BUFFERED_STREAM *bp)
-{
- int c;
-
- while ((c = bufstream_getc(bp)) != EOF)
- putchar(c);
-}
-
-BASH_INPUT bash_input;
-
-struct stat dsb; /* can be used from gdb */
-
-/* imitate /bin/cat */
-main(int argc, char **argv)
-{
- register int i;
- BUFFERED_STREAM *bp;
-
- if (argc == 1) {
- bp = fd_to_buffered_stream (0);
- process(bp);
- exit(0);
- }
- for (i = 1; i < argc; i++) {
- if (argv[i][0] == '-' && argv[i][1] == '\0') {
- bp = fd_to_buffered_stream (0);
- if (!bp)
- continue;
- process(bp);
- free_buffered_stream (bp);
- } else {
- bp = open_buffered_stream (argv[i]);
- if (!bp)
- continue;
- process(bp);
- close_buffered_stream (bp);
- }
- }
- exit(0);
-}
-#endif /* TEST */
diff --git a/lib/doc-support/Makefile.in b/lib/doc-support/Makefile.in
deleted file mode 100644
index a4205011..00000000
--- a/lib/doc-support/Makefile.in
+++ /dev/null
@@ -1,53 +0,0 @@
-# simple makefile to create texindex
-#
-# Copyright (C) 1996-2005 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
-
-topdir = @top_srcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-BUILD_DIR = @BUILD_DIR@
-
-CC = @CC@
-RM = rm
-
-SHELL = @MAKE_SHELL@
-
-DEFS = @DEFS@
-CFLAGS = @CFLAGS@ @LOCAL_CFLAGS@
-LDFLAGS = @LDFLAGS@ @LOCAL_LDFLAGS@
-CPPFLAGS = @CPPFLAGS@
-
-INCLUDES = -I. -I../.. -I$(topdir)
-
-CCFLAGS = $(CFLAGS) $(DEFS) $(CPPFLAGS) ${INCLUDES}
-
-.c.o:
- $(RM) -f $@
- $(CC) $(CCFLAGS) -c $<
-
-OBJECTS = texindex.o getopt.o getopt1.o
-SOURCES = texindex.c getopt.c getopt1.c
-
-all: texindex
-
-texindex: $(OBJECTS)
- $(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(LIBS)
-
-clean:
- $(RM) $(OBJECTS) texindex
-
-distclean mostlyclean realclean maintainer-clean: clean
- $(RM) Makefile
diff --git a/lib/doc-support/getopt.c b/lib/doc-support/getopt.c
deleted file mode 100644
index 802f0e3d..00000000
--- a/lib/doc-support/getopt.c
+++ /dev/null
@@ -1,731 +0,0 @@
-/* getopt.c - Getopt for GNU. */
-
-/* NOTE: getopt is now part of the C library, so if you don't know what
- "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu
- before changing it! */
-
-/* Copyright (C) 1987, 88, 89, 90, 91, 92, 1993, 2008,2009 Free Software Foundation, Inc.
-
- Bash 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 3 of the License, or
- (at your option) any later version.
-
- Bash 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 Bash. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-/* NOTE!!! AIX requires this to be the first thing in the file.
- Do not put ANYTHING before it! */
-#if !defined (__GNUC__) && defined (_AIX)
- #pragma alloca
-#endif
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#ifdef __GNUC__
-#define alloca __builtin_alloca
-#else /* not __GNUC__ */
-#if defined (HAVE_ALLOCA_H) || (defined(sparc) && (defined(sun) || (!defined(USG) && !defined(SVR4) && !defined(__svr4__))))
-#include <alloca.h>
-#else
-#ifndef _AIX
-char *alloca ();
-#endif
-#endif /* alloca.h */
-#endif /* not __GNUC__ */
-
-#if !__STDC__ && !defined(const) && IN_GCC
-#define const
-#endif
-
-/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>. */
-#ifndef _NO_PROTO
-#define _NO_PROTO
-#endif
-
-#include <stdio.h>
-
-/* Comment out all this code if we are using the GNU C Library, and are not
- actually compiling the library itself. This code is part of the GNU C
- Library, but also included in many other GNU distributions. Compiling
- and linking in this code is a waste when using the GNU C library
- (especially if it is a shared library). Rather than having every GNU
- program understand `configure --with-gnu-libc' and omit the object files,
- it is simpler to just do this in the source for each such file. */
-
-#if defined (_LIBC) || !defined (__GNU_LIBRARY__)
-
-
-/* This needs to come after some library #include
- to get __GNU_LIBRARY__ defined. */
-#ifdef __GNU_LIBRARY__
-#undef alloca
-/* Don't include stdlib.h for non-GNU C libraries because some of them
- contain conflicting prototypes for getopt. */
-#include <stdlib.h>
-#else /* Not GNU C library. */
-#define __alloca alloca
-#endif /* GNU C library. */
-
-/* If GETOPT_COMPAT is defined, `+' as well as `--' can introduce a
- long-named option. Because this is not POSIX.2 compliant, it is
- being phased out. */
-/* #define GETOPT_COMPAT */
-
-/* This version of `getopt' appears to the caller like standard Unix `getopt'
- but it behaves differently for the user, since it allows the user
- to intersperse the options with the other arguments.
-
- As `getopt' works, it permutes the elements of ARGV so that,
- when it is done, all the options precede everything else. Thus
- all application programs are extended to handle flexible argument order.
-
- Setting the environment variable POSIXLY_CORRECT disables permutation.
- Then the behavior is completely standard.
-
- GNU application programs can use a third alternative mode in which
- they can distinguish the relative order of options and other arguments. */
-
-#include "getopt.h"
-
-/* For communication from `getopt' to the caller.
- When `getopt' finds an option that takes an argument,
- the argument value is returned here.
- Also, when `ordering' is RETURN_IN_ORDER,
- each non-option ARGV-element is returned here. */
-
-char *optarg = 0;
-
-/* Index in ARGV of the next element to be scanned.
- This is used for communication to and from the caller
- and for communication between successive calls to `getopt'.
-
- On entry to `getopt', zero means this is the first call; initialize.
-
- When `getopt' returns EOF, this is the index of the first of the
- non-option elements that the caller should itself scan.
-
- Otherwise, `optind' communicates from one call to the next
- how much of ARGV has been scanned so far. */
-
-/* XXX 1003.2 says this must be 1 before any call. */
-int optind = 0;
-
-/* The next char to be scanned in the option-element
- in which the last option character we returned was found.
- This allows us to pick up the scan where we left off.
-
- If this is zero, or a null string, it means resume the scan
- by advancing to the next ARGV-element. */
-
-static char *nextchar;
-
-/* Callers store zero here to inhibit the error message
- for unrecognized options. */
-
-int opterr = 1;
-
-/* Set to an option character which was unrecognized.
- This must be initialized on some systems to avoid linking in the
- system's own getopt implementation. */
-
-int optopt = '?';
-
-/* Describe how to deal with options that follow non-option ARGV-elements.
-
- If the caller did not specify anything,
- the default is REQUIRE_ORDER if the environment variable
- POSIXLY_CORRECT is defined, PERMUTE otherwise.
-
- REQUIRE_ORDER means don't recognize them as options;
- stop option processing when the first non-option is seen.
- This is what Unix does.
- This mode of operation is selected by either setting the environment
- variable POSIXLY_CORRECT, or using `+' as the first character
- of the list of option characters.
-
- PERMUTE is the default. We permute the contents of ARGV as we scan,
- so that eventually all the non-options are at the end. This allows options
- to be given in any order, even with programs that were not written to
- expect this.
-
- RETURN_IN_ORDER is an option available to programs that were written
- to expect options and other ARGV-elements in any order and that care about
- the ordering of the two. We describe each non-option ARGV-element
- as if it were the argument of an option with character code 1.
- Using `-' as the first character of the list of option characters
- selects this mode of operation.
-
- The special argument `--' forces an end of option-scanning regardless
- of the value of `ordering'. In the case of RETURN_IN_ORDER, only
- `--' can cause `getopt' to return EOF with `optind' != ARGC. */
-
-static enum
-{
- REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
-} ordering;
-
-#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
-#define my_bcopy(src, dst, n) memcpy ((dst), (src), (n))
-#else
-
-/* Avoid depending on library functions or files
- whose names are inconsistent. */
-
-char *getenv ();
-
-static char *
-my_index (str, chr)
- const char *str;
- int chr;
-{
- while (*str)
- {
- if (*str == chr)
- return (char *) str;
- str++;
- }
- return 0;
-}
-
-static void
-my_bcopy (from, to, size)
- const char *from;
- char *to;
- int size;
-{
- int i;
- for (i = 0; i < size; i++)
- to[i] = from[i];
-}
-#endif /* GNU C library. */
-
-/* Handle permutation of arguments. */
-
-/* Describe the part of ARGV that contains non-options that have
- been skipped. `first_nonopt' is the index in ARGV of the first of them;
- `last_nonopt' is the index after the last of them. */
-
-static int first_nonopt;
-static int last_nonopt;
-
-/* Exchange two adjacent subsequences of ARGV.
- One subsequence is elements [first_nonopt,last_nonopt)
- which contains all the non-options that have been skipped so far.
- The other is elements [last_nonopt,optind), which contains all
- the options processed since those non-options were skipped.
-
- `first_nonopt' and `last_nonopt' are relocated so that they describe
- the new indices of the non-options in ARGV after they are moved. */
-
-static void
-exchange (argv)
- char **argv;
-{
- int nonopts_size = (last_nonopt - first_nonopt) * sizeof (char *);
- char **temp = (char **) __alloca (nonopts_size);
-
- /* Interchange the two blocks of data in ARGV. */
-
- my_bcopy ((char *) &argv[first_nonopt], (char *) temp, nonopts_size);
- my_bcopy ((char *) &argv[last_nonopt], (char *) &argv[first_nonopt],
- (optind - last_nonopt) * sizeof (char *));
- my_bcopy ((char *) temp,
- (char *) &argv[first_nonopt + optind - last_nonopt],
- nonopts_size);
-
- /* Update records for the slots the non-options now occupy. */
-
- first_nonopt += (optind - last_nonopt);
- last_nonopt = optind;
-}
-
-/* Scan elements of ARGV (whose length is ARGC) for option characters
- given in OPTSTRING.
-
- If an element of ARGV starts with '-', and is not exactly "-" or "--",
- then it is an option element. The characters of this element
- (aside from the initial '-') are option characters. If `getopt'
- is called repeatedly, it returns successively each of the option characters
- from each of the option elements.
-
- If `getopt' finds another option character, it returns that character,
- updating `optind' and `nextchar' so that the next call to `getopt' can
- resume the scan with the following option character or ARGV-element.
-
- If there are no more option characters, `getopt' returns `EOF'.
- Then `optind' is the index in ARGV of the first ARGV-element
- that is not an option. (The ARGV-elements have been permuted
- so that those that are not options now come last.)
-
- OPTSTRING is a string containing the legitimate option characters.
- If an option character is seen that is not listed in OPTSTRING,
- return '?' after printing an error message. If you set `opterr' to
- zero, the error message is suppressed but we still return '?'.
-
- If a char in OPTSTRING is followed by a colon, that means it wants an arg,
- so the following text in the same ARGV-element, or the text of the following
- ARGV-element, is returned in `optarg'. Two colons mean an option that
- wants an optional arg; if there is text in the current ARGV-element,
- it is returned in `optarg', otherwise `optarg' is set to zero.
-
- If OPTSTRING starts with `-' or `+', it requests different methods of
- handling the non-option ARGV-elements.
- See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
-
- Long-named options begin with `--' instead of `-'.
- Their names may be abbreviated as long as the abbreviation is unique
- or is an exact match for some defined option. If they have an
- argument, it follows the option name in the same ARGV-element, separated
- from the option name by a `=', or else the in next ARGV-element.
- When `getopt' finds a long-named option, it returns 0 if that option's
- `flag' field is nonzero, the value of the option's `val' field
- if the `flag' field is zero.
-
- The elements of ARGV aren't really const, because we permute them.
- But we pretend they're const in the prototype to be compatible
- with other systems.
-
- LONGOPTS is a vector of `struct option' terminated by an
- element containing a name which is zero.
-
- LONGIND returns the index in LONGOPT of the long-named option found.
- It is only valid when a long-named option has been found by the most
- recent call.
-
- If LONG_ONLY is nonzero, '-' as well as '--' can introduce
- long-named options. */
-
-int
-_getopt_internal (argc, argv, optstring, longopts, longind, long_only)
- int argc;
- char *const *argv;
- const char *optstring;
- const struct option *longopts;
- int *longind;
- int long_only;
-{
- int option_index;
-
- optarg = 0;
-
- /* Initialize the internal data when the first call is made.
- Start processing options with ARGV-element 1 (since ARGV-element 0
- is the program name); the sequence of previously skipped
- non-option ARGV-elements is empty. */
-
- if (optind == 0)
- {
- first_nonopt = last_nonopt = optind = 1;
-
- nextchar = NULL;
-
- /* Determine how to handle the ordering of options and nonoptions. */
-
- if (optstring[0] == '-')
- {
- ordering = RETURN_IN_ORDER;
- ++optstring;
- }
- else if (optstring[0] == '+')
- {
- ordering = REQUIRE_ORDER;
- ++optstring;
- }
- else if (getenv ("POSIXLY_CORRECT") != NULL)
- ordering = REQUIRE_ORDER;
- else
- ordering = PERMUTE;
- }
-
- if (nextchar == NULL || *nextchar == '\0')
- {
- if (ordering == PERMUTE)
- {
- /* If we have just processed some options following some non-options,
- exchange them so that the options come first. */
-
- if (first_nonopt != last_nonopt && last_nonopt != optind)
- exchange ((char **) argv);
- else if (last_nonopt != optind)
- first_nonopt = optind;
-
- /* Now skip any additional non-options
- and extend the range of non-options previously skipped. */
-
- while (optind < argc
- && (argv[optind][0] != '-' || argv[optind][1] == '\0')
-#ifdef GETOPT_COMPAT
- && (longopts == NULL
- || argv[optind][0] != '+' || argv[optind][1] == '\0')
-#endif /* GETOPT_COMPAT */
- )
- optind++;
- last_nonopt = optind;
- }
-
- /* Special ARGV-element `--' means premature end of options.
- Skip it like a null option,
- then exchange with previous non-options as if it were an option,
- then skip everything else like a non-option. */
-
- if (optind != argc && !strcmp (argv[optind], "--"))
- {
- optind++;
-
- if (first_nonopt != last_nonopt && last_nonopt != optind)
- exchange ((char **) argv);
- else if (first_nonopt == last_nonopt)
- first_nonopt = optind;
- last_nonopt = argc;
-
- optind = argc;
- }
-
- /* If we have done all the ARGV-elements, stop the scan
- and back over any non-options that we skipped and permuted. */
-
- if (optind == argc)
- {
- /* Set the next-arg-index to point at the non-options
- that we previously skipped, so the caller will digest them. */
- if (first_nonopt != last_nonopt)
- optind = first_nonopt;
- return EOF;
- }
-
- /* If we have come to a non-option and did not permute it,
- either stop the scan or describe it to the caller and pass it by. */
-
- if ((argv[optind][0] != '-' || argv[optind][1] == '\0')
-#ifdef GETOPT_COMPAT
- && (longopts == NULL
- || argv[optind][0] != '+' || argv[optind][1] == '\0')
-#endif /* GETOPT_COMPAT */
- )
- {
- if (ordering == REQUIRE_ORDER)
- return EOF;
- optarg = argv[optind++];
- return 1;
- }
-
- /* We have found another option-ARGV-element.
- Start decoding its characters. */
-
- nextchar = (argv[optind] + 1
- + (longopts != NULL && argv[optind][1] == '-'));
- }
-
- if (longopts != NULL
- && ((argv[optind][0] == '-'
- && (argv[optind][1] == '-' || long_only))
-#ifdef GETOPT_COMPAT
- || argv[optind][0] == '+'
-#endif /* GETOPT_COMPAT */
- ))
- {
- const struct option *p;
- char *s = nextchar;
- int exact = 0;
- int ambig = 0;
- const struct option *pfound = NULL;
- int indfound;
-
- while (*s && *s != '=')
- s++;
-
- /* Test all options for either exact match or abbreviated matches. */
- for (p = longopts, option_index = 0; p->name;
- p++, option_index++)
- if (!strncmp (p->name, nextchar, s - nextchar))
- {
- if (s - nextchar == strlen (p->name))
- {
- /* Exact match found. */
- pfound = p;
- indfound = option_index;
- exact = 1;
- break;
- }
- else if (pfound == NULL)
- {
- /* First nonexact match found. */
- pfound = p;
- indfound = option_index;
- }
- else
- /* Second nonexact match found. */
- ambig = 1;
- }
-
- if (ambig && !exact)
- {
- if (opterr)
- fprintf (stderr, "%s: option `%s' is ambiguous\n",
- argv[0], argv[optind]);
- nextchar += strlen (nextchar);
- optind++;
- return '?';
- }
-
- if (pfound != NULL)
- {
- option_index = indfound;
- optind++;
- if (*s)
- {
- /* Don't test has_arg with >, because some C compilers don't
- allow it to be used on enums. */
- if (pfound->has_arg)
- optarg = s + 1;
- else
- {
- if (opterr)
- {
- if (argv[optind - 1][1] == '-')
- /* --option */
- fprintf (stderr,
- "%s: option `--%s' doesn't allow an argument\n",
- argv[0], pfound->name);
- else
- /* +option or -option */
- fprintf (stderr,
- "%s: option `%c%s' doesn't allow an argument\n",
- argv[0], argv[optind - 1][0], pfound->name);
- }
- nextchar += strlen (nextchar);
- return '?';
- }
- }
- else if (pfound->has_arg == 1)
- {
- if (optind < argc)
- optarg = argv[optind++];
- else
- {
- if (opterr)
- fprintf (stderr, "%s: option `%s' requires an argument\n",
- argv[0], argv[optind - 1]);
- nextchar += strlen (nextchar);
- return optstring[0] == ':' ? ':' : '?';
- }
- }
- nextchar += strlen (nextchar);
- if (longind != NULL)
- *longind = option_index;
- if (pfound->flag)
- {
- *(pfound->flag) = pfound->val;
- return 0;
- }
- return pfound->val;
- }
- /* Can't find it as a long option. If this is not getopt_long_only,
- or the option starts with '--' or is not a valid short
- option, then it's an error.
- Otherwise interpret it as a short option. */
- if (!long_only || argv[optind][1] == '-'
-#ifdef GETOPT_COMPAT
- || argv[optind][0] == '+'
-#endif /* GETOPT_COMPAT */
- || my_index (optstring, *nextchar) == NULL)
- {
- if (opterr)
- {
- if (argv[optind][1] == '-')
- /* --option */
- fprintf (stderr, "%s: unrecognized option `--%s'\n",
- argv[0], nextchar);
- else
- /* +option or -option */
- fprintf (stderr, "%s: unrecognized option `%c%s'\n",
- argv[0], argv[optind][0], nextchar);
- }
- nextchar = (char *) "";
- optind++;
- return '?';
- }
- }
-
- /* Look at and handle the next option-character. */
-
- {
- char c = *nextchar++;
- char *temp = my_index (optstring, c);
-
- /* Increment `optind' when we start to process its last character. */
- if (*nextchar == '\0')
- ++optind;
-
- if (temp == NULL || c == ':')
- {
- if (opterr)
- {
-#if 0
- if (c < 040 || c >= 0177)
- fprintf (stderr, "%s: unrecognized option, character code 0%o\n",
- argv[0], c);
- else
- fprintf (stderr, "%s: unrecognized option `-%c'\n", argv[0], c);
-#else
- /* 1003.2 specifies the format of this message. */
- fprintf (stderr, "%s: illegal option -- %c\n", argv[0], c);
-#endif
- }
- optopt = c;
- return '?';
- }
- if (temp[1] == ':')
- {
- if (temp[2] == ':')
- {
- /* This is an option that accepts an argument optionally. */
- if (*nextchar != '\0')
- {
- optarg = nextchar;
- optind++;
- }
- else
- optarg = 0;
- nextchar = NULL;
- }
- else
- {
- /* This is an option that requires an argument. */
- if (*nextchar != '\0')
- {
- optarg = nextchar;
- /* If we end this ARGV-element by taking the rest as an arg,
- we must advance to the next element now. */
- optind++;
- }
- else if (optind == argc)
- {
- if (opterr)
- {
-#if 0
- fprintf (stderr, "%s: option `-%c' requires an argument\n",
- argv[0], c);
-#else
- /* 1003.2 specifies the format of this message. */
- fprintf (stderr, "%s: option requires an argument -- %c\n",
- argv[0], c);
-#endif
- }
- optopt = c;
- if (optstring[0] == ':')
- c = ':';
- else
- c = '?';
- }
- else
- /* We already incremented `optind' once;
- increment it again when taking next ARGV-elt as argument. */
- optarg = argv[optind++];
- nextchar = NULL;
- }
- }
- return c;
- }
-}
-
-int
-getopt (argc, argv, optstring)
- int argc;
- char *const *argv;
- const char *optstring;
-{
- return _getopt_internal (argc, argv, optstring,
- (const struct option *) 0,
- (int *) 0,
- 0);
-}
-
-#endif /* _LIBC or not __GNU_LIBRARY__. */
-
-#ifdef TEST
-
-/* Compile with -DTEST to make an executable for use in testing
- the above definition of `getopt'. */
-
-int
-main (argc, argv)
- int argc;
- char **argv;
-{
- int c;
- int digit_optind = 0;
-
- while (1)
- {
- int this_option_optind = optind ? optind : 1;
-
- c = getopt (argc, argv, "abc:d:0123456789");
- if (c == EOF)
- break;
-
- switch (c)
- {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- if (digit_optind != 0 && digit_optind != this_option_optind)
- printf ("digits occur in two different argv-elements.\n");
- digit_optind = this_option_optind;
- printf ("option %c\n", c);
- break;
-
- case 'a':
- printf ("option a\n");
- break;
-
- case 'b':
- printf ("option b\n");
- break;
-
- case 'c':
- printf ("option c with value `%s'\n", optarg);
- break;
-
- case '?':
- break;
-
- default:
- printf ("?? getopt returned character code 0%o ??\n", c);
- }
- }
-
- if (optind < argc)
- {
- printf ("non-option ARGV-elements: ");
- while (optind < argc)
- printf ("%s ", argv[optind++]);
- printf ("\n");
- }
-
- exit (0);
-}
-
-#endif /* TEST */
diff --git a/lib/doc-support/getopt.h b/lib/doc-support/getopt.h
deleted file mode 100644
index 5c045337..00000000
--- a/lib/doc-support/getopt.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/* getopt.h - public declarations for getopt. */
-
-/* Copyright (C) 1989, 1990, 1991, 1992, 1993, 2008,2009 Free Software Foundation, Inc.
-
- This file is part of GNU Bash, the Bourne Again SHell.
-
- Bash 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 3 of the License, or
- (at your option) any later version.
-
- Bash 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 Bash. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _GETOPT_H
-#define _GETOPT_H 1
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* For communication from `getopt' to the caller.
- When `getopt' finds an option that takes an argument,
- the argument value is returned here.
- Also, when `ordering' is RETURN_IN_ORDER,
- each non-option ARGV-element is returned here. */
-
-extern char *optarg;
-
-/* Index in ARGV of the next element to be scanned.
- This is used for communication to and from the caller
- and for communication between successive calls to `getopt'.
-
- On entry to `getopt', zero means this is the first call; initialize.
-
- When `getopt' returns EOF, this is the index of the first of the
- non-option elements that the caller should itself scan.
-
- Otherwise, `optind' communicates from one call to the next
- how much of ARGV has been scanned so far. */
-
-extern int optind;
-
-/* Callers store zero here to inhibit the error message `getopt' prints
- for unrecognized options. */
-
-extern int opterr;
-
-/* Set to an option character which was unrecognized. */
-
-extern int optopt;
-
-/* Describe the long-named options requested by the application.
- The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
- of `struct option' terminated by an element containing a name which is
- zero.
-
- The field `has_arg' is:
- no_argument (or 0) if the option does not take an argument,
- required_argument (or 1) if the option requires an argument,
- optional_argument (or 2) if the option takes an optional argument.
-
- If the field `flag' is not NULL, it points to a variable that is set
- to the value given in the field `val' when the option is found, but
- left unchanged if the option is not found.
-
- To have a long-named option do something other than set an `int' to
- a compiled-in constant, such as set a value from `optarg', set the
- option's `flag' field to zero and its `val' field to a nonzero
- value (the equivalent single-letter option character, if there is
- one). For long options that have a zero `flag' field, `getopt'
- returns the contents of the `val' field. */
-
-struct option
-{
-#if __STDC__
- const char *name;
-#else
- char *name;
-#endif
- /* has_arg can't be an enum because some compilers complain about
- type mismatches in all the code that assumes it is an int. */
- int has_arg;
- int *flag;
- int val;
-};
-
-/* Names for the values of the `has_arg' field of `struct option'. */
-
-#define no_argument 0
-#define required_argument 1
-#define optional_argument 2
-
-#if __STDC__
-#if defined(__GNU_LIBRARY__)
-/* Many other libraries have conflicting prototypes for getopt, with
- differences in the consts, in stdlib.h. To avoid compilation
- errors, only prototype getopt for the GNU C library. */
-extern int getopt (int argc, char *const *argv, const char *shortopts);
-#else /* not __GNU_LIBRARY__ */
-extern int getopt ();
-#endif /* not __GNU_LIBRARY__ */
-extern int getopt_long (int argc, char *const *argv, const char *shortopts,
- const struct option *longopts, int *longind);
-extern int getopt_long_only (int argc, char *const *argv,
- const char *shortopts,
- const struct option *longopts, int *longind);
-
-/* Internal only. Users should not call this directly. */
-extern int _getopt_internal (int argc, char *const *argv,
- const char *shortopts,
- const struct option *longopts, int *longind,
- int long_only);
-#else /* not __STDC__ */
-extern int getopt ();
-extern int getopt_long ();
-extern int getopt_long_only ();
-
-extern int _getopt_internal ();
-#endif /* not __STDC__ */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _GETOPT_H */
diff --git a/lib/doc-support/getopt1.c b/lib/doc-support/getopt1.c
deleted file mode 100644
index f51e6c00..00000000
--- a/lib/doc-support/getopt1.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/* getopt1.c - getopt_long and getopt_long_only entry points for GNU getopt.
-
-/* Copyright (C) 1987, 88, 89, 90, 91, 92, 1993, 2008,2009 Free Software Foundation, Inc.
-
- This file is part of GNU Bash, the Bourne Again SHell.
-
- Bash 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 3 of the License, or
- (at your option) any later version.
-
- Bash 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 Bash. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "getopt.h"
-
-#if !__STDC__ && !defined(const) && IN_GCC
-#define const
-#endif
-
-#include <stdio.h>
-
-/* Comment out all this code if we are using the GNU C Library, and are not
- actually compiling the library itself. This code is part of the GNU C
- Library, but also included in many other GNU distributions. Compiling
- and linking in this code is a waste when using the GNU C library
- (especially if it is a shared library). Rather than having every GNU
- program understand `configure --with-gnu-libc' and omit the object files,
- it is simpler to just do this in the source for each such file. */
-
-#if defined (_LIBC) || !defined (__GNU_LIBRARY__)
-
-
-/* This needs to come after some library #include
- to get __GNU_LIBRARY__ defined. */
-#ifdef __GNU_LIBRARY__
-#include <stdlib.h>
-#else
-char *getenv ();
-#endif
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-int
-getopt_long (argc, argv, options, long_options, opt_index)
- int argc;
- char *const *argv;
- const char *options;
- const struct option *long_options;
- int *opt_index;
-{
- return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
-}
-
-/* Like getopt_long, but '-' as well as '--' can indicate a long option.
- If an option that starts with '-' (not '--') doesn't match a long option,
- but does match a short option, it is parsed as a short option
- instead. */
-
-int
-getopt_long_only (argc, argv, options, long_options, opt_index)
- int argc;
- char *const *argv;
- const char *options;
- const struct option *long_options;
- int *opt_index;
-{
- return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
-}
-
-
-#endif /* _LIBC or not __GNU_LIBRARY__. */
-
-#ifdef TEST
-
-#include <stdio.h>
-
-int
-main (argc, argv)
- int argc;
- char **argv;
-{
- int c;
- int digit_optind = 0;
-
- while (1)
- {
- int this_option_optind = optind ? optind : 1;
- int option_index = 0;
- static struct option long_options[] =
- {
- {"add", 1, 0, 0},
- {"append", 0, 0, 0},
- {"delete", 1, 0, 0},
- {"verbose", 0, 0, 0},
- {"create", 0, 0, 0},
- {"file", 1, 0, 0},
- {0, 0, 0, 0}
- };
-
- c = getopt_long (argc, argv, "abc:d:0123456789",
- long_options, &option_index);
- if (c == EOF)
- break;
-
- switch (c)
- {
- case 0:
- printf ("option %s", long_options[option_index].name);
- if (optarg)
- printf (" with arg %s", optarg);
- printf ("\n");
- break;
-
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- if (digit_optind != 0 && digit_optind != this_option_optind)
- printf ("digits occur in two different argv-elements.\n");
- digit_optind = this_option_optind;
- printf ("option %c\n", c);
- break;
-
- case 'a':
- printf ("option a\n");
- break;
-
- case 'b':
- printf ("option b\n");
- break;
-
- case 'c':
- printf ("option c with value `%s'\n", optarg);
- break;
-
- case 'd':
- printf ("option d with value `%s'\n", optarg);
- break;
-
- case '?':
- break;
-
- default:
- printf ("?? getopt returned character code 0%o ??\n", c);
- }
- }
-
- if (optind < argc)
- {
- printf ("non-option ARGV-elements: ");
- while (optind < argc)
- printf ("%s ", argv[optind++]);
- printf ("\n");
- }
-
- exit (0);
-}
-
-#endif /* TEST */
diff --git a/lib/doc-support/texindex.c b/lib/doc-support/texindex.c
deleted file mode 100644
index 646df599..00000000
--- a/lib/doc-support/texindex.c
+++ /dev/null
@@ -1,1665 +0,0 @@
-/* Prepare TeX index dribble output into an actual index.
-
- Version 1.45
-
- Copyright (C) 1987, 1991, 1992 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include <stdio.h>
-#include <ctype.h>
-#include <errno.h>
-#include "getopt.h"
-#include "bashansi.h"
-
-#if !defined (errno)
-extern int errno;
-#endif
-
-#if defined (HAVE_UNISTD_H)
-# include <unistd.h>
-#else /* !HAVE_UNISTD_H */
-extern long lseek ();
-#endif /* !HAVE_UNISTD_H */
-
-extern char *mktemp ();
-
-#if !defined (HAVE_STRERROR)
-extern int sys_nerr;
-extern char *sys_errlist[];
-#endif
-
-#include <sys/types.h>
-
-#if defined (_AIX) || !defined (_POSIX_VERSION)
-# include <sys/file.h>
-#endif
-
-#include <fcntl.h>
-
-#define TI_NO_ERROR 0
-#define TI_FATAL_ERROR 1
-
-#if !defined (SEEK_SET)
-# define SEEK_SET 0
-# define SEEK_CUR 1
-# define SEEK_END 2
-#endif /* !SEEK_SET */
-
-/* When sorting in core, this structure describes one line
- and the position and length of its first keyfield. */
-struct lineinfo
-{
- char *text; /* The actual text of the line. */
- union {
- char *text; /* The start of the key (for textual comparison). */
- long number; /* The numeric value (for numeric comparison). */
- } key;
- long keylen; /* Length of KEY field. */
-};
-
-/* This structure describes a field to use as a sort key. */
-struct keyfield
-{
- int startwords; /* Number of words to skip. */
- int startchars; /* Number of additional chars to skip. */
- int endwords; /* Number of words to ignore at end. */
- int endchars; /* Ditto for characters of last word. */
- char ignore_blanks; /* Non-zero means ignore spaces and tabs. */
- char fold_case; /* Non-zero means case doesn't matter. */
- char reverse; /* Non-zero means compare in reverse order. */
- char numeric; /* Non-zeros means field is ASCII numeric. */
- char positional; /* Sort according to file position. */
- char braced; /* Count balanced-braced groupings as fields. */
-};
-
-/* Vector of keyfields to use. */
-struct keyfield keyfields[3];
-
-/* Number of keyfields stored in that vector. */
-int num_keyfields = 3;
-
-/* Vector of input file names, terminated with a null pointer. */
-char **infiles;
-
-/* Vector of corresponding output file names, or NULL, meaning default it
- (add an `s' to the end). */
-char **outfiles;
-
-/* Length of `infiles'. */
-int num_infiles;
-
-/* Pointer to the array of pointers to lines being sorted. */
-char **linearray;
-
-/* The allocated length of `linearray'. */
-long nlines;
-
-/* Directory to use for temporary files. On Unix, it ends with a slash. */
-char *tempdir;
-
-/* Start of filename to use for temporary files. */
-char *tempbase;
-
-/* Number of last temporary file. */
-int tempcount;
-
-/* Number of last temporary file already deleted.
- Temporary files are deleted by `flush_tempfiles' in order of creation. */
-int last_deleted_tempcount;
-
-/* During in-core sort, this points to the base of the data block
- which contains all the lines of data. */
-char *text_base;
-
-/* Additional command switches .*/
-
-/* Nonzero means do not delete tempfiles -- for debugging. */
-int keep_tempfiles;
-
-/* The name this program was run with. */
-char *program_name;
-
-/* Forward declarations of functions in this file. */
-
-void decode_command ();
-void sort_in_core ();
-void sort_offline ();
-char **parsefile ();
-char *find_field ();
-char *find_pos ();
-long find_value ();
-char *find_braced_pos ();
-char *find_braced_end ();
-void writelines ();
-int compare_field ();
-int compare_full ();
-long readline ();
-int merge_files ();
-int merge_direct ();
-void pfatal_with_name ();
-void fatal ();
-void error ();
-void *xmalloc (), *xrealloc ();
-char *concat ();
-char *maketempname ();
-void flush_tempfiles ();
-char *tempcopy ();
-
-#define MAX_IN_CORE_SORT 500000
-
-void
-main (argc, argv)
- int argc;
- char **argv;
-{
- int i;
-
- tempcount = 0;
- last_deleted_tempcount = 0;
- program_name = argv[0];
-
- /* Describe the kind of sorting to do. */
- /* The first keyfield uses the first braced field and folds case. */
- keyfields[0].braced = 1;
- keyfields[0].fold_case = 1;
- keyfields[0].endwords = -1;
- keyfields[0].endchars = -1;
-
- /* The second keyfield uses the second braced field, numerically. */
- keyfields[1].braced = 1;
- keyfields[1].numeric = 1;
- keyfields[1].startwords = 1;
- keyfields[1].endwords = -1;
- keyfields[1].endchars = -1;
-
- /* The third keyfield (which is ignored while discarding duplicates)
- compares the whole line. */
- keyfields[2].endwords = -1;
- keyfields[2].endchars = -1;
-
- decode_command (argc, argv);
-
- tempbase = mktemp (concat ("txiXXXXXX", "", ""));
-
- /* Process input files completely, one by one. */
-
- for (i = 0; i < num_infiles; i++)
- {
- int desc;
- long ptr;
- char *outfile;
-
- desc = open (infiles[i], O_RDONLY, 0);
- if (desc < 0)
- pfatal_with_name (infiles[i]);
- lseek (desc, 0L, SEEK_END);
- ptr = lseek (desc, 0L, SEEK_CUR);
-
- close (desc);
-
- outfile = outfiles[i];
- if (!outfile)
- {
- outfile = concat (infiles[i], "s", "");
- }
-
- if (ptr < MAX_IN_CORE_SORT)
- /* Sort a small amount of data. */
- sort_in_core (infiles[i], ptr, outfile);
- else
- sort_offline (infiles[i], ptr, outfile);
- }
-
- flush_tempfiles (tempcount);
- exit (TI_NO_ERROR);
-}
-
-void
-usage ()
-{
- fprintf (stderr, "\
-Usage: %s [-k] infile [-o outfile] ...\n", program_name);
- exit (1);
-}
-
-/* Decode the command line arguments to set the parameter variables
- and set up the vector of keyfields and the vector of input files. */
-
-void
-decode_command (argc, argv)
- int argc;
- char **argv;
-{
- int optc;
- char **ip;
- char **op;
-
- /* Store default values into parameter variables. */
-
- tempdir = getenv ("TMPDIR");
- if (tempdir == NULL)
- tempdir = "/tmp/";
- else
- tempdir = concat (tempdir, "/", "");
-
- keep_tempfiles = 0;
-
- /* Allocate ARGC input files, which must be enough. */
-
- infiles = (char **) xmalloc (argc * sizeof (char *));
- outfiles = (char **) xmalloc (argc * sizeof (char *));
- ip = infiles;
- op = outfiles;
-
- while ((optc = getopt (argc, argv, "-ko:")) != EOF)
- {
- switch (optc)
- {
- case 1: /* Non-option filename. */
- *ip++ = optarg;
- *op++ = NULL;
- break;
-
- case 'k':
- keep_tempfiles = 1;
- break;
-
- case 'o':
- if (op > outfiles)
- *(op - 1) = optarg;
- break;
-
- default:
- usage ();
- }
- }
-
- /* Record number of keyfields and terminate list of filenames. */
- num_infiles = ip - infiles;
- *ip = 0;
- if (num_infiles == 0)
- usage ();
-}
-
-/* Return a name for a temporary file. */
-
-char *
-maketempname (count)
- int count;
-{
- char tempsuffix[10];
- sprintf (tempsuffix, "%d", count);
- return concat (tempdir, tempbase, tempsuffix);
-}
-
-/* Delete all temporary files up to TO_COUNT. */
-
-void
-flush_tempfiles (to_count)
- int to_count;
-{
- if (keep_tempfiles)
- return;
- while (last_deleted_tempcount < to_count)
- unlink (maketempname (++last_deleted_tempcount));
-}
-
-/* Copy the input file open on IDESC into a temporary file
- and return the temporary file name. */
-
-#define BUFSIZE 1024
-
-char *
-tempcopy (idesc)
- int idesc;
-{
- char *outfile = maketempname (++tempcount);
- int odesc;
- char buffer[BUFSIZE];
-
- odesc = open (outfile, O_WRONLY | O_CREAT, 0666);
-
- if (odesc < 0)
- pfatal_with_name (outfile);
-
- while (1)
- {
- int nread = read (idesc, buffer, BUFSIZE);
- write (odesc, buffer, nread);
- if (!nread)
- break;
- }
-
- close (odesc);
-
- return outfile;
-}
-
-/* Compare LINE1 and LINE2 according to the specified set of keyfields. */
-
-int
-compare_full (line1, line2)
- char **line1, **line2;
-{
- int i;
-
- /* Compare using the first keyfield;
- if that does not distinguish the lines, try the second keyfield;
- and so on. */
-
- for (i = 0; i < num_keyfields; i++)
- {
- long length1, length2;
- char *start1 = find_field (&keyfields[i], *line1, &length1);
- char *start2 = find_field (&keyfields[i], *line2, &length2);
- int tem = compare_field (&keyfields[i], start1, length1, *line1 - text_base,
- start2, length2, *line2 - text_base);
- if (tem)
- {
- if (keyfields[i].reverse)
- return -tem;
- return tem;
- }
- }
-
- return 0; /* Lines match exactly. */
-}
-
-/* Compare LINE1 and LINE2, described by structures
- in which the first keyfield is identified in advance.
- For positional sorting, assumes that the order of the lines in core
- reflects their nominal order. */
-
-int
-compare_prepared (line1, line2)
- struct lineinfo *line1, *line2;
-{
- int i;
- int tem;
- char *text1, *text2;
-
- /* Compare using the first keyfield, which has been found for us already. */
- if (keyfields->positional)
- {
- if (line1->text - text_base > line2->text - text_base)
- tem = 1;
- else
- tem = -1;
- }
- else if (keyfields->numeric)
- tem = line1->key.number - line2->key.number;
- else
- tem = compare_field (keyfields, line1->key.text, line1->keylen, 0,
- line2->key.text, line2->keylen, 0);
- if (tem)
- {
- if (keyfields->reverse)
- return -tem;
- return tem;
- }
-
- text1 = line1->text;
- text2 = line2->text;
-
- /* Compare using the second keyfield;
- if that does not distinguish the lines, try the third keyfield;
- and so on. */
-
- for (i = 1; i < num_keyfields; i++)
- {
- long length1, length2;
- char *start1 = find_field (&keyfields[i], text1, &length1);
- char *start2 = find_field (&keyfields[i], text2, &length2);
- int tem = compare_field (&keyfields[i], start1, length1, text1 - text_base,
- start2, length2, text2 - text_base);
- if (tem)
- {
- if (keyfields[i].reverse)
- return -tem;
- return tem;
- }
- }
-
- return 0; /* Lines match exactly. */
-}
-
-/* Like compare_full but more general.
- You can pass any strings, and you can say how many keyfields to use.
- POS1 and POS2 should indicate the nominal positional ordering of
- the two lines in the input. */
-
-int
-compare_general (str1, str2, pos1, pos2, use_keyfields)
- char *str1, *str2;
- long pos1, pos2;
- int use_keyfields;
-{
- int i;
-
- /* Compare using the first keyfield;
- if that does not distinguish the lines, try the second keyfield;
- and so on. */
-
- for (i = 0; i < use_keyfields; i++)
- {
- long length1, length2;
- char *start1 = find_field (&keyfields[i], str1, &length1);
- char *start2 = find_field (&keyfields[i], str2, &length2);
- int tem = compare_field (&keyfields[i], start1, length1, pos1,
- start2, length2, pos2);
- if (tem)
- {
- if (keyfields[i].reverse)
- return -tem;
- return tem;
- }
- }
-
- return 0; /* Lines match exactly. */
-}
-
-/* Find the start and length of a field in STR according to KEYFIELD.
- A pointer to the starting character is returned, and the length
- is stored into the int that LENGTHPTR points to. */
-
-char *
-find_field (keyfield, str, lengthptr)
- struct keyfield *keyfield;
- char *str;
- long *lengthptr;
-{
- char *start;
- char *end;
- char *(*fun) ();
-
- if (keyfield->braced)
- fun = find_braced_pos;
- else
- fun = find_pos;
-
- start = (*fun) (str, keyfield->startwords, keyfield->startchars,
- keyfield->ignore_blanks);
- if (keyfield->endwords < 0)
- {
- if (keyfield->braced)
- end = find_braced_end (start);
- else
- {
- end = start;
- while (*end && *end != '\n')
- end++;
- }
- }
- else
- {
- end = (*fun) (str, keyfield->endwords, keyfield->endchars, 0);
- if (end - str < start - str)
- end = start;
- }
- *lengthptr = end - start;
- return start;
-}
-
-/* Return a pointer to a specified place within STR,
- skipping (from the beginning) WORDS words and then CHARS chars.
- If IGNORE_BLANKS is nonzero, we skip all blanks
- after finding the specified word. */
-
-char *
-find_pos (str, words, chars, ignore_blanks)
- char *str;
- int words, chars;
- int ignore_blanks;
-{
- int i;
- char *p = str;
-
- for (i = 0; i < words; i++)
- {
- char c;
- /* Find next bunch of nonblanks and skip them. */
- while ((c = *p) == ' ' || c == '\t')
- p++;
- while ((c = *p) && c != '\n' && !(c == ' ' || c == '\t'))
- p++;
- if (!*p || *p == '\n')
- return p;
- }
-
- while (*p == ' ' || *p == '\t')
- p++;
-
- for (i = 0; i < chars; i++)
- {
- if (!*p || *p == '\n')
- break;
- p++;
- }
- return p;
-}
-
-/* Like find_pos but assumes that each field is surrounded by braces
- and that braces within fields are balanced. */
-
-char *
-find_braced_pos (str, words, chars, ignore_blanks)
- char *str;
- int words, chars;
- int ignore_blanks;
-{
- int i;
- int bracelevel;
- char *p = str;
- char c;
-
- for (i = 0; i < words; i++)
- {
- bracelevel = 1;
- while ((c = *p++) != '{' && c != '\n' && c)
- /* Do nothing. */ ;
- if (c != '{')
- return p - 1;
- while (bracelevel)
- {
- c = *p++;
- if (c == '{')
- bracelevel++;
- if (c == '}')
- bracelevel--;
- if (c == 0 || c == '\n')
- return p - 1;
- }
- }
-
- while ((c = *p++) != '{' && c != '\n' && c)
- /* Do nothing. */ ;
-
- if (c != '{')
- return p - 1;
-
- if (ignore_blanks)
- while ((c = *p) == ' ' || c == '\t')
- p++;
-
- for (i = 0; i < chars; i++)
- {
- if (!*p || *p == '\n')
- break;
- p++;
- }
- return p;
-}
-
-/* Find the end of the balanced-brace field which starts at STR.
- The position returned is just before the closing brace. */
-
-char *
-find_braced_end (str)
- char *str;
-{
- int bracelevel;
- char *p = str;
- char c;
-
- bracelevel = 1;
- while (bracelevel)
- {
- c = *p++;
- if (c == '{')
- bracelevel++;
- if (c == '}')
- bracelevel--;
- if (c == 0 || c == '\n')
- return p - 1;
- }
- return p - 1;
-}
-
-long
-find_value (start, length)
- char *start;
- long length;
-{
- while (length != 0L)
- {
- if (isdigit (*start))
- return atol (start);
- length--;
- start++;
- }
- return 0l;
-}
-
-/* Vector used to translate characters for comparison.
- This is how we make all alphanumerics follow all else,
- and ignore case in the first sorting. */
-int char_order[256];
-
-void
-init_char_order ()
-{
- int i;
- for (i = 1; i < 256; i++)
- char_order[i] = i;
-
- for (i = '0'; i <= '9'; i++)
- char_order[i] += 512;
-
- for (i = 'a'; i <= 'z'; i++)
- {
- char_order[i] = 512 + i;
- char_order[i + 'A' - 'a'] = 512 + i;
- }
-}
-
-/* Compare two fields (each specified as a start pointer and a character count)
- according to KEYFIELD.
- The sign of the value reports the relation between the fields. */
-
-int
-compare_field (keyfield, start1, length1, pos1, start2, length2, pos2)
- struct keyfield *keyfield;
- char *start1;
- long length1;
- long pos1;
- char *start2;
- long length2;
- long pos2;
-{
- if (keyfields->positional)
- {
- if (pos1 > pos2)
- return 1;
- else
- return -1;
- }
- if (keyfield->numeric)
- {
- long value = find_value (start1, length1) - find_value (start2, length2);
- if (value > 0)
- return 1;
- if (value < 0)
- return -1;
- return 0;
- }
- else
- {
- char *p1 = start1;
- char *p2 = start2;
- char *e1 = start1 + length1;
- char *e2 = start2 + length2;
-
- while (1)
- {
- int c1, c2;
-
- if (p1 == e1)
- c1 = 0;
- else
- c1 = *p1++;
- if (p2 == e2)
- c2 = 0;
- else
- c2 = *p2++;
-
- if (char_order[c1] != char_order[c2])
- return char_order[c1] - char_order[c2];
- if (!c1)
- break;
- }
-
- /* Strings are equal except possibly for case. */
- p1 = start1;
- p2 = start2;
- while (1)
- {
- int c1, c2;
-
- if (p1 == e1)
- c1 = 0;
- else
- c1 = *p1++;
- if (p2 == e2)
- c2 = 0;
- else
- c2 = *p2++;
-
- if (c1 != c2)
- /* Reverse sign here so upper case comes out last. */
- return c2 - c1;
- if (!c1)
- break;
- }
-
- return 0;
- }
-}
-
-/* A `struct linebuffer' is a structure which holds a line of text.
- `readline' reads a line from a stream into a linebuffer
- and works regardless of the length of the line. */
-
-struct linebuffer
-{
- long size;
- char *buffer;
-};
-
-/* Initialize LINEBUFFER for use. */
-
-void
-initbuffer (linebuffer)
- struct linebuffer *linebuffer;
-{
- linebuffer->size = 200;
- linebuffer->buffer = (char *) xmalloc (200);
-}
-
-/* Read a line of text from STREAM into LINEBUFFER.
- Return the length of the line. */
-
-long
-readline (linebuffer, stream)
- struct linebuffer *linebuffer;
- FILE *stream;
-{
- char *buffer = linebuffer->buffer;
- char *p = linebuffer->buffer;
- char *end = p + linebuffer->size;
-
- while (1)
- {
- int c = getc (stream);
- if (p == end)
- {
- buffer = (char *) xrealloc (buffer, linebuffer->size *= 2);
- p += buffer - linebuffer->buffer;
- end += buffer - linebuffer->buffer;
- linebuffer->buffer = buffer;
- }
- if (c < 0 || c == '\n')
- {
- *p = 0;
- break;
- }
- *p++ = c;
- }
-
- return p - buffer;
-}
-
-/* Sort an input file too big to sort in core. */
-
-void
-sort_offline (infile, nfiles, total, outfile)
- char *infile;
- int nfiles;
- long total;
- char *outfile;
-{
- /* More than enough. */
- int ntemps = 2 * (total + MAX_IN_CORE_SORT - 1) / MAX_IN_CORE_SORT;
- char **tempfiles = (char **) xmalloc (ntemps * sizeof (char *));
- FILE *istream = fopen (infile, "r");
- int i;
- struct linebuffer lb;
- long linelength;
- int failure = 0;
-
- initbuffer (&lb);
-
- /* Read in one line of input data. */
-
- linelength = readline (&lb, istream);
-
- if (lb.buffer[0] != '\\' && lb.buffer[0] != '@')
- {
- error ("%s: not a texinfo index file", infile);
- return;
- }
-
- /* Split up the input into `ntemps' temporary files, or maybe fewer,
- and put the new files' names into `tempfiles' */
-
- for (i = 0; i < ntemps; i++)
- {
- char *outname = maketempname (++tempcount);
- FILE *ostream = fopen (outname, "w");
- long tempsize = 0;
-
- if (!ostream)
- pfatal_with_name (outname);
- tempfiles[i] = outname;
-
- /* Copy lines into this temp file as long as it does not make file
- "too big" or until there are no more lines. */
-
- while (tempsize + linelength + 1 <= MAX_IN_CORE_SORT)
- {
- tempsize += linelength + 1;
- fputs (lb.buffer, ostream);
- putc ('\n', ostream);
-
- /* Read another line of input data. */
-
- linelength = readline (&lb, istream);
- if (!linelength && feof (istream))
- break;
-
- if (lb.buffer[0] != '\\' && lb.buffer[0] != '@')
- {
- error ("%s: not a texinfo index file", infile);
- failure = 1;
- goto fail;
- }
- }
- fclose (ostream);
- if (feof (istream))
- break;
- }
-
- free (lb.buffer);
-
-fail:
- /* Record number of temp files we actually needed. */
-
- ntemps = i;
-
- /* Sort each tempfile into another tempfile.
- Delete the first set of tempfiles and put the names of the second
- into `tempfiles'. */
-
- for (i = 0; i < ntemps; i++)
- {
- char *newtemp = maketempname (++tempcount);
- sort_in_core (&tempfiles[i], MAX_IN_CORE_SORT, newtemp);
- if (!keep_tempfiles)
- unlink (tempfiles[i]);
- tempfiles[i] = newtemp;
- }
-
- if (failure)
- return;
-
- /* Merge the tempfiles together and indexify. */
-
- merge_files (tempfiles, ntemps, outfile);
-}
-
-/* Sort INFILE, whose size is TOTAL,
- assuming that is small enough to be done in-core,
- then indexify it and send the output to OUTFILE (or to stdout). */
-
-void
-sort_in_core (infile, total, outfile)
- char *infile;
- long total;
- char *outfile;
-{
- char **nextline;
- char *data = (char *) xmalloc (total + 1);
- char *file_data;
- long file_size;
- int i;
- FILE *ostream = stdout;
- struct lineinfo *lineinfo;
-
- /* Read the contents of the file into the moby array `data'. */
-
- int desc = open (infile, O_RDONLY, 0);
-
- if (desc < 0)
- fatal ("failure reopening %s", infile);
- for (file_size = 0;;)
- {
- i = read (desc, data + file_size, total - file_size);
- if (i <= 0)
- break;
- file_size += i;
- }
- file_data = data;
- data[file_size] = 0;
-
- close (desc);
-
- if (file_size > 0 && data[0] != '\\' && data[0] != '@')
- {
- error ("%s: not a texinfo index file", infile);
- return;
- }
-
- init_char_order ();
-
- /* Sort routines want to know this address. */
-
- text_base = data;
-
- /* Create the array of pointers to lines, with a default size
- frequently enough. */
-
- nlines = total / 50;
- if (!nlines)
- nlines = 2;
- linearray = (char **) xmalloc (nlines * sizeof (char *));
-
- /* `nextline' points to the next free slot in this array.
- `nlines' is the allocated size. */
-
- nextline = linearray;
-
- /* Parse the input file's data, and make entries for the lines. */
-
- nextline = parsefile (infile, nextline, file_data, file_size);
- if (nextline == 0)
- {
- error ("%s: not a texinfo index file", infile);
- return;
- }
-
- /* Sort the lines. */
-
- /* If we have enough space, find the first keyfield of each line in advance.
- Make a `struct lineinfo' for each line, which records the keyfield
- as well as the line, and sort them. */
-
- lineinfo = (struct lineinfo *) malloc ((nextline - linearray) * sizeof (struct lineinfo));
-
- if (lineinfo)
- {
- struct lineinfo *lp;
- char **p;
-
- for (lp = lineinfo, p = linearray; p != nextline; lp++, p++)
- {
- lp->text = *p;
- lp->key.text = find_field (keyfields, *p, &lp->keylen);
- if (keyfields->numeric)
- lp->key.number = find_value (lp->key.text, lp->keylen);
- }
-
- qsort (lineinfo, nextline - linearray, sizeof (struct lineinfo), compare_prepared);
-
- for (lp = lineinfo, p = linearray; p != nextline; lp++, p++)
- *p = lp->text;
-
- free (lineinfo);
- }
- else
- qsort (linearray, nextline - linearray, sizeof (char *), compare_full);
-
- /* Open the output file. */
-
- if (outfile)
- {
- ostream = fopen (outfile, "w");
- if (!ostream)
- pfatal_with_name (outfile);
- }
-
- writelines (linearray, nextline - linearray, ostream);
- if (outfile)
- fclose (ostream);
-
- free (linearray);
- free (data);
-}
-
-/* Parse an input string in core into lines.
- DATA is the input string, and SIZE is its length.
- Data goes in LINEARRAY starting at NEXTLINE.
- The value returned is the first entry in LINEARRAY still unused.
- Value 0 means input file contents are invalid. */
-
-char **
-parsefile (filename, nextline, data, size)
- char *filename;
- char **nextline;
- char *data;
- long size;
-{
- char *p, *end;
- char **line = nextline;
-
- p = data;
- end = p + size;
- *end = 0;
-
- while (p != end)
- {
- if (p[0] != '\\' && p[0] != '@')
- return 0;
-
- *line = p;
- while (*p && *p != '\n')
- p++;
- if (p != end)
- p++;
-
- line++;
- if (line == linearray + nlines)
- {
- char **old = linearray;
- linearray = (char **) xrealloc (linearray, sizeof (char *) * (nlines *= 4));
- line += linearray - old;
- }
- }
-
- return line;
-}
-
-/* Indexification is a filter applied to the sorted lines
- as they are being written to the output file.
- Multiple entries for the same name, with different page numbers,
- get combined into a single entry with multiple page numbers.
- The first braced field, which is used for sorting, is discarded.
- However, its first character is examined, folded to lower case,
- and if it is different from that in the previous line fed to us
- a \initial line is written with one argument, the new initial.
-
- If an entry has four braced fields, then the second and third
- constitute primary and secondary names.
- In this case, each change of primary name
- generates a \primary line which contains only the primary name,
- and in between these are \secondary lines which contain
- just a secondary name and page numbers. */
-
-/* The last primary name we wrote a \primary entry for.
- If only one level of indexing is being done, this is the last name seen. */
-char *lastprimary;
-/* Length of storage allocated for lastprimary. */
-int lastprimarylength;
-
-/* Similar, for the secondary name. */
-char *lastsecondary;
-int lastsecondarylength;
-
-/* Zero if we are not in the middle of writing an entry.
- One if we have written the beginning of an entry but have not
- yet written any page numbers into it.
- Greater than one if we have written the beginning of an entry
- plus at least one page number. */
-int pending;
-
-/* The initial (for sorting purposes) of the last primary entry written.
- When this changes, a \initial {c} line is written */
-
-char *lastinitial;
-
-int lastinitiallength;
-
-/* When we need a string of length 1 for the value of lastinitial,
- store it here. */
-
-char lastinitial1[2];
-
-/* Initialize static storage for writing an index. */
-
-static void
-xbzero(s, n)
- char *s;
- int n;
-{
- register char *p;
- for (p = s; n--; )
- *p++ = '\0';
-}
-
-void
-init_index ()
-{
- pending = 0;
- lastinitial = lastinitial1;
- lastinitial1[0] = 0;
- lastinitial1[1] = 0;
- lastinitiallength = 0;
- lastprimarylength = 100;
- lastprimary = (char *) xmalloc (lastprimarylength + 1);
- xbzero (lastprimary, lastprimarylength + 1);
- lastsecondarylength = 100;
- lastsecondary = (char *) xmalloc (lastsecondarylength + 1);
- xbzero (lastsecondary, lastsecondarylength + 1);
-}
-
-/* Indexify. Merge entries for the same name,
- insert headers for each initial character, etc. */
-
-void
-indexify (line, ostream)
- char *line;
- FILE *ostream;
-{
- char *primary, *secondary, *pagenumber;
- int primarylength, secondarylength = 0, pagelength;
- int nosecondary;
- int initiallength;
- char *initial;
- char initial1[2];
- register char *p;
-
- /* First, analyze the parts of the entry fed to us this time. */
-
- p = find_braced_pos (line, 0, 0, 0);
- if (*p == '{')
- {
- initial = p;
- /* Get length of inner pair of braces starting at `p',
- including that inner pair of braces. */
- initiallength = find_braced_end (p + 1) + 1 - p;
- }
- else
- {
- initial = initial1;
- initial1[0] = *p;
- initial1[1] = 0;
- initiallength = 1;
-
- if (initial1[0] >= 'a' && initial1[0] <= 'z')
- initial1[0] -= 040;
- }
-
- pagenumber = find_braced_pos (line, 1, 0, 0);
- pagelength = find_braced_end (pagenumber) - pagenumber;
- if (pagelength == 0)
- abort ();
-
- primary = find_braced_pos (line, 2, 0, 0);
- primarylength = find_braced_end (primary) - primary;
-
- secondary = find_braced_pos (line, 3, 0, 0);
- nosecondary = !*secondary;
- if (!nosecondary)
- secondarylength = find_braced_end (secondary) - secondary;
-
- /* If the primary is different from before, make a new primary entry. */
- if (strncmp (primary, lastprimary, primarylength))
- {
- /* Close off current secondary entry first, if one is open. */
- if (pending)
- {
- fputs ("}\n", ostream);
- pending = 0;
- }
-
- /* If this primary has a different initial, include an entry for
- the initial. */
- if (initiallength != lastinitiallength ||
- strncmp (initial, lastinitial, initiallength))
- {
- fprintf (ostream, "\\initial {");
- fwrite (initial, 1, initiallength, ostream);
- fprintf (ostream, "}\n", initial);
- if (initial == initial1)
- {
- lastinitial = lastinitial1;
- *lastinitial1 = *initial1;
- }
- else
- {
- lastinitial = initial;
- }
- lastinitiallength = initiallength;
- }
-
- /* Make the entry for the primary. */
- if (nosecondary)
- fputs ("\\entry {", ostream);
- else
- fputs ("\\primary {", ostream);
- fwrite (primary, primarylength, 1, ostream);
- if (nosecondary)
- {
- fputs ("}{", ostream);
- pending = 1;
- }
- else
- fputs ("}\n", ostream);
-
- /* Record name of most recent primary. */
- if (lastprimarylength < primarylength)
- {
- lastprimarylength = primarylength + 100;
- lastprimary = (char *) xrealloc (lastprimary,
- 1 + lastprimarylength);
- }
- strncpy (lastprimary, primary, primarylength);
- lastprimary[primarylength] = 0;
-
- /* There is no current secondary within this primary, now. */
- lastsecondary[0] = 0;
- }
-
- /* Should not have an entry with no subtopic following one with a subtopic. */
-
- if (nosecondary && *lastsecondary)
- error ("entry %s follows an entry with a secondary name", line);
-
- /* Start a new secondary entry if necessary. */
- if (!nosecondary && strncmp (secondary, lastsecondary, secondarylength))
- {
- if (pending)
- {
- fputs ("}\n", ostream);
- pending = 0;
- }
-
- /* Write the entry for the secondary. */
- fputs ("\\secondary {", ostream);
- fwrite (secondary, secondarylength, 1, ostream);
- fputs ("}{", ostream);
- pending = 1;
-
- /* Record name of most recent secondary. */
- if (lastsecondarylength < secondarylength)
- {
- lastsecondarylength = secondarylength + 100;
- lastsecondary = (char *) xrealloc (lastsecondary,
- 1 + lastsecondarylength);
- }
- strncpy (lastsecondary, secondary, secondarylength);
- lastsecondary[secondarylength] = 0;
- }
-
- /* Here to add one more page number to the current entry. */
- if (pending++ != 1)
- fputs (", ", ostream); /* Punctuate first, if this is not the first. */
- fwrite (pagenumber, pagelength, 1, ostream);
-}
-
-/* Close out any unfinished output entry. */
-
-void
-finish_index (ostream)
- FILE *ostream;
-{
- if (pending)
- fputs ("}\n", ostream);
- free (lastprimary);
- free (lastsecondary);
-}
-
-/* Copy the lines in the sorted order.
- Each line is copied out of the input file it was found in. */
-
-void
-writelines (linearray, nlines, ostream)
- char **linearray;
- int nlines;
- FILE *ostream;
-{
- char **stop_line = linearray + nlines;
- char **next_line;
-
- init_index ();
-
- /* Output the text of the lines, and free the buffer space. */
-
- for (next_line = linearray; next_line != stop_line; next_line++)
- {
- /* If -u was specified, output the line only if distinct from previous one. */
- if (next_line == linearray
- /* Compare previous line with this one, using only the
- explicitly specd keyfields. */
- || compare_general (*(next_line - 1), *next_line, 0L, 0L, num_keyfields - 1))
- {
- char *p = *next_line;
- char c;
-
- while ((c = *p++) && c != '\n')
- /* Do nothing. */ ;
- *(p - 1) = 0;
- indexify (*next_line, ostream);
- }
- }
-
- finish_index (ostream);
-}
-
-/* Assume (and optionally verify) that each input file is sorted;
- merge them and output the result.
- Returns nonzero if any input file fails to be sorted.
-
- This is the high-level interface that can handle an unlimited
- number of files. */
-
-#define MAX_DIRECT_MERGE 10
-
-int
-merge_files (infiles, nfiles, outfile)
- char **infiles;
- int nfiles;
- char *outfile;
-{
- char **tempfiles;
- int ntemps;
- int i;
- int value = 0;
- int start_tempcount = tempcount;
-
- if (nfiles <= MAX_DIRECT_MERGE)
- return merge_direct (infiles, nfiles, outfile);
-
- /* Merge groups of MAX_DIRECT_MERGE input files at a time,
- making a temporary file to hold each group's result. */
-
- ntemps = (nfiles + MAX_DIRECT_MERGE - 1) / MAX_DIRECT_MERGE;
- tempfiles = (char **) xmalloc (ntemps * sizeof (char *));
- for (i = 0; i < ntemps; i++)
- {
- int nf = MAX_DIRECT_MERGE;
- if (i + 1 == ntemps)
- nf = nfiles - i * MAX_DIRECT_MERGE;
- tempfiles[i] = maketempname (++tempcount);
- value |= merge_direct (&infiles[i * MAX_DIRECT_MERGE], nf, tempfiles[i]);
- }
-
- /* All temporary files that existed before are no longer needed
- since their contents have been merged into our new tempfiles.
- So delete them. */
- flush_tempfiles (start_tempcount);
-
- /* Now merge the temporary files we created. */
-
- merge_files (tempfiles, ntemps, outfile);
-
- free (tempfiles);
-
- return value;
-}
-
-/* Assume (and optionally verify) that each input file is sorted;
- merge them and output the result.
- Returns nonzero if any input file fails to be sorted.
-
- This version of merging will not work if the number of
- input files gets too high. Higher level functions
- use it only with a bounded number of input files. */
-
-int
-merge_direct (infiles, nfiles, outfile)
- char **infiles;
- int nfiles;
- char *outfile;
-{
- struct linebuffer *lb1, *lb2;
- struct linebuffer **thisline, **prevline;
- FILE **streams;
- int i;
- int nleft;
- int lossage = 0;
- int *file_lossage;
- struct linebuffer *prev_out = 0;
- FILE *ostream = stdout;
-
- if (outfile)
- {
- ostream = fopen (outfile, "w");
- }
- if (!ostream)
- pfatal_with_name (outfile);
-
- init_index ();
-
- if (nfiles == 0)
- {
- if (outfile)
- fclose (ostream);
- return 0;
- }
-
- /* For each file, make two line buffers.
- Also, for each file, there is an element of `thisline'
- which points at any time to one of the file's two buffers,
- and an element of `prevline' which points to the other buffer.
- `thisline' is supposed to point to the next available line from the file,
- while `prevline' holds the last file line used,
- which is remembered so that we can verify that the file is properly sorted. */
-
- /* lb1 and lb2 contain one buffer each per file. */
- lb1 = (struct linebuffer *) xmalloc (nfiles * sizeof (struct linebuffer));
- lb2 = (struct linebuffer *) xmalloc (nfiles * sizeof (struct linebuffer));
-
- /* thisline[i] points to the linebuffer holding the next available line in file i,
- or is zero if there are no lines left in that file. */
- thisline = (struct linebuffer **)
- xmalloc (nfiles * sizeof (struct linebuffer *));
- /* prevline[i] points to the linebuffer holding the last used line
- from file i. This is just for verifying that file i is properly
- sorted. */
- prevline = (struct linebuffer **)
- xmalloc (nfiles * sizeof (struct linebuffer *));
- /* streams[i] holds the input stream for file i. */
- streams = (FILE **) xmalloc (nfiles * sizeof (FILE *));
- /* file_lossage[i] is nonzero if we already know file i is not
- properly sorted. */
- file_lossage = (int *) xmalloc (nfiles * sizeof (int));
-
- /* Allocate and initialize all that storage. */
-
- for (i = 0; i < nfiles; i++)
- {
- initbuffer (&lb1[i]);
- initbuffer (&lb2[i]);
- thisline[i] = &lb1[i];
- prevline[i] = &lb2[i];
- file_lossage[i] = 0;
- streams[i] = fopen (infiles[i], "r");
- if (!streams[i])
- pfatal_with_name (infiles[i]);
-
- readline (thisline[i], streams[i]);
- }
-
- /* Keep count of number of files not at eof. */
- nleft = nfiles;
-
- while (nleft)
- {
- struct linebuffer *best = 0;
- struct linebuffer *exch;
- int bestfile = -1;
- int i;
-
- /* Look at the next avail line of each file; choose the least one. */
-
- for (i = 0; i < nfiles; i++)
- {
- if (thisline[i] &&
- (!best ||
- 0 < compare_general (best->buffer, thisline[i]->buffer,
- (long) bestfile, (long) i, num_keyfields)))
- {
- best = thisline[i];
- bestfile = i;
- }
- }
-
- /* Output that line, unless it matches the previous one and we
- don't want duplicates. */
-
- if (!(prev_out &&
- !compare_general (prev_out->buffer,
- best->buffer, 0L, 1L, num_keyfields - 1)))
- indexify (best->buffer, ostream);
- prev_out = best;
-
- /* Now make the line the previous of its file, and fetch a new
- line from that file. */
-
- exch = prevline[bestfile];
- prevline[bestfile] = thisline[bestfile];
- thisline[bestfile] = exch;
-
- while (1)
- {
- /* If the file has no more, mark it empty. */
-
- if (feof (streams[bestfile]))
- {
- thisline[bestfile] = 0;
- /* Update the number of files still not empty. */
- nleft--;
- break;
- }
- readline (thisline[bestfile], streams[bestfile]);
- if (thisline[bestfile]->buffer[0] || !feof (streams[bestfile]))
- break;
- }
- }
-
- finish_index (ostream);
-
- /* Free all storage and close all input streams. */
-
- for (i = 0; i < nfiles; i++)
- {
- fclose (streams[i]);
- free (lb1[i].buffer);
- free (lb2[i].buffer);
- }
- free (file_lossage);
- free (lb1);
- free (lb2);
- free (thisline);
- free (prevline);
- free (streams);
-
- if (outfile)
- fclose (ostream);
-
- return lossage;
-}
-
-/* Print error message and exit. */
-
-void
-fatal (s1, s2)
- char *s1, *s2;
-{
- error (s1, s2);
- exit (TI_FATAL_ERROR);
-}
-
-/* Print error message. S1 is printf control string, S2 is arg for it. */
-
-void
-error (s1, s2)
- char *s1, *s2;
-{
- printf ("%s: ", program_name);
- printf (s1, s2);
- printf ("\n");
-}
-
-#if !defined (HAVE_STRERROR)
-static char *
-strerror (n)
- int n;
-{
- static char ebuf[40];
-
- if (n < sys_nerr)
- return sys_errlist[n];
- else
- {
- sprintf (ebuf, "Unknown error %d", n);
- return ebuf;
- }
-}
-#endif
-
-void
-perror_with_name (name)
- char *name;
-{
- char *s;
-
- s = concat ("", strerror (errno), " for %s");
- error (s, name);
-}
-
-void
-pfatal_with_name (name)
- char *name;
-{
- char *s;
-
- s = concat ("", strerror (errno), " for %s");
- fatal (s, name);
-}
-
-/* Return a newly-allocated string whose contents concatenate those of
- S1, S2, S3. */
-
-char *
-concat (s1, s2, s3)
- char *s1, *s2, *s3;
-{
- int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3);
- char *result = (char *) xmalloc (len1 + len2 + len3 + 1);
-
- strcpy (result, s1);
- strcpy (result + len1, s2);
- strcpy (result + len1 + len2, s3);
- *(result + len1 + len2 + len3) = 0;
-
- return result;
-}
-
-/* Just like malloc, but kills the program in case of fatal error. */
-void *
-xmalloc (nbytes)
- int nbytes;
-{
- void *temp = (void *) malloc (nbytes);
-
- if (nbytes && temp == (void *)NULL)
- memory_error ("xmalloc", nbytes);
-
- return (temp);
-}
-
-/* Like realloc (), but barfs if there isn't enough memory. */
-void *
-xrealloc (pointer, nbytes)
- void *pointer;
- int nbytes;
-{
- void *temp;
-
- if (!pointer)
- temp = (void *)xmalloc (nbytes);
- else
- temp = (void *)realloc (pointer, nbytes);
-
- if (nbytes && !temp)
- memory_error ("xrealloc", nbytes);
-
- return (temp);
-}
-
-memory_error (callers_name, bytes_wanted)
- char *callers_name;
- int bytes_wanted;
-{
- char printable_string[80];
-
- sprintf (printable_string,
- "Virtual memory exhausted in %s ()! Needed %d bytes.",
- callers_name, bytes_wanted);
-
- error (printable_string, "");
- abort ();
-}
diff --git a/lib/glob/gm_loop.c b/lib/glob/gm_loop.c
index 840631da..583ba2f4 100644
--- a/lib/glob/gm_loop.c
+++ b/lib/glob/gm_loop.c
@@ -18,8 +18,7 @@
#if EXTENDED_GLOB
int
-EXTGLOB_PATTERN_P (pat)
- const CHAR *pat;
+EXTGLOB_PATTERN_P (const CHAR *pat)
{
switch (pat[0])
{
@@ -42,9 +41,7 @@ EXTGLOB_PATTERN_P (pat)
versions. FLAGS is a subset of strmatch flags; used to do case-insensitive
matching for now. */
int
-MATCH_PATTERN_CHAR (pat, string, flags)
- CHAR *pat, *string;
- int flags;
+MATCH_PATTERN_CHAR (CHAR *pat, CHAR *string, int flags)
{
CHAR c;
@@ -71,9 +68,7 @@ MATCH_PATTERN_CHAR (pat, string, flags)
}
int
-MATCHLEN (pat, max)
- CHAR *pat;
- size_t max;
+MATCHLEN (CHAR *pat, size_t max)
{
CHAR c;
int matlen, bracklen, in_cclass, in_collsym, in_equiv;
diff --git a/lib/glob/ndir.h b/lib/glob/ndir.h
new file mode 100644
index 00000000..31261eb0
--- /dev/null
+++ b/lib/glob/ndir.h
@@ -0,0 +1,50 @@
+/* <dir.h> -- definitions for 4.2BSD-compatible directory access.
+ last edit: 09-Jul-1983 D A Gwyn. */
+
+#if defined (VMS)
+# if !defined (FAB$C_BID)
+# include <fab.h>
+# endif
+# if !defined (NAM$C_BID)
+# include <nam.h>
+# endif
+# if !defined (RMS$_SUC)
+# include <rmsdef.h>
+# endif
+# include "dir.h"
+#endif /* VMS */
+
+/* Size of directory block. */
+#define DIRBLKSIZ 512
+
+/* NOTE: MAXNAMLEN must be one less than a multiple of 4 */
+
+#if defined (VMS)
+# define MAXNAMLEN (DIR$S_NAME + 7) /* 80 plus room for version #. */
+# define MAXFULLSPEC NAM$C_MAXRSS /* Maximum full spec */
+#else
+# define MAXNAMLEN 15 /* Maximum filename length. */
+#endif /* VMS */
+
+/* Data from readdir (). */
+struct direct {
+ long d_ino; /* Inode number of entry. */
+ unsigned short d_reclen; /* Length of this record. */
+ unsigned short d_namlen; /* Length of string in d_name. */
+ char d_name[MAXNAMLEN + 1]; /* Name of file. */
+};
+
+/* Stream data from opendir (). */
+typedef struct {
+ int dd_fd; /* File descriptor. */
+ int dd_loc; /* Offset in block. */
+ int dd_size; /* Amount of valid data. */
+ char dd_buf[DIRBLKSIZ]; /* Directory block. */
+} DIR;
+
+extern DIR *opendir ();
+extern struct direct *readdir ();
+extern long telldir ();
+extern void seekdir (), closedir ();
+
+#define rewinddir(dirp) seekdir (dirp, 0L)
diff --git a/lib/intl/plural.c b/lib/intl/plural.c
index 8b907364..4a8ea39a 100644
--- a/lib/intl/plural.c
+++ b/lib/intl/plural.c
@@ -1,42 +1,31 @@
-/* A Bison parser, made by GNU Bison 3.8.2. */
+/* A Bison parser, made by GNU Bison 2.0. */
-/* Bison implementation for Yacc-like parsers in C
+/* Skeleton parser for Yacc-like parsing with Bison,
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2022 Free Software Foundation, Inc.
- Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
- Inc.
+ This file is part of GNU Bash.
- This program is free software: you can redistribute it and/or modify
+ Bash 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 3 of the License, or
(at your option) any later version.
- This program is distributed in the hope that it will be useful,
+ Bash 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, see <https://www.gnu.org/licenses/>. */
-
-/* As a special exception, you may create a larger work that contains
- part or all of the Bison parser skeleton and distribute that work
- under terms of your choice, so long as that work isn't itself a
- parser generator using the skeleton or a modified version thereof
- as a parser skeleton. Alternatively, if you modify or redistribute
- the parser skeleton itself, you may (at your option) remove this
- special exception, which will cause the skeleton and the resulting
- Bison output files to be licensed under the GNU General Public
- License without this special exception.
-
- This special exception was added by the Free Software Foundation in
- version 2.2 of Bison. */
+ along with Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
-/* C LALR(1) parser skeleton written by Richard Stallman, by
- simplifying the original so-called "semantic" parser. */
+/* As a special exception, when this file is copied by Bison into a
+ Bison output file, you may use that output file without restriction.
+ This special exception was added by the Free Software Foundation
+ in version 1.24 of Bison. */
-/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
- especially those whose name start with YY_ or yy_. They are
- private implementation details that can be changed or removed. */
+/* Written by Richard Stallman by simplifying the original so called
+ ``semantic'' parser. */
/* All symbols defined below should begin with yy or YY, to avoid
infringing on user name space. This should be done even for local
@@ -45,11 +34,8 @@
define necessary library symbols; they are noted "INFRINGES ON
USER NAME SPACE" below. */
-/* Identify Bison output, and Bison version. */
-#define YYBISON 30802
-
-/* Bison version string. */
-#define YYBISON_VERSION "3.8.2"
+/* Identify Bison output. */
+#define YYBISON 1
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
@@ -57,26 +43,47 @@
/* Pure parsers. */
#define YYPURE 1
-/* Push parsers. */
-#define YYPUSH 0
+/* Using locations. */
+#define YYLSP_NEEDED 0
+
+/* Substitute the variable and function names. */
+#define yyparse __gettextparse
+#define yylex __gettextlex
+#define yyerror __gettexterror
+#define yylval __gettextlval
+#define yychar __gettextchar
+#define yydebug __gettextdebug
+#define yynerrs __gettextnerrs
+
+
+/* Tokens. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
+ know about them. */
+ enum yytokentype {
+ EQUOP2 = 258,
+ CMPOP2 = 259,
+ ADDOP2 = 260,
+ MULOP2 = 261,
+ NUMBER = 262
+ };
+#endif
+#define EQUOP2 258
+#define CMPOP2 259
+#define ADDOP2 260
+#define MULOP2 261
+#define NUMBER 262
-/* Pull parsers. */
-#define YYPULL 1
-/* Substitute the variable and function names. */
-#define yyparse __gettextparse
-#define yylex __gettextlex
-#define yyerror __gettexterror
-#define yydebug __gettextdebug
-#define yynerrs __gettextnerrs
-/* First part of user prologue. */
-#line 1 "/fs2/chet/bash/bash-git/bash/lib/intl/plural.y"
+/* Copy the first part of user declarations. */
+#line 1 "/usr/src/local/bash/bash-20080814/lib/intl/plural.y"
/* plural.y - Expression parsing for plural form selection. */
-/* Copyright (C) 2000, 2001, 2005-2009, 2022 Free Software Foundation, Inc.
+/* Copyright (C) 2000, 2001, 2005-2009 Free Software Foundation, Inc.
Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
This file is part of GNU Bash.
@@ -120,59 +127,38 @@
#define YYLEX_PARAM &((struct parse_args *) arg)->cp
#define YYPARSE_PARAM arg
-#line 124 "/fs2/chet/bash/bash-git/bash/lib/intl/plural.c"
-# ifndef YY_CAST
-# ifdef __cplusplus
-# define YY_CAST(Type, Val) static_cast<Type> (Val)
-# define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
-# else
-# define YY_CAST(Type, Val) ((Type) (Val))
-# define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
-# endif
-# endif
-# ifndef YY_NULLPTR
-# if defined __cplusplus
-# if 201103L <= __cplusplus
-# define YY_NULLPTR nullptr
-# else
-# define YY_NULLPTR 0
-# endif
-# else
-# define YY_NULLPTR ((void*)0)
-# endif
-# endif
+/* Enabling traces. */
+#ifndef YYDEBUG
+# define YYDEBUG 0
+#endif
+
+/* Enabling verbose error messages. */
+#ifdef YYERROR_VERBOSE
+# undef YYERROR_VERBOSE
+# define YYERROR_VERBOSE 1
+#else
+# define YYERROR_VERBOSE 0
+#endif
+
+#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
+#line 51 "/usr/src/local/bash/bash-20080814/lib/intl/plural.y"
+typedef union YYSTYPE {
+ unsigned long int num;
+ enum operator op;
+ struct expression *exp;
+} YYSTYPE;
+/* Line 190 of yacc.c. */
+#line 152 "/usr/src/local/bash/bash-20080814/lib/intl/plural.c"
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+# define YYSTYPE_IS_TRIVIAL 1
+#endif
-#include "plural.h"
-/* Symbol kind. */
-enum yysymbol_kind_t
-{
- YYSYMBOL_YYEMPTY = -2,
- YYSYMBOL_YYEOF = 0, /* "end of file" */
- YYSYMBOL_YYerror = 1, /* error */
- YYSYMBOL_YYUNDEF = 2, /* "invalid token" */
- YYSYMBOL_3_ = 3, /* '?' */
- YYSYMBOL_4_ = 4, /* '|' */
- YYSYMBOL_5_ = 5, /* '&' */
- YYSYMBOL_6_ = 6, /* '!' */
- YYSYMBOL_EQUOP2 = 7, /* EQUOP2 */
- YYSYMBOL_CMPOP2 = 8, /* CMPOP2 */
- YYSYMBOL_ADDOP2 = 9, /* ADDOP2 */
- YYSYMBOL_MULOP2 = 10, /* MULOP2 */
- YYSYMBOL_NUMBER = 11, /* NUMBER */
- YYSYMBOL_12_ = 12, /* ':' */
- YYSYMBOL_13_n_ = 13, /* 'n' */
- YYSYMBOL_14_ = 14, /* '(' */
- YYSYMBOL_15_ = 15, /* ')' */
- YYSYMBOL_YYACCEPT = 16, /* $accept */
- YYSYMBOL_start = 17, /* start */
- YYSYMBOL_exp = 18 /* exp */
-};
-typedef enum yysymbol_kind_t yysymbol_kind_t;
-/* Second part of user prologue. */
-#line 57 "/fs2/chet/bash/bash-git/bash/lib/intl/plural.y"
+/* Copy the second part of user declarations. */
+#line 57 "/usr/src/local/bash/bash-20080814/lib/intl/plural.y"
/* Prototypes for local functions. */
static struct expression *new_exp (int nargs, enum operator op,
@@ -271,201 +257,18 @@ new_exp_3 (op, bexp, tbranch, fbranch)
}
-#line 275 "/fs2/chet/bash/bash-git/bash/lib/intl/plural.c"
-
-
-#ifdef short
-# undef short
-#endif
-
-/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
- <limits.h> and (if available) <stdint.h> are included
- so that the code can choose integer types of a good width. */
-
-#ifndef __PTRDIFF_MAX__
-# include <limits.h> /* INFRINGES ON USER NAME SPACE */
-# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
-# include <stdint.h> /* INFRINGES ON USER NAME SPACE */
-# define YY_STDINT_H
-# endif
-#endif
-
-/* Narrow types that promote to a signed type and that can represent a
- signed or unsigned integer of at least N bits. In tables they can
- save space and decrease cache pressure. Promoting to a signed type
- helps avoid bugs in integer arithmetic. */
-
-#ifdef __INT_LEAST8_MAX__
-typedef __INT_LEAST8_TYPE__ yytype_int8;
-#elif defined YY_STDINT_H
-typedef int_least8_t yytype_int8;
-#else
-typedef signed char yytype_int8;
-#endif
-
-#ifdef __INT_LEAST16_MAX__
-typedef __INT_LEAST16_TYPE__ yytype_int16;
-#elif defined YY_STDINT_H
-typedef int_least16_t yytype_int16;
-#else
-typedef short yytype_int16;
-#endif
-
-/* Work around bug in HP-UX 11.23, which defines these macros
- incorrectly for preprocessor constants. This workaround can likely
- be removed in 2023, as HPE has promised support for HP-UX 11.23
- (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of
- <https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>. */
-#ifdef __hpux
-# undef UINT_LEAST8_MAX
-# undef UINT_LEAST16_MAX
-# define UINT_LEAST8_MAX 255
-# define UINT_LEAST16_MAX 65535
-#endif
-
-#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
-typedef __UINT_LEAST8_TYPE__ yytype_uint8;
-#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
- && UINT_LEAST8_MAX <= INT_MAX)
-typedef uint_least8_t yytype_uint8;
-#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
-typedef unsigned char yytype_uint8;
-#else
-typedef short yytype_uint8;
-#endif
-
-#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
-typedef __UINT_LEAST16_TYPE__ yytype_uint16;
-#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
- && UINT_LEAST16_MAX <= INT_MAX)
-typedef uint_least16_t yytype_uint16;
-#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
-typedef unsigned short yytype_uint16;
-#else
-typedef int yytype_uint16;
-#endif
-#ifndef YYPTRDIFF_T
-# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
-# define YYPTRDIFF_T __PTRDIFF_TYPE__
-# define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
-# elif defined PTRDIFF_MAX
-# ifndef ptrdiff_t
-# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
-# endif
-# define YYPTRDIFF_T ptrdiff_t
-# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
-# else
-# define YYPTRDIFF_T long
-# define YYPTRDIFF_MAXIMUM LONG_MAX
-# endif
-#endif
-
-#ifndef YYSIZE_T
-# ifdef __SIZE_TYPE__
-# define YYSIZE_T __SIZE_TYPE__
-# elif defined size_t
-# define YYSIZE_T size_t
-# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
-# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
-# define YYSIZE_T size_t
-# else
-# define YYSIZE_T unsigned
-# endif
-#endif
-
-#define YYSIZE_MAXIMUM \
- YY_CAST (YYPTRDIFF_T, \
- (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
- ? YYPTRDIFF_MAXIMUM \
- : YY_CAST (YYSIZE_T, -1)))
-
-#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
+/* Line 213 of yacc.c. */
+#line 262 "/usr/src/local/bash/bash-20080814/lib/intl/plural.c"
+#if ! defined (yyoverflow) || YYERROR_VERBOSE
-/* Stored state numbers (used for stacks). */
-typedef yytype_int8 yy_state_t;
-
-/* State numbers in computations. */
-typedef int yy_state_fast_t;
-
-#ifndef YY_
-# if defined YYENABLE_NLS && YYENABLE_NLS
-# if ENABLE_NLS
-# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
-# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
-# endif
+# ifndef YYFREE
+# define YYFREE free
# endif
-# ifndef YY_
-# define YY_(Msgid) Msgid
+# ifndef YYMALLOC
+# define YYMALLOC malloc
# endif
-#endif
-
-
-#ifndef YY_ATTRIBUTE_PURE
-# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
-# define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
-# else
-# define YY_ATTRIBUTE_PURE
-# endif
-#endif
-
-#ifndef YY_ATTRIBUTE_UNUSED
-# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
-# define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
-# else
-# define YY_ATTRIBUTE_UNUSED
-# endif
-#endif
-
-/* Suppress unused-variable warnings by "using" E. */
-#if ! defined lint || defined __GNUC__
-# define YY_USE(E) ((void) (E))
-#else
-# define YY_USE(E) /* empty */
-#endif
-
-/* Suppress an incorrect diagnostic about yylval being uninitialized. */
-#if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
-# if __GNUC__ * 100 + __GNUC_MINOR__ < 407
-# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
- _Pragma ("GCC diagnostic push") \
- _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")
-# else
-# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
- _Pragma ("GCC diagnostic push") \
- _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
- _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
-# endif
-# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
- _Pragma ("GCC diagnostic pop")
-#else
-# define YY_INITIAL_VALUE(Value) Value
-#endif
-#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
-# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
-# define YY_IGNORE_MAYBE_UNINITIALIZED_END
-#endif
-#ifndef YY_INITIAL_VALUE
-# define YY_INITIAL_VALUE(Value) /* Nothing. */
-#endif
-
-#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
-# define YY_IGNORE_USELESS_CAST_BEGIN \
- _Pragma ("GCC diagnostic push") \
- _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
-# define YY_IGNORE_USELESS_CAST_END \
- _Pragma ("GCC diagnostic pop")
-#endif
-#ifndef YY_IGNORE_USELESS_CAST_BEGIN
-# define YY_IGNORE_USELESS_CAST_BEGIN
-# define YY_IGNORE_USELESS_CAST_END
-#endif
-
-
-#define YY_ASSERT(E) ((void) (0 && (E)))
-
-#if !defined yyoverflow
/* The parser invokes alloca or malloc; define the necessary symbols. */
@@ -473,158 +276,116 @@ typedef int yy_state_fast_t;
# if YYSTACK_USE_ALLOCA
# ifdef __GNUC__
# define YYSTACK_ALLOC __builtin_alloca
-# elif defined __BUILTIN_VA_ARG_INCR
-# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
-# elif defined _AIX
-# define YYSTACK_ALLOC __alloca
-# elif defined _MSC_VER
-# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
-# define alloca _alloca
# else
# define YYSTACK_ALLOC alloca
-# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
-# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
- /* Use EXIT_SUCCESS as a witness for stdlib.h. */
-# ifndef EXIT_SUCCESS
-# define EXIT_SUCCESS 0
-# endif
-# endif
# endif
# endif
# endif
# ifdef YYSTACK_ALLOC
- /* Pacify GCC's 'empty if-body' warning. */
+ /* Pacify GCC's `empty if-body' warning. */
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
-# ifndef YYSTACK_ALLOC_MAXIMUM
- /* The OS might guarantee only one guard page at the bottom of the stack,
- and a page size can be as small as 4096 bytes. So we cannot safely
- invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
- to allow for a few compiler-allocated temporary stack slots. */
-# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
-# endif
# else
-# define YYSTACK_ALLOC YYMALLOC
-# define YYSTACK_FREE YYFREE
-# ifndef YYSTACK_ALLOC_MAXIMUM
-# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
-# endif
-# if (defined __cplusplus && ! defined EXIT_SUCCESS \
- && ! ((defined YYMALLOC || defined malloc) \
- && (defined YYFREE || defined free)))
+# if defined (__STDC__) || defined (__cplusplus)
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
-# ifndef EXIT_SUCCESS
-# define EXIT_SUCCESS 0
-# endif
-# endif
-# ifndef YYMALLOC
-# define YYMALLOC malloc
-# if ! defined malloc && ! defined EXIT_SUCCESS
-void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
-# endif
-# endif
-# ifndef YYFREE
-# define YYFREE free
-# if ! defined free && ! defined EXIT_SUCCESS
-void free (void *); /* INFRINGES ON USER NAME SPACE */
-# endif
+# define YYSIZE_T size_t
# endif
+# define YYSTACK_ALLOC YYMALLOC
+# define YYSTACK_FREE YYFREE
# endif
-#endif /* !defined yyoverflow */
+#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
+
-#if (! defined yyoverflow \
- && (! defined __cplusplus \
- || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
+#if (! defined (yyoverflow) \
+ && (! defined (__cplusplus) \
+ || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
/* A type that is properly aligned for any stack member. */
union yyalloc
{
- yy_state_t yyss_alloc;
- YYSTYPE yyvs_alloc;
-};
+ short int yyss;
+ YYSTYPE yyvs;
+ };
/* The size of the maximum gap between one aligned stack and the next. */
-# define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
+# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
/* The size of an array large to enough to hold all stacks, each with
N elements. */
# define YYSTACK_BYTES(N) \
- ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
+ ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
+ YYSTACK_GAP_MAXIMUM)
-# define YYCOPY_NEEDED 1
+/* Copy COUNT objects from FROM to TO. The source and destination do
+ not overlap. */
+# ifndef YYCOPY
+# if defined (__GNUC__) && 1 < __GNUC__
+# define YYCOPY(To, From, Count) \
+ __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
+# else
+# define YYCOPY(To, From, Count) \
+ do \
+ { \
+ register YYSIZE_T yyi; \
+ for (yyi = 0; yyi < (Count); yyi++) \
+ (To)[yyi] = (From)[yyi]; \
+ } \
+ while (0)
+# endif
+# endif
/* Relocate STACK from its old location to the new one. The
local variables YYSIZE and YYSTACKSIZE give the old and new number of
elements in the stack, and YYPTR gives the new location of the
stack. Advance YYPTR to a properly aligned location for the next
stack. */
-# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
- do \
- { \
- YYPTRDIFF_T yynewbytes; \
- YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
- Stack = &yyptr->Stack_alloc; \
- yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
- yyptr += yynewbytes / YYSIZEOF (*yyptr); \
- } \
+# define YYSTACK_RELOCATE(Stack) \
+ do \
+ { \
+ YYSIZE_T yynewbytes; \
+ YYCOPY (&yyptr->Stack, Stack, yysize); \
+ Stack = &yyptr->Stack; \
+ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
+ yyptr += yynewbytes / sizeof (*yyptr); \
+ } \
while (0)
#endif
-#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
-/* Copy COUNT objects from SRC to DST. The source and destination do
- not overlap. */
-# ifndef YYCOPY
-# if defined __GNUC__ && 1 < __GNUC__
-# define YYCOPY(Dst, Src, Count) \
- __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
-# else
-# define YYCOPY(Dst, Src, Count) \
- do \
- { \
- YYPTRDIFF_T yyi; \
- for (yyi = 0; yyi < (Count); yyi++) \
- (Dst)[yyi] = (Src)[yyi]; \
- } \
- while (0)
-# endif
-# endif
-#endif /* !YYCOPY_NEEDED */
+#if defined (__STDC__) || defined (__cplusplus)
+ typedef signed char yysigned_char;
+#else
+ typedef short int yysigned_char;
+#endif
-/* YYFINAL -- State number of the termination state. */
+/* YYFINAL -- State number of the termination state. */
#define YYFINAL 9
/* YYLAST -- Last index in YYTABLE. */
-#define YYLAST 56
+#define YYLAST 54
-/* YYNTOKENS -- Number of terminals. */
+/* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS 16
-/* YYNNTS -- Number of nonterminals. */
+/* YYNNTS -- Number of nonterminals. */
#define YYNNTS 3
-/* YYNRULES -- Number of rules. */
+/* YYNRULES -- Number of rules. */
#define YYNRULES 13
-/* YYNSTATES -- Number of states. */
+/* YYNRULES -- Number of states. */
#define YYNSTATES 27
-/* YYMAXUTOK -- Last valid token kind. */
+/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
+#define YYUNDEFTOK 2
#define YYMAXUTOK 262
+#define YYTRANSLATE(YYX) \
+ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
-/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
- as returned by yylex, with out-of-bounds checking. */
-#define YYTRANSLATE(YYX) \
- (0 <= (YYX) && (YYX) <= YYMAXUTOK \
- ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \
- : YYSYMBOL_YYUNDEF)
-
-/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
- as returned by yylex. */
-static const yytype_int8 yytranslate[] =
+/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
+static const unsigned char yytranslate[] =
{
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 6, 2, 2, 2, 2, 5, 2,
+ 2, 2, 2, 10, 2, 2, 2, 2, 5, 2,
14, 15, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 12, 2,
2, 2, 2, 3, 2, 2, 2, 2, 2, 2,
@@ -646,166 +407,244 @@ static const yytype_int8 yytranslate[] =
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 1, 2, 7, 8,
- 9, 10, 11
+ 2, 2, 2, 2, 2, 2, 1, 2, 6, 7,
+ 8, 9, 11
};
#if YYDEBUG
-/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
-static const yytype_uint8 yyrline[] =
+/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
+ YYRHS. */
+static const unsigned char yyprhs[] =
+{
+ 0, 0, 3, 5, 11, 15, 19, 23, 27, 31,
+ 35, 38, 40, 42
+};
+
+/* YYRHS -- A `-1'-separated list of the rules' RHS. */
+static const yysigned_char yyrhs[] =
+{
+ 17, 0, -1, 18, -1, 18, 3, 18, 12, 18,
+ -1, 18, 4, 18, -1, 18, 5, 18, -1, 18,
+ 6, 18, -1, 18, 7, 18, -1, 18, 8, 18,
+ -1, 18, 9, 18, -1, 10, 18, -1, 13, -1,
+ 11, -1, 14, 18, 15, -1
+};
+
+/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
+static const unsigned char yyrline[] =
{
0, 176, 176, 184, 188, 192, 196, 200, 204, 208,
212, 216, 220, 225
};
#endif
-/** Accessing symbol of state STATE. */
-#define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
-
-#if YYDEBUG || 0
-/* The user-facing name of the symbol whose (internal) number is
- YYSYMBOL. No bounds checking. */
-static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
-
-/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
- First, the terminals, then, starting at YYNTOKENS, nonterminals. */
+#if YYDEBUG || YYERROR_VERBOSE
+/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
+ First, the terminals, then, starting at YYNTOKENS, nonterminals. */
static const char *const yytname[] =
{
- "\"end of file\"", "error", "\"invalid token\"", "'?'", "'|'", "'&'",
- "'!'", "EQUOP2", "CMPOP2", "ADDOP2", "MULOP2", "NUMBER", "':'", "'n'",
- "'('", "')'", "$accept", "start", "exp", YY_NULLPTR
+ "$end", "error", "$undefined", "'?'", "'|'", "'&'", "EQUOP2", "CMPOP2",
+ "ADDOP2", "MULOP2", "'!'", "NUMBER", "':'", "'n'", "'('", "')'",
+ "$accept", "start", "exp", 0
};
-
-static const char *
-yysymbol_name (yysymbol_kind_t yysymbol)
-{
- return yytname[yysymbol];
-}
#endif
-#define YYPACT_NINF (-4)
-
-#define yypact_value_is_default(Yyn) \
- ((Yyn) == YYPACT_NINF)
-
-#define YYTABLE_NINF (-1)
+# ifdef YYPRINT
+/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
+ token YYLEX-NUM. */
+static const unsigned short int yytoknum[] =
+{
+ 0, 256, 257, 63, 124, 38, 258, 259, 260, 261,
+ 33, 262, 58, 110, 40, 41
+};
+# endif
-#define yytable_value_is_error(Yyn) \
- 0
+/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
+static const unsigned char yyr1[] =
+{
+ 0, 16, 17, 18, 18, 18, 18, 18, 18, 18,
+ 18, 18, 18, 18
+};
-/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
- STATE-NUM. */
-static const yytype_int8 yypact[] =
+/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
+static const unsigned char yyr2[] =
{
- 27, 27, -4, -4, 27, 1, 39, -4, 13, -4,
- 27, 27, 27, 27, 27, 27, 27, -4, 22, -3,
- 43, 46, 26, -2, -4, 27, 39
+ 0, 2, 1, 5, 3, 3, 3, 3, 3, 3,
+ 2, 1, 1, 3
};
-/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
- Performed when YYTABLE does not specify something else to do. Zero
+/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
+ STATE-NUM when YYTABLE doesn't specify something else to do. Zero
means the default is an error. */
-static const yytype_int8 yydefact[] =
+static const unsigned char yydefact[] =
{
0, 0, 12, 11, 0, 0, 2, 10, 0, 1,
0, 0, 0, 0, 0, 0, 0, 13, 0, 4,
5, 6, 7, 8, 9, 0, 3
};
-/* YYPGOTO[NTERM-NUM]. */
-static const yytype_int8 yypgoto[] =
+/* YYDEFGOTO[NTERM-NUM]. */
+static const yysigned_char yydefgoto[] =
{
- -4, -4, -1
+ -1, 5, 6
};
-/* YYDEFGOTO[NTERM-NUM]. */
-static const yytype_int8 yydefgoto[] =
+/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
+ STATE-NUM. */
+#define YYPACT_NINF -10
+static const yysigned_char yypact[] =
{
- 0, 5, 6
+ -9, -9, -10, -10, -9, 8, 36, -10, 13, -10,
+ -9, -9, -9, -9, -9, -9, -9, -10, 26, 41,
+ 45, 18, -2, 14, -10, -9, 36
};
-/* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
- positive, shift that token. If negative, reduce the rule whose
- number is the opposite. If YYTABLE_NINF, syntax error. */
-static const yytype_int8 yytable[] =
+/* YYPGOTO[NTERM-NUM]. */
+static const yysigned_char yypgoto[] =
{
- 7, 9, 12, 8, 13, 14, 15, 16, 16, 18,
- 19, 20, 21, 22, 23, 24, 10, 11, 12, 0,
- 13, 14, 15, 16, 26, 10, 11, 12, 17, 13,
- 14, 15, 16, 1, 25, 15, 16, 0, 2, 0,
- 3, 4, 10, 11, 12, 0, 13, 14, 15, 16,
- 13, 14, 15, 16, 14, 15, 16
+ -10, -10, -1
};
-static const yytype_int8 yycheck[] =
+/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
+ positive, shift that token. If negative, reduce the rule which
+ number is the opposite. If zero, do what YYDEFACT says.
+ If YYTABLE_NINF, syntax error. */
+#define YYTABLE_NINF -1
+static const unsigned char yytable[] =
{
- 1, 0, 5, 4, 7, 8, 9, 10, 10, 10,
- 11, 12, 13, 14, 15, 16, 3, 4, 5, -1,
- 7, 8, 9, 10, 25, 3, 4, 5, 15, 7,
- 8, 9, 10, 6, 12, 9, 10, -1, 11, -1,
- 13, 14, 3, 4, 5, -1, 7, 8, 9, 10,
- 7, 8, 9, 10, 8, 9, 10
+ 7, 1, 2, 8, 3, 4, 15, 16, 9, 18,
+ 19, 20, 21, 22, 23, 24, 10, 11, 12, 13,
+ 14, 15, 16, 16, 26, 14, 15, 16, 17, 10,
+ 11, 12, 13, 14, 15, 16, 0, 0, 25, 10,
+ 11, 12, 13, 14, 15, 16, 12, 13, 14, 15,
+ 16, 13, 14, 15, 16
};
-/* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
- state STATE-NUM. */
-static const yytype_int8 yystos[] =
+static const yysigned_char yycheck[] =
{
- 0, 6, 11, 13, 14, 17, 18, 18, 18, 0,
- 3, 4, 5, 7, 8, 9, 10, 15, 18, 18,
- 18, 18, 18, 18, 18, 12, 18
+ 1, 10, 11, 4, 13, 14, 8, 9, 0, 10,
+ 11, 12, 13, 14, 15, 16, 3, 4, 5, 6,
+ 7, 8, 9, 9, 25, 7, 8, 9, 15, 3,
+ 4, 5, 6, 7, 8, 9, -1, -1, 12, 3,
+ 4, 5, 6, 7, 8, 9, 5, 6, 7, 8,
+ 9, 6, 7, 8, 9
};
-/* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */
-static const yytype_int8 yyr1[] =
+/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
+ symbol of state STATE-NUM. */
+static const unsigned char yystos[] =
{
- 0, 16, 17, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18
+ 0, 10, 11, 13, 14, 17, 18, 18, 18, 0,
+ 3, 4, 5, 6, 7, 8, 9, 15, 18, 18,
+ 18, 18, 18, 18, 18, 12, 18
};
-/* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */
-static const yytype_int8 yyr2[] =
-{
- 0, 2, 1, 5, 3, 3, 3, 3, 3, 3,
- 2, 1, 1, 3
-};
+#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
+# define YYSIZE_T __SIZE_TYPE__
+#endif
+#if ! defined (YYSIZE_T) && defined (size_t)
+# define YYSIZE_T size_t
+#endif
+#if ! defined (YYSIZE_T)
+# if defined (__STDC__) || defined (__cplusplus)
+# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
+# define YYSIZE_T size_t
+# endif
+#endif
+#if ! defined (YYSIZE_T)
+# define YYSIZE_T unsigned int
+#endif
+#define yyerrok (yyerrstatus = 0)
+#define yyclearin (yychar = YYEMPTY)
+#define YYEMPTY (-2)
+#define YYEOF 0
-enum { YYENOMEM = -2 };
+#define YYACCEPT goto yyacceptlab
+#define YYABORT goto yyabortlab
+#define YYERROR goto yyerrorlab
-#define yyerrok (yyerrstatus = 0)
-#define yyclearin (yychar = YYEMPTY)
-#define YYACCEPT goto yyacceptlab
-#define YYABORT goto yyabortlab
-#define YYERROR goto yyerrorlab
-#define YYNOMEM goto yyexhaustedlab
+/* Like YYERROR except do call yyerror. This remains here temporarily
+ to ease the transition to the new meaning of YYERROR, for GCC.
+ Once GCC version 2 has supplanted version 1, this can go. */
+#define YYFAIL goto yyerrlab
#define YYRECOVERING() (!!yyerrstatus)
-#define YYBACKUP(Token, Value) \
- do \
- if (yychar == YYEMPTY) \
- { \
- yychar = (Token); \
- yylval = (Value); \
- YYPOPSTACK (yylen); \
- yystate = *yyssp; \
- goto yybackup; \
- } \
- else \
- { \
- yyerror (YY_("syntax error: cannot back up")); \
- YYERROR; \
- } \
- while (0)
-
-/* Backward compatibility with an undocumented macro.
- Use YYerror or YYUNDEF. */
-#define YYERRCODE YYUNDEF
+#define YYBACKUP(Token, Value) \
+do \
+ if (yychar == YYEMPTY && yylen == 1) \
+ { \
+ yychar = (Token); \
+ yylval = (Value); \
+ yytoken = YYTRANSLATE (yychar); \
+ YYPOPSTACK; \
+ goto yybackup; \
+ } \
+ else \
+ { \
+ yyerror ("syntax error: cannot back up");\
+ YYERROR; \
+ } \
+while (0)
+
+
+#define YYTERROR 1
+#define YYERRCODE 256
+
+
+/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
+ If N is 0, then set CURRENT to the empty location which ends
+ the previous symbol: RHS[0] (always defined). */
+
+#define YYRHSLOC(Rhs, K) ((Rhs)[K])
+#ifndef YYLLOC_DEFAULT
+# define YYLLOC_DEFAULT(Current, Rhs, N) \
+ do \
+ if (N) \
+ { \
+ (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
+ (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
+ (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
+ (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
+ } \
+ else \
+ { \
+ (Current).first_line = (Current).last_line = \
+ YYRHSLOC (Rhs, 0).last_line; \
+ (Current).first_column = (Current).last_column = \
+ YYRHSLOC (Rhs, 0).last_column; \
+ } \
+ while (0)
+#endif
+
+
+/* YY_LOCATION_PRINT -- Print the location on the stream.
+ This macro was not mandated originally: define only if we know
+ we won't break user code: when these are the locations we know. */
+
+#ifndef YY_LOCATION_PRINT
+# if YYLTYPE_IS_TRIVIAL
+# define YY_LOCATION_PRINT(File, Loc) \
+ fprintf (File, "%d.%d-%d.%d", \
+ (Loc).first_line, (Loc).first_column, \
+ (Loc).last_line, (Loc).last_column)
+# else
+# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
+# endif
+#endif
+/* YYLEX -- calling `yylex' with the right arguments. */
+
+#ifdef YYLEX_PARAM
+# define YYLEX yylex (&yylval, YYLEX_PARAM)
+#else
+# define YYLEX yylex (&yylval)
+#endif
+
/* Enable debugging if requested. */
#if YYDEBUG
@@ -814,81 +653,48 @@ enum { YYENOMEM = -2 };
# define YYFPRINTF fprintf
# endif
-# define YYDPRINTF(Args) \
-do { \
- if (yydebug) \
- YYFPRINTF Args; \
+# define YYDPRINTF(Args) \
+do { \
+ if (yydebug) \
+ YYFPRINTF Args; \
} while (0)
-
-
-
-# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
-do { \
- if (yydebug) \
- { \
- YYFPRINTF (stderr, "%s ", Title); \
- yy_symbol_print (stderr, \
- Kind, Value); \
- YYFPRINTF (stderr, "\n"); \
- } \
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
+do { \
+ if (yydebug) \
+ { \
+ YYFPRINTF (stderr, "%s ", Title); \
+ yysymprint (stderr, \
+ Type, Value); \
+ YYFPRINTF (stderr, "\n"); \
+ } \
} while (0)
-
-/*-----------------------------------.
-| Print this symbol's value on YYO. |
-`-----------------------------------*/
-
-static void
-yy_symbol_value_print (FILE *yyo,
- yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
-{
- FILE *yyoutput = yyo;
- YY_USE (yyoutput);
- if (!yyvaluep)
- return;
- YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
- YY_USE (yykind);
- YY_IGNORE_MAYBE_UNINITIALIZED_END
-}
-
-
-/*---------------------------.
-| Print this symbol on YYO. |
-`---------------------------*/
-
-static void
-yy_symbol_print (FILE *yyo,
- yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
-{
- YYFPRINTF (yyo, "%s %s (",
- yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
-
- yy_symbol_value_print (yyo, yykind, yyvaluep);
- YYFPRINTF (yyo, ")");
-}
-
/*------------------------------------------------------------------.
| yy_stack_print -- Print the state stack from its BOTTOM up to its |
| TOP (included). |
`------------------------------------------------------------------*/
+#if defined (__STDC__) || defined (__cplusplus)
static void
-yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
+yy_stack_print (short int *bottom, short int *top)
+#else
+static void
+yy_stack_print (bottom, top)
+ short int *bottom;
+ short int *top;
+#endif
{
YYFPRINTF (stderr, "Stack now");
- for (; yybottom <= yytop; yybottom++)
- {
- int yybot = *yybottom;
- YYFPRINTF (stderr, " %d", yybot);
- }
+ for (/* Nothing. */; bottom <= top; ++bottom)
+ YYFPRINTF (stderr, " %d", *bottom);
YYFPRINTF (stderr, "\n");
}
-# define YY_STACK_PRINT(Bottom, Top) \
-do { \
- if (yydebug) \
- yy_stack_print ((Bottom), (Top)); \
+# define YY_STACK_PRINT(Bottom, Top) \
+do { \
+ if (yydebug) \
+ yy_stack_print ((Bottom), (Top)); \
} while (0)
@@ -896,45 +702,44 @@ do { \
| Report that the YYRULE is going to be reduced. |
`------------------------------------------------*/
+#if defined (__STDC__) || defined (__cplusplus)
static void
-yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,
- int yyrule)
+yy_reduce_print (int yyrule)
+#else
+static void
+yy_reduce_print (yyrule)
+ int yyrule;
+#endif
{
- int yylno = yyrline[yyrule];
- int yynrhs = yyr2[yyrule];
int yyi;
- YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
+ unsigned int yylno = yyrline[yyrule];
+ YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
yyrule - 1, yylno);
- /* The symbols being reduced. */
- for (yyi = 0; yyi < yynrhs; yyi++)
- {
- YYFPRINTF (stderr, " $%d = ", yyi + 1);
- yy_symbol_print (stderr,
- YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
- &yyvsp[(yyi + 1) - (yynrhs)]);
- YYFPRINTF (stderr, "\n");
- }
+ /* Print the symbols being reduced, and their result. */
+ for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
+ YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
+ YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
}
-# define YY_REDUCE_PRINT(Rule) \
-do { \
- if (yydebug) \
- yy_reduce_print (yyssp, yyvsp, Rule); \
+# define YY_REDUCE_PRINT(Rule) \
+do { \
+ if (yydebug) \
+ yy_reduce_print (Rule); \
} while (0)
/* Nonzero means print parse trace. It is left uninitialized so that
multiple parsers can coexist. */
int yydebug;
#else /* !YYDEBUG */
-# define YYDPRINTF(Args) ((void) 0)
-# define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
+# define YYDPRINTF(Args)
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
# define YY_STACK_PRINT(Bottom, Top)
# define YY_REDUCE_PRINT(Rule)
#endif /* !YYDEBUG */
/* YYINITDEPTH -- initial size of the parser's stacks. */
-#ifndef YYINITDEPTH
+#ifndef YYINITDEPTH
# define YYINITDEPTH 200
#endif
@@ -942,35 +747,154 @@ int yydebug;
if the built-in stack extension method is used).
Do not make this value too large; the results are undefined if
- YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
+ SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
evaluated with infinite-precision integer arithmetic. */
#ifndef YYMAXDEPTH
# define YYMAXDEPTH 10000
#endif
+
+
+#if YYERROR_VERBOSE
+
+# ifndef yystrlen
+# if defined (__GLIBC__) && defined (_STRING_H)
+# define yystrlen strlen
+# else
+/* Return the length of YYSTR. */
+static YYSIZE_T
+# if defined (__STDC__) || defined (__cplusplus)
+yystrlen (const char *yystr)
+# else
+yystrlen (yystr)
+ const char *yystr;
+# endif
+{
+ register const char *yys = yystr;
+
+ while (*yys++ != '\0')
+ continue;
+
+ return yys - yystr - 1;
+}
+# endif
+# endif
+
+# ifndef yystpcpy
+# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
+# define yystpcpy stpcpy
+# else
+/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
+ YYDEST. */
+static char *
+# if defined (__STDC__) || defined (__cplusplus)
+yystpcpy (char *yydest, const char *yysrc)
+# else
+yystpcpy (yydest, yysrc)
+ char *yydest;
+ const char *yysrc;
+# endif
+{
+ register char *yyd = yydest;
+ register const char *yys = yysrc;
+ while ((*yyd++ = *yys++) != '\0')
+ continue;
+ return yyd - 1;
+}
+# endif
+# endif
+#endif /* !YYERROR_VERBOSE */
+
+#if YYDEBUG
+/*--------------------------------.
+| Print this symbol on YYOUTPUT. |
+`--------------------------------*/
+
+#if defined (__STDC__) || defined (__cplusplus)
+static void
+yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
+#else
+static void
+yysymprint (yyoutput, yytype, yyvaluep)
+ FILE *yyoutput;
+ int yytype;
+ YYSTYPE *yyvaluep;
+#endif
+{
+ /* Pacify ``unused variable'' warnings. */
+ (void) yyvaluep;
+
+ if (yytype < YYNTOKENS)
+ YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
+ else
+ YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
+
+
+# ifdef YYPRINT
+ if (yytype < YYNTOKENS)
+ YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
+# endif
+ switch (yytype)
+ {
+ default:
+ break;
+ }
+ YYFPRINTF (yyoutput, ")");
+}
+
+#endif /* ! YYDEBUG */
/*-----------------------------------------------.
| Release the memory associated to this symbol. |
`-----------------------------------------------*/
+#if defined (__STDC__) || defined (__cplusplus)
+static void
+yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
+#else
static void
-yydestruct (const char *yymsg,
- yysymbol_kind_t yykind, YYSTYPE *yyvaluep)
+yydestruct (yymsg, yytype, yyvaluep)
+ const char *yymsg;
+ int yytype;
+ YYSTYPE *yyvaluep;
+#endif
{
- YY_USE (yyvaluep);
+ /* Pacify ``unused variable'' warnings. */
+ (void) yyvaluep;
+
if (!yymsg)
yymsg = "Deleting";
- YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
+ YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
- YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
- YY_USE (yykind);
- YY_IGNORE_MAYBE_UNINITIALIZED_END
+ switch (yytype)
+ {
+
+ default:
+ break;
+ }
}
+
+
+/* Prevent warnings from -Wmissing-prototypes. */
+
+#ifdef YYPARSE_PARAM
+# if defined (__STDC__) || defined (__cplusplus)
+int yyparse (void *YYPARSE_PARAM);
+# else
+int yyparse ();
+# endif
+#else /* ! YYPARSE_PARAM */
+#if defined (__STDC__) || defined (__cplusplus)
+int yyparse (void);
+#else
+int yyparse ();
+#endif
+#endif /* ! YYPARSE_PARAM */
@@ -981,193 +905,204 @@ yydestruct (const char *yymsg,
| yyparse. |
`----------*/
+#ifdef YYPARSE_PARAM
+# if defined (__STDC__) || defined (__cplusplus)
+int yyparse (void *YYPARSE_PARAM)
+# else
+int yyparse (YYPARSE_PARAM)
+ void *YYPARSE_PARAM;
+# endif
+#else /* ! YYPARSE_PARAM */
+#if defined (__STDC__) || defined (__cplusplus)
int
yyparse (void)
+#else
+int
+yyparse ()
+
+#endif
+#endif
{
-/* Lookahead token kind. */
+ /* The look-ahead symbol. */
int yychar;
+/* The semantic value of the look-ahead symbol. */
+YYSTYPE yylval;
+
+/* Number of syntax errors so far. */
+int yynerrs;
-/* The semantic value of the lookahead symbol. */
-/* Default value used for initialization, for pacifying older GCCs
- or non-GCC compilers. */
-YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
-YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
+ register int yystate;
+ register int yyn;
+ int yyresult;
+ /* Number of tokens to shift before error messages enabled. */
+ int yyerrstatus;
+ /* Look-ahead token as an internal (translated) token number. */
+ int yytoken = 0;
- /* Number of syntax errors so far. */
- int yynerrs = 0;
+ /* Three stacks and their tools:
+ `yyss': related to states,
+ `yyvs': related to semantic values,
+ `yyls': related to locations.
- yy_state_fast_t yystate = 0;
- /* Number of tokens to shift before error messages enabled. */
- int yyerrstatus = 0;
+ Refer to the stacks thru separate pointers, to allow yyoverflow
+ to reallocate them elsewhere. */
- /* Refer to the stacks through separate pointers, to allow yyoverflow
- to reallocate them elsewhere. */
+ /* The state stack. */
+ short int yyssa[YYINITDEPTH];
+ short int *yyss = yyssa;
+ register short int *yyssp;
- /* Their size. */
- YYPTRDIFF_T yystacksize = YYINITDEPTH;
+ /* The semantic value stack. */
+ YYSTYPE yyvsa[YYINITDEPTH];
+ YYSTYPE *yyvs = yyvsa;
+ register YYSTYPE *yyvsp;
- /* The state stack: array, bottom, top. */
- yy_state_t yyssa[YYINITDEPTH];
- yy_state_t *yyss = yyssa;
- yy_state_t *yyssp = yyss;
- /* The semantic value stack: array, bottom, top. */
- YYSTYPE yyvsa[YYINITDEPTH];
- YYSTYPE *yyvs = yyvsa;
- YYSTYPE *yyvsp = yyvs;
- int yyn;
- /* The return value of yyparse. */
- int yyresult;
- /* Lookahead symbol kind. */
- yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
+#define YYPOPSTACK (yyvsp--, yyssp--)
+
+ YYSIZE_T yystacksize = YYINITDEPTH;
+
/* The variables used to return semantic value and location from the
action routines. */
YYSTYPE yyval;
+ /* When reducing, the number of symbols on the RHS of the reduced
+ rule. */
+ int yylen;
-#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
+ YYDPRINTF ((stderr, "Starting parse\n"));
- /* The number of symbols on the RHS of the reduced rule.
- Keep to zero when no symbol should be popped. */
- int yylen = 0;
+ yystate = 0;
+ yyerrstatus = 0;
+ yynerrs = 0;
+ yychar = YYEMPTY; /* Cause a token to be read. */
- YYDPRINTF ((stderr, "Starting parse\n"));
+ /* Initialize stack pointers.
+ Waste one element of value and location stack
+ so that they stay on the same level as the state stack.
+ The wasted elements are never initialized. */
- yychar = YYEMPTY; /* Cause a token to be read. */
+ yyssp = yyss;
+ yyvsp = yyvs;
- goto yysetstate;
+ yyvsp[0] = yylval;
+
+ goto yysetstate;
/*------------------------------------------------------------.
-| yynewstate -- push a new state, which is found in yystate. |
+| yynewstate -- Push a new state, which is found in yystate. |
`------------------------------------------------------------*/
-yynewstate:
+ yynewstate:
/* In all cases, when you get here, the value and location stacks
- have just been pushed. So pushing a state here evens the stacks. */
+ have just been pushed. so pushing a state here evens the stacks.
+ */
yyssp++;
-
-/*--------------------------------------------------------------------.
-| yysetstate -- set current state (the top of the stack) to yystate. |
-`--------------------------------------------------------------------*/
-yysetstate:
- YYDPRINTF ((stderr, "Entering state %d\n", yystate));
- YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
- YY_IGNORE_USELESS_CAST_BEGIN
- *yyssp = YY_CAST (yy_state_t, yystate);
- YY_IGNORE_USELESS_CAST_END
- YY_STACK_PRINT (yyss, yyssp);
+ yysetstate:
+ *yyssp = yystate;
if (yyss + yystacksize - 1 <= yyssp)
-#if !defined yyoverflow && !defined YYSTACK_RELOCATE
- YYNOMEM;
-#else
{
/* Get the current used size of the three stacks, in elements. */
- YYPTRDIFF_T yysize = yyssp - yyss + 1;
+ YYSIZE_T yysize = yyssp - yyss + 1;
-# if defined yyoverflow
+#ifdef yyoverflow
{
- /* Give user a chance to reallocate the stack. Use copies of
- these so that the &'s don't force the real ones into
- memory. */
- yy_state_t *yyss1 = yyss;
- YYSTYPE *yyvs1 = yyvs;
-
- /* Each stack pointer address is followed by the size of the
- data in use in that stack, in bytes. This used to be a
- conditional around just the two extra args, but that might
- be undefined if yyoverflow is a macro. */
- yyoverflow (YY_("memory exhausted"),
- &yyss1, yysize * YYSIZEOF (*yyssp),
- &yyvs1, yysize * YYSIZEOF (*yyvsp),
- &yystacksize);
- yyss = yyss1;
- yyvs = yyvs1;
+ /* Give user a chance to reallocate the stack. Use copies of
+ these so that the &'s don't force the real ones into
+ memory. */
+ YYSTYPE *yyvs1 = yyvs;
+ short int *yyss1 = yyss;
+
+
+ /* Each stack pointer address is followed by the size of the
+ data in use in that stack, in bytes. This used to be a
+ conditional around just the two extra args, but that might
+ be undefined if yyoverflow is a macro. */
+ yyoverflow ("parser stack overflow",
+ &yyss1, yysize * sizeof (*yyssp),
+ &yyvs1, yysize * sizeof (*yyvsp),
+
+ &yystacksize);
+
+ yyss = yyss1;
+ yyvs = yyvs1;
}
-# else /* defined YYSTACK_RELOCATE */
+#else /* no yyoverflow */
+# ifndef YYSTACK_RELOCATE
+ goto yyoverflowlab;
+# else
/* Extend the stack our own way. */
if (YYMAXDEPTH <= yystacksize)
- YYNOMEM;
+ goto yyoverflowlab;
yystacksize *= 2;
if (YYMAXDEPTH < yystacksize)
- yystacksize = YYMAXDEPTH;
+ yystacksize = YYMAXDEPTH;
{
- yy_state_t *yyss1 = yyss;
- union yyalloc *yyptr =
- YY_CAST (union yyalloc *,
- YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
- if (! yyptr)
- YYNOMEM;
- YYSTACK_RELOCATE (yyss_alloc, yyss);
- YYSTACK_RELOCATE (yyvs_alloc, yyvs);
+ short int *yyss1 = yyss;
+ union yyalloc *yyptr =
+ (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
+ if (! yyptr)
+ goto yyoverflowlab;
+ YYSTACK_RELOCATE (yyss);
+ YYSTACK_RELOCATE (yyvs);
+
# undef YYSTACK_RELOCATE
- if (yyss1 != yyssa)
- YYSTACK_FREE (yyss1);
+ if (yyss1 != yyssa)
+ YYSTACK_FREE (yyss1);
}
# endif
+#endif /* no yyoverflow */
yyssp = yyss + yysize - 1;
yyvsp = yyvs + yysize - 1;
- YY_IGNORE_USELESS_CAST_BEGIN
- YYDPRINTF ((stderr, "Stack size increased to %ld\n",
- YY_CAST (long, yystacksize)));
- YY_IGNORE_USELESS_CAST_END
+
+ YYDPRINTF ((stderr, "Stack size increased to %lu\n",
+ (unsigned long int) yystacksize));
if (yyss + yystacksize - 1 <= yyssp)
- YYABORT;
+ YYABORT;
}
-#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
-
- if (yystate == YYFINAL)
- YYACCEPT;
+ YYDPRINTF ((stderr, "Entering state %d\n", yystate));
goto yybackup;
-
/*-----------.
| yybackup. |
`-----------*/
yybackup:
- /* Do appropriate processing given the current state. Read a
- lookahead token if we need one and don't already have one. */
- /* First try to decide what to do without reference to lookahead token. */
+/* Do appropriate processing given the current state. */
+/* Read a look-ahead token if we need one and don't already have one. */
+/* yyresume: */
+
+ /* First try to decide what to do without reference to look-ahead token. */
+
yyn = yypact[yystate];
- if (yypact_value_is_default (yyn))
+ if (yyn == YYPACT_NINF)
goto yydefault;
- /* Not known => get a lookahead token if don't already have one. */
+ /* Not known => get a look-ahead token if don't already have one. */
- /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
+ /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
if (yychar == YYEMPTY)
{
- YYDPRINTF ((stderr, "Reading a token\n"));
- yychar = yylex (&yylval);
+ YYDPRINTF ((stderr, "Reading a token: "));
+ yychar = YYLEX;
}
if (yychar <= YYEOF)
{
- yychar = YYEOF;
- yytoken = YYSYMBOL_YYEOF;
+ yychar = yytoken = YYEOF;
YYDPRINTF ((stderr, "Now at end of input.\n"));
}
- else if (yychar == YYerror)
- {
- /* The scanner already issued an error message, process directly
- to error recovery. But do not keep the error token as
- lookahead, it is too special and may lead us to an endless
- loop in error recovery. */
- yychar = YYUNDEF;
- yytoken = YYSYMBOL_YYerror;
- goto yyerrlab1;
- }
else
{
yytoken = YYTRANSLATE (yychar);
@@ -1182,26 +1117,31 @@ yybackup:
yyn = yytable[yyn];
if (yyn <= 0)
{
- if (yytable_value_is_error (yyn))
- goto yyerrlab;
+ if (yyn == 0 || yyn == YYTABLE_NINF)
+ goto yyerrlab;
yyn = -yyn;
goto yyreduce;
}
+ if (yyn == YYFINAL)
+ YYACCEPT;
+
+ /* Shift the look-ahead token. */
+ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
+
+ /* Discard the token being shifted unless it is eof. */
+ if (yychar != YYEOF)
+ yychar = YYEMPTY;
+
+ *++yyvsp = yylval;
+
+
/* Count tokens shifted since error; after three, turn off error
status. */
if (yyerrstatus)
yyerrstatus--;
- /* Shift the lookahead token. */
- YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
yystate = yyn;
- YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
- *++yyvsp = yylval;
- YY_IGNORE_MAYBE_UNINITIALIZED_END
-
- /* Discard the shifted token. */
- yychar = YYEMPTY;
goto yynewstate;
@@ -1216,14 +1156,14 @@ yydefault:
/*-----------------------------.
-| yyreduce -- do a reduction. |
+| yyreduce -- Do a reduction. |
`-----------------------------*/
yyreduce:
/* yyn is the number of a rule to reduce with. */
yylen = yyr2[yyn];
/* If YYLEN is nonzero, implement the default value of the action:
- '$$ = $1'.
+ `$$ = $1'.
Otherwise, the following line sets YYVAL to garbage.
This behavior is undocumented and Bison
@@ -1236,176 +1176,223 @@ yyreduce:
YY_REDUCE_PRINT (yyn);
switch (yyn)
{
- case 2: /* start: exp */
-#line 177 "/fs2/chet/bash/bash-git/bash/lib/intl/plural.y"
- {
+ case 2:
+#line 177 "/usr/src/local/bash/bash-20080814/lib/intl/plural.y"
+ {
if ((yyvsp[0].exp) == NULL)
YYABORT;
((struct parse_args *) arg)->res = (yyvsp[0].exp);
}
-#line 1247 "/fs2/chet/bash/bash-git/bash/lib/intl/plural.c"
break;
- case 3: /* exp: exp '?' exp ':' exp */
-#line 185 "/fs2/chet/bash/bash-git/bash/lib/intl/plural.y"
- {
+ case 3:
+#line 185 "/usr/src/local/bash/bash-20080814/lib/intl/plural.y"
+ {
(yyval.exp) = new_exp_3 (qmop, (yyvsp[-4].exp), (yyvsp[-2].exp), (yyvsp[0].exp));
}
-#line 1255 "/fs2/chet/bash/bash-git/bash/lib/intl/plural.c"
break;
- case 4: /* exp: exp '|' exp */
-#line 189 "/fs2/chet/bash/bash-git/bash/lib/intl/plural.y"
- {
+ case 4:
+#line 189 "/usr/src/local/bash/bash-20080814/lib/intl/plural.y"
+ {
(yyval.exp) = new_exp_2 (lor, (yyvsp[-2].exp), (yyvsp[0].exp));
}
-#line 1263 "/fs2/chet/bash/bash-git/bash/lib/intl/plural.c"
break;
- case 5: /* exp: exp '&' exp */
-#line 193 "/fs2/chet/bash/bash-git/bash/lib/intl/plural.y"
- {
+ case 5:
+#line 193 "/usr/src/local/bash/bash-20080814/lib/intl/plural.y"
+ {
(yyval.exp) = new_exp_2 (land, (yyvsp[-2].exp), (yyvsp[0].exp));
}
-#line 1271 "/fs2/chet/bash/bash-git/bash/lib/intl/plural.c"
break;
- case 6: /* exp: exp EQUOP2 exp */
-#line 197 "/fs2/chet/bash/bash-git/bash/lib/intl/plural.y"
- {
+ case 6:
+#line 197 "/usr/src/local/bash/bash-20080814/lib/intl/plural.y"
+ {
(yyval.exp) = new_exp_2 ((yyvsp[-1].op), (yyvsp[-2].exp), (yyvsp[0].exp));
}
-#line 1279 "/fs2/chet/bash/bash-git/bash/lib/intl/plural.c"
break;
- case 7: /* exp: exp CMPOP2 exp */
-#line 201 "/fs2/chet/bash/bash-git/bash/lib/intl/plural.y"
- {
+ case 7:
+#line 201 "/usr/src/local/bash/bash-20080814/lib/intl/plural.y"
+ {
(yyval.exp) = new_exp_2 ((yyvsp[-1].op), (yyvsp[-2].exp), (yyvsp[0].exp));
}
-#line 1287 "/fs2/chet/bash/bash-git/bash/lib/intl/plural.c"
break;
- case 8: /* exp: exp ADDOP2 exp */
-#line 205 "/fs2/chet/bash/bash-git/bash/lib/intl/plural.y"
- {
+ case 8:
+#line 205 "/usr/src/local/bash/bash-20080814/lib/intl/plural.y"
+ {
(yyval.exp) = new_exp_2 ((yyvsp[-1].op), (yyvsp[-2].exp), (yyvsp[0].exp));
}
-#line 1295 "/fs2/chet/bash/bash-git/bash/lib/intl/plural.c"
break;
- case 9: /* exp: exp MULOP2 exp */
-#line 209 "/fs2/chet/bash/bash-git/bash/lib/intl/plural.y"
- {
+ case 9:
+#line 209 "/usr/src/local/bash/bash-20080814/lib/intl/plural.y"
+ {
(yyval.exp) = new_exp_2 ((yyvsp[-1].op), (yyvsp[-2].exp), (yyvsp[0].exp));
}
-#line 1303 "/fs2/chet/bash/bash-git/bash/lib/intl/plural.c"
break;
- case 10: /* exp: '!' exp */
-#line 213 "/fs2/chet/bash/bash-git/bash/lib/intl/plural.y"
- {
+ case 10:
+#line 213 "/usr/src/local/bash/bash-20080814/lib/intl/plural.y"
+ {
(yyval.exp) = new_exp_1 (lnot, (yyvsp[0].exp));
}
-#line 1311 "/fs2/chet/bash/bash-git/bash/lib/intl/plural.c"
break;
- case 11: /* exp: 'n' */
-#line 217 "/fs2/chet/bash/bash-git/bash/lib/intl/plural.y"
- {
+ case 11:
+#line 217 "/usr/src/local/bash/bash-20080814/lib/intl/plural.y"
+ {
(yyval.exp) = new_exp_0 (var);
}
-#line 1319 "/fs2/chet/bash/bash-git/bash/lib/intl/plural.c"
break;
- case 12: /* exp: NUMBER */
-#line 221 "/fs2/chet/bash/bash-git/bash/lib/intl/plural.y"
- {
+ case 12:
+#line 221 "/usr/src/local/bash/bash-20080814/lib/intl/plural.y"
+ {
if (((yyval.exp) = new_exp_0 (num)) != NULL)
(yyval.exp)->val.num = (yyvsp[0].num);
}
-#line 1328 "/fs2/chet/bash/bash-git/bash/lib/intl/plural.c"
break;
- case 13: /* exp: '(' exp ')' */
-#line 226 "/fs2/chet/bash/bash-git/bash/lib/intl/plural.y"
- {
+ case 13:
+#line 226 "/usr/src/local/bash/bash-20080814/lib/intl/plural.y"
+ {
(yyval.exp) = (yyvsp[-1].exp);
}
-#line 1336 "/fs2/chet/bash/bash-git/bash/lib/intl/plural.c"
break;
-#line 1340 "/fs2/chet/bash/bash-git/bash/lib/intl/plural.c"
-
- default: break;
}
- /* User semantic actions sometimes alter yychar, and that requires
- that yytoken be updated with the new translation. We take the
- approach of translating immediately before every use of yytoken.
- One alternative is translating here after every semantic action,
- but that translation would be missed if the semantic action invokes
- YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
- if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
- incorrect destructor might then be invoked immediately. In the
- case of YYERROR or YYBACKUP, subsequent parser actions might lead
- to an incorrect destructor call or verbose syntax error message
- before the lookahead is translated. */
- YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
-
- YYPOPSTACK (yylen);
- yylen = 0;
+
+/* Line 1037 of yacc.c. */
+#line 1270 "/usr/src/local/bash/bash-20080814/lib/intl/plural.c"
+
+ yyvsp -= yylen;
+ yyssp -= yylen;
+
+
+ YY_STACK_PRINT (yyss, yyssp);
*++yyvsp = yyval;
- /* Now 'shift' the result of the reduction. Determine what state
+
+ /* Now `shift' the result of the reduction. Determine what state
that goes to, based on the state we popped back to and the rule
number reduced by. */
- {
- const int yylhs = yyr1[yyn] - YYNTOKENS;
- const int yyi = yypgoto[yylhs] + *yyssp;
- yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
- ? yytable[yyi]
- : yydefgoto[yylhs]);
- }
+
+ yyn = yyr1[yyn];
+
+ yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
+ if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
+ yystate = yytable[yystate];
+ else
+ yystate = yydefgoto[yyn - YYNTOKENS];
goto yynewstate;
-/*--------------------------------------.
-| yyerrlab -- here on detecting error. |
-`--------------------------------------*/
+/*------------------------------------.
+| yyerrlab -- here on detecting error |
+`------------------------------------*/
yyerrlab:
- /* Make sure we have latest lookahead translation. See comments at
- user semantic actions for why this is necessary. */
- yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
/* If not already recovering from an error, report this error. */
if (!yyerrstatus)
{
++yynerrs;
- yyerror (YY_("syntax error"));
+#if YYERROR_VERBOSE
+ yyn = yypact[yystate];
+
+ if (YYPACT_NINF < yyn && yyn < YYLAST)
+ {
+ YYSIZE_T yysize = 0;
+ int yytype = YYTRANSLATE (yychar);
+ const char* yyprefix;
+ char *yymsg;
+ int yyx;
+
+ /* Start YYX at -YYN if negative to avoid negative indexes in
+ YYCHECK. */
+ int yyxbegin = yyn < 0 ? -yyn : 0;
+
+ /* Stay within bounds of both yycheck and yytname. */
+ int yychecklim = YYLAST - yyn;
+ int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
+ int yycount = 0;
+
+ yyprefix = ", expecting ";
+ for (yyx = yyxbegin; yyx < yyxend; ++yyx)
+ if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
+ {
+ yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]);
+ yycount += 1;
+ if (yycount == 5)
+ {
+ yysize = 0;
+ break;
+ }
+ }
+ yysize += (sizeof ("syntax error, unexpected ")
+ + yystrlen (yytname[yytype]));
+ yymsg = (char *) YYSTACK_ALLOC (yysize);
+ if (yymsg != 0)
+ {
+ char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
+ yyp = yystpcpy (yyp, yytname[yytype]);
+
+ if (yycount < 5)
+ {
+ yyprefix = ", expecting ";
+ for (yyx = yyxbegin; yyx < yyxend; ++yyx)
+ if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
+ {
+ yyp = yystpcpy (yyp, yyprefix);
+ yyp = yystpcpy (yyp, yytname[yyx]);
+ yyprefix = " or ";
+ }
+ }
+ yyerror (yymsg);
+ YYSTACK_FREE (yymsg);
+ }
+ else
+ yyerror ("syntax error; also virtual memory exhausted");
+ }
+ else
+#endif /* YYERROR_VERBOSE */
+ yyerror ("syntax error");
}
+
+
if (yyerrstatus == 3)
{
- /* If just tried and failed to reuse lookahead token after an
- error, discard it. */
+ /* If just tried and failed to reuse look-ahead token after an
+ error, discard it. */
if (yychar <= YYEOF)
{
- /* Return failure if at end of input. */
- if (yychar == YYEOF)
- YYABORT;
+ /* If at end of input, pop the error token,
+ then the rest of the stack, then return failure. */
+ if (yychar == YYEOF)
+ for (;;)
+ {
+
+ YYPOPSTACK;
+ if (yyssp == yyss)
+ YYABORT;
+ yydestruct ("Error: popping",
+ yystos[*yyssp], yyvsp);
+ }
}
else
- {
- yydestruct ("Error: discarding",
- yytoken, &yylval);
- yychar = YYEMPTY;
- }
+ {
+ yydestruct ("Error: discarding", yytoken, &yylval);
+ yychar = YYEMPTY;
+ }
}
- /* Else will try to reuse lookahead token after shifting the error
+ /* Else will try to reuse look-ahead token after shifting the error
token. */
goto yyerrlab1;
@@ -1414,17 +1401,16 @@ yyerrlab:
| yyerrorlab -- error raised explicitly by YYERROR. |
`---------------------------------------------------*/
yyerrorlab:
- /* Pacify compilers when the user code never invokes YYERROR and the
- label yyerrorlab therefore never appears in user code. */
+
+#ifdef __GNUC__
+ /* Pacify GCC when the user code never invokes YYERROR and the label
+ yyerrorlab therefore never appears in user code. */
if (0)
- YYERROR;
- ++yynerrs;
+ goto yyerrorlab;
+#endif
- /* Do not reclaim the symbols of the rule whose action triggered
- this YYERROR. */
- YYPOPSTACK (yylen);
- yylen = 0;
- YY_STACK_PRINT (yyss, yyssp);
+yyvsp -= yylen;
+ yyssp -= yylen;
yystate = *yyssp;
goto yyerrlab1;
@@ -1433,42 +1419,41 @@ yyerrorlab:
| yyerrlab1 -- common code for both syntax error and YYERROR. |
`-------------------------------------------------------------*/
yyerrlab1:
- yyerrstatus = 3; /* Each real token shifted decrements this. */
+ yyerrstatus = 3; /* Each real token shifted decrements this. */
- /* Pop stack until we find a state that shifts the error token. */
for (;;)
{
yyn = yypact[yystate];
- if (!yypact_value_is_default (yyn))
- {
- yyn += YYSYMBOL_YYerror;
- if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
- {
- yyn = yytable[yyn];
- if (0 < yyn)
- break;
- }
- }
+ if (yyn != YYPACT_NINF)
+ {
+ yyn += YYTERROR;
+ if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
+ {
+ yyn = yytable[yyn];
+ if (0 < yyn)
+ break;
+ }
+ }
/* Pop the current state because it cannot handle the error token. */
if (yyssp == yyss)
- YYABORT;
+ YYABORT;
- yydestruct ("Error: popping",
- YY_ACCESSING_SYMBOL (yystate), yyvsp);
- YYPOPSTACK (1);
+ yydestruct ("Error: popping", yystos[yystate], yyvsp);
+ YYPOPSTACK;
yystate = *yyssp;
YY_STACK_PRINT (yyss, yyssp);
}
- YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
+ if (yyn == YYFINAL)
+ YYACCEPT;
+
*++yyvsp = yylval;
- YY_IGNORE_MAYBE_UNINITIALIZED_END
- /* Shift the error token. */
- YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
+ /* Shift the error token. */
+ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
yystate = yyn;
goto yynewstate;
@@ -1479,57 +1464,38 @@ yyerrlab1:
`-------------------------------------*/
yyacceptlab:
yyresult = 0;
- goto yyreturnlab;
-
+ goto yyreturn;
/*-----------------------------------.
| yyabortlab -- YYABORT comes here. |
`-----------------------------------*/
yyabortlab:
+ yydestruct ("Error: discarding lookahead",
+ yytoken, &yylval);
+ yychar = YYEMPTY;
yyresult = 1;
- goto yyreturnlab;
-
+ goto yyreturn;
-/*-----------------------------------------------------------.
-| yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here. |
-`-----------------------------------------------------------*/
-yyexhaustedlab:
- yyerror (YY_("memory exhausted"));
+#ifndef yyoverflow
+/*----------------------------------------------.
+| yyoverflowlab -- parser overflow comes here. |
+`----------------------------------------------*/
+yyoverflowlab:
+ yyerror ("parser stack overflow");
yyresult = 2;
- goto yyreturnlab;
-
+ /* Fall through. */
+#endif
-/*----------------------------------------------------------.
-| yyreturnlab -- parsing is finished, clean up and return. |
-`----------------------------------------------------------*/
-yyreturnlab:
- if (yychar != YYEMPTY)
- {
- /* Make sure we have latest lookahead translation. See comments at
- user semantic actions for why this is necessary. */
- yytoken = YYTRANSLATE (yychar);
- yydestruct ("Cleanup: discarding lookahead",
- yytoken, &yylval);
- }
- /* Do not reclaim the symbols of the rule whose action triggered
- this YYABORT or YYACCEPT. */
- YYPOPSTACK (yylen);
- YY_STACK_PRINT (yyss, yyssp);
- while (yyssp != yyss)
- {
- yydestruct ("Cleanup: popping",
- YY_ACCESSING_SYMBOL (+*yyssp), yyvsp);
- YYPOPSTACK (1);
- }
+yyreturn:
#ifndef yyoverflow
if (yyss != yyssa)
YYSTACK_FREE (yyss);
#endif
-
return yyresult;
}
-#line 231 "/fs2/chet/bash/bash-git/bash/lib/intl/plural.y"
+
+#line 231 "/usr/src/local/bash/bash-20080814/lib/intl/plural.y"
inline void
diff --git a/lib/posixheaders.old/ansi_stdlib.h b/lib/posixheaders.old/ansi_stdlib.h
deleted file mode 100644
index 52339da5..00000000
--- a/lib/posixheaders.old/ansi_stdlib.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* ansi_stdlib.h -- An ANSI Standard stdlib.h. */
-/* A minimal stdlib.h containing extern declarations for those functions
- that bash uses. */
-
-/* Copyright (C) 1993 Free Software Foundation, Inc.
-
- This file is part of GNU Bash, the Bourne Again SHell.
-
- Bash 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.
-
- Bash 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 Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#if !defined (_STDLIB_H_)
-#define _STDLIB_H_ 1
-
-/* String conversion functions. */
-extern int atoi ();
-extern long int atol ();
-
-/* Memory allocation functions. */
-extern char *malloc ();
-extern char *realloc ();
-extern void free ();
-
-/* Other miscellaneous functions. */
-extern void abort ();
-extern void exit ();
-extern char *getenv ();
-extern void qsort ();
-
-#endif /* _STDLIB_H */
diff --git a/lib/posixheaders.old/filecntl.h b/lib/posixheaders.old/filecntl.h
deleted file mode 100644
index cf5054de..00000000
--- a/lib/posixheaders.old/filecntl.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* filecntl.h - Definitions to set file descriptors to close-on-exec. */
-
-/* Copyright (C) 1993 Free Software Foundation, Inc.
-
- This file is part of GNU Bash, the Bourne Again SHell.
-
- Bash 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.
-
- Bash 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 Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#if !defined (_FILECNTL_H_)
-#define _FILECNTL_H_
-
-#include <fcntl.h>
-
-/* Definitions to set file descriptors to close-on-exec, the Posix way. */
-#if !defined (FD_CLOEXEC)
-#define FD_CLOEXEC 1
-#endif
-
-#define FD_NCLOEXEC 0
-
-#define SET_CLOSE_ON_EXEC(fd) (fcntl ((fd), F_SETFD, FD_CLOEXEC))
-#define SET_OPEN_ON_EXEC(fd) (fcntl ((fd), F_SETFD, FD_NCLOEXEC))
-
-/* How to open a file in non-blocking mode, the Posix.1 way. */
-#if !defined (O_NONBLOCK)
-# if defined (O_NDELAY)
-# define O_NONBLOCK O_NDELAY
-# else
-# define O_NONBLOCK 0
-# endif
-#endif
-
-#endif /* ! _FILECNTL_H_ */
diff --git a/lib/posixheaders.old/memalloc.h b/lib/posixheaders.old/memalloc.h
deleted file mode 100644
index c68961f3..00000000
--- a/lib/posixheaders.old/memalloc.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* memalloc.h -- consolidate code for including alloca.h or malloc.h and
- defining alloca. */
-
-/* Copyright (C) 1993 Free Software Foundation, Inc.
-
- This file is part of GNU Bash, the Bourne Again SHell.
-
- Bash 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.
-
- Bash 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 Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#if !defined (_MEMALLOC_H_)
-# define _MEMALLOC_H_
-
-#if defined (sparc) && defined (sun) && !defined (HAVE_ALLOCA_H)
-# define HAVE_ALLOCA_H
-#endif
-
-#if defined (__GNUC__) && !defined (HAVE_ALLOCA)
-# define HAVE_ALLOCA
-#endif
-
-#if defined (HAVE_ALLOCA_H) && !defined (HAVE_ALLOCA)
-# define HAVE_ALLOCA
-#endif /* HAVE_ALLOCA_H && !HAVE_ALLOCA */
-
-#if defined (__GNUC__) && !defined (C_ALLOCA)
-# undef alloca
-# define alloca __builtin_alloca
-#else /* !__GNUC__ || C_ALLOCA */
-# if defined (HAVE_ALLOCA_H) && !defined (C_ALLOCA)
-# if defined (IBMESA)
-# include <malloc.h>
-# else /* !IBMESA */
-# include <alloca.h>
-# endif /* !IBMESA */
-# else /* !HAVE_ALLOCA_H || C_ALLOCA */
-# if defined (__hpux) && defined (__STDC__) && !defined (alloca)
-extern void *alloca ();
-# else
-# if !defined (alloca)
-extern char *alloca ();
-# endif /* !alloca */
-# endif /* !__hpux || !__STDC__ && !alloca */
-# endif /* !HAVE_ALLOCA_H || C_ALLOCA */
-#endif /* !__GNUC__ || C_ALLOCA */
-
-#endif /* _MEMALLOC_H_ */
diff --git a/lib/posixheaders.old/posixdir.h b/lib/posixheaders.old/posixdir.h
deleted file mode 100644
index 7480a93d..00000000
--- a/lib/posixheaders.old/posixdir.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* posixdir.h -- Posix directory reading includes and defines. */
-
-/* Copyright (C) 1987,1991 Free Software Foundation, Inc.
-
- This file is part of GNU Bash, the Bourne Again SHell.
-
- Bash 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 1, or (at your option)
- any later version.
-
- Bash 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 Bash; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* This file should be included instead of <dirent.h> or <sys/dir.h>. */
-
-#if !defined (_POSIXDIR_H_)
-#define _POSIXDIR_H_
-
-#if defined (HAVE_DIRENT_H)
-# include <dirent.h>
-# define D_NAMLEN(d) (strlen ((d)->d_name))
-#else
-# if defined (HAVE_SYS_NDIR_H)
-# include <sys/ndir.h>
-# endif
-# if defined (HAVE_SYS_DIR_H)
-# include <sys/dir.h>
-# endif
-# if defined (HAVE_NDIR_H)
-# include <ndir.h>
-# endif
-# if !defined (dirent)
-# define dirent direct
-# endif /* !dirent */
-# define D_NAMLEN(d) ((d)->d_namlen)
-#endif /* !HAVE_DIRENT_H */
-
-#if defined (STRUCT_DIRENT_HAS_D_INO) && !defined (STRUCT_DIRENT_HAS_D_FILENO)
-# define d_fileno d_ino
-#endif
-
-#endif /* !_POSIXDIR_H_ */
diff --git a/lib/posixheaders.old/posixjmp.h b/lib/posixheaders.old/posixjmp.h
deleted file mode 100644
index 1347cc07..00000000
--- a/lib/posixheaders.old/posixjmp.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/* posixjmp.h -- wrapper for setjmp.h with changes for POSIX systems. */
-
-#ifndef _POSIXJMP_H_
-#define _POSIXJMP_H_
-
-#include <setjmp.h>
-
-/* This *must* be included *after* config.h */
-
-#if defined (HAVE_POSIX_SIGSETJMP)
-# define procenv_t sigjmp_buf
-# if !defined (__OPENNT)
-# undef setjmp
-# define setjmp(x) sigsetjmp((x), 1)
-# undef longjmp
-# define longjmp(x, n) siglongjmp((x), (n))
-# endif /* !__OPENNT */
-#else
-# define procenv_t jmp_buf
-#endif
-
-#endif /* _POSIXJMP_H_ */
diff --git a/lib/posixheaders.old/posixstat.h b/lib/posixheaders.old/posixstat.h
deleted file mode 100644
index bfce8c04..00000000
--- a/lib/posixheaders.old/posixstat.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/* posixstat.h -- Posix stat(2) definitions for systems that
- don't have them. */
-
-/* Copyright (C) 1987,1991 Free Software Foundation, Inc.
-
- This file is part of GNU Bash, the Bourne Again SHell.
-
- Bash 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 1, or (at your option)
- any later version.
-
- Bash 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 Bash; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* This file should be included instead of <sys/stat.h>.
- It relies on the local sys/stat.h to work though. */
-#if !defined (_POSIXSTAT_H_)
-#define _POSIXSTAT_H_
-
-#include <sys/stat.h>
-
-#if defined (STAT_MACROS_BROKEN)
-# undef S_ISBLK
-# undef S_ISCHR
-# undef S_ISDIR
-# undef S_ISFIFO
-# undef S_ISREG
-# undef S_ISLNK
-#endif /* STAT_MACROS_BROKEN */
-
-/* These are guaranteed to work only on isc386 */
-#if !defined (S_IFDIR) && !defined (S_ISDIR)
-# define S_IFDIR 0040000
-#endif /* !S_IFDIR && !S_ISDIR */
-#if !defined (S_IFMT)
-# define S_IFMT 0170000
-#endif /* !S_IFMT */
-
-/* Posix 1003.1 5.6.1.1 <sys/stat.h> file types */
-
-/* Some Posix-wannabe systems define _S_IF* macros instead of S_IF*, but
- do not provide the S_IS* macros that Posix requires. */
-
-#if defined (_S_IFMT) && !defined (S_IFMT)
-#define S_IFMT _S_IFMT
-#endif
-#if defined (_S_IFIFO) && !defined (S_IFIFO)
-#define S_IFIFO _S_IFIFO
-#endif
-#if defined (_S_IFCHR) && !defined (S_IFCHR)
-#define S_IFCHR _S_IFCHR
-#endif
-#if defined (_S_IFDIR) && !defined (S_IFDIR)
-#define S_IFDIR _S_IFDIR
-#endif
-#if defined (_S_IFBLK) && !defined (S_IFBLK)
-#define S_IFBLK _S_IFBLK
-#endif
-#if defined (_S_IFREG) && !defined (S_IFREG)
-#define S_IFREG _S_IFREG
-#endif
-#if defined (_S_IFLNK) && !defined (S_IFLNK)
-#define S_IFLNK _S_IFLNK
-#endif
-#if defined (_S_IFSOCK) && !defined (S_IFSOCK)
-#define S_IFSOCK _S_IFSOCK
-#endif
-
-/* Test for each symbol individually and define the ones necessary (some
- systems claiming Posix compatibility define some but not all). */
-
-#if defined (S_IFBLK) && !defined (S_ISBLK)
-#define S_ISBLK(m) (((m)&S_IFMT) == S_IFBLK) /* block device */
-#endif
-
-#if defined (S_IFCHR) && !defined (S_ISCHR)
-#define S_ISCHR(m) (((m)&S_IFMT) == S_IFCHR) /* character device */
-#endif
-
-#if defined (S_IFDIR) && !defined (S_ISDIR)
-#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) /* directory */
-#endif
-
-#if defined (S_IFREG) && !defined (S_ISREG)
-#define S_ISREG(m) (((m)&S_IFMT) == S_IFREG) /* file */
-#endif
-
-#if defined (S_IFIFO) && !defined (S_ISFIFO)
-#define S_ISFIFO(m) (((m)&S_IFMT) == S_IFIFO) /* fifo - named pipe */
-#endif
-
-#if defined (S_IFLNK) && !defined (S_ISLNK)
-#define S_ISLNK(m) (((m)&S_IFMT) == S_IFLNK) /* symbolic link */
-#endif
-
-#if defined (S_IFSOCK) && !defined (S_ISSOCK)
-#define S_ISSOCK(m) (((m)&S_IFMT) == S_IFSOCK) /* socket */
-#endif
-
-/*
- * POSIX 1003.1 5.6.1.2 <sys/stat.h> File Modes
- */
-
-#if !defined (S_IRWXU)
-# if !defined (S_IREAD)
-# define S_IREAD 00400
-# define S_IWRITE 00200
-# define S_IEXEC 00100
-# endif /* S_IREAD */
-
-# if !defined (S_IRUSR)
-# define S_IRUSR S_IREAD /* read, owner */
-# define S_IWUSR S_IWRITE /* write, owner */
-# define S_IXUSR S_IEXEC /* execute, owner */
-
-# define S_IRGRP (S_IREAD >> 3) /* read, group */
-# define S_IWGRP (S_IWRITE >> 3) /* write, group */
-# define S_IXGRP (S_IEXEC >> 3) /* execute, group */
-
-# define S_IROTH (S_IREAD >> 6) /* read, other */
-# define S_IWOTH (S_IWRITE >> 6) /* write, other */
-# define S_IXOTH (S_IEXEC >> 6) /* execute, other */
-# endif /* !S_IRUSR */
-
-# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
-# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
-# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
-#endif /* !S_IRWXU */
-
-/* These are non-standard, but are used in builtins.c$symbolic_umask() */
-#define S_IRUGO (S_IRUSR | S_IRGRP | S_IROTH)
-#define S_IWUGO (S_IWUSR | S_IWGRP | S_IWOTH)
-#define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
-
-#endif /* _POSIXSTAT_H_ */
diff --git a/lib/posixheaders.old/stdc.h b/lib/posixheaders.old/stdc.h
deleted file mode 100644
index f1590c6d..00000000
--- a/lib/posixheaders.old/stdc.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/* stdc.h -- macros to make source compile on both ANSI C and K&R C
- compilers. */
-
-/* Copyright (C) 1993 Free Software Foundation, Inc.
-
- This file is part of GNU Bash, the Bourne Again SHell.
-
- Bash 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 1, or (at your option)
- any later version.
-
- Bash 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 Bash; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#if !defined (_STDC_H_)
-#define _STDC_H_
-
-/* Adapted from BSD /usr/include/sys/cdefs.h. */
-
-/* A function can be defined using prototypes and compile on both ANSI C
- and traditional C compilers with something like this:
- extern char *func __P((char *, char *, int)); */
-
-#if defined (__STDC__)
-
-# if !defined (__P)
-# define __P(protos) protos
-# endif
-# define __STRING(x) #x
-
-# if !defined (__GNUC__)
-# define inline
-# endif
-
-#else /* !__STDC__ */
-
-# if !defined (__P)
-# define __P(protos) ()
-# endif
-# define __STRING(x) "x"
-
-#if defined (__GNUC__) /* gcc with -traditional */
-# if !defined (const)
-# define const __const
-# endif
-# if !defined (inline)
-# define inline __inline
-# endif
-# if !defined (signed)
-# define signed __signed
-# endif
-# if !defined (volatile)
-# define volatile __volatile
-# endif
-#else /* !__GNUC__ */
-# if !defined (const)
-# define const
-# endif
-# if !defined (inline)
-# define inline
-# endif
-# if !defined (signed)
-# define signed
-# endif
-# if !defined (volatile)
-# define volatile
-# endif
-#endif /* !__GNUC__ */
-
-#endif /* !__STDC__ */
-
-#endif /* !_STDC_H_ */
diff --git a/lib/readline/bind.c b/lib/readline/bind.c
index 54ee5cde..524ef34a 100644
--- a/lib/readline/bind.c
+++ b/lib/readline/bind.c
@@ -1167,9 +1167,7 @@ _rl_init_file_error (va_alist)
/* **************************************************************** */
static int
-parse_comparison_op (s, indp)
- const char *s;
- int *indp;
+parse_comparison_op (const char *s, int *indp)
{
int i, peekc, op;
diff --git a/lib/readline/doc/hstech.texi b/lib/readline/doc/hstech.texi
index 7a6d7627..5d4efe53 100644
--- a/lib/readline/doc/hstech.texi
+++ b/lib/readline/doc/hstech.texi
@@ -517,9 +517,8 @@ The following program demonstrates simple use of the @sc{gnu} History Library.
#include <stdio.h>
#include <readline/history.h>
-main (argc, argv)
- int argc;
- char **argv;
+int
+main (int argc, char **argv)
@{
char line[1024], *t;
int len, done = 0;
diff --git a/lib/readline/doc/rltech.texi b/lib/readline/doc/rltech.texi
index f40bc2bd..db38a311 100644
--- a/lib/readline/doc/rltech.texi
+++ b/lib/readline/doc/rltech.texi
@@ -2425,8 +2425,8 @@ COMMAND commands[] = @{
@};
/* Forward declarations. */
-char *stripwhite ();
-COMMAND *find_command ();
+char *stripwhite (char *);
+COMMAND *find_command (char *);
/* The name of this program, as taken from argv[0]. */
char *progname;
@@ -2435,8 +2435,7 @@ char *progname;
int done;
char *
-dupstr (s)
- char *s;
+dupstr (char *s)
@{
char *r;
@@ -2445,9 +2444,8 @@ dupstr (s)
return (r);
@}
-main (argc, argv)
- int argc;
- char **argv;
+int
+main (int argc, char **argv)
@{
char *line, *s;
@@ -2483,8 +2481,7 @@ main (argc, argv)
/* Execute a command line. */
int
-execute_line (line)
- char *line;
+execute_line (char *line)
@{
register int i;
COMMAND *command;
@@ -2523,8 +2520,7 @@ execute_line (line)
/* Look up NAME as the name of a command, and return a pointer to that
command. Return a NULL pointer if NAME isn't a command name. */
COMMAND *
-find_command (name)
- char *name;
+find_command (char *name)
@{
register int i;
@@ -2538,8 +2534,7 @@ find_command (name)
/* Strip whitespace from the start and end of STRING. Return a pointer
into STRING. */
char *
-stripwhite (string)
- char *string;
+stripwhite (char *string)
@{
register char *s, *t;
@@ -2563,13 +2558,14 @@ stripwhite (string)
/* */
/* **************************************************************** */
-char *command_generator PARAMS((const char *, int));
-char **fileman_completion PARAMS((const char *, int, int));
+char *command_generator (const char *, int);
+char **fileman_completion (const char *, int, int);
/* Tell the GNU Readline library how to complete. We want to try to complete
on command names if this is the first word in the line, or on filenames
if not. */
-initialize_readline ()
+void
+initialize_readline (void)
@{
/* Allow conditional parsing of the ~/.inputrc file. */
rl_readline_name = "FileMan";
@@ -2584,9 +2580,7 @@ initialize_readline ()
in case we want to do some simple parsing. Return the array of matches,
or NULL if there aren't any. */
char **
-fileman_completion (text, start, end)
- const char *text;
- int start, end;
+fileman_completion (const char *text, int start, int end)
@{
char **matches;
@@ -2605,9 +2599,7 @@ fileman_completion (text, start, end)
to start from scratch; without any state (i.e. STATE == 0), then we
start at the top of the list. */
char *
-command_generator (text, state)
- const char *text;
- int state;
+command_generator (const char *text, int state)
@{
static int list_index, len;
char *name;
@@ -2645,8 +2637,8 @@ command_generator (text, state)
static char syscom[1024];
/* List the file(s) named in arg. */
-com_list (arg)
- char *arg;
+int
+com_list (char *arg)
@{
if (!arg)
arg = "";
@@ -2655,8 +2647,8 @@ com_list (arg)
return (system (syscom));
@}
-com_view (arg)
- char *arg;
+int
+com_view (char *arg)
@{
if (!valid_argument ("view", arg))
return 1;
@@ -2670,15 +2662,15 @@ com_view (arg)
return (system (syscom));
@}
-com_rename (arg)
- char *arg;
+int
+com_rename (char *arg)
@{
too_dangerous ("rename");
return (1);
@}
-com_stat (arg)
- char *arg;
+int
+com_stat (char *arg)
@{
struct stat finfo;
@@ -2705,8 +2697,8 @@ com_stat (arg)
return (0);
@}
-com_delete (arg)
- char *arg;
+int
+com_delete (char *arg)
@{
too_dangerous ("delete");
return (1);
@@ -2714,8 +2706,8 @@ com_delete (arg)
/* Print out help for ARG, or for all of the commands if ARG is
not present. */
-com_help (arg)
- char *arg;
+int
+com_help (char *arg)
@{
register int i;
int printed = 0;
@@ -2753,8 +2745,8 @@ com_help (arg)
@}
/* Change to the directory ARG. */
-com_cd (arg)
- char *arg;
+int
+com_cd (char *arg)
@{
if (chdir (arg) == -1)
@{
@@ -2767,8 +2759,8 @@ com_cd (arg)
@}
/* Print out the current working directory. */
-com_pwd (ignore)
- char *ignore;
+int
+com_pwd (char *ignore)
@{
char dir[1024], *s;
@@ -2784,16 +2776,16 @@ com_pwd (ignore)
@}
/* The user wishes to quit using this program. Just set DONE non-zero. */
-com_quit (arg)
- char *arg;
+int
+com_quit (char *arg)
@{
done = 1;
return (0);
@}
/* Function which tells you that you can't do this. */
-too_dangerous (caller)
- char *caller;
+void
+too_dangerous (char *caller)
@{
fprintf (stderr,
"%s: Too dangerous for me to distribute. Write it yourself.\n",
@@ -2803,8 +2795,7 @@ too_dangerous (caller)
/* Return non-zero if ARG is a valid argument for CALLER, else print
an error message and return zero. */
int
-valid_argument (caller, arg)
- char *caller, *arg;
+valid_argument (char *caller, char *arg)
@{
if (!arg || !*arg)
@{
diff --git a/lib/readline/doc/version.texi b/lib/readline/doc/version.texi
index a72ee264..865a7152 100644
--- a/lib/readline/doc/version.texi
+++ b/lib/readline/doc/version.texi
@@ -5,7 +5,7 @@ Copyright (C) 1988-2023 Free Software Foundation, Inc.
@set EDITION 8.2
@set VERSION 8.2
-@set UPDATED 17 February 2023
-@set UPDATED-MONTH February 2023
+@set UPDATED 27 March 2023
+@set UPDATED-MONTH March 2023
-@set LASTCHANGE Fri Feb 17 11:03:17 EST 2023
+@set LASTCHANGE Mon Mar 27 11:41:20 EDT 2023
diff --git a/lib/readline/histexpand.c b/lib/readline/histexpand.c
index d21240bf..78cc25bf 100644
--- a/lib/readline/histexpand.c
+++ b/lib/readline/histexpand.c
@@ -1600,6 +1600,8 @@ get_word:
if (nestdelim == 0 && delimiter == 0 && member (string[i], "<>$!@?+*") && string[i+1] == '(') /*)*/
{
i += 2;
+ if (string[i] == 0)
+ break; /* could just return i here */
delimopen = '(';
delimiter = ')';
nestdelim = 1;
diff --git a/lib/readline/rltty.c b/lib/readline/rltty.c
index d9b0cd1c..337f0af4 100644
--- a/lib/readline/rltty.c
+++ b/lib/readline/rltty.c
@@ -1,7 +1,7 @@
/* rltty.c -- functions to prepare and restore the terminal for readline's
use. */
-/* Copyright (C) 1992-2022 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2023 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -80,8 +80,7 @@ static int ksrflow;
/* Dummy call to force a backgrounded readline to stop before it tries
to get the tty settings. */
static void
-set_winsize (tty)
- int tty;
+set_winsize (int tty)
{
#if defined (TIOCGWINSZ)
struct winsize w;
diff --git a/lib/readline/text.c b/lib/readline/text.c
index abe99b34..62e4da2a 100644
--- a/lib/readline/text.c
+++ b/lib/readline/text.c
@@ -1764,8 +1764,7 @@ _rl_char_search (int count, int fdir, int bdir)
#if defined (READLINE_CALLBACKS)
static int
-_rl_char_search_callback (data)
- _rl_callback_generic_arg *data;
+_rl_char_search_callback (_rl_callback_generic_arg *data)
{
_rl_callback_func = 0;
_rl_want_redisplay = 1;
diff --git a/lib/sh/random.c b/lib/sh/random.c
index 1faeacae..16877430 100644
--- a/lib/sh/random.c
+++ b/lib/sh/random.c
@@ -91,7 +91,7 @@ genseed (void)
u_bits32_t iv;
gettimeofday (&tv, NULL);
- iv = (u_bits32_t)seedrand; /* let the compiler truncate */
+ iv = (uintptr_t)seedrand; /* let the compiler truncate */
iv = tv.tv_sec ^ tv.tv_usec ^ getpid () ^ getppid () ^ current_user.uid ^ iv;
return (iv);
}
diff --git a/lib/tilde/shell.c b/lib/tilde/shell.c
index 9805a924..de974366 100644
--- a/lib/tilde/shell.c
+++ b/lib/tilde/shell.c
@@ -45,7 +45,7 @@
#include <pwd.h>
#if !defined (HAVE_GETPW_DECLS)
-extern struct passwd *getpwuid ();
+extern struct passwd *getpwuid (uid_t);
#endif /* !HAVE_GETPW_DECLS */
char *
diff --git a/shell.c b/shell.c
index 28940ad1..993b9a1f 100644
--- a/shell.c
+++ b/shell.c
@@ -94,7 +94,7 @@ extern int get_tty_state (void);
#endif
#if !defined (HAVE_GETPW_DECLS)
-extern struct passwd *getpwuid ();
+extern struct passwd *getpwuid (uid_t);
#endif /* !HAVE_GETPW_DECLS */
#if !defined (errno)
diff --git a/support/bashversion.c b/support/bashversion.c
index 63a634d0..cf98ca57 100644
--- a/support/bashversion.c
+++ b/support/bashversion.c
@@ -1,6 +1,6 @@
/* bashversion.c -- Display bash version information. */
-/* Copyright (C) 2001-2022 Free Software Foundation, Inc.
+/* Copyright (C) 2001-2022,2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -54,15 +54,13 @@ char *shell_name = "bash";
char *progname;
static void
-usage()
+usage(void)
{
fprintf(stderr, "%s: usage: %s [-hrvpmlsx]\n", progname, progname);
}
int
-main (argc, argv)
- int argc;
- char **argv;
+main (int argc, char **argv)
{
int opt, oflags;
char dv[128], *rv;
diff --git a/support/endian.c b/support/endian.c
index 3c92ae8f..27f5b125 100644
--- a/support/endian.c
+++ b/support/endian.c
@@ -39,9 +39,8 @@ char nstring[9];
/* Stuff "1234" into a long, and compare it against a character string
"1234". If the results are EQ, the machine is big endian like a 68000
or Sparc, otherwise it is little endian, like a Vax, or 386. */
-main (argc, argv)
- int argc;
- char **argv;
+int
+main (int argc, char **argv)
{
#if defined (__STDC__)
register size_t i;
diff --git a/support/memtest.c b/support/memtest.c
index 39ffd0f3..80cafa23 100644
--- a/support/memtest.c
+++ b/support/memtest.c
@@ -37,6 +37,7 @@ int interrupt_immediately = 0;
static char xp[64];
+int
main(int c, char **v)
{
char *p;
diff --git a/support/mksignames.c b/support/mksignames.c
index 0a48cee4..9d0a0135 100644
--- a/support/mksignames.c
+++ b/support/mksignames.c
@@ -1,7 +1,7 @@
/* mksignames.c -- Create and write `signames.h', which contains an array of
signal names. */
-/* Copyright (C) 1992-2022 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -39,14 +39,13 @@
#define LASTSIG NSIG+2
/* Imported from signames.c */
-extern void initialize_signames ();
+extern void initialize_signames (void);
extern char *signal_names[];
char *progname;
void
-write_signames (stream)
- FILE *stream;
+write_signames (FILE *stream)
{
register int i;
@@ -71,9 +70,7 @@ write_signames (stream)
}
int
-main (argc, argv)
- int argc;
- char **argv;
+main (int argc, char **argv)
{
char *stream_name;
FILE *stream;
diff --git a/support/printenv.c b/support/printenv.c
index 154e086c..20ad96df 100644
--- a/support/printenv.c
+++ b/support/printenv.c
@@ -6,7 +6,7 @@
chet@po.cwru.edu
*/
-/* Copyright (C) 1997-2002 Free Software Foundation, Inc.
+/* Copyright (C) 1997-2002,2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -34,9 +34,7 @@
extern char **environ;
int
-main (argc, argv)
- int argc;
- char **argv;
+main (int argc, char **argv)
{
register char **envp, *eval;
int len;
diff --git a/support/recho.c b/support/recho.c
index 7e3c6bc6..7643cc47 100644
--- a/support/recho.c
+++ b/support/recho.c
@@ -6,7 +6,7 @@
chet@po.cwru.edu
*/
-/* Copyright (C) 2002-2005 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2005,2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -31,12 +31,10 @@
#include "bashansi.h"
#include <stdio.h>
-void strprint();
+void strprint(char *);
int
-main(argc, argv)
-int argc;
-char **argv;
+main(int argc, char **argv)
{
register int i;
@@ -49,8 +47,7 @@ char **argv;
}
void
-strprint(str)
-char *str;
+strprint(char *str)
{
register unsigned char *s;
diff --git a/support/rlvers.sh b/support/rlvers.sh
index 64cadc77..03ed901f 100644
--- a/support/rlvers.sh
+++ b/support/rlvers.sh
@@ -78,6 +78,7 @@ cat > $TDIR/rlvers.c << EOF
#include <stdio.h>
extern char *rl_library_version;
+int
main()
{
printf("%s\n", rl_library_version ? rl_library_version : "0");
diff --git a/support/signames.c b/support/signames.c
index 84864fd7..6b60bc7d 100644
--- a/support/signames.c
+++ b/support/signames.c
@@ -67,7 +67,7 @@ extern char *progname;
#endif
void
-initialize_signames ()
+initialize_signames (void)
{
register int i;
#if defined (SIGRTMAX) || defined (SIGRTMIN)
diff --git a/support/xcase.c b/support/xcase.c
index 527840db..683330f4 100644
--- a/support/xcase.c
+++ b/support/xcase.c
@@ -1,6 +1,6 @@
/* xcase - change uppercase characters to lowercase or vice versa. */
-/* Copyright (C) 2008,2009 Free Software Foundation, Inc.
+/* Copyright (C) 2008,2009,2023 Free Software Foundation, Inc.
This file is part of GNU Bash.
@@ -42,9 +42,7 @@ extern int optind;
#define UPPER 2
int
-main(ac, av)
-int ac;
-char **av;
+main(int ac, char **av)
{
int c, x;
int op;
diff --git a/support/zecho.c b/support/zecho.c
index f3a4fe03..6a125f48 100644
--- a/support/zecho.c
+++ b/support/zecho.c
@@ -26,9 +26,7 @@
#include <stdio.h>
int
-main(argc, argv)
-int argc;
-char **argv;
+main(int argc, char **argv)
{
argv++;
diff --git a/version.c b/version.c
index 5bb456ac..eb90bc7f 100644
--- a/version.c
+++ b/version.c
@@ -1,6 +1,6 @@
/* version.c -- distribution and version numbers. */
-/* Copyright (C) 1989-2022 Free Software Foundation, Inc.
+/* Copyright (C) 1989-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -57,7 +57,7 @@ extern void show_shell_version (int);
/* Give version information about this shell. */
char *
-shell_version_string ()
+shell_version_string (void)
{
static char tt[32] = { '\0' };
@@ -80,8 +80,7 @@ shell_version_string ()
}
void
-show_shell_version (extended)
- int extended;
+show_shell_version (int extended)
{
printf (_("GNU bash, version %s (%s)\n"), shell_version_string (), MACHTYPE);
if (extended)