Bash-5.3-alpha release

This commit is contained in:
Chet Ramey
2024-04-22 10:33:38 -04:00
parent f3b6bd1945
commit 622d318652
700 changed files with 136534 additions and 96420 deletions
+59 -145
View File
@@ -9,7 +9,7 @@
* chet@ins.cwru.edu
*/
/* Copyright (C) 1997-2021 Free Software Foundation, Inc.
/* Copyright (C) 1997-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -47,15 +47,13 @@
#define ARRAY_MAX_DOUBLE 16777216
static ARRAY_ELEMENT **array_copy_elements PARAMS((ARRAY *));
static char *array_to_string_internal PARAMS((ARRAY *, arrayind_t, arrayind_t, char *, int));
static ARRAY_ELEMENT **array_copy_elements (ARRAY *);
static char *array_to_string_internal (ARRAY *, arrayind_t, arrayind_t, char *, int);
static char *spacesep = " ";
void
array_alloc (a, n)
ARRAY *a;
arrayind_t n;
array_alloc (ARRAY *a, arrayind_t n)
{
arrayind_t i;
@@ -68,9 +66,7 @@ arrayind_t n;
}
void
array_resize (a, n)
ARRAY *a;
arrayind_t n;
array_resize (ARRAY *a, arrayind_t n)
{
ARRAY_ELEMENT **e, *ae;
arrayind_t i, nsize;
@@ -90,9 +86,7 @@ arrayind_t n;
}
void
array_expand (a, n)
ARRAY *a;
arrayind_t n;
array_expand (ARRAY *a, arrayind_t n)
{
arrayind_t nsize;
@@ -107,7 +101,7 @@ arrayind_t n;
}
ARRAY *
array_create()
array_create(void)
{
ARRAY *r;
@@ -120,8 +114,7 @@ array_create()
}
void
array_flush (a)
ARRAY *a;
array_flush (ARRAY *a)
{
int r;
@@ -141,8 +134,7 @@ ARRAY *a;
}
void
array_dispose_elements(elist)
ARRAY_ELEMENT **elist;
array_dispose_elements(ARRAY_ELEMENT **elist)
{
arrayind_t i;
@@ -154,8 +146,7 @@ ARRAY_ELEMENT **elist;
}
void
array_dispose(a)
ARRAY *a;
array_dispose(ARRAY *a)
{
if (a == 0)
return;
@@ -165,8 +156,7 @@ ARRAY *a;
}
static ARRAY_ELEMENT **
array_copy_elements (a)
ARRAY *a;
array_copy_elements (ARRAY *a)
{
ARRAY_ELEMENT **ret;
arrayind_t i;
@@ -180,8 +170,7 @@ ARRAY *a;
}
ARRAY *
array_copy(a)
ARRAY *a;
array_copy(ARRAY *a)
{
ARRAY *a1;
@@ -203,9 +192,7 @@ ARRAY *a;
* S to E, inclusive. The callers do the bounds checking.
*/
ARRAY *
array_slice(array, s, e)
ARRAY *array;
arrayind_t s, e;
array_slice(ARRAY *array, arrayind_t s, arrayind_t e)
{
ARRAY *a;
ARRAY_ELEMENT *p, *n;
@@ -239,10 +226,7 @@ arrayind_t s, e;
* element as the argument.
*/
void
array_walk(a, func, udata)
ARRAY *a;
sh_ae_map_func_t *func;
void *udata;
array_walk(ARRAY *a, sh_ae_map_func_t *func, void *udata)
{
arrayind_t i;
register ARRAY_ELEMENT *ae;
@@ -266,9 +250,7 @@ void *udata;
* returns NULL.
*/
ARRAY_ELEMENT **
array_shift(a, n, flags)
ARRAY *a;
int n, flags;
array_shift(ARRAY *a, int n, int flags)
{
ARRAY_ELEMENT **r, *ae;
register arrayind_t ni, ri;
@@ -354,10 +336,7 @@ if (j < n)
* shift.
*/
int
array_rshift (a, n, s)
ARRAY *a;
int n;
char *s;
array_rshift (ARRAY *a, int n, char *s)
{
register ARRAY_ELEMENT *ae, *new;
arrayind_t ni, nsize;
@@ -399,8 +378,7 @@ char *s;
}
ARRAY_ELEMENT *
array_unshift_element(a)
ARRAY *a;
array_unshift_element(ARRAY *a)
{
ARRAY_ELEMENT **r, *ret;
@@ -411,16 +389,13 @@ ARRAY *a;
}
int
array_shift_element(a, v)
ARRAY *a;
char *v;
array_shift_element(ARRAY *a, char *v)
{
return (array_rshift (a, 1, v));
}
ARRAY *
array_quote(array)
ARRAY *array;
array_quote(ARRAY *array)
{
register arrayind_t i;
ARRAY_ELEMENT *a;
@@ -439,8 +414,7 @@ ARRAY *array;
}
ARRAY *
array_quote_escapes(array)
ARRAY *array;
array_quote_escapes(ARRAY *array)
{
register arrayind_t i;
ARRAY_ELEMENT *a;
@@ -459,8 +433,7 @@ ARRAY *array;
}
ARRAY *
array_dequote(array)
ARRAY *array;
array_dequote(ARRAY *array)
{
register arrayind_t i;
ARRAY_ELEMENT *a;
@@ -480,8 +453,7 @@ ARRAY *array;
}
ARRAY *
array_dequote_escapes(array)
ARRAY *array;
array_dequote_escapes(ARRAY *array)
{
register arrayind_t i;
ARRAY_ELEMENT *a;
@@ -500,8 +472,7 @@ ARRAY *array;
}
ARRAY *
array_remove_quoted_nulls(array)
ARRAY *array;
array_remove_quoted_nulls(ARRAY *array)
{
register arrayind_t i;
ARRAY_ELEMENT *a;
@@ -522,10 +493,7 @@ ARRAY *array;
* Since arrays are sparse, unset array elements are not counted.
*/
char *
array_subrange (a, start, nelem, starsub, quoted, pflags)
ARRAY *a;
arrayind_t start, nelem;
int starsub, quoted, pflags;
array_subrange (ARRAY *a, arrayind_t start, arrayind_t nelem, int starsub, int quoted, int pflags)
{
ARRAY *a2;
arrayind_t s, e;
@@ -568,10 +536,7 @@ int starsub, quoted, pflags;
}
char *
array_patsub (a, pat, rep, mflags)
ARRAY *a;
char *pat, *rep;
int mflags;
array_patsub (ARRAY *a, char *pat, char *rep, int mflags)
{
char *t;
int pchar, qflags, pflags;
@@ -601,11 +566,7 @@ int mflags;
}
char *
array_modcase (a, pat, modop, mflags)
ARRAY *a;
char *pat;
int modop;
int mflags;
array_modcase (ARRAY *a, char *pat, int modop, int mflags)
{
char *t;
int pchar, qflags, pflags;
@@ -639,9 +600,7 @@ int mflags;
* VALUE.
*/
ARRAY_ELEMENT *
array_create_element(indx, value)
arrayind_t indx;
char *value;
array_create_element(arrayind_t indx, char *value)
{
ARRAY_ELEMENT *r;
@@ -652,16 +611,14 @@ char *value;
}
ARRAY_ELEMENT *
array_copy_element(ae)
ARRAY_ELEMENT *ae;
array_copy_element(ARRAY_ELEMENT *ae)
{
return(ae ? array_create_element(element_index(ae), element_value(ae))
: (ARRAY_ELEMENT *) NULL);
}
void
array_dispose_element(ae)
ARRAY_ELEMENT *ae;
array_dispose_element(ARRAY_ELEMENT *ae)
{
if (ae) {
FREE(ae->value);
@@ -673,10 +630,7 @@ ARRAY_ELEMENT *ae;
* Add a new element with index I and value V to array A (a[i] = v).
*/
int
array_insert(a, i, v)
ARRAY *a;
arrayind_t i;
char *v;
array_insert(ARRAY *a, arrayind_t i, char *v)
{
register ARRAY_ELEMENT *new, *old;
arrayind_t nsize;
@@ -709,9 +663,7 @@ char *v;
* caller can dispose of it.
*/
ARRAY_ELEMENT *
array_remove(a, i)
ARRAY *a;
arrayind_t i;
array_remove(ARRAY *a, arrayind_t i)
{
register ARRAY_ELEMENT *ae;
arrayind_t ind;
@@ -746,9 +698,7 @@ arrayind_t i;
* Return the value of a[i].
*/
char *
array_reference(a, i)
ARRAY *a;
arrayind_t i;
array_reference(ARRAY *a, arrayind_t i)
{
register ARRAY_ELEMENT *ae;
@@ -765,8 +715,7 @@ arrayind_t i;
by the rest of the code. */
WORD_LIST *
array_to_word_list(a)
ARRAY *a;
array_to_word_list(ARRAY *a)
{
register arrayind_t i;
WORD_LIST *list;
@@ -785,8 +734,7 @@ ARRAY *a;
}
ARRAY *
array_from_word_list (list)
WORD_LIST *list;
array_from_word_list (WORD_LIST *list)
{
ARRAY *a;
@@ -797,8 +745,7 @@ WORD_LIST *list;
}
WORD_LIST *
array_keys_to_word_list(a)
ARRAY *a;
array_keys_to_word_list(ARRAY *a)
{
arrayind_t ind;
WORD_LIST *list;
@@ -819,8 +766,7 @@ ARRAY *a;
}
WORD_LIST *
array_to_kvpair_list(a)
ARRAY *a;
array_to_kvpair_list (ARRAY *a)
{
arrayind_t ind;
WORD_LIST *list;
@@ -843,9 +789,7 @@ 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;
@@ -856,9 +800,7 @@ WORD_LIST *list;
}
char **
array_to_argv (a, countp)
ARRAY *a;
int *countp;
array_to_argv (ARRAY *a, int *countp)
{
char **ret, *t;
int i;
@@ -883,10 +825,7 @@ int *countp;
}
ARRAY *
array_from_argv(a, vec, count)
ARRAY *a;
char **vec;
int count;
array_from_argv(ARRAY *a, char **vec, int count)
{
arrayind_t i;
char *t;
@@ -935,9 +874,7 @@ int count;
* Return the next non-null array element after A[IND]
*/
arrayind_t
element_forw(a, ind)
ARRAY *a;
arrayind_t ind;
element_forw(ARRAY *a, arrayind_t ind)
{
register arrayind_t i;
@@ -953,9 +890,7 @@ arrayind_t ind;
* Return the previous non-null array element before A[IND]
*/
arrayind_t
element_back (a, ind)
ARRAY *a;
arrayind_t ind;
element_back (ARRAY *a, arrayind_t ind)
{
register arrayind_t i;
@@ -972,11 +907,7 @@ arrayind_t ind;
* to END, separated by SEP.
*/
static char *
array_to_string_internal (a, start, end, sep, quoted)
ARRAY *a;
arrayind_t start, end;
char *sep;
int quoted;
array_to_string_internal (ARRAY *a, arrayind_t start, arrayind_t end, char *sep, int quoted)
{
arrayind_t i;
char *result, *t;
@@ -1014,9 +945,7 @@ int quoted;
}
char *
array_to_kvpair (a, quoted)
ARRAY *a;
int quoted;
array_to_kvpair (ARRAY *a, int quoted)
{
arrayind_t ind;
char *result, *valstr, *is;
@@ -1071,9 +1000,7 @@ int quoted;
}
char *
array_to_assign (a, quoted)
ARRAY *a;
int quoted;
array_to_assign (ARRAY *a, int quoted)
{
arrayind_t ind;
char *result, *valstr, *is;
@@ -1128,10 +1055,7 @@ int quoted;
}
char *
array_to_string (a, sep, quoted)
ARRAY *a;
char *sep;
int quoted;
array_to_string (ARRAY *a, char *sep, int quoted)
{
if (a == 0)
return((char *)NULL);
@@ -1145,8 +1069,7 @@ int quoted;
* Return an array consisting of elements in S, separated by SEP
*/
ARRAY *
array_from_string(s, sep)
char *s, *sep;
array_from_string(char *s, char *sep)
{
ARRAY *a;
WORD_LIST *w;
@@ -1169,8 +1092,7 @@ char *s, *sep;
int interrupt_immediately = 0;
int
signal_is_trapped(s)
int s;
signal_is_trapped(int s)
{
return 0;
}
@@ -1190,8 +1112,7 @@ programming_error(const char *s, ...)
}
WORD_DESC *
make_bare_word (s)
const char *s;
make_bare_word (const char *s)
{
WORD_DESC *w;
@@ -1202,9 +1123,7 @@ const char *s;
}
WORD_LIST *
make_word_list(x, l)
WORD_DESC *x;
WORD_LIST *l;
make_word_list(WORD_DESC *x, WORD_LIST *l)
{
WORD_LIST *w;
@@ -1215,9 +1134,7 @@ WORD_LIST *l;
}
WORD_LIST *
list_string(s, t, i)
char *s, *t;
int i;
list_string(char *s, char *t, int i)
{
char *r, *a;
WORD_LIST *wl;
@@ -1235,8 +1152,7 @@ int i;
}
GENERIC_LIST *
list_reverse (list)
GENERIC_LIST *list;
list_reverse (GENERIC_LIST *list)
{
register GENERIC_LIST *next, *prev;
@@ -1250,22 +1166,19 @@ GENERIC_LIST *list;
}
char *
pat_subst(s, t, u, i)
char *s, *t, *u;
int i;
pat_subst(char *s, char *t, char *u, int i)
{
return ((char *)NULL);
}
char *
quote_string(s)
char *s;
quote_string(char *s)
{
return savestring(s);
}
print_element(ae)
ARRAY_ELEMENT *ae;
void
print_element(ARRAY_ELEMENT *ae)
{
char lbuf[INT_STRLEN_BOUND (intmax_t) + 1];
@@ -1274,14 +1187,15 @@ ARRAY_ELEMENT *ae;
element_value(ae));
}
print_array(a)
ARRAY *a;
void
print_array(ARRAY *a)
{
printf("\n");
array_walk(a, print_element, (void *)NULL);
}
main()
int
main(int c, char **v)
{
ARRAY *a, *new_a, *copy_of_a;
ARRAY_ELEMENT *ae, *aew;