xmalloc.c, array2.c, list.c, dispose_cmd.c, copy_cmd.c, bracecomp.c, mksyntax.c
- PARAMS: remove for ANSI C-ification
- C89-style function declarations
+
+ 12/30
+ -----
+hashlib.c,assoc.c,input.c,hashcmd.c,alias.c,alias.h,array.c,flags.c,pcomplib.c,
+pcomplib.h,locale.c
+variables.c,arrayfunc.c,bashhist.c,bashline.c,error.c,pathexp.c,nojobs.c,
+stringlib.c,eval.c,findcmd.c,mailcheck.c,make_cmd.c,shell.c,print_cmd.c,
+general.c,expr.c
+ - PARAMS: remove for ANSI C-ification
+ - C89-style function declarations
+ - add `const' and `inline' where it makes sense
+
+ 12/31
+ -----
+test.c,execute_cmd.c,parse.y,pcomplete.c,trap.c,subst.c,braces.c,jobs.c,sig.c
+builtins/{evalstring.c,gen-helpfiles.c,mkbuiltins.c}
+builtins/{alias.def,bind.def,break.def,builtin.def,caller.def,cd.def,colon.def}
+builtins/{command.def,complete.def,declare.def,echo.def,enable.def,eval.def}
+builtins/{exec.def,exit.def,fc.def,fg_bg.def,hash.def,help.def,history.def}
+builtins/{jobs.def,kill.def,let.def,mapfile.def,printf.def,pushd.def,read.def}
+builtins/{return.def,set.def,setattr.def,shift.def,shopt.def,source.def}
+builtins/{suspend.def,test.def,times.def,trap.def,type.def,ulimit.def}
+builtins/{umask.def,wait.def}
+ - PARAMS: remove for ANSI C-ification
+ - C89-style function declarations
+ - add `const' and `inline' where it makes sense
+
/* alias.c -- Not a full alias, but just the kind that we use in the
shell. Csh style alias is somewhere else (`over there, in a box'). */
-/* Copyright (C) 1987-2021 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
#define ALIAS_HASH_BUCKETS 64 /* must be power of two */
-typedef int sh_alias_map_func_t PARAMS((alias_t *));
+typedef int sh_alias_map_func_t (alias_t *);
-static void free_alias_data PARAMS((PTR_T));
-static alias_t **map_over_aliases PARAMS((sh_alias_map_func_t *));
-static void sort_aliases PARAMS((alias_t **));
-static int qsort_alias_compare PARAMS((alias_t **, alias_t **));
+static void free_alias_data (PTR_T);
+static alias_t **map_over_aliases (sh_alias_map_func_t *);
+static void sort_aliases (alias_t **);
+static int qsort_alias_compare (alias_t **, alias_t **);
#if defined (READLINE)
-static int skipquotes PARAMS((char *, int));
-static int skipws PARAMS((char *, int));
-static int rd_token PARAMS((char *, int));
+static int skipquotes (char *, int);
+static int skipws (char *, int);
+static int rd_token (char *, int);
#endif
/* Non-zero means expand all words on the line. Otherwise, expand
HASH_TABLE *aliases = (HASH_TABLE *)NULL;
void
-initialize_aliases ()
+initialize_aliases (void)
{
if (aliases == 0)
aliases = hash_create (ALIAS_HASH_BUCKETS);
/* Scan the list of aliases looking for one with NAME. Return NULL
if the alias doesn't exist, else a pointer to the alias_t. */
alias_t *
-find_alias (name)
- char *name;
+find_alias (const char *name)
{
BUCKET_CONTENTS *al;
/* Return the value of the alias for NAME, or NULL if there is none. */
char *
-get_alias_value (name)
- char *name;
+get_alias_value (const char *name)
{
alias_t *alias;
/* Make a new alias from NAME and VALUE. If NAME can be found,
then replace its value. */
void
-add_alias (name, value)
- char *name, *value;
+add_alias (const char *name, const char *value)
{
BUCKET_CONTENTS *elt;
alias_t *temp;
/* Delete a single alias structure. */
static void
-free_alias_data (data)
- PTR_T data;
+free_alias_data (PTR_T data)
{
register alias_t *a;
the number of aliases left in the table, or -1 if the alias didn't
exist. */
int
-remove_alias (name)
- char *name;
+remove_alias (const char *name)
{
BUCKET_CONTENTS *elt;
/* Delete all aliases. */
void
-delete_all_aliases ()
+delete_all_aliases (void)
{
if (aliases == 0)
return;
/* Return an array of aliases that satisfy the conditions tested by FUNCTION.
If FUNCTION is NULL, return all aliases. */
static alias_t **
-map_over_aliases (function)
- sh_alias_map_func_t *function;
+map_over_aliases (sh_alias_map_func_t *function)
{
register int i;
register BUCKET_CONTENTS *tlist;
return (list);
}
-static void
-sort_aliases (array)
- alias_t **array;
-{
- qsort (array, strvec_len ((char **)array), sizeof (alias_t *), (QSFUNC *)qsort_alias_compare);
-}
-
static int
-qsort_alias_compare (as1, as2)
- alias_t **as1, **as2;
+qsort_alias_compare (alias_t **as1, alias_t **as2)
{
int result;
return (result);
}
+static void
+sort_aliases (alias_t **array)
+{
+ qsort (array, strvec_len ((char **)array), sizeof (alias_t *), (QSFUNC *)qsort_alias_compare);
+}
+
/* Return a sorted list of all defined aliases */
alias_t **
-all_aliases ()
+all_aliases (void)
{
alias_t **list;
}
char *
-alias_expand_word (s)
- char *s;
+alias_expand_word (const char *s)
{
alias_t *r;
backslash-escaped characters. */
static int
-skipquotes (string, start)
- char *string;
- int start;
+skipquotes (char *string, int start)
{
register int i;
int delimiter = string[start];
START. Return the new index into STRING, after zero or more characters
have been skipped. */
static int
-skipws (string, start)
- char *string;
- int start;
+skipws (char *string, int start)
{
register int i;
int pass_next, backslash_quoted_word;
skipquotes () for quoted strings in the middle or at the end of tokens,
so all characters show up (e.g. foo'' and foo""bar) */
static int
-rd_token (string, start)
- char *string;
- int start;
+rd_token (char *string, int start)
{
register int i;
/* Return a new line, with any aliases substituted. */
char *
-alias_expand (string)
- char *string;
+
+alias_expand (char *string)
{
+
register int i, j, start;
char *line, *token;
int line_len, tl, real_start, expand_next, expand_this_token;
/* Scan the list of aliases looking for one with NAME. Return NULL
if the alias doesn't exist, else a pointer to the alias. */
-extern alias_t *find_alias (char *);
+extern alias_t *find_alias (const char *);
/* Return the value of the alias for NAME, or NULL if there is none. */
-extern char *get_alias_value (char *);
+extern char *get_alias_value (const char *);
/* Make a new alias from NAME and VALUE. If NAME can be found,
then replace its value. */
-extern void add_alias (char *, char *);
+extern void add_alias (const char *, const char *);
/* Remove the alias with name NAME from the alias list. Returns
the index of the removed alias, or -1 if the alias didn't exist. */
-extern int remove_alias (char *);
+extern int remove_alias (const char *);
/* Remove all aliases. */
extern void delete_all_aliases (void);
extern alias_t **all_aliases (void);
/* Expand a single word for aliases. */
-extern char *alias_expand_word (char *);
+extern char *alias_expand_word (const char *);
/* Return a new line, with any aliases expanded. */
extern char *alias_expand (char *);
* chet@ins.cwru.edu
*/
-/* Copyright (C) 1997-2021 Free Software Foundation, Inc.
+/* Copyright (C) 1997-2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
ae->next = new; \
} while (0)
-static char *array_to_string_internal PARAMS((ARRAY_ELEMENT *, ARRAY_ELEMENT *, char *, int));
+static char *array_to_string_internal (ARRAY_ELEMENT *, ARRAY_ELEMENT *, char *, int);
static char *spacesep = " ";
#define UNSET_LASTREF(a) a->lastref = 0;
ARRAY *
-array_create()
+array_create(void)
{
ARRAY *r;
ARRAY_ELEMENT *head;
}
void
-array_flush (a)
-ARRAY *a;
+array_flush (ARRAY *a)
{
register ARRAY_ELEMENT *r, *r1;
}
void
-array_dispose(a)
-ARRAY *a;
+array_dispose(ARRAY *a)
{
if (a == 0)
return;
}
ARRAY *
-array_copy(a)
-ARRAY *a;
+array_copy(ARRAY *a)
{
ARRAY *a1;
ARRAY_ELEMENT *ae, *new;
* S to E, inclusive.
*/
ARRAY *
-array_slice(array, s, e)
-ARRAY *array;
-ARRAY_ELEMENT *s, *e;
+array_slice(ARRAY *array, ARRAY_ELEMENT *s, ARRAY_ELEMENT *e)
{
ARRAY *a;
ARRAY_ELEMENT *p, *n;
* 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)
{
register ARRAY_ELEMENT *ae;
* and returns NULL.
*/
ARRAY_ELEMENT *
-array_shift(a, n, flags)
-ARRAY *a;
-int n, flags;
+array_shift(ARRAY *a, int n, int flags)
{
register ARRAY_ELEMENT *ae, *ret;
register int i;
* 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;
}
ARRAY_ELEMENT *
-array_unshift_element(a)
-ARRAY *a;
+array_unshift_element(ARRAY *a)
{
return (array_shift (a, 1, 0));
}
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)
{
ARRAY_ELEMENT *a;
char *t;
}
ARRAY *
-array_quote_escapes(array)
-ARRAY *array;
+array_quote_escapes(ARRAY *array)
{
ARRAY_ELEMENT *a;
char *t;
}
ARRAY *
-array_dequote(array)
-ARRAY *array;
+array_dequote(ARRAY *array)
{
ARRAY_ELEMENT *a;
char *t;
}
ARRAY *
-array_dequote_escapes(array)
-ARRAY *array;
+array_dequote_escapes(ARRAY *array)
{
ARRAY_ELEMENT *a;
char *t;
}
ARRAY *
-array_remove_quoted_nulls(array)
-ARRAY *array;
+array_remove_quoted_nulls(ARRAY *array)
{
ARRAY_ELEMENT *a;
* 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;
ARRAY_ELEMENT *h, *p;
}
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;
}
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;
* VALUE.
*/
ARRAY_ELEMENT *
-array_create_element(indx, value)
-arrayind_t indx;
-char *value;
+array_create_element(arrayind_t indx, char *value)
{
ARRAY_ELEMENT *r;
#ifdef INCLUDE_UNUSED
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);
#endif
void
-array_dispose_element(ae)
-ARRAY_ELEMENT *ae;
+array_dispose_element(ARRAY_ELEMENT *ae)
{
if (ae) {
FREE(ae->value);
* 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, *ae, *start;
arrayind_t startind;
* 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, *start;
arrayind_t startind;
* 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, *start;
arrayind_t startind;
by the rest of the code. */
WORD_LIST *
-array_to_word_list(a)
-ARRAY *a;
+array_to_word_list(ARRAY *a)
{
WORD_LIST *list;
ARRAY_ELEMENT *ae;
}
ARRAY *
-array_from_word_list (list)
-WORD_LIST *list;
+array_from_word_list (WORD_LIST *list)
{
ARRAY *a;
}
WORD_LIST *
-array_keys_to_word_list(a)
-ARRAY *a;
+array_keys_to_word_list(ARRAY *a)
{
WORD_LIST *list;
ARRAY_ELEMENT *ae;
}
WORD_LIST *
-array_to_kvpair_list(a)
-ARRAY *a;
+array_to_kvpair_list(ARRAY *a)
{
WORD_LIST *list;
ARRAY_ELEMENT *ae;
}
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;
}
char **
-array_to_argv (a, countp)
-ARRAY *a;
-int *countp;
+array_to_argv (ARRAY *a, int *countp)
{
char **ret, *t;
int i;
}
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;
ARRAY_ELEMENT *ae;
* to END, separated by SEP.
*/
static char *
-array_to_string_internal (start, end, sep, quoted)
-ARRAY_ELEMENT *start, *end;
-char *sep;
-int quoted;
+array_to_string_internal (ARRAY_ELEMENT *start, ARRAY_ELEMENT *end, char *sep, int quoted)
{
char *result, *t;
ARRAY_ELEMENT *ae;
}
char *
-array_to_kvpair (a, quoted)
-ARRAY *a;
-int quoted;
+array_to_kvpair (ARRAY *a, int quoted)
{
char *result, *valstr, *is;
char indstr[INT_STRLEN_BOUND(intmax_t) + 1];
}
char *
-array_to_assign (a, quoted)
-ARRAY *a;
-int quoted;
+array_to_assign (ARRAY *a, int quoted)
{
char *result, *valstr, *is;
char indstr[INT_STRLEN_BOUND(intmax_t) + 1];
}
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);
* 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;
int interrupt_immediately = 0;
int
-signal_is_trapped(s)
-int s;
+signal_is_trapped(int s)
{
return 0;
}
}
WORD_DESC *
-make_bare_word (s)
-const char *s;
+make_bare_word (const char *s)
{
WORD_DESC *w;
}
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;
}
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;
}
GENERIC_LIST *
-list_reverse (list)
-GENERIC_LIST *list;
+list_reverse (GENERIC_LIST *list)
{
register GENERIC_LIST *next, *prev;
}
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;
+print_element(ARRAY_ELEMENT *ae)
{
char lbuf[INT_STRLEN_BOUND (intmax_t) + 1];
element_value(ae));
}
-print_array(a)
-ARRAY *a;
+print_array(ARRAY *a)
{
printf("\n");
array_walk(a, print_element, (void *)NULL);
}
-main()
+main(int c, char **v)
{
ARRAY *a, *new_a, *copy_of_a;
ARRAY_ELEMENT *ae, *aew;
/* arrayfunc.c -- High-level array functions used by other parts of the shell. */
-/* Copyright (C) 2001-2021 Free Software Foundation, Inc.
+/* Copyright (C) 2001-2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
/* Ditto for indexed array subscripts -- currently unused */
int array_expand_once = 0;
-static SHELL_VAR *bind_array_var_internal PARAMS((SHELL_VAR *, arrayind_t, char *, char *, int));
-static SHELL_VAR *assign_array_element_internal PARAMS((SHELL_VAR *, char *, char *, char *, int, char *, int, array_eltstate_t *));
+static SHELL_VAR *bind_array_var_internal (SHELL_VAR *, arrayind_t, char *, char *, int);
+static SHELL_VAR *assign_array_element_internal (SHELL_VAR *, char *, char *, char *, int, char *, int, array_eltstate_t *);
-static void assign_assoc_from_kvlist PARAMS((SHELL_VAR *, WORD_LIST *, HASH_TABLE *, int));
+static void assign_assoc_from_kvlist (SHELL_VAR *, WORD_LIST *, HASH_TABLE *, int);
-static char *quote_assign PARAMS((const char *));
-static void quote_array_assignment_chars PARAMS((WORD_LIST *));
-static char *quote_compound_array_word PARAMS((char *, int));
-static char *array_value_internal PARAMS((const char *, int, int, array_eltstate_t *));
+static char *quote_assign (const char *);
+static void quote_array_assignment_chars (WORD_LIST *);
+static char *quote_compound_array_word (char *, int);
+static char *array_value_internal (const char *, int, int, array_eltstate_t *);
/* Standard error message to use when encountering an invalid array subscript */
const char * const bash_badsub_errmsg = N_("bad array subscript");
/* Convert a shell variable to an array variable. The original value is
saved as array[0]. */
SHELL_VAR *
-convert_var_to_array (var)
- SHELL_VAR *var;
+convert_var_to_array (SHELL_VAR *var)
{
char *oldval;
ARRAY *array;
/* Convert a shell variable to an array variable. The original value is
saved as array[0]. */
SHELL_VAR *
-convert_var_to_assoc (var)
- SHELL_VAR *var;
+convert_var_to_assoc (SHELL_VAR *var)
{
char *oldval;
HASH_TABLE *hash;
}
char *
-make_array_variable_value (entry, ind, key, value, flags)
- SHELL_VAR *entry;
- arrayind_t ind;
- char *key;
- char *value;
- int flags;
+make_array_variable_value (SHELL_VAR *entry, arrayind_t ind, char *key, char *value, int flags)
{
SHELL_VAR *dentry;
char *newval;
XXX - make sure that any dynamic associative array variables recreate the
hash table on each assignment. BASH_CMDS and BASH_ALIASES already do this */
static SHELL_VAR *
-bind_assoc_var_internal (entry, hash, key, value, flags)
- SHELL_VAR *entry;
- HASH_TABLE *hash;
- char *key;
- char *value;
- int flags;
+bind_assoc_var_internal (SHELL_VAR *entry, HASH_TABLE *hash, char *key, char *value, int flags)
{
char *newval;
/* Perform ENTRY[IND]=VALUE or ENTRY[KEY]=VALUE. This is not called for every
assignment to an associative array; see assign_compound_array_list below. */
static SHELL_VAR *
-bind_array_var_internal (entry, ind, key, value, flags)
- SHELL_VAR *entry;
- arrayind_t ind;
- char *key;
- char *value;
- int flags;
+bind_array_var_internal (SHELL_VAR *entry, arrayind_t ind, char *key, char *value, int flags)
{
char *newval;
If NAME does not exist, just create an array variable, no matter what
IND's value may be. */
SHELL_VAR *
-bind_array_variable (name, ind, value, flags)
- char *name;
- arrayind_t ind;
- char *value;
- int flags;
+bind_array_variable (char *name, arrayind_t ind, char *value, int flags)
{
SHELL_VAR *entry;
}
SHELL_VAR *
-bind_array_element (entry, ind, value, flags)
- SHELL_VAR *entry;
- arrayind_t ind;
- char *value;
- int flags;
+bind_array_element (SHELL_VAR *entry, arrayind_t ind, char *value, int flags)
{
return (bind_array_var_internal (entry, ind, 0, value, flags));
}
SHELL_VAR *
-bind_assoc_variable (entry, name, key, value, flags)
- SHELL_VAR *entry;
- char *name;
- char *key;
- char *value;
- int flags;
+bind_assoc_variable (SHELL_VAR *entry, char *name, char *key, char *value, int flags)
{
if ((readonly_p (entry) && (flags&ASS_FORCE) == 0) || noassign_p (entry))
{
assign VALUE to that array element by calling bind_array_variable().
Flags are ASS_ assignment flags */
SHELL_VAR *
-assign_array_element (name, value, flags, estatep)
- char *name, *value;
- int flags;
- array_eltstate_t *estatep;
+assign_array_element (char *name, char *value, int flags, array_eltstate_t *estatep)
{
char *sub, *vname;
int sublen, isassoc, avflags;
}
static SHELL_VAR *
-assign_array_element_internal (entry, name, vname, sub, sublen, value, flags, estatep)
- SHELL_VAR *entry;
- char *name; /* only used for error messages */
- char *vname;
- char *sub;
- int sublen;
- char *value;
- int flags;
- array_eltstate_t *estatep;
+assign_array_element_internal (SHELL_VAR *entry, char *name, char *vname,
+ char *sub, int sublen, char *value,
+ int flags, array_eltstate_t *estatep)
{
char *akey, *nkey;
arrayind_t ind;
for assignment (e.g., by the `read' builtin). If FLAGS&2 is non-zero, we
create an associative array. */
SHELL_VAR *
-find_or_make_array_variable (name, flags)
- char *name;
- int flags;
+find_or_make_array_variable (char *name, int flags)
{
SHELL_VAR *var;
/* Perform a compound assignment statement for array NAME, where VALUE is
the text between the parens: NAME=( VALUE ) */
SHELL_VAR *
-assign_array_from_string (name, value, flags)
- char *name, *value;
- int flags;
+assign_array_from_string (char *name, char *value, int flags)
{
SHELL_VAR *var;
int vflags;
/* Sequentially assign the indices of indexed array variable VAR from the
words in LIST. */
SHELL_VAR *
-assign_array_var_from_word_list (var, list, flags)
- SHELL_VAR *var;
- WORD_LIST *list;
- int flags;
+assign_array_var_from_word_list (SHELL_VAR *var, WORD_LIST *list, int flags)
{
register arrayind_t i;
register WORD_LIST *l;
}
WORD_LIST *
-expand_compound_array_assignment (var, value, flags)
- SHELL_VAR *var;
- char *value;
- int flags;
+expand_compound_array_assignment (SHELL_VAR *var, char *value, int flags)
{
WORD_LIST *list, *nlist;
char *val;
#if ASSOC_KVPAIR_ASSIGNMENT
static void
-assign_assoc_from_kvlist (var, nlist, h, flags)
- SHELL_VAR *var;
- WORD_LIST *nlist;
- HASH_TABLE *h;
- int flags;
+assign_assoc_from_kvlist (SHELL_VAR *var, WORD_LIST *nlist, HASH_TABLE *h, int flags)
{
WORD_LIST *list;
char *akey, *aval, *k, *v;
/* Return non-zero if L appears to be a key-value pair associative array
compound assignment. */
int
-kvpair_assignment_p (l)
- WORD_LIST *l;
+kvpair_assignment_p (WORD_LIST *l)
{
return (l && (l->word->flags & W_ASSIGNMENT) == 0 && l->word->word[0] != '['); /*]*/
}
char *
-expand_and_quote_kvpair_word (w)
- char *w;
+expand_and_quote_kvpair_word (char *w)
{
char *r, *s, *t;
If this is an associative array, we perform the assignments into NHASH and
set NHASH to be the value of VAR after processing the assignments in NLIST */
void
-assign_compound_array_list (var, nlist, flags)
- SHELL_VAR *var;
- WORD_LIST *nlist;
- int flags;
+assign_compound_array_list (SHELL_VAR *var, WORD_LIST *nlist, int flags)
{
ARRAY *a;
HASH_TABLE *h, *nhash;
/* Perform a compound array assignment: VAR->name=( VALUE ). The
VALUE has already had the parentheses stripped. */
SHELL_VAR *
-assign_array_var_from_string (var, value, flags)
- SHELL_VAR *var;
- char *value;
- int flags;
+assign_array_var_from_string (SHELL_VAR *var, char *value, int flags)
{
WORD_LIST *nlist;
statement (usually a compound array assignment) to protect them from
unwanted filename expansion or word splitting. */
static char *
-quote_assign (string)
- const char *string;
+quote_assign (const char *string)
{
size_t slen;
int saw_eq;
indexed arrays. W has already undergone word expansions. If W has no [IND]=,
just single-quote and return it. */
static char *
-quote_compound_array_word (w, type)
- char *w;
- int type;
+quote_compound_array_word (char *w, int type)
{
char *nword, *sub, *value, *t;
int ind, wlen, i;
Used for compound assignments to associative arrays that are arguments to
declaration builtins (declare -A a=( list )). */
char *
-expand_and_quote_assoc_word (w, type)
- char *w;
- int type;
+expand_and_quote_assoc_word (char *w, int type)
{
char *nword, *key, *value, *s, *t;
int ind, wlen, i;
the = sign (and any `+') alone. If it's not an assignment, just single-
quote the word. This is used for indexed arrays. */
void
-quote_compound_array_list (list, type)
- WORD_LIST *list;
- int type;
+quote_compound_array_list (WORD_LIST *list, int type)
{
char *s, *t;
WORD_LIST *l;
/* For each word in a compound array assignment, if the word looks like
[ind]=value, quote globbing chars and characters in $IFS before the `='. */
static void
-quote_array_assignment_chars (list)
- WORD_LIST *list;
+quote_array_assignment_chars (WORD_LIST *list)
{
char *nword;
WORD_LIST *l;
the subscript, we just assume the subscript ends with a close bracket,
if one is present, and use what's inside the brackets. */
int
-unbind_array_element (var, sub, flags)
- SHELL_VAR *var;
- char *sub;
- int flags;
+unbind_array_element (SHELL_VAR *var, char *sub, int flags)
{
arrayind_t ind;
char *akey;
/* Format and output an array assignment in compound form VAR=(VALUES),
suitable for re-use as input. */
void
-print_array_assignment (var, quoted)
- SHELL_VAR *var;
- int quoted;
+print_array_assignment (SHELL_VAR *var, int quoted)
{
char *vstr;
/* Format and output an associative array assignment in compound form
VAR=(VALUES), suitable for re-use as input. */
void
-print_assoc_assignment (var, quoted)
- SHELL_VAR *var;
- int quoted;
+print_assoc_assignment (SHELL_VAR *var, int quoted)
{
char *vstr;
/* Return 1 if NAME is a properly-formed array reference v[sub]. */
-/* Return 1 if NAME is a properly-formed array reference v[sub]. */
-
/* When NAME is a properly-formed array reference and a non-null argument SUBP
is supplied, '[' and ']' that enclose the subscript are replaced by '\0',
and the pointer to the subscript in NAME is assigned to *SUBP, so that NAME
not be modified. */
/* We need to reserve 1 for FLAGS, which we pass to skipsubscript. */
int
-tokenize_array_reference (name, flags, subp)
- char *name;
- int flags;
- char **subp;
+tokenize_array_reference (char *name, int flags, char **subp)
{
char *t;
int r, len, isassoc, ssflags;
/* We need to reserve 1 for FLAGS, which we pass to skipsubscript. */
int
-valid_array_reference (name, flags)
- const char *name;
- int flags;
+valid_array_reference (const char *name, int flags)
{
return tokenize_array_reference ((char *)name, flags, (char **)NULL);
}
/* Expand the array index beginning at S and extending LEN characters. */
arrayind_t
-array_expand_index (var, s, len, flags)
- SHELL_VAR *var;
- char *s;
- int len;
- int flags;
+array_expand_index (SHELL_VAR *var, char *s, int len, int flags)
{
char *exp, *t, *savecmd;
int expok, eflag;
in *SUBP. If LENP is non-null, the length of the subscript is returned
in *LENP. This returns newly-allocated memory. */
char *
-array_variable_name (s, flags, subp, lenp)
- const char *s;
- int flags;
- char **subp;
- int *lenp;
+array_variable_name (const char *s, int flags, char **subp, int *lenp)
{
char *t, *ret;
int ind, ni, ssflags;
non-null, return a pointer to the start of the subscript in *SUBP.
If LENP is non-null, the length of the subscript is returned in *LENP. */
SHELL_VAR *
-array_variable_part (s, flags, subp, lenp)
- const char *s;
- int flags;
- char **subp;
- int *lenp;
+array_variable_part (const char *s, int flags, char **subp, int *lenp)
{
char *t;
SHELL_VAR *var;
is non-null it gets 1 if the array reference is name[*], 2 if the
reference is name[@], and 0 otherwise. */
static char *
-array_value_internal (s, quoted, flags, estatep)
- const char *s;
- int quoted, flags;
- array_eltstate_t *estatep;
+array_value_internal (const char *s, int quoted, int flags, array_eltstate_t *estatep)
{
int len, isassoc, subtype;
arrayind_t ind;
/* Return a string containing the elements described by the array and
subscript contained in S, obeying quoting for subscripts * and @. */
char *
-array_value (s, quoted, flags, estatep)
- const char *s;
- int quoted, flags;
- array_eltstate_t *estatep;
+array_value (const char *s, int quoted, int flags, array_eltstate_t *estatep)
{
char *retval;
is used by other parts of the shell such as the arithmetic expression
evaluator in expr.c. */
char *
-get_array_value (s, flags, estatep)
- const char *s;
- int flags;
- array_eltstate_t *estatep;
+get_array_value (const char *s, int flags, array_eltstate_t *estatep)
{
char *retval;
}
char *
-array_keys (s, quoted, pflags)
- char *s;
- int quoted, pflags;
+array_keys (char *s, int quoted, int pflags)
{
int len;
char *retval, *t, *temp;
* chet@ins.cwru.edu
*/
-/* Copyright (C) 2008,2009,2011-2021 Free Software Foundation, Inc.
+/* Copyright (C) 2008,2009,2011-2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
#include "assoc.h"
#include "builtins/common.h"
-static WORD_LIST *assoc_to_word_list_internal PARAMS((HASH_TABLE *, int));
+static WORD_LIST *assoc_to_word_list_internal (HASH_TABLE *, int);
/* assoc_create == hash_create */
void
-assoc_dispose (hash)
- HASH_TABLE *hash;
+assoc_dispose (HASH_TABLE *hash)
{
if (hash)
{
}
void
-assoc_flush (hash)
- HASH_TABLE *hash;
+assoc_flush (HASH_TABLE *hash)
{
hash_flush (hash, 0);
}
int
-assoc_insert (hash, key, value)
- HASH_TABLE *hash;
- char *key;
- char *value;
+assoc_insert (HASH_TABLE *hash, char *key, char *value)
{
BUCKET_CONTENTS *b;
/* Like assoc_insert, but returns b->data instead of freeing it */
PTR_T
-assoc_replace (hash, key, value)
- HASH_TABLE *hash;
- char *key;
- char *value;
+assoc_replace (HASH_TABLE *hash, char *key, char *value)
{
BUCKET_CONTENTS *b;
PTR_T t;
}
void
-assoc_remove (hash, string)
- HASH_TABLE *hash;
- char *string;
+assoc_remove (HASH_TABLE *hash, char *string)
{
BUCKET_CONTENTS *b;
}
char *
-assoc_reference (hash, string)
- HASH_TABLE *hash;
- char *string;
+assoc_reference (HASH_TABLE *hash, char *string)
{
BUCKET_CONTENTS *b;
/* Quote the data associated with each element of the hash table ASSOC,
using quote_string */
HASH_TABLE *
-assoc_quote (h)
- HASH_TABLE *h;
+assoc_quote (HASH_TABLE *h)
{
int i;
BUCKET_CONTENTS *tlist;
/* Quote escape characters in the data associated with each element
of the hash table ASSOC, using quote_escapes */
HASH_TABLE *
-assoc_quote_escapes (h)
- HASH_TABLE *h;
+assoc_quote_escapes (HASH_TABLE *h)
{
int i;
BUCKET_CONTENTS *tlist;
}
HASH_TABLE *
-assoc_dequote (h)
- HASH_TABLE *h;
+assoc_dequote (HASH_TABLE *h)
{
int i;
BUCKET_CONTENTS *tlist;
}
HASH_TABLE *
-assoc_dequote_escapes (h)
- HASH_TABLE *h;
+assoc_dequote_escapes (HASH_TABLE *h)
{
int i;
BUCKET_CONTENTS *tlist;
}
HASH_TABLE *
-assoc_remove_quoted_nulls (h)
- HASH_TABLE *h;
+assoc_remove_quoted_nulls (HASH_TABLE *h)
{
int i;
BUCKET_CONTENTS *tlist;
* the STARTth element and spanning NELEM members. Null elements are counted.
*/
char *
-assoc_subrange (hash, start, nelem, starsub, quoted, pflags)
- HASH_TABLE *hash;
- arrayind_t start, nelem;
- int starsub, quoted, pflags;
+assoc_subrange (HASH_TABLE *hash, arrayind_t start, arrayind_t nelem, int starsub, int quoted, int pflags)
{
WORD_LIST *l, *save, *h, *t;
int i, j;
dispose_words (save);
return (ret);
-
}
+/* Substitute REP for each match of PAT in each element of hash table H,
+ qualified by FLAGS to say what kind of quoting to do. */
char *
-assoc_patsub (h, pat, rep, mflags)
- HASH_TABLE *h;
- char *pat, *rep;
- int mflags;
+assoc_patsub (HASH_TABLE *h, char *pat, char *rep, int mflags)
{
char *t;
int pchar, qflags, pflags;
}
char *
-assoc_modcase (h, pat, modop, mflags)
- HASH_TABLE *h;
- char *pat;
- int modop;
- int mflags;
+assoc_modcase (HASH_TABLE *h, char *pat, int modop, int mflags)
{
char *t;
int pchar, qflags, pflags;
}
char *
-assoc_to_kvpair (hash, quoted)
- HASH_TABLE *hash;
- int quoted;
+assoc_to_kvpair (HASH_TABLE *hash, int quoted)
{
char *ret;
char *istr, *vstr;
}
char *
-assoc_to_assign (hash, quoted)
- HASH_TABLE *hash;
- int quoted;
+assoc_to_assign (HASH_TABLE *hash, int quoted)
{
char *ret;
char *istr, *vstr;
}
static WORD_LIST *
-assoc_to_word_list_internal (h, t)
- HASH_TABLE *h;
- int t;
+assoc_to_word_list_internal (HASH_TABLE *h, int t)
{
WORD_LIST *list;
int i;
}
WORD_LIST *
-assoc_to_word_list (h)
- HASH_TABLE *h;
+assoc_to_word_list (HASH_TABLE *h)
{
return (assoc_to_word_list_internal (h, 0));
}
WORD_LIST *
-assoc_keys_to_word_list (h)
- HASH_TABLE *h;
+assoc_keys_to_word_list (HASH_TABLE *h)
{
return (assoc_to_word_list_internal (h, 1));
}
WORD_LIST *
-assoc_to_kvpair_list (h)
- HASH_TABLE *h;
+assoc_to_kvpair_list (HASH_TABLE *h)
{
WORD_LIST *list;
int i;
}
char *
-assoc_to_string (h, sep, quoted)
- HASH_TABLE *h;
- char *sep;
- int quoted;
+assoc_to_string (HASH_TABLE *h, char *sep, int quoted)
{
BUCKET_CONTENTS *tlist;
int i;
/* bashhist.c -- bash interface to the GNU history library. */
-/* Copyright (C) 1993-2021 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
extern int errno;
#endif
-static int histignore_item_func PARAMS((struct ign *));
-static int check_history_control PARAMS((char *));
-static void hc_erasedups PARAMS((char *));
-static void really_add_history PARAMS((char *));
+static int histignore_item_func (struct ign *);
+static int check_history_control (char *);
+static void hc_erasedups (char *);
+static void really_add_history (char *);
static struct ignorevar histignore =
{
int dont_save_function_defs;
#if defined (BANG_HISTORY)
-static int bash_history_inhibit_expansion PARAMS((char *, int));
+static int bash_history_inhibit_expansion (char *, int);
#endif
#if defined (READLINE)
-static void re_edit PARAMS((char *));
+static void re_edit (char *);
#endif
-static int history_expansion_p PARAMS((char *));
-static int shell_comment PARAMS((char *));
-static int should_expand PARAMS((char *));
-static HIST_ENTRY *last_history_entry PARAMS((void));
-static char *expand_histignore_pattern PARAMS((char *));
-static int history_should_ignore PARAMS((char *));
+static int history_expansion_p (char *);
+static int shell_comment (char *);
+static int should_expand (char *);
+static HIST_ENTRY *last_history_entry (void);
+static char *expand_histignore_pattern (char *);
+static int history_should_ignore (char *);
#if defined (BANG_HISTORY)
/* Is the history expansion starting at string[i] one that should not
be expanded? */
static int
-bash_history_inhibit_expansion (string, i)
- char *string;
- int i;
+bash_history_inhibit_expansion (char *string, int i)
{
int t, si;
char hx[2];
#endif
void
-bash_initialize_history ()
+bash_initialize_history (void)
{
history_quotes_inhibit_expansion = 1;
history_search_delimiter_chars = ";&()|<>";
}
void
-bash_history_reinit (interact)
- int interact;
+bash_history_reinit (int interact)
{
#if defined (BANG_HISTORY)
history_expansion = (interact == 0) ? histexp_flag : HISTEXPAND_DEFAULT;
}
void
-bash_history_disable ()
+bash_history_disable (void)
{
remember_on_history = 0;
#if defined (BANG_HISTORY)
}
void
-bash_history_enable ()
+bash_history_enable (void)
{
remember_on_history = enable_history_list = 1;
#if defined (BANG_HISTORY)
/* Load the history list from the history file. */
void
-load_history ()
+load_history (void)
{
char *hf;
}
void
-bash_clear_history ()
+bash_clear_history (void)
{
clear_history ();
history_lines_this_session = 0;
/* Delete and free the history list entry at offset I. */
int
-bash_delete_histent (i)
- int i;
+bash_delete_histent (int i)
{
HIST_ENTRY *discard;
}
int
-bash_delete_history_range (first, last)
- int first, last;
+bash_delete_history_range (int first, int last)
{
register int i;
HIST_ENTRY **discard_list;
}
int
-bash_delete_last_history ()
+bash_delete_last_history (void)
{
register int i;
HIST_ENTRY **hlist, *histent;
#ifdef INCLUDE_UNUSED
/* Write the existing history out to the history file. */
void
-save_history ()
+save_history (void)
{
char *hf;
int r;
#endif
int
-maybe_append_history (filename)
- char *filename;
+maybe_append_history (char *filename)
{
int fd, result, histlen;
struct stat buf;
/* If this is an interactive shell, then append the lines executed
this session to the history file. */
int
-maybe_save_shell_history ()
+maybe_save_shell_history (void)
{
int result;
char *hf;
#if defined (READLINE)
/* Tell readline () that we have some text for it to edit. */
static void
-re_edit (text)
- char *text;
+re_edit (char *text)
{
if (bash_input.type == st_stdin)
bash_re_edit (text);
/* Return 1 if this line needs history expansion. */
static int
-history_expansion_p (line)
- char *line;
+history_expansion_p (char *line)
{
register char *s;
REMEMBER_ON_HISTORY can veto, and does.
Right now this does history expansion. */
char *
-pre_process_line (line, print_changes, addit)
- char *line;
- int print_changes, addit;
+pre_process_line (char *line, int print_changes, int addit)
{
char *history_value;
char *return_value;
first non-whitespace character. Return 0 if the line does not contain a
comment. */
static int
-shell_comment (line)
- char *line;
+shell_comment (char *line)
{
char *p;
int n;
/* Remove shell comments from LINE. A `#' and anything after it is a comment.
This isn't really useful yet, since it doesn't handle quoting. */
static char *
-filter_comments (line)
- char *line;
+filter_comments (char *line)
{
char *p;
/* Check LINE against what HISTCONTROL says to do. Returns 1 if the line
should be saved; 0 if it should be discarded. */
static int
-check_history_control (line)
- char *line;
+check_history_control (char *line)
{
HIST_ENTRY *temp;
int r;
/* Remove all entries matching LINE from the history list. Triggered when
HISTCONTROL includes `erasedups'. */
static void
-hc_erasedups (line)
- char *line;
+hc_erasedups (char *line)
{
HIST_ENTRY *temp;
int r;
entered. We also make sure to save multiple-line quoted strings or other
constructs. */
void
-maybe_add_history (line)
- char *line;
+maybe_add_history (char *line)
{
int is_comment;
history if it's OK. Used by `history -s' as well as maybe_add_history().
Returns 1 if the line was saved in the history, 0 otherwise. */
int
-check_add_history (line, force)
- char *line;
- int force;
+check_add_history (char *line, int force)
{
if (check_history_control (line) && history_should_ignore (line) == 0)
{
#endif
void
-bash_syslog_history (line)
- const char *line;
+bash_syslog_history (const char *line)
{
char trunc[SYSLOG_MAXLEN], *msg;
char loghdr[SYSLOG_MAXHDR];
complete parser construct, append LINE to the last history line instead
of adding it as a new line. */
void
-bash_add_history (line)
- char *line;
+bash_add_history (char *line)
{
int add_it, offset, curlen, is_comment;
HIST_ENTRY *current, *old;
}
static void
-really_add_history (line)
- char *line;
+really_add_history (char *line)
{
hist_last_line_added = 1;
hist_last_line_pushed = 0;
}
int
-history_number ()
+history_number (void)
{
using_history ();
return ((remember_on_history || enable_history_list) ? history_base + where_history () : 1);
}
-static int
-should_expand (s)
- char *s;
+static inline int
+should_expand (char *s)
{
char *p;
}
static int
-histignore_item_func (ign)
- struct ign *ign;
+histignore_item_func (struct ign *ign)
{
if (should_expand (ign->val))
ign->flags |= HIGN_EXPAND;
}
void
-setup_history_ignore (varname)
- char *varname;
+setup_history_ignore (char *varname)
{
setup_ignore_patterns (&histignore);
}
static HIST_ENTRY *
-last_history_entry ()
+last_history_entry (void)
{
HIST_ENTRY *he;
}
char *
-last_history_line ()
+last_history_line (void)
{
HIST_ENTRY *he;
}
static char *
-expand_histignore_pattern (pat)
- char *pat;
+expand_histignore_pattern (char *pat)
{
HIST_ENTRY *phe;
char *ret;
/* Return 1 if we should not put LINE into the history according to the
patterns in HISTIGNORE. */
static int
-history_should_ignore (line)
- char *line;
+history_should_ignore (char *line)
{
register int i, match;
char *npat;
#define RL_BOOLEAN_VARIABLE_VALUE(s) ((s)[0] == 'o' && (s)[1] == 'n' && (s)[2] == '\0')
#if defined (BRACE_COMPLETION)
-extern int bash_brace_completion PARAMS((int, int));
+extern int bash_brace_completion (int, int);
#endif /* BRACE_COMPLETION */
/* To avoid including curses.h/term.h/termcap.h and that whole mess. */
#ifdef _MINIX
-extern int tputs PARAMS((const char *string, int nlines, void (*outx)(int)));
+extern int tputs (const char *string, int nlines, void (*outx)(int));
#else
-extern int tputs PARAMS((const char *string, int nlines, int (*outx)(int)));
+extern int tputs (const char *string, int nlines, int (*outx)(int));
#endif
/* Forward declarations */
/* Functions bound to keys in Readline for Bash users. */
-static int shell_expand_line PARAMS((int, int));
-static int display_shell_version PARAMS((int, int));
+static int shell_expand_line (int, int);
+static int display_shell_version (int, int);
-static int bash_ignore_filenames PARAMS((char **));
-static int bash_ignore_everything PARAMS((char **));
-static int bash_progcomp_ignore_filenames PARAMS((char **));
+static int bash_ignore_filenames (char **);
+static int bash_ignore_everything (char **);
+static int bash_progcomp_ignore_filenames (char **);
#if defined (BANG_HISTORY)
-static char *history_expand_line_internal PARAMS((char *));
-static int history_expand_line PARAMS((int, int));
-static int tcsh_magic_space PARAMS((int, int));
+static char *history_expand_line_internal (char *);
+static int history_expand_line (int, int);
+static int tcsh_magic_space (int, int);
#endif /* BANG_HISTORY */
#ifdef ALIAS
-static int alias_expand_line PARAMS((int, int));
+static int alias_expand_line (int, int);
#endif
#if defined (BANG_HISTORY) && defined (ALIAS)
-static int history_and_alias_expand_line PARAMS((int, int));
+static int history_and_alias_expand_line (int, int);
#endif
-static int bash_forward_shellword PARAMS((int, int));
-static int bash_backward_shellword PARAMS((int, int));
-static int bash_kill_shellword PARAMS((int, int));
-static int bash_backward_kill_shellword PARAMS((int, int));
-static int bash_transpose_shellwords PARAMS((int, int));
+static int bash_forward_shellword (int, int);
+static int bash_backward_shellword (int, int);
+static int bash_kill_shellword (int, int);
+static int bash_backward_kill_shellword (int, int);
+static int bash_transpose_shellwords (int, int);
-static int bash_spell_correct_shellword PARAMS((int, int));
+static int bash_spell_correct_shellword (int, int);
/* Helper functions for Readline. */
-static char *restore_tilde PARAMS((char *, char *));
-static char *maybe_restore_tilde PARAMS((char *, char *));
-
-static char *bash_filename_rewrite_hook PARAMS((char *, int));
-
-static void bash_directory_expansion PARAMS((char **));
-static char *bash_expand_filename PARAMS((char *));
-static int bash_filename_stat_hook PARAMS((char **));
-static int bash_command_name_stat_hook PARAMS((char **));
-static int bash_directory_completion_hook PARAMS((char **));
-static int filename_completion_ignore PARAMS((char **));
-static int bash_push_line PARAMS((void));
-
-static int executable_completion PARAMS((const char *, int));
-
-static rl_icppfunc_t *save_directory_hook PARAMS((void));
-static void restore_directory_hook PARAMS((rl_icppfunc_t));
-
-static int directory_exists PARAMS((const char *, int));
-
-static void cleanup_expansion_error PARAMS((void));
-static void maybe_make_readline_line PARAMS((char *));
-static void set_up_new_line PARAMS((char *));
-
-static int check_redir PARAMS((int));
-static char **attempt_shell_completion PARAMS((const char *, int, int));
-static char *variable_completion_function PARAMS((const char *, int));
-static char *hostname_completion_function PARAMS((const char *, int));
-static char *command_subst_completion_function PARAMS((const char *, int));
-
-static void build_history_completion_array PARAMS((void));
-static char *history_completion_generator PARAMS((const char *, int));
-static int dynamic_complete_history PARAMS((int, int));
-static int bash_dabbrev_expand PARAMS((int, int));
-
-static void initialize_hostname_list PARAMS((void));
-static void add_host_name PARAMS((char *));
-static void snarf_hosts_from_file PARAMS((char *));
-static char **hostnames_matching PARAMS((char *));
-
-static void _ignore_completion_names PARAMS((char **, sh_ignore_func_t *));
-static int name_is_acceptable PARAMS((const char *));
-static int test_for_directory PARAMS((const char *));
-static int test_for_canon_directory PARAMS((const char *));
-static int return_zero PARAMS((const char *));
-
-static char *bash_dequote_filename PARAMS((char *, int));
-static char *quote_word_break_chars PARAMS((char *));
-static int bash_check_expchar PARAMS((char *, int, int *, int *));
-static void set_filename_quote_chars PARAMS((int, int, int));
-static void set_filename_bstab PARAMS((const char *));
-static char *bash_quote_filename PARAMS((char *, int, char *));
+static char *restore_tilde (char *, char *);
+static char *maybe_restore_tilde (char *, char *);
+
+static char *bash_filename_rewrite_hook (char *, int);
+
+static void bash_directory_expansion (char **);
+static char *bash_expand_filename (char *);
+static int bash_filename_stat_hook (char **);
+static int bash_command_name_stat_hook (char **);
+static int bash_directory_completion_hook (char **);
+static int filename_completion_ignore (char **);
+static int bash_push_line (void);
+
+static int executable_completion (const char *, int);
+
+static rl_icppfunc_t *save_directory_hook (void);
+static void restore_directory_hook (rl_icppfunc_t);
+
+static int directory_exists (const char *, int);
+
+static void cleanup_expansion_error (void);
+static void maybe_make_readline_line (char *);
+static void set_up_new_line (char *);
+
+static int check_redir (int);
+static char **attempt_shell_completion (const char *, int, int);
+static char *variable_completion_function (const char *, int);
+static char *hostname_completion_function (const char *, int);
+static char *command_subst_completion_function (const char *, int);
+
+static void build_history_completion_array (void);
+static char *history_completion_generator (const char *, int);
+static int dynamic_complete_history (int, int);
+static int bash_dabbrev_expand (int, int);
+
+static void initialize_hostname_list (void);
+static void add_host_name (char *);
+static void snarf_hosts_from_file (char *);
+static char **hostnames_matching (char *);
+
+static void _ignore_completion_names (char **, sh_ignore_func_t *);
+static int name_is_acceptable (const char *);
+static int test_for_directory (const char *);
+static int test_for_canon_directory (const char *);
+static int return_zero (const char *);
+
+static char *bash_dequote_filename (char *, int);
+static char *quote_word_break_chars (char *);
+static int bash_check_expchar (char *, int, int *, int *);
+static void set_filename_quote_chars (int, int, int);
+static void set_filename_bstab (const char *);
+static char *bash_quote_filename (char *, int, char *);
#ifdef _MINIX
-static void putx PARAMS((int));
+static void putx (int);
#else
-static int putx PARAMS((int));
+static int putx (int);
#endif
-static int readline_get_char_offset PARAMS((int));
-static void readline_set_char_offset PARAMS((int, int *));
+static int readline_get_char_offset (int);
+static void readline_set_char_offset (int, int *);
-static Keymap get_cmd_xmap_from_edit_mode PARAMS((void));
-static Keymap get_cmd_xmap_from_keymap PARAMS((Keymap));
+static Keymap get_cmd_xmap_from_edit_mode (void);
+static Keymap get_cmd_xmap_from_keymap (Keymap);
-static void init_unix_command_map PARAMS((void));
-static int isolate_sequence PARAMS((char *, int, int, int *));
+static void init_unix_command_map (void);
+static int isolate_sequence (char *, int, int, int *);
-static int set_saved_history PARAMS((void));
+static int set_saved_history (void);
#if defined (ALIAS)
-static int posix_edit_macros PARAMS((int, int));
+static int posix_edit_macros (int, int);
#endif
-static int bash_event_hook PARAMS((void));
+static int bash_event_hook (void);
#if defined (PROGRAMMABLE_COMPLETION)
-static int find_cmd_start PARAMS((int));
-static int find_cmd_end PARAMS((int));
-static char *find_cmd_name PARAMS((int, int *, int *));
-static char *prog_complete_return PARAMS((const char *, int));
+static int find_cmd_start (int);
+static int find_cmd_end (int);
+static char *find_cmd_name (int, int *, int *);
+static char *prog_complete_return (const char *, int);
static char **prog_complete_matches;
#endif
#define SPECIFIC_COMPLETION_FUNCTIONS
#if defined (SPECIFIC_COMPLETION_FUNCTIONS)
-static int bash_specific_completion PARAMS((int, rl_compentry_func_t *));
-
-static int bash_complete_filename_internal PARAMS((int));
-static int bash_complete_username_internal PARAMS((int));
-static int bash_complete_hostname_internal PARAMS((int));
-static int bash_complete_variable_internal PARAMS((int));
-static int bash_complete_command_internal PARAMS((int));
-
-static int bash_complete_filename PARAMS((int, int));
-static int bash_possible_filename_completions PARAMS((int, int));
-static int bash_complete_username PARAMS((int, int));
-static int bash_possible_username_completions PARAMS((int, int));
-static int bash_complete_hostname PARAMS((int, int));
-static int bash_possible_hostname_completions PARAMS((int, int));
-static int bash_complete_variable PARAMS((int, int));
-static int bash_possible_variable_completions PARAMS((int, int));
-static int bash_complete_command PARAMS((int, int));
-static int bash_possible_command_completions PARAMS((int, int));
-
-static int completion_glob_pattern PARAMS((char *));
-static char *glob_complete_word PARAMS((const char *, int));
-static int bash_glob_completion_internal PARAMS((int));
-static int bash_glob_complete_word PARAMS((int, int));
-static int bash_glob_expand_word PARAMS((int, int));
-static int bash_glob_list_expansions PARAMS((int, int));
+static int bash_specific_completion (int, rl_compentry_func_t *);
+
+static int bash_complete_filename_internal (int);
+static int bash_complete_username_internal (int);
+static int bash_complete_hostname_internal (int);
+static int bash_complete_variable_internal (int);
+static int bash_complete_command_internal (int);
+
+static int bash_complete_filename (int, int);
+static int bash_possible_filename_completions (int, int);
+static int bash_complete_username (int, int);
+static int bash_possible_username_completions (int, int);
+static int bash_complete_hostname (int, int);
+static int bash_possible_hostname_completions (int, int);
+static int bash_complete_variable (int, int);
+static int bash_possible_variable_completions (int, int);
+static int bash_complete_command (int, int);
+static int bash_possible_command_completions (int, int);
+
+static int completion_glob_pattern (char *);
+static char *glob_complete_word (const char *, int);
+static int bash_glob_completion_internal (int);
+static int bash_glob_complete_word (int, int);
+static int bash_glob_expand_word (int, int);
+static int bash_glob_list_expansions (int, int);
#endif /* SPECIFIC_COMPLETION_FUNCTIONS */
-static int edit_and_execute_command PARAMS((int, int, int, char *));
+static int edit_and_execute_command (int, int, int, char *);
#if defined (VI_MODE)
-static int vi_edit_and_execute_command PARAMS((int, int));
-static int bash_vi_complete PARAMS((int, int));
+static int vi_edit_and_execute_command (int, int);
+static int bash_vi_complete (int, int);
#endif
-static int emacs_edit_and_execute_command PARAMS((int, int));
+static int emacs_edit_and_execute_command (int, int);
/* Non-zero once initialize_readline () has been called. */
int bash_readline_initialized = 0;
/* Change the readline VI-mode keymaps into or out of Posix.2 compliance.
Called when the shell is put into or out of `posix' mode. */
void
-posix_readline_initialize (on_or_off)
- int on_or_off;
+posix_readline_initialize (int on_or_off)
{
static char kseq[2] = { CTRL ('I'), 0 }; /* TAB */
}
void
-reset_completer_word_break_chars ()
+reset_completer_word_break_chars (void)
{
rl_completer_word_break_characters = perform_hostname_completion ? savestring (bash_completer_word_break_characters) : savestring (bash_nohostname_word_break_characters);
}
/* When this function returns, rl_completer_word_break_characters points to
dynamically allocated memory. */
int
-enable_hostname_completion (on_or_off)
- int on_or_off;
+enable_hostname_completion (int on_or_off)
{
int old_value;
char *nv, *nval;
/* Called once from parse.y if we are going to use readline. */
void
-initialize_readline ()
+initialize_readline (void)
{
rl_command_func_t *func;
char kseq[2];
}
void
-bashline_reinitialize ()
+bashline_reinitialize (void)
{
bash_readline_initialized = 0;
}
void
-bashline_set_event_hook ()
+bashline_set_event_hook (void)
{
rl_signal_event_hook = bash_event_hook;
}
void
-bashline_reset_event_hook ()
+bashline_reset_event_hook (void)
{
rl_signal_event_hook = 0;
}
word. This just resets all the completion functions to the right thing.
It's called from throw_to_top_level(). */
void
-bashline_reset ()
+bashline_reset (void)
{
tilde_initialize ();
rl_attempted_completion_function = attempt_shell_completion;
/* Push the contents of push_to_readline into the
readline buffer. */
static int
-bash_push_line ()
+bash_push_line (void)
{
if (push_to_readline)
{
/* Call this to set the initial text for the next line to read
from readline. */
int
-bash_re_edit (line)
- char *line;
+bash_re_edit (char *line)
{
FREE (push_to_readline);
}
static int
-display_shell_version (count, c)
- int count, c;
+display_shell_version (int count, int c)
{
rl_crlf ();
show_shell_version (0);
/* Initialize the hostname completion table. */
static void
-initialize_hostname_list ()
+initialize_hostname_list (void)
{
char *temp;
/* Add NAME to the list of hosts. */
static void
-add_host_name (name)
- char *name;
+add_host_name (char *name)
{
if (hostname_list_length + 2 > hostname_list_size)
{
#define cr_whitespace(c) ((c) == '\r' || (c) == '\n' || whitespace(c))
static void
-snarf_hosts_from_file (filename)
- char *filename;
+snarf_hosts_from_file (char *filename)
{
FILE *file;
char *temp, buffer[256], name[256];
/* Return the hostname list. */
char **
-get_hostname_list ()
+get_hostname_list (void)
{
if (hostname_list_initialized == 0)
initialize_hostname_list ();
}
void
-clear_hostname_list ()
+clear_hostname_list (void)
{
register int i;
Initialize the hostname list the first time if necessary.
The array is malloc ()'ed, but not the individual strings. */
static char **
-hostnames_matching (text)
- char *text;
+hostnames_matching (char *text)
{
register int i, len, nmatch, rsize;
char **result;
#define POSIX_VI_EDIT_COMMAND "fc -e vi"
static int
-edit_and_execute_command (count, c, editing_mode, edit_command)
- int count, c, editing_mode;
- char *edit_command;
+edit_and_execute_command (int count, int c, int editing_mode, char *edit_command)
{
char *command, *metaval;
int r, rrs, metaflag;
#if defined (VI_MODE)
static int
-vi_edit_and_execute_command (count, c)
- int count, c;
+vi_edit_and_execute_command (int count, int key)
{
if (posixly_correct)
- return (edit_and_execute_command (count, c, VI_EDITING_MODE, POSIX_VI_EDIT_COMMAND));
+ return (edit_and_execute_command (count, key, VI_EDITING_MODE, POSIX_VI_EDIT_COMMAND));
else
- return (edit_and_execute_command (count, c, VI_EDITING_MODE, VI_EDIT_COMMAND));
+ return (edit_and_execute_command (count, key, VI_EDITING_MODE, VI_EDIT_COMMAND));
}
#endif /* VI_MODE */
static int
-emacs_edit_and_execute_command (count, c)
- int count, c;
+emacs_edit_and_execute_command (int count, int key)
{
- return (edit_and_execute_command (count, c, EMACS_EDITING_MODE, EMACS_EDIT_COMMAND));
+ return (edit_and_execute_command (count, key, EMACS_EDITING_MODE, EMACS_EDIT_COMMAND));
}
#if defined (ALIAS)
static int
-posix_edit_macros (count, key)
- int count, key;
+posix_edit_macros (int count, int key)
{
int c;
char alias_name[3], *alias_value, *macro;
#define WORDDELIM(c) (shellmeta(c) || shellblank(c))
static int
-bash_forward_shellword (count, key)
- int count, key;
+bash_forward_shellword (int count, int key)
{
size_t slen;
int c, p;
}
static int
-bash_backward_shellword (count, key)
- int count, key;
+bash_backward_shellword (int count, int key)
{
size_t slen;
int c, p, prev_p;
}
static int
-bash_kill_shellword (count, key)
- int count, key;
+bash_kill_shellword (int count, int key)
{
int p;
}
static int
-bash_backward_kill_shellword (count, key)
- int count, key;
+bash_backward_kill_shellword (int count, int key)
{
int p;
}
static int
-bash_transpose_shellwords (count, key)
- int count, key;
+bash_transpose_shellwords (int count, int key)
{
char *word1, *word2;
int w1_beg, w1_end, w2_beg, w2_end;
/* Directory name spelling correction on the current word (not shellword).
COUNT > 1 is not exactly correct yet. */
static int
-bash_spell_correct_shellword (count, key)
- int count, key;
+bash_spell_correct_shellword (int count, int key)
{
int opoint, wbeg, wend;
char *text, *newdir;
/* check for redirections and other character combinations that are not
command separators */
-static int
-check_redir (ti)
- int ti;
+static inline int
+check_redir (int ti)
{
register int this_char, prev_char;
* happen, but fix later after 2.05a-release.
*/
static int
-find_cmd_start (start)
- int start;
+find_cmd_start (int start)
{
register int s, os, ns;
}
static int
-find_cmd_end (end)
- int end;
+find_cmd_end (int end)
{
register int e;
}
static char *
-find_cmd_name (start, sp, ep)
- int start;
- int *sp, *ep;
+find_cmd_name (int start, int *sp, int *ep)
{
char *name;
register int s, e;
}
static char *
-prog_complete_return (text, matchnum)
- const char *text;
- int matchnum;
+prog_complete_return (const char *text, int matchnum)
{
static int ind;
/* Try and catch completion attempts that are syntax errors or otherwise
invalid. */
static int
-invalid_completion (text, ind)
- const char *text;
- int ind;
+invalid_completion (const char *text, int ind)
{
int pind;
/* Do some completion on TEXT. The indices of TEXT in RL_LINE_BUFFER are
at START and END. Return an array of matches, or NULL if none. */
static char **
-attempt_shell_completion (text, start, end)
- const char *text;
- int start, end;
+attempt_shell_completion (const char *text, int start, int end)
{
int in_command_position, ti, qc, dflags;
char **matches, *command_separator_chars;
}
char **
-bash_default_completion (text, start, end, qc, compflags)
- const char *text;
- int start, end, qc, compflags;
+bash_default_completion (const char *text, int start, int end, int qc, int compflags)
{
char **matches, *t;
}
static int
-bash_command_name_stat_hook (name)
- char **name;
+bash_command_name_stat_hook (char **name)
{
char *cname, *result;
}
static int
-executable_completion (filename, searching_path)
- const char *filename;
- int searching_path;
+executable_completion (const char *filename, int searching_path)
{
char *f, c;
int r;
that match. It also scans aliases, function names, and the shell_builtin
table. */
char *
-command_word_completion_function (hint_text, state)
- const char *hint_text;
- int state;
+command_word_completion_function (const char *hint_text, int state)
{
static char *hint = (char *)NULL;
static char *path = (char *)NULL;
/* Completion inside an unterminated command substitution. */
static char *
-command_subst_completion_function (text, state)
- const char *text;
- int state;
+command_subst_completion_function (const char *text, int state)
{
static char **matches = (char **)NULL;
static const char *orig_start;
/* Okay, now we write the entry_function for variable completion. */
static char *
-variable_completion_function (text, state)
- const char *text;
- int state;
+variable_completion_function (const char *text, int state)
{
static char **varlist = (char **)NULL;
static int varlist_index;
/* How about a completion function for hostnames? */
static char *
-hostname_completion_function (text, state)
- const char *text;
- int state;
+hostname_completion_function (const char *text, int state)
{
static char **list = (char **)NULL;
static int list_index = 0;
* A completion function for service names from /etc/services (or wherever).
*/
char *
-bash_servicename_completion_function (text, state)
- const char *text;
- int state;
+bash_servicename_completion_function (const char *text, int state)
{
#if defined (__WIN32__) || defined (__OPENNT) || !defined (HAVE_GETSERVENT)
return ((char *)NULL);
* A completion function for group names from /etc/group (or wherever).
*/
char *
-bash_groupname_completion_function (text, state)
- const char *text;
- int state;
+bash_groupname_completion_function (const char *text, int state)
{
#if defined (__WIN32__) || defined (__OPENNT) || !defined (HAVE_GRP_H)
return ((char *)NULL);
is done, pre_process_line() returns what it was passed, so we need to
allocate a new line here. */
static char *
-history_expand_line_internal (line)
- char *line;
+history_expand_line_internal (char *line)
{
char *new_line;
int old_verify;
/* There was an error in expansion. Let the preprocessor print
the error here. */
static void
-cleanup_expansion_error ()
+cleanup_expansion_error (void)
{
char *to_free;
#if defined (BANG_HISTORY)
undo record to get from the readline line buffer contents to the new
line and make NEW_LINE the current readline line. */
static void
-maybe_make_readline_line (new_line)
- char *new_line;
+maybe_make_readline_line (char *new_line)
{
if (new_line && strcmp (new_line, rl_line_buffer) != 0)
{
/* Make NEW_LINE be the current readline line. This frees NEW_LINE. */
static void
-set_up_new_line (new_line)
- char *new_line;
+set_up_new_line (char *new_line)
{
int old_point, at_end;
#if defined (ALIAS)
/* Expand aliases in the current readline line. */
static int
-alias_expand_line (count, ignore)
- int count, ignore;
+alias_expand_line (int count, int ignore)
{
char *new_line;
#if defined (BANG_HISTORY)
/* History expand the line. */
static int
-history_expand_line (count, ignore)
- int count, ignore;
+history_expand_line (int count, int ignore)
{
char *new_line;
/* Expand history substitutions in the current line and then insert a
space (hopefully close to where we were before). */
static int
-tcsh_magic_space (count, ignore)
- int count, ignore;
+tcsh_magic_space (int count, int ignore)
{
int dist_from_end, old_point;
/* History and alias expand the line. */
static int
-history_and_alias_expand_line (count, ignore)
- int count, ignore;
+history_and_alias_expand_line (int count, int ignore)
{
char *new_line, *t;
because we want the variable expansions as a separate undo'able
set of operations. */
static int
-shell_expand_line (count, ignore)
- int count, ignore;
+shell_expand_line (int count, int ignore)
{
char *new_line, *t;
WORD_LIST *expanded_string;
};
static void
-_ignore_completion_names (names, name_func)
- char **names;
- sh_ignore_func_t *name_func;
+_ignore_completion_names (char **names, sh_ignore_func_t *name_func)
{
char **newnames;
int idx, nidx;
}
static int
-name_is_acceptable (name)
- const char *name;
+name_is_acceptable (const char *name)
{
struct ign *p;
int nlen;
#if 0
static int
-ignore_dot_names (name)
- char *name;
+ignore_dot_names (char *name)
{
return (name[0] != '.');
}
#endif
static int
-filename_completion_ignore (names)
- char **names;
+filename_completion_ignore (char **names)
{
#if 0
if (glob_dot_filenames == 0)
/* Return 1 if NAME is a directory. NAME undergoes tilde expansion. */
static int
-test_for_directory (name)
- const char *name;
+test_for_directory (const char *name)
{
char *fn;
int r;
}
static int
-test_for_canon_directory (name)
- const char *name;
+test_for_canon_directory (const char *name)
{
char *fn;
int r;
/* Remove files from NAMES, leaving directories. */
static int
-bash_ignore_filenames (names)
- char **names;
+bash_ignore_filenames (char **names)
{
_ignore_completion_names (names, test_for_directory);
return 0;
}
static int
-bash_progcomp_ignore_filenames (names)
- char **names;
+bash_progcomp_ignore_filenames (char **names)
{
_ignore_completion_names (names, test_for_canon_directory);
return 0;
}
static int
-return_zero (name)
- const char *name;
+return_zero (const char *name)
{
return 0;
}
static int
-bash_ignore_everything (names)
- char **names;
+bash_ignore_everything (char **names)
{
_ignore_completion_names (names, return_zero);
return 0;
is an expanded filename. DIRECTORY_PART is the tilde-prefix portion
of the un-tilde-expanded version of VAL (what the user typed). */
static char *
-restore_tilde (val, directory_part)
- char *val, *directory_part;
+restore_tilde (char *val, char *directory_part)
{
int l, vl, dl2, xl;
char *dh2, *expdir, *ret, *v;
}
static char *
-maybe_restore_tilde (val, directory_part)
- char *val, *directory_part;
+maybe_restore_tilde (char *val, char *directory_part)
{
rl_icppfunc_t *save;
char *ret;
rl_filename_completion_function. This must be called with the address of
a pointer to malloc'd memory. */
static void
-bash_directory_expansion (dirname)
- char **dirname;
+bash_directory_expansion (char **dirname)
{
char *d, *nd;
/* If necessary, rewrite directory entry */
static char *
-bash_filename_rewrite_hook (fname, fnlen)
- char *fname;
- int fnlen;
+bash_filename_rewrite_hook (char *fname, int fnlen)
{
char *conv;
/* Functions to save and restore the appropriate directory hook */
/* This is not static so the shopt code can call it */
void
-set_directory_hook ()
+set_directory_hook (void)
{
if (dircomplete_expand)
{
}
static rl_icppfunc_t *
-save_directory_hook ()
+save_directory_hook (void)
{
rl_icppfunc_t *ret;
}
static void
-restore_directory_hook (hookf)
- rl_icppfunc_t *hookf;
+restore_directory_hook (rl_icppfunc_t *hookf)
{
if (dircomplete_expand)
rl_directory_completion_hook = hookf;
/* Check whether not DIRNAME, with any trailing slash removed, exists. If
SHOULD_DEQUOTE is non-zero, we dequote the directory name first. */
static int
-directory_exists (dirname, should_dequote)
- const char *dirname;
- int should_dequote;
+directory_exists (const char *dirname, int should_dequote)
{
char *new_dirname;
int dirlen, r;
}
static char *
-bash_expand_filename (filename)
- char *filename;
+bash_expand_filename (char *filename)
{
char *newname;
int global_nounset;
/* Expand a filename before the readline completion code passes it to stat(2).
The filename will already have had tilde expansion performed. */
static int
-bash_filename_stat_hook (dirname)
- char **dirname;
+bash_filename_stat_hook (char **dirname)
{
char *local_dirname, *new_dirname, *t;
int should_expand_dirname, return_value;
the DIRNAME argument, 0 otherwise. It should make sure not to modify
DIRNAME if it returns 0. */
static int
-bash_directory_completion_hook (dirname)
- char **dirname;
+bash_directory_completion_hook (char **dirname)
{
char *local_dirname, *new_dirname, *t;
int return_value, should_expand_dirname, nextch, closer;
static int harry_len;
static void
-build_history_completion_array ()
+build_history_completion_array (void)
{
register int i, j;
HIST_ENTRY **hlist;
}
static char *
-history_completion_generator (hint_text, state)
- const char *hint_text;
- int state;
+history_completion_generator (const char *hint_text, int state)
{
static int local_index, len;
static const char *text;
}
static int
-dynamic_complete_history (count, key)
- int count, key;
+dynamic_complete_history (int count, int key)
{
int r;
rl_compentry_func_t *orig_func;
}
static int
-bash_dabbrev_expand (count, key)
- int count, key;
+bash_dabbrev_expand (int count, int key)
{
int r, orig_suppress, orig_sort;
rl_compentry_func_t *orig_func;
#if defined (SPECIFIC_COMPLETION_FUNCTIONS)
static int
-bash_complete_username (ignore, ignore2)
- int ignore, ignore2;
+bash_complete_username (int ignore, int ignore2)
{
return bash_complete_username_internal (rl_completion_mode (bash_complete_username));
}
static int
-bash_possible_username_completions (ignore, ignore2)
- int ignore, ignore2;
+bash_possible_username_completions (int ignore, int ignore2)
{
return bash_complete_username_internal ('?');
}
static int
-bash_complete_username_internal (what_to_do)
- int what_to_do;
+bash_complete_username_internal (int what_to_do)
{
return bash_specific_completion (what_to_do, rl_username_completion_function);
}
static int
-bash_complete_filename (ignore, ignore2)
- int ignore, ignore2;
+bash_complete_filename (int ignore, int ignore2)
{
return bash_complete_filename_internal (rl_completion_mode (bash_complete_filename));
}
static int
-bash_possible_filename_completions (ignore, ignore2)
- int ignore, ignore2;
+bash_possible_filename_completions (int ignore, int ignore2)
{
return bash_complete_filename_internal ('?');
}
static int
-bash_complete_filename_internal (what_to_do)
- int what_to_do;
+bash_complete_filename_internal (int what_to_do)
{
rl_compentry_func_t *orig_func;
rl_completion_func_t *orig_attempt_func;
}
static int
-bash_complete_hostname (ignore, ignore2)
- int ignore, ignore2;
+bash_complete_hostname (int ignore, int ignore2)
{
return bash_complete_hostname_internal (rl_completion_mode (bash_complete_hostname));
}
static int
-bash_possible_hostname_completions (ignore, ignore2)
- int ignore, ignore2;
+bash_possible_hostname_completions (int ignore, int ignore2)
{
return bash_complete_hostname_internal ('?');
}
static int
-bash_complete_variable (ignore, ignore2)
- int ignore, ignore2;
+bash_complete_variable (int ignore, int ignore2)
{
return bash_complete_variable_internal (rl_completion_mode (bash_complete_variable));
}
static int
-bash_possible_variable_completions (ignore, ignore2)
- int ignore, ignore2;
+bash_possible_variable_completions (int ignore, int ignore2)
{
return bash_complete_variable_internal ('?');
}
static int
-bash_complete_command (ignore, ignore2)
- int ignore, ignore2;
+bash_complete_command (int ignore, int ignore2)
{
return bash_complete_command_internal (rl_completion_mode (bash_complete_command));
}
static int
-bash_possible_command_completions (ignore, ignore2)
- int ignore, ignore2;
+bash_possible_command_completions (int ignore, int ignore2)
{
return bash_complete_command_internal ('?');
}
static int
-bash_complete_hostname_internal (what_to_do)
- int what_to_do;
+bash_complete_hostname_internal (int what_to_do)
{
return bash_specific_completion (what_to_do, hostname_completion_function);
}
static int
-bash_complete_variable_internal (what_to_do)
- int what_to_do;
+bash_complete_variable_internal (int what_to_do)
{
return bash_specific_completion (what_to_do, variable_completion_function);
}
static int
-bash_complete_command_internal (what_to_do)
- int what_to_do;
+bash_complete_command_internal (int what_to_do)
{
return bash_specific_completion (what_to_do, command_word_completion_function);
}
static int
-completion_glob_pattern (string)
- char *string;
+completion_glob_pattern (char *string)
{
return (glob_pattern_p (string) == 1);
}
static char *globorig;
static char *
-glob_complete_word (text, state)
- const char *text;
- int state;
+glob_complete_word (const char *text, int state)
{
static char **matches = (char **)NULL;
static int ind;
}
static int
-bash_glob_completion_internal (what_to_do)
- int what_to_do;
+bash_glob_completion_internal (int what_to_do)
{
return bash_specific_completion (what_to_do, glob_complete_word);
}
/* A special quoting function so we don't end up quoting globbing characters
in the word if there are no matches or multiple matches. */
static char *
-bash_glob_quote_filename (s, rtype, qcp)
- char *s;
- int rtype;
- char *qcp;
+bash_glob_quote_filename (char *s, int rtype, char *qcp)
{
if (globorig && qcp && *qcp == '\0' && STREQ (s, globorig))
return (savestring (s));
}
static int
-bash_glob_complete_word (count, key)
- int count, key;
+bash_glob_complete_word (int count, int key)
{
int r;
rl_quote_func_t *orig_quoting_function;
}
static int
-bash_glob_expand_word (count, key)
- int count, key;
+bash_glob_expand_word (int count, int key)
{
return bash_glob_completion_internal ('*');
}
static int
-bash_glob_list_expansions (count, key)
- int count, key;
+bash_glob_list_expansions (int count, int key)
{
return bash_glob_completion_internal ('?');
}
static int
-bash_specific_completion (what_to_do, generator)
- int what_to_do;
- rl_compentry_func_t *generator;
+bash_specific_completion (int what_to_do, rl_compentry_func_t *generator)
{
rl_compentry_func_t *orig_func;
rl_completion_func_t *orig_attempt_func;
specifies, which is to append a `*' and attempt filename generation (which
has the side effect of expanding any globbing characters in the word). */
static int
-bash_vi_complete (count, key)
- int count, key;
+bash_vi_complete (int count, int key)
{
#if defined (SPECIFIC_COMPLETION_FUNCTIONS)
int p, r;
quotes, and backslashes). It allows single quotes to appear
within double quotes, and vice versa. It should be smarter. */
static char *
-bash_dequote_filename (text, quote_char)
- char *text;
- int quote_char;
+bash_dequote_filename (char *text, int quote_char)
{
char *ret, *p, *r;
int l, quoted;
word break characters with backslashes. Pass backslash-quoted
characters through without examination. */
static char *
-quote_word_break_chars (text)
- char *text;
+quote_word_break_chars (char *text)
{
char *ret, *r, *s;
int l;
used in case DIRNAME is going to be expanded. If DIRNAME is just going to
be quoted, NEED_CLOSER will be 0. */
static int
-bash_check_expchar (dirname, need_closer, nextp, closerp)
- char *dirname;
- int need_closer;
- int *nextp, *closerp;
+bash_check_expchar (char *dirname, int need_closer, int *nextp, int *closerp)
{
char *t;
int ret, n, c;
of characters to be backslash-escaped. This is the only place
custom_filename_quote_characters is modified. */
static void
-set_filename_quote_chars (expchar, nextch, closer)
- int expchar, nextch, closer;
+set_filename_quote_chars (int expchar, int nextch, int closer)
{
int i, j, c;
be backslash-quoted. The table will be used for sh_backslash_quote from
this file. */
static void
-set_filename_bstab (string)
- const char *string;
+set_filename_bstab (const char *string)
{
const char *s;
quote_word_break_chars on the result. This returns newly-allocated
memory. */
static char *
-bash_quote_filename (s, rtype, qcp)
- char *s;
- int rtype;
- char *qcp;
+bash_quote_filename (char *s, int rtype, char *qcp)
{
char *rtext, *mtext, *ret;
int rlen, cs;
#else
static int
#endif
-putx(c)
- int c;
+putx(int c)
{
int x;
x = putc (c, rl_outstream);
}
static int
-readline_get_char_offset (ind)
- int ind;
+readline_get_char_offset (int ind)
{
int r, old_ch;
}
static void
-readline_set_char_offset (ind, varp)
- int ind;
- int *varp;
+readline_set_char_offset (int ind, int *varp)
{
int i;
}
int
-bash_execute_unix_command (count, key)
- int count; /* ignored */
- int key;
+bash_execute_unix_command (int count, int key)
{
int type;
register int i, r;
}
int
-print_unix_command_map ()
+print_unix_command_map (void)
{
Keymap save, cmd_xmap;
}
static void
-init_unix_command_map ()
+init_unix_command_map (void)
{
emacs_std_cmd_xmap = rl_make_bare_keymap ();
}
static Keymap
-get_cmd_xmap_from_edit_mode ()
+get_cmd_xmap_from_edit_mode (void)
{
if (emacs_std_cmd_xmap == 0)
init_unix_command_map ();
}
static Keymap
-get_cmd_xmap_from_keymap (kmap)
- Keymap kmap;
+get_cmd_xmap_from_keymap (Keymap kmap)
{
if (emacs_std_cmd_xmap == 0)
init_unix_command_map ();
}
static int
-isolate_sequence (string, ind, need_dquote, startp)
- char *string;
- int ind, need_dquote, *startp;
+isolate_sequence (char *string, int ind, int need_dquote, int *startp)
{
register int i;
int c, passc, delim;
}
int
-bind_keyseq_to_unix_command (line)
- char *line;
+bind_keyseq_to_unix_command (char *line)
{
Keymap kmap, cmd_xmap;
char *kseq, *value;
}
int
-unbind_unix_command (kseq)
- char *kseq;
+unbind_unix_command (char *kseq)
{
Keymap cmd_xmap;
but return only directories as matches. Dequotes the filename before
attempting to find matches. */
char **
-bash_directory_completion_matches (text)
- const char *text;
+bash_directory_completion_matches (const char *text)
{
char **m1;
char *dfn;
}
char *
-bash_dequote_text (text)
- const char *text;
+bash_dequote_text (const char *text)
{
char *dtxt;
int qc;
and fatal signals without executing too much code in a signal handler
context. */
static int
-bash_event_hook ()
+bash_event_hook (void)
{
int sig;
/* braces.c -- code for doing word expansion in curly braces. */
-/* Copyright (C) 1987-2020 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2020,2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
#define BRACE_SEQ_SPECIFIER ".."
-extern int asprintf PARAMS((char **, const char *, ...)) __attribute__((__format__ (printf, 2, 3)));
+extern int asprintf (char **, const char *, ...) __attribute__((__format__ (printf, 2, 3)));
/* Basic idea:
/* The character which is used to separate arguments. */
static const int brace_arg_separator = ',';
-#if defined (PARAMS)
-static int brace_gobbler PARAMS((char *, size_t, int *, int));
-static char **expand_amble PARAMS((char *, size_t, int));
-static char **expand_seqterm PARAMS((char *, size_t));
-static char **mkseq PARAMS((intmax_t, intmax_t, intmax_t, int, int));
-static char **array_concat PARAMS((char **, char **));
-#else
-static int brace_gobbler ();
-static char **expand_amble ();
-static char **expand_seqterm ();
-static char **mkseq();
-static char **array_concat ();
-#endif
+static int brace_gobbler (char *, size_t, int *, int);
+static char **expand_amble (char *, size_t, int);
+static char **expand_seqterm (char *, size_t);
+static char **mkseq (intmax_t, intmax_t, intmax_t, int, int);
+static char **array_concat (char **, char **);
#if 0
static void
/* Return an array of strings; the brace expansion of TEXT. */
char **
-brace_expand (text)
- char *text;
+brace_expand (char *text)
{
register int start;
size_t tlen;
expand each slot which needs it, until there are no more slots which
need it. */
static char **
-expand_amble (text, tlen, flags)
- char *text;
- size_t tlen;
- int flags;
+expand_amble (char *text, size_t tlen, int flags)
{
char **result, **partial, **tresult;
char *tem;
#define ST_ZINT 3
static char **
-mkseq (start, end, incr, type, width)
- intmax_t start, end, incr;
- int type, width;
+mkseq (intmax_t start, intmax_t end, intmax_t incr, int type, int width)
{
intmax_t n, prevn;
int i, nelem;
}
static char **
-expand_seqterm (text, tlen)
- char *text;
- size_t tlen;
+expand_seqterm (char *text, size_t tlen)
{
char *t, *lhs, *rhs;
int lhs_t, rhs_t, lhs_l, rhs_l, width;
an inner set of braces.
*/
static int
-brace_gobbler (text, tlen, indx, satisfy)
- char *text;
- size_t tlen;
- int *indx;
- int satisfy;
+brace_gobbler (char *text, size_t tlen, int *indx, int satisfy)
{
register int i, c, quoted, level, commas, pass_next;
#if defined (SHELL)
are free ()'ed. ARR1 can be NULL, in that case, a new version of ARR2
is returned. */
static char **
-array_concat (arr1, arr2)
- char **arr1, **arr2;
+array_concat (char **arr1, char **arr2)
{
register int i, j, len, len1, len2;
register char **result;
#include <stdio.h>
void *
-xmalloc(n)
- size_t n;
+xmalloc(size_t n)
{
return (malloc (n));
}
void *
-xrealloc(p, n)
- void *p;
- size_t n;
+xrealloc(void *p, size_t n)
{
return (realloc (p, n));
}
int
-internal_error (format, arg1, arg2)
- char *format, *arg1, *arg2;
+internal_error (char *format, char *arg1, char *arg2)
{
fprintf (stderr, format, arg1, arg2);
fprintf (stderr, "\n");
}
-main ()
+main (int c, char **v)
{
char example[256];
/* Hack the alias command in a Korn shell way. */
int
-alias_builtin (list)
- WORD_LIST *list;
+alias_builtin (WORD_LIST *list)
{
int any_failed, offset, pflag, dflags;
alias_t **alias_list, *t;
#if defined (ALIAS)
/* Remove aliases named in LIST from the aliases database. */
int
-unalias_builtin (list)
- register WORD_LIST *list;
+unalias_builtin (WORD_LIST *list)
{
- register alias_t *alias;
+ alias_t *alias;
int opt, aflag;
aflag = 0;
/* Output ALIAS in such a way as to allow it to be read back in. */
static void
-print_alias (alias, flags)
- alias_t *alias;
- int flags;
+print_alias (alias_t *alias, int flags)
{
char *value;
#define XXFLAG 0x2000
int
-bind_builtin (list)
- WORD_LIST *list;
+bind_builtin (WORD_LIST *list)
{
int return_code;
Keymap kmap, saved_keymap;
}
static int
-query_bindings (name)
- char *name;
+query_bindings (char *name)
{
rl_command_func_t *function;
char **keyseqs;
}
static int
-unbind_command (name)
- char *name;
+unbind_command (char *name)
{
rl_command_func_t *function;
}
static int
-unbind_keyseq (seq)
- char *seq;
+unbind_keyseq (char *seq)
{
char *kseq;
int kslen, type;
/* Set up to break x levels, where x defaults to 1, but can be specified
as the first argument. */
int
-break_builtin (list)
- WORD_LIST *list;
+break_builtin (WORD_LIST *list)
{
intmax_t newbreak;
/* Set up to continue x levels, where x defaults to 1, but can be specified
as the first argument. */
int
-continue_builtin (list)
- WORD_LIST *list;
+continue_builtin (WORD_LIST *list)
{
intmax_t newcont;
/* Return non-zero if a break or continue command would be okay.
Print an error message if break or continue is meaningless here. */
static int
-check_loop_level ()
+check_loop_level (void)
{
#if defined (BREAK_COMPLAINS)
if (loop_level == 0 && posixly_correct == 0)
This file is builtin.def, from which is created builtin.c.
It implements the builtin "builtin" in Bash.
-Copyright (C) 1987-2017 Free Software Foundation, Inc.
+Copyright (C) 1987-2017,2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
/* Run the command mentioned in list directly, without going through the
normal alias/function/builtin/filename lookup process. */
int
-builtin_builtin (list)
- WORD_LIST *list;
+builtin_builtin (WORD_LIST *list)
{
sh_builtin_func_t *function;
register char *command;
builtin "caller" in Bash.
Copyright (C) 2002-2008 Rocky Bernstein for Free Software Foundation, Inc.
-Copyright (C) 2008-2019 Free Software Foundation, Inc.
+Copyright (C) 2008-2019,2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
#endif /* !errno */
int
-caller_builtin (list)
- WORD_LIST *list;
+caller_builtin (WORD_LIST *list)
{
#if !defined (ARRAY_VARS)
printf ("1 NULL\n");
/* Just set $PWD, don't change OLDPWD. Used by `pwd -P' in posix mode. */
static int
-setpwd (dirname)
- char *dirname;
+setpwd (char *dirname)
{
int old_anm;
SHELL_VAR *tvar;
}
static int
-bindpwd (no_symlinks)
- int no_symlinks;
+bindpwd (int no_symlinks)
{
char *dirname, *pwdvar;
int old_anm, r, canon_failed;
/* Call get_working_directory to reset the value of
the_current_working_directory () */
static char *
-resetpwd (caller)
- char *caller;
+resetpwd (char *caller)
{
char *tdir;
return (tdir);
}
+/* return new constructed directory name in *NDIRP */
static int
-cdxattr (dir, ndirp)
- char *dir; /* don't assume we can always free DIR */
- char **ndirp; /* return new constructed directory name */
+cdxattr (char *dir, char **ndirp)
{
#if defined (O_XATTR)
int apfd, fd, r, e;
/* Clean up the O_XATTR baggage. Currently only closes xattrfd */
static void
-resetxattr ()
+resetxattr (void)
{
#if defined (O_XATTR)
if (xattrfd >= 0)
so the programming interface is simple, and it handles errors and
restrictions properly. */
int
-cd_builtin (list)
- WORD_LIST *list;
+cd_builtin (WORD_LIST *list)
{
char *dirname, *cdpath, *path, *temp;
int path_index, no_symlinks, opt, lflag, e;
/* Print the name of the current working directory. */
int
-pwd_builtin (list)
- WORD_LIST *list;
+pwd_builtin (WORD_LIST *list)
{
char *directory;
int opt, pflag;
to the working directory. Return 1 on success, 0 on failure. */
static int
-change_to_directory (newdir, nolinks, xattr)
- char *newdir;
- int nolinks, xattr;
+change_to_directory (char *newdir, int nolinks, int xattr)
{
char *t, *tdir, *ndir;
int err, canon_failed, r, ndlen;
This file is colon.def, from which is created colon.c.
It implements the builtin ":" in Bash.
-Copyright (C) 1987-2019 Free Software Foundation, Inc.
+Copyright (C) 1987-2019,2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
/* Return a successful result. */
int
-colon_builtin (ignore)
- WORD_LIST *ignore;
+colon_builtin (WORD_LIST *ignore)
{
return (0);
}
/* Return an unsuccessful result. */
int
-false_builtin (ignore)
- WORD_LIST *ignore;
+false_builtin (WORD_LIST *ignore)
{
return (1);
}
/* Run the commands mentioned in LIST without paying attention to shell
functions. */
int
-command_builtin (list)
- WORD_LIST *list;
+command_builtin (WORD_LIST *list)
{
int result, verbose, use_standard_path, opt;
COMMAND *command;
};
static int
-find_compact (name)
- char *name;
+find_compact (char *name)
{
register int i;
}
static int
-find_compopt (name)
- char *name;
+find_compopt (char *name)
{
register int i;
*/
static int
-build_actions (list, flagp, actp, optp)
- WORD_LIST *list;
- struct _optflags *flagp;
- unsigned long *actp, *optp;
+build_actions (WORD_LIST *list, struct _optflags *flagp, unsigned long *actp, unsigned long *optp)
{
int opt, ind, opt_given;
unsigned long acts, copts;
/* Add, remove, and display completion specifiers. */
int
-complete_builtin (list)
- WORD_LIST *list;
+complete_builtin (WORD_LIST *list)
{
int opt_given, rval;
unsigned long acts, copts;
}
static int
-remove_cmd_completions (list)
- WORD_LIST *list;
+remove_cmd_completions (WORD_LIST *list)
{
WORD_LIST *l;
int ret;
}
static void
-print_compoptions (copts, full)
- unsigned long copts;
- int full;
+print_compoptions (unsigned long copts, int full)
{
const struct _compopt *co;
}
static void
-print_compactions (acts)
- unsigned long acts;
+print_compactions (unsigned long acts)
{
const struct _compacts *ca;
}
static void
-print_arg (arg, flag, quote)
- const char *arg, *flag;
- int quote;
+print_arg (const char *arg, const char *flag, int quote)
{
char *x;
}
static void
-print_cmd_name (cmd)
- const char *cmd;
+print_cmd_name (const char *cmd)
{
char *x;
}
static int
-print_one_completion (cmd, cs)
- char *cmd;
- COMPSPEC *cs;
+print_one_completion (char *cmd, COMPSPEC *cs)
{
printf ("complete ");
}
static void
-print_compopts (cmd, cs, full)
- const char *cmd;
- COMPSPEC *cs;
- int full;
+print_compopts (const char *cmd, COMPSPEC *cs, int full)
{
printf ("compopt ");
}
static int
-print_compitem (item)
- BUCKET_CONTENTS *item;
+print_compitem (BUCKET_CONTENTS *item)
{
COMPSPEC *cs;
char *cmd;
}
static void
-print_all_completions ()
+print_all_completions (void)
{
progcomp_walk (print_compitem);
}
static int
-print_cmd_completions (list)
- WORD_LIST *list;
+print_cmd_completions (WORD_LIST *list)
{
WORD_LIST *l;
COMPSPEC *cs;
$END
int
-compgen_builtin (list)
- WORD_LIST *list;
+compgen_builtin (WORD_LIST *list)
{
int rval;
unsigned long acts, copts;
$END
int
-compopt_builtin (list)
- WORD_LIST *list;
+compopt_builtin (WORD_LIST *list)
{
int opts_on, opts_off, *opts, opt, oind, ret, Dflag, Eflag, Iflag;
WORD_LIST *l, *wl;
/* Declare or change variable attributes. */
int
-declare_builtin (list)
- register WORD_LIST *list;
+declare_builtin (WORD_LIST *list)
{
return (declare_internal (list, 0));
}
assignment error occurs, or the shell is not executing a function.
$END
int
-local_builtin (list)
- register WORD_LIST *list;
+local_builtin (WORD_LIST *list)
{
/* Catch a straight `local --help' before checking function context */
if (list && list->word && STREQ (list->word->word, "--help"))
#endif
static SHELL_VAR *
-declare_find_variable (name, mkglobal, chklocal)
- const char *name;
- int mkglobal, chklocal;
+declare_find_variable (const char *name, int mkglobal, int chklocal)
{
SHELL_VAR *var;
NAME[SUBSCRIPT][[+]=VALUE]
from expanding a nameref into NAME */
static char *
-declare_build_newname (name, subscript_start, offset, value, aflags)
- char *name, *subscript_start;
- int offset;
- char *value;
- int aflags;
+declare_build_newname (char *name, char *subscript_start, int offset, char *value, int aflags)
{
size_t namelen, savelen;
char *ret;
}
static char *
-declare_transform_name (name, flags_on, flags_off)
- char *name;
- int flags_on, flags_off;
+declare_transform_name (char *name, int flags_on, int flags_off)
{
SHELL_VAR *var, *v;
char *newname;
/* The workhorse function. */
static int
-declare_internal (list, local_var)
- register WORD_LIST *list;
- int local_var;
+declare_internal (WORD_LIST *list, int local_var)
{
int flags_on, flags_off, *flags;
int any_failed, assign_error, pflag, nodefs, opt, onref, offref;
This file is echo.def, from which is created echo.c.
It implements the builtin "echo" in Bash.
-Copyright (C) 1987-2018 Free Software Foundation, Inc.
+Copyright (C) 1987-2018,2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
`-n', then don't print a trailing newline. We also support the
echo syntax from Version 9 Unix systems. */
int
-echo_builtin (list)
- WORD_LIST *list;
+echo_builtin (WORD_LIST *list)
{
int display_return, do_v9, i, len;
char *temp, *s;
then print out a list of shell commands showing which are enabled and
which are disabled. */
int
-enable_builtin (list)
- WORD_LIST *list;
+enable_builtin (WORD_LIST *list)
{
int result, flags;
int opt, filter;
}
/* List some builtins.
- FILTER is a mask with two slots: ENABLED and DISABLED. */
+ FILTER is a mask with three slots: SPECIAL, ENABLED, and DISABLED. */
static void
-list_some_builtins (filter)
- int filter;
+list_some_builtins (int filter)
{
register int i;
/* Enable the shell command NAME. If DISABLE_P is non-zero, then
disable NAME instead. */
static int
-enable_shell_command (name, disable_p)
- char *name;
- int disable_p;
+enable_shell_command (char *name, int disable_p)
{
struct builtin *b;
#endif
static int
-dyn_load_builtin (list, flags, filename)
- WORD_LIST *list;
- int flags;
- char *filename;
+dyn_load_builtin (WORD_LIST *list, int flags, char *filename)
{
WORD_LIST *l;
void *handle;
#if defined (HAVE_DLCLOSE)
static void
-delete_builtin (b)
- struct builtin *b;
+delete_builtin (struct builtin *b)
{
int ind, size;
struct builtin *new_shell_builtins;
/* Tenon's MachTen has a dlclose that doesn't return a value, so we
finesse it with a local wrapper. */
static int
-local_dlclose (handle)
- void *handle;
+local_dlclose (void *handle)
{
#if !defined (__MACHTEN__)
return (dlclose (handle));
}
static int
-dyn_unload_builtin (name)
- char *name;
+dyn_unload_builtin (char *name)
{
struct builtin *b;
void *handle;
This file is eval.def, from which is created eval.c.
It implements the builtin "eval" in Bash.
-Copyright (C) 1987-2016 Free Software Foundation, Inc.
+Copyright (C) 1987-2016,2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
/* Parse the string that these words make, and execute the command found. */
int
-eval_builtin (list)
- WORD_LIST *list;
+eval_builtin (WORD_LIST *list)
{
if (no_options (list))
return (EX_USAGE);
#if defined (HISTORY)
static void
-set_history_remembering ()
+set_history_remembering (void)
{
remember_on_history = enable_history_list;
}
#endif
static void
-restore_lastcom (x)
- char *x;
+restore_lastcom (char *x)
{
FREE (the_printed_command_except_trap);
the_printed_command_except_trap = x;
}
int
-should_optimize_fork (command, subshell)
- COMMAND *command;
- int subshell;
+should_optimize_fork (COMMAND *command, int subshell)
{
return (running_trap == 0 &&
command->type == cm_simple &&
-c command but has been extended to command and process substitution
(basically any time you call parse_and_execute in a subshell). */
int
-should_suppress_fork (command)
- COMMAND *command;
+should_suppress_fork (COMMAND *command)
{
int subshell;
}
int
-can_optimize_connection (command)
- COMMAND *command;
+can_optimize_connection (COMMAND *command)
{
return (*bash_input.location.string == '\0' &&
parser_expanding_alias () == 0 &&
}
void
-optimize_connection_fork (command)
- COMMAND *command;
+optimize_connection_fork (COMMAND *command)
{
if (command->type == cm_connection &&
(command->value.Connection->connector == AND_AND || command->value.Connection->connector == OR_OR || command->value.Connection->connector == ';') &&
}
void
-optimize_subshell_command (command)
- COMMAND *command;
+optimize_subshell_command (COMMAND *command)
{
if (should_optimize_fork (command, 0))
{
}
void
-optimize_shell_function (command)
- COMMAND *command;
+optimize_shell_function (COMMAND *command)
{
COMMAND *fc;
}
int
-can_optimize_cat_file (command)
- COMMAND *command;
+can_optimize_cat_file (COMMAND *command)
{
return (command->type == cm_simple && !command->redirects &&
(command->flags & CMD_TIME_PIPELINE) == 0 &&
/* How to force parse_and_execute () to clean up after itself. */
void
-parse_and_execute_cleanup (old_running_trap)
- int old_running_trap;
+parse_and_execute_cleanup (int old_running_trap)
{
if (running_trap > 0)
{
}
static void
-parse_prologue (string, flags, tag)
- char *string;
- int flags;
- char *tag;
+parse_prologue (char *string, int flags, char *tag)
{
char *orig_string, *lastcom;
int x;
*/
int
-parse_and_execute (string, from_file, flags)
- char *string;
- const char *from_file;
- int flags;
+parse_and_execute (char *string, const char *from_file, int flags)
{
int code, lreset, ignore_return;
volatile int should_jump_to_top_level, last_result;
command substitutions during parsing to obey Posix rules about finding
the end of the command and balancing parens. */
int
-parse_string (string, from_file, flags, cmdp, endp)
- char *string;
- const char *from_file;
- int flags;
- COMMAND **cmdp;
- char **endp;
+parse_string (char *string, const char *from_file, int flags, COMMAND **cmdp, char **endp)
{
int code, nc;
volatile int should_jump_to_top_level;
}
int
-open_redir_file (r, fnp)
- REDIRECT *r;
- char **fnp;
+open_redir_file (REDIRECT *r, char **fnp)
{
char *fn;
int fd, rval;
returning errors as appropriate, then just cats the file to the standard
output. */
static int
-cat_file (r)
- REDIRECT *r;
+cat_file (REDIRECT *r)
{
char *fn;
int fd, rval;
}
int
-evalstring (string, from_file, flags)
- char *string;
- const char *from_file;
- int flags;
+evalstring (char *string, const char *from_file, int flags)
{
volatile int r, rflag, rcatch;
volatile int was_trap;
This file is exec.def, from which is created exec.c.
It implements the builtin "exec" in Bash.
-Copyright (C) 1987-2021 Free Software Foundation, Inc.
+Copyright (C) 1987-2021,2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
/* If the user wants this to look like a login shell, then
prepend a `-' onto NAME and return the new name. */
static char *
-mkdashname (name)
- char *name;
+mkdashname (char *name)
{
char *ret;
}
int
-exec_builtin (list)
- WORD_LIST *list;
+exec_builtin (WORD_LIST *list)
{
int exit_value = EXECUTION_FAILURE;
int cleanenv, login, opt, orig_job_control;
static int sourced_logout;
int
-exit_builtin (list)
- WORD_LIST *list;
+exit_builtin (WORD_LIST *list)
{
CHECK_HELPOPT (list);
/* How to logout. */
int
-logout_builtin (list)
- WORD_LIST *list;
+logout_builtin (WORD_LIST *list)
{
CHECK_HELPOPT (list);
}
static int
-exit_or_logout (list)
- WORD_LIST *list;
+exit_or_logout (WORD_LIST *list)
{
int exit_value;
}
void
-bash_logout ()
+bash_logout (void)
{
/* Run our `~/.bash_logout' file if it exists, and this is a login shell. */
if (login_shell && sourced_logout++ == 0 && subshell_environment == 0)
#endif
static void
-set_verbose_flag ()
+set_verbose_flag (void)
{
echo_input_at_read = verbose_flag;
}
#endif
int
-fc_builtin (list)
- WORD_LIST *list;
+fc_builtin (WORD_LIST *list)
{
register int i;
register char *sep;
/* Return 1 if LIST->word->word is a legal number for fc's use. */
static int
-fc_number (list)
- WORD_LIST *list;
+fc_number (WORD_LIST *list)
{
char *s;
are executing them. If MODE includes HN_FIRST we are looking for the
first history number specification. */
static int
-fc_gethnum (command, hlist, mode)
- char *command;
- HIST_ENTRY **hlist;
- int mode;
+fc_gethnum (char *command, HIST_ENTRY **hlist, int mode)
{
int sign, n, clen, rh;
register int i, j, last_hist, real_last, listing;
COMMAND in HLIST, and return a malloc()'ed copy of it.
MODE is 1 if we are listing commands, 0 if we are executing them. */
static char *
-fc_gethist (command, hlist, mode)
- char *command;
- HIST_ENTRY **hlist;
- int mode;
+fc_gethist (char *command, HIST_ENTRY **hlist, int mode)
{
int i;
one at a time. This can read unlimited length lines. The
caller should free the storage. */
static char *
-fc_readline (stream)
- FILE *stream;
+fc_readline (FILE *stream)
{
register int c;
int line_len = 0, lindex = 0;
Return a pointer to a malloc'ed string which contains the substituted
command. */
static char *
-fc_dosubs (command, subs)
- char *command;
- REPL *subs;
+fc_dosubs (char *command, REPL *subs)
{
register char *new, *t;
register REPL *r;
become the history entry, and that `fc' should never appear in the
history list. This way you can do `r' to your heart's content. */
static void
-fc_replhist (command)
- char *command;
+fc_replhist (char *command)
{
int n;
#ifdef INCLUDE_UNUSED
/* Add LINE to the history, after removing a single trailing newline. */
static void
-fc_addhist (line)
- char *line;
+fc_addhist (char *line)
{
register int n;
/* How to bring a job into the foreground. */
int
-fg_builtin (list)
- WORD_LIST *list;
+fg_builtin (WORD_LIST *list)
{
int fg_bit;
register WORD_LIST *t;
#if defined (JOB_CONTROL)
/* How to put a job into the background. */
int
-bg_builtin (list)
- WORD_LIST *list;
+bg_builtin (WORD_LIST *list)
{
int r;
/* How to put a job into the foreground/background. */
static int
-fg_bg (list, foreground)
- WORD_LIST *list;
- int foreground;
+fg_bg (WORD_LIST *list, int foreground)
{
sigset_t set, oset;
int job, status, old_async_pid;
write the information to STRUCTFILE and EXTERNFILE, while
creating the production file if necessary. */
int
-main (argc, argv)
- int argc;
- char **argv;
+main (int argc, char **argv)
{
int arg_index = 1;
internationalization (gettext) and the single-string vs. multiple-strings
issues. */
void
-write_documentation (stream, documentation, indentation)
- FILE *stream;
- char *documentation;
- int indentation;
+write_documentation (FILE *stream, char *documentation, int indentation)
{
if (stream == 0)
return;
}
int
-write_helpfiles (builtins)
- struct builtin *builtins;
+write_helpfiles (struct builtin *builtins)
{
char *helpfile, *bname, *fname;
FILE *helpfp;
not empty, then rehash (or hash in the first place) the specified
commands. */
int
-hash_builtin (list)
- WORD_LIST *list;
+hash_builtin (WORD_LIST *list)
{
int expunge_hash_table, list_targets, list_portably, delete, opt;
char *w, *pathname;
}
static int
-add_hashed_command (w, quiet)
- char *w;
- int quiet;
+add_hashed_command (char *w, int quiet)
{
int rv;
char *full_path;
/* Print information about current hashed info. */
static int
-print_hash_info (item)
- BUCKET_CONTENTS *item;
+print_hash_info (BUCKET_CONTENTS *item)
{
printf ("%4d\t%s\n", item->times_found, pathdata(item)->path);
return 0;
}
static int
-print_portable_hash_info (item)
- BUCKET_CONTENTS *item;
+print_portable_hash_info (BUCKET_CONTENTS *item)
{
char *fp, *fn;
}
static int
-print_hashed_commands (fmt)
- int fmt;
+print_hashed_commands (int fmt)
{
if (hashed_filenames == 0 || HASH_ENTRIES (hashed_filenames) == 0)
return (0);
}
static int
-list_hashed_filename_targets (list, fmt)
- WORD_LIST *list;
- int fmt;
+list_hashed_filename_targets (WORD_LIST *list, int fmt)
{
int all_found, multiple;
char *target;
If LIST is supplied, print out the list which matches for each pattern
specified. */
int
-help_builtin (list)
- WORD_LIST *list;
+help_builtin (WORD_LIST *list)
{
register int i;
char *pattern, *name;
}
void
-builtin_help ()
+builtin_help (void)
{
int ind;
ptrdiff_t d;
}
static int
-open_helpfile (name)
- char *name;
+open_helpfile (char *name)
{
int fd;
used, the long_doc array contains one string -- the full pathname of the
help file for this builtin. */
static void
-show_longdoc (i)
- int i;
+show_longdoc (int i)
{
register int j;
char * const *doc;
}
static void
-show_desc (name, i)
- char *name;
- int i;
+show_desc (char *name, int i)
{
register int j, r;
char **doc, *line;
/* Print builtin help in pseudo-manpage format. */
static void
-show_manpage (name, i)
- char *name;
- int i;
+show_manpage (char *name, int i)
{
register int j;
char **doc, *line;
}
static void
-dispcolumn (i, buf, bufsize, width, height)
- int i;
- char *buf;
- size_t bufsize;
- int width, height;
+dispcolumn (int i, char *buf, size_t bufsize, int width, int height)
{
int j;
int dispcols;
#if defined (HANDLE_MULTIBYTE)
static void
-wdispcolumn (i, buf, bufsize, width, height)
- int i;
- char *buf;
- size_t bufsize;
- int width, height;
+wdispcolumn (int i, char *buf, size_t bufsize, int width, int height)
{
int j;
int dispcols, dispchars;
#endif /* HANDLE_MULTIBYTE */
static void
-show_builtin_command_help ()
+show_builtin_command_help (void)
{
int i, j;
int height, width;
#endif
int
-history_builtin (list)
- WORD_LIST *list;
+history_builtin (WORD_LIST *list)
{
int flags, opt, result, old_history_lines, obase, ind;
char *filename, *delete_arg, *range;
#define histdata(i) (hlist[(i)]->data)
static char *
-histtime (hlist, histtimefmt)
- HIST_ENTRY *hlist;
- const char *histtimefmt;
+histtime (HIST_ENTRY *hlist, const char *histtimefmt)
{
static char timestr[TIMELEN_MAX];
time_t t;
}
static int
-display_history (list)
- WORD_LIST *list;
+display_history (WORD_LIST *list)
{
register int i;
intmax_t limit;
/* Remove the last entry in the history list and add each argument in
LIST to the history. */
static void
-push_history (list)
- WORD_LIST *list;
+push_history (WORD_LIST *list)
{
char *s;
#if defined (BANG_HISTORY)
static int
-expand_and_print_history (list)
- WORD_LIST *list;
+expand_and_print_history (WORD_LIST *list)
{
char *s;
int r, result;
group leader and execute the command. The -r and -s options mean
to print info about running and stopped jobs only, respectively. */
int
-jobs_builtin (list)
- WORD_LIST *list;
+jobs_builtin (WORD_LIST *list)
{
int form, execute, state, opt, any_failed, job;
sigset_t set, oset;
}
static int
-execute_list_with_replacements (list)
- WORD_LIST *list;
+execute_list_with_replacements (WORD_LIST *list)
{
register WORD_LIST *l;
int job, result;
#if defined (JOB_CONTROL)
int
-disown_builtin (list)
- WORD_LIST *list;
+disown_builtin (WORD_LIST *list)
{
int opt, job, retval, nohup_only, running_jobs, all_jobs;
sigset_t set, oset;
kill -KILL %1? No, if you fill up the process table this way you
can still kill some. */
int
-kill_builtin (list)
- WORD_LIST *list;
+kill_builtin (WORD_LIST *list)
{
int sig, any_succeeded, listing, saw_signal, dflags;
char *sigspec, *word;
}
static void
-kill_error (pid, e)
- pid_t pid;
- int e;
+kill_error (pid_t pid, int e)
{
char *x;
/* Arithmetic LET function. */
int
-let_builtin (list)
- WORD_LIST *list;
+let_builtin (WORD_LIST *list)
{
intmax_t ret;
int expok;
#ifdef INCLUDE_UNUSED
int
-exp_builtin (list)
- WORD_LIST *list;
+exp_builtin (WORD_LIST *list)
{
char *exp;
intmax_t ret;
static int delim;
static int
-run_callback (callback, curindex, curline)
- const char *callback;
- unsigned int curindex;
- const char *curline;
+run_callback (const char *callback, unsigned int curindex, const char *curline)
{
unsigned int execlen;
char *execstr, *qline;
}
static void
-do_chop(line, delim)
- char *line;
- unsigned char delim;
+do_chop(char *line, unsigned char delim)
{
int length;
}
static int
-mapfile (fd, line_count_goal, origin, nskip, callback_quantum, callback, array_name, delim, flags)
- int fd;
- long line_count_goal, origin, nskip, callback_quantum;
- char *callback, *array_name;
- int delim;
- int flags;
+mapfile (int fd, long line_count_goal, long origin, long nskip, long callback_quantum,
+ char *callback, char *array_name, int delim, int flags)
{
char *line;
size_t line_length;
}
int
-mapfile_builtin (list)
- WORD_LIST *list;
+mapfile_builtin (WORD_LIST *list)
{
int opt, code, fd, flags;
intmax_t intval;
#else
int
-mapfile_builtin (list)
- WORD_LIST *list;
+mapfile_builtin (WORD_LIST *list)
{
builtin_error (_("array variable support required"));
return (EXECUTION_FAILURE);
};
/* Forward declarations. */
-static int is_special_builtin ();
-static int is_assignment_builtin ();
-static int is_localvar_builtin ();
-static int is_posix_builtin ();
-static int is_arrayvar_builtin ();
+static int is_special_builtin (char *);
+static int is_assignment_builtin (char *);
+static int is_localvar_builtin (char *);
+static int is_posix_builtin (char *);
+static int is_arrayvar_builtin (char *);
#if !defined (HAVE_RENAME)
-static int rename ();
+static int rename (char *, char *);
#endif
-void extract_info ();
+void extract_info (char *, FILE *, FILE *);
-void file_error ();
-void line_error ();
+void file_error (char *);
+void line_error (DEF_FILE *, char *, char *, char *);
-void write_file_headers ();
-void write_file_footers ();
-void write_ifdefs ();
-void write_endifs ();
-void write_documentation ();
-void write_longdocs ();
-void write_builtins ();
+void write_file_headers (FILE *, FILE *);
+void write_file_footers (FILE *, FILE *);
+void write_ifdefs (FILE *, char **);
+void write_endifs (FILE *, char **);
+void write_documentation (FILE *, char **, int, int);
+void write_dummy_declarations (FILE *, ARRAY *);
+void write_longdocs (FILE *, ARRAY *);
+void write_builtins (DEF_FILE *, FILE *, FILE *);
-int write_helpfiles ();
+int write_helpfiles (ARRAY *);
-void free_defs ();
-void add_documentation ();
+static int _find_in_table (char *, char **);
-void must_be_building ();
-void remove_trailing_whitespace ();
+void free_defs (DEF_FILE *);
+void add_documentation (DEF_FILE *, char *);
+
+void must_be_building (char *, DEF_FILE *);
+void remove_trailing_whitespace (char *);
#define document_name(b) ((b)->docname ? (b)->docname : (b)->name)
-\f
/* For each file mentioned on the command line, process it and
write the information to STRUCTFILE and EXTERNFILE, while
creating the production file if necessary. */
int
-main (argc, argv)
- int argc;
- char **argv;
+main (int argc, char **argv)
{
int arg_index = 1;
FILE *structfile, *externfile;
/* Make a new array, and return a pointer to it. The array will
contain elements of size WIDTH, and is initialized to no elements. */
ARRAY *
-array_create (width)
- int width;
+array_create (int width)
{
ARRAY *array;
/* Copy the array of strings in ARRAY. */
ARRAY *
-copy_string_array (array)
- ARRAY *array;
+copy_string_array (ARRAY *array)
{
register int i;
ARRAY *copy;
/* Add ELEMENT to ARRAY, growing the array if necessary. */
void
-array_add (element, array)
- char *element;
- ARRAY *array;
+array_add (char *element, ARRAY *array)
{
if (array->sindex + 2 > array->size)
array->array = (char **)xrealloc
/* Free an allocated array and data pointer. */
void
-array_free (array)
- ARRAY *array;
+array_free (ARRAY *array)
{
if (array->array)
free (array->array);
/* Return the entry in the table of handlers for NAME. */
HANDLER_ENTRY *
-find_directive (directive)
- char *directive;
+find_directive (char *directive)
{
register int i;
builtins found in each $BUILTIN. Plain text found before the $PRODUCES
is ignored, as is "$$ comment text". */
void
-extract_info (filename, structfile, externfile)
- char *filename;
- FILE *structfile, *externfile;
+extract_info (char *filename, FILE *structfile, FILE *externfile)
{
register int i;
DEF_FILE *defs;
if (!handler)
{
- line_error (defs, "Unknown directive `%s'", directive);
+ line_error (defs, "Unknown directive `%s'", directive, "");
free (directive);
continue;
}
#define free_safely(x) if (x) free (x)
static void
-free_builtin (builtin)
- BUILTIN_DESC *builtin;
+free_builtin (BUILTIN_DESC *builtin)
{
register int i;
/* Free all of the memory allocated to a DEF_FILE. */
void
-free_defs (defs)
- DEF_FILE *defs;
+free_defs (DEF_FILE *defs)
{
register int i;
register BUILTIN_DESC *builtin;
/* Strip surrounding whitespace from STRING, and
return a pointer to the start of it. */
char *
-strip_whitespace (string)
- char *string;
+strip_whitespace (char *string)
{
while (whitespace (*string))
string++;
/* Remove only the trailing whitespace from STRING. */
void
-remove_trailing_whitespace (string)
- char *string;
+remove_trailing_whitespace (char *string)
{
register int i;
DEFS is the DEF_FILE in which the directive is found.
If there is no argument, produce an error. */
char *
-get_arg (for_whom, defs, string)
- char *for_whom, *string;
- DEF_FILE *defs;
+get_arg (char *for_whom, DEF_FILE *defs, char *string)
{
char *new;
new = strip_whitespace (string);
if (!*new)
- line_error (defs, "%s requires an argument", for_whom);
+ line_error (defs, "%s requires an argument", for_whom, "");
return (savestring (new));
}
/* Error if not building a builtin. */
void
-must_be_building (directive, defs)
- char *directive;
- DEF_FILE *defs;
+must_be_building (char *directive, DEF_FILE *defs)
{
if (!building_builtin)
- line_error (defs, "%s must be inside of a $BUILTIN block", directive);
+ line_error (defs, "%s must be inside of a $BUILTIN block", directive, "");
}
/* Return the current builtin. */
BUILTIN_DESC *
-current_builtin (directive, defs)
- char *directive;
- DEF_FILE *defs;
+current_builtin (char *directive, DEF_FILE *defs)
{
must_be_building (directive, defs);
if (defs->builtins)
/* Add LINE to the long documentation for the current builtin.
Ignore blank lines until the first non-blank line has been seen. */
void
-add_documentation (defs, line)
- DEF_FILE *defs;
- char *line;
+add_documentation (DEF_FILE *defs, char *line)
{
register BUILTIN_DESC *builtin;
/* How to handle the $BUILTIN directive. */
int
-builtin_handler (self, defs, arg)
- char *self;
- DEF_FILE *defs;
- char *arg;
+builtin_handler (char *self, DEF_FILE *defs, char *arg)
{
BUILTIN_DESC *new;
char *name;
/* If we are already building a builtin, we cannot start a new one. */
if (building_builtin)
{
- line_error (defs, "%s found before $END", self);
+ line_error (defs, "%s found before $END", self, "");
return (-1);
}
/* How to handle the $FUNCTION directive. */
int
-function_handler (self, defs, arg)
- char *self;
- DEF_FILE *defs;
- char *arg;
+function_handler (char *self, DEF_FILE *defs, char *arg)
{
register BUILTIN_DESC *builtin;
if (builtin == 0)
{
- line_error (defs, "syntax error: no current builtin for $FUNCTION directive");
+ line_error (defs, "syntax error: no current builtin for $FUNCTION directive", "", "");
exit (1);
}
if (builtin->function)
/* How to handle the $DOCNAME directive. */
int
-docname_handler (self, defs, arg)
- char *self;
- DEF_FILE *defs;
- char *arg;
+docname_handler (char *self, DEF_FILE *defs, char *arg)
{
register BUILTIN_DESC *builtin;
/* How to handle the $SHORT_DOC directive. */
int
-short_doc_handler (self, defs, arg)
- char *self;
- DEF_FILE *defs;
- char *arg;
+short_doc_handler (char *self, DEF_FILE *defs, char *arg)
{
register BUILTIN_DESC *builtin;
/* How to handle the $COMMENT directive. */
int
-comment_handler (self, defs, arg)
- char *self;
- DEF_FILE *defs;
- char *arg;
+comment_handler (char *self, DEF_FILE *defs, char *arg)
{
return (0);
}
/* How to handle the $DEPENDS_ON directive. */
int
-depends_on_handler (self, defs, arg)
- char *self;
- DEF_FILE *defs;
- char *arg;
+depends_on_handler (char *self, DEF_FILE *defs, char *arg)
{
register BUILTIN_DESC *builtin;
char *dependent;
/* How to handle the $PRODUCES directive. */
int
-produces_handler (self, defs, arg)
- char *self;
- DEF_FILE *defs;
- char *arg;
+produces_handler (char *self, DEF_FILE *defs, char *arg)
{
/* If just hacking documentation, don't change any of the production
files. */
/* How to handle the $END directive. */
int
-end_handler (self, defs, arg)
- char *self;
- DEF_FILE *defs;
- char *arg;
+end_handler (char *self, DEF_FILE *defs, char *arg)
{
must_be_building (self, defs);
building_builtin = 0;
/* Produce an error for DEFS with FORMAT and ARGS. */
void
-line_error (defs, format, arg1, arg2)
- DEF_FILE *defs;
- char *format, *arg1, *arg2;
+line_error (DEF_FILE *defs, char *format, char *arg1, char *arg2)
{
if (defs->filename[0] != '/')
fprintf (stderr, "%s", error_directory ? error_directory : "./");
/* Print error message for FILENAME. */
void
-file_error (filename)
- char *filename;
+file_error (char *filename)
{
perror (filename);
exit (2);
/* */
/* **************************************************************** */
-static void memory_error_and_abort ();
+static void memory_error_and_abort (void);
static char *
-xmalloc (bytes)
- int bytes;
+xmalloc (size_t bytes)
{
char *temp = (char *)malloc (bytes);
}
static char *
-xrealloc (pointer, bytes)
- char *pointer;
- int bytes;
+xrealloc (void *pointer, size_t bytes)
{
char *temp;
}
static void
-memory_error_and_abort ()
+memory_error_and_abort (void)
{
fprintf (stderr, "mkbuiltins: out of virtual memory\n");
abort ();
/* Return a pointer to a newly allocated builtin which is
an exact copy of BUILTIN. */
BUILTIN_DESC *
-copy_builtin (builtin)
- BUILTIN_DESC *builtin;
+copy_builtin (BUILTIN_DESC *builtin)
{
BUILTIN_DESC *new;
/* How to save away a builtin. */
void
-save_builtin (builtin)
- BUILTIN_DESC *builtin;
+save_builtin (BUILTIN_DESC *builtin)
{
BUILTIN_DESC *newbuiltin;
/* Write out any necessary opening information for
STRUCTFILE and EXTERNFILE. */
void
-write_file_headers (structfile, externfile)
- FILE *structfile, *externfile;
+write_file_headers (FILE *structfile, FILE *externfile)
{
register int i;
/* Write out any necessary closing information for
STRUCTFILE and EXTERNFILE. */
void
-write_file_footers (structfile, externfile)
- FILE *structfile, *externfile;
+write_file_footers (FILE *structfile, FILE *externfile)
{
register int i;
/* Write out the information accumulated in DEFS to
STRUCTFILE and EXTERNFILE. */
void
-write_builtins (defs, structfile, externfile)
- DEF_FILE *defs;
- FILE *structfile, *externfile;
+write_builtins (DEF_FILE *defs, FILE *structfile, FILE *externfile)
{
register int i;
/* Write out the long documentation strings in BUILTINS to STREAM. */
void
-write_longdocs (stream, builtins)
- FILE *stream;
- ARRAY *builtins;
+write_longdocs (FILE *stream, ARRAY *builtins)
{
register int i;
register BUILTIN_DESC *builtin;
}
void
-write_dummy_declarations (stream, builtins)
- FILE *stream;
- ARRAY *builtins;
+write_dummy_declarations (FILE *stream, ARRAY *builtins)
{
register int i;
BUILTIN_DESC *builtin;
If a define is preceded by an `!', then the sense of the test is
reversed. */
void
-write_ifdefs (stream, defines)
- FILE *stream;
- char **defines;
+write_ifdefs (FILE *stream, char **defines)
{
register int i;
STREAM is the stream to write the information to.
DEFINES is a null terminated array of define names. */
void
-write_endifs (stream, defines)
- FILE *stream;
- char **defines;
+write_endifs (FILE *stream, char **defines)
{
register int i;
internationalization (gettext) and the single-string vs. multiple-strings
issues. */
void
-write_documentation (stream, documentation, indentation, flags)
- FILE *stream;
- char **documentation;
- int indentation, flags;
+write_documentation (FILE *stream, char **documentation, int indentation, int flags)
{
register int i, j;
register char *line;
}
int
-write_helpfiles (builtins)
- ARRAY *builtins;
+write_helpfiles (ARRAY *builtins)
{
char *helpfile, *bname;
FILE *helpfp;
}
static int
-_find_in_table (name, name_table)
- char *name, *name_table[];
+_find_in_table (char *name, char **name_table)
{
register int i;
}
static int
-is_special_builtin (name)
- char *name;
+is_special_builtin (char *name)
{
return (_find_in_table (name, special_builtins));
}
static int
-is_assignment_builtin (name)
- char *name;
+is_assignment_builtin (char *name)
{
return (_find_in_table (name, assignment_builtins));
}
static int
-is_localvar_builtin (name)
- char *name;
+is_localvar_builtin (char *name)
{
return (_find_in_table (name, localvar_builtins));
}
static int
-is_posix_builtin (name)
- char *name;
+is_posix_builtin (char *name)
{
return (_find_in_table (name, posix_builtins));
}
static int
-is_arrayvar_builtin (name)
- char *name;
+is_arrayvar_builtin (char *name)
{
return (_find_in_table (name, arrayvar_builtins));
}
#if !defined (HAVE_RENAME)
static int
-rename (from, to)
- char *from, *to;
+rename (char *from, char *to)
{
unlink (to);
if (link (from, to) < 0)
static size_t conv_bufsize;
int
-printf_builtin (list)
- WORD_LIST *list;
+printf_builtin (WORD_LIST *list)
{
int ch, fieldwidth, precision;
int have_fieldwidth, have_precision, use_Lmod, altform;
}
static void
-printf_erange (s)
- char *s;
+printf_erange (char *s)
{
builtin_error (_("warning: %s: %s"), s, strerror(ERANGE));
}
/* We duplicate a lot of what printf(3) does here. */
+/* FMT: format
+ STRING: expanded string argument
+ LEN: length of expanded string
+ FIELDWIDTH: argument for width of `*'
+ PRECISION: argument for precision of `*' */
static int
-printstr (fmt, string, len, fieldwidth, precision)
- char *fmt; /* format */
- char *string; /* expanded string argument */
- int len; /* length of expanded string */
- int fieldwidth; /* argument for width of `*' */
- int precision; /* argument for precision of `*' */
+printstr (char *fmt, char *string, int len, int fieldwidth, int precision)
{
#if 0
char *s;
do the \c short-circuiting, and \c is treated as an unrecognized escape
sequence; we also bypass the other processing specific to %b arguments. */
static int
-tescape (estart, cp, lenp, sawc)
- char *estart;
- char *cp;
- int *lenp, *sawc;
+tescape (char *estart, char *cp, int *lenp, int *sawc)
{
register char *p;
int temp, c, evalue;
}
static char *
-bexpand (string, len, sawc, lenp)
- char *string;
- int len, *sawc, *lenp;
+bexpand (char *string, int len, int *sawc, int *lenp)
{
int temp;
char *ret, *r, *s, c;
}
static char *
-vbadd (buf, blen)
- char *buf;
- int blen;
+vbadd (char *buf, int blen)
{
size_t nlen;
}
static int
-#if defined (PREFER_STDARG)
vbprintf (const char *format, ...)
-#else
-vbprintf (format, va_alist)
- const char *format;
- va_dcl
-#endif
{
va_list args;
size_t nlen;
}
static char *
-mklong (str, modifiers, mlen)
- char *str;
- char *modifiers;
- size_t mlen;
+mklong (char *str, char *modifiers, size_t mlen)
{
size_t len, slen;
}
static int
-getchr ()
+getchr (void)
{
int ret;
}
static char *
-getstr ()
+getstr (void)
{
char *ret;
}
static int
-getint ()
+getint (void)
{
intmax_t ret;
}
static intmax_t
-getintmax ()
+getintmax (void)
{
intmax_t ret;
char *ep;
}
static uintmax_t
-getuintmax ()
+getuintmax (void)
{
uintmax_t ret;
char *ep;
}
static double
-getdouble ()
+getdouble (void)
{
double ret;
char *ep;
}
static floatmax_t
-getfloatmax ()
+getfloatmax (void)
{
floatmax_t ret;
char *ep;
/* NO check is needed for garglist here. */
static intmax_t
-asciicode ()
+asciicode (void)
{
register intmax_t ch;
#if defined (HANDLE_MULTIBYTE)
#define CLEARSTAK 0x08
int
-pushd_builtin (list)
- WORD_LIST *list;
+pushd_builtin (WORD_LIST *list)
{
WORD_LIST *orig_list;
char *temp, *current_directory, *top;
If LIST is non-null it should consist of a word +N or -N, which says
what element to delete from the stack. The default is the top one. */
int
-popd_builtin (list)
- WORD_LIST *list;
+popd_builtin (WORD_LIST *list)
{
register int i;
intmax_t which;
/* Print the current list of directories on the directory stack. */
int
-dirs_builtin (list)
- WORD_LIST *list;
+dirs_builtin (WORD_LIST *list)
{
int flags, desired_index, index_flag, vflag;
intmax_t i;
}
static void
-pushd_error (offset, arg)
- int offset;
- char *arg;
+pushd_error (int offset, char *arg)
{
if (offset == 0)
builtin_error (_("directory stack empty"));
}
static void
-clear_directory_stack ()
+clear_directory_stack (void)
{
register int i;
so if the result is EXECUTION_FAILURE then an error message has already
been printed. */
static int
-cd_to_string (name)
- char *name;
+cd_to_string (char *name)
{
WORD_LIST *tlist;
WORD_LIST *dir;
}
static int
-change_to_temp (temp)
- char *temp;
+change_to_temp (char *temp)
{
int tt;
}
static void
-add_dirstack_element (dir)
- char *dir;
+add_dirstack_element (char *dir)
{
if (directory_list_offset == directory_list_size)
pushd_directory_list = strvec_resize (pushd_directory_list, directory_list_size += 10);
}
static int
-get_dirstack_index (ind, sign, indexp)
- intmax_t ind;
- int sign, *indexp;
+get_dirstack_index (intmax_t ind, int sign, int *indexp)
{
if (indexp)
*indexp = sign > 0 ? 1 : 2;
/* Used by the tilde expansion code. */
char *
-get_dirstack_from_string (string)
- char *string;
+get_dirstack_from_string (char *string)
{
int ind, sign, index_flag;
intmax_t i;
#ifdef INCLUDE_UNUSED
char *
-get_dirstack_element (ind, sign)
- intmax_t ind;
- int sign;
+get_dirstack_element (intmax_t ind, int sign)
{
int i;
#endif
void
-set_dirstack_element (ind, sign, value)
- intmax_t ind;
- int sign;
- char *value;
+set_dirstack_element (intmax_t ind, int sign, char *value)
{
int i;
}
WORD_LIST *
-get_directory_stack (flags)
- int flags;
+get_directory_stack (int flags)
{
register int i;
WORD_LIST *ret;
/* Set a flag that check_read_timeout can check. This relies on zread or
read_builtin calling trap.c:check_signals() (which calls check_read_timeout()) */
static sighandler
-sigalrm (s)
- int s;
+sigalrm (int s)
{
/* Display warning if this is called without read_timeout set? */
if (read_timeout)
}
static void
-reset_timeout ()
+reset_timeout (void)
{
/* Cancel alarm before restoring signal handler. */
if (read_timeout)
}
void
-check_read_timeout ()
+check_read_timeout (void)
{
if (read_timeout && shtimer_chktimeout (read_timeout))
sh_longjmp (read_timeout->jmpenv, 1);
}
int
-read_builtin_timeout (fd)
- int fd;
+read_builtin_timeout (int fd)
{
if ((read_timeout == 0) ||
(read_timeout->fd != fd) ||
gets the remainder of the words on the line. If no variables
are mentioned in LIST, then the default variable is $REPLY. */
int
-read_builtin (list)
- WORD_LIST *list;
+read_builtin (WORD_LIST *list)
{
register char *varname;
int size, nr, pass_next, saw_escape, eof, opt, retval, code, print_ps2, nflag;
}
static SHELL_VAR *
-bind_read_variable (name, value, flags)
- char *name, *value;
- int flags;
+bind_read_variable (char *name, char *value, int flags)
{
SHELL_VAR *v;
#if defined (HANDLE_MULTIBYTE)
static int
-read_mbchar (fd, string, ind, ch, unbuffered)
- int fd;
- char *string;
- int ind, ch, unbuffered;
+read_mbchar (int fd, char *string, int ind, int ch, int unbuffered)
{
char mbchar[MB_LEN_MAX + 1];
int i, n, r;
static void
-ttyrestore (ttp)
- struct ttsave *ttp;
+ttyrestore (struct ttsave *ttp)
{
ttsetattr (ttp->fd, &(ttp->attrs));
tty_modified = 0;
}
void
-read_tty_cleanup ()
+read_tty_cleanup (void)
{
if (tty_modified)
ttyrestore (&termsave);
}
int
-read_tty_modified ()
+read_tty_modified (void)
{
return (tty_modified);
}
static char *deftext;
static void
-reset_attempted_completion_function (cp)
- char *cp;
+reset_attempted_completion_function (char *cp)
{
if (rl_attempted_completion_function == 0 && old_attempted_completion_function)
rl_attempted_completion_function = old_attempted_completion_function;
}
static int
-set_itext ()
+set_itext (void)
{
int r1, r2;
}
static char *
-edit_line (p, itext)
- char *p;
- char *itext;
+edit_line (char *p, char *itext)
{
char *ret;
int len;
}
static void
-set_readline_timeout (t, sec, usec)
- sh_timer *t;
- time_t sec;
- long usec;
+set_readline_timeout (sh_timer *t, time_t sec, long usec)
{
t->tmout.tv_sec = sec;
t->tmout.tv_usec = usec;
static unsigned char delim_char;
static void
-set_eol_delim (c)
- int c;
+set_eol_delim (int c)
{
Keymap cmap;
}
static void
-reset_eol_delim (cp)
- char *cp;
+reset_eol_delim (char *cp)
{
Keymap cmap;
specified as an argument. if no argument is given, then the last
exit status is used. */
int
-return_builtin (list)
- WORD_LIST *list;
+return_builtin (WORD_LIST *list)
{
CHECK_HELPOPT (list);
: (*o_options[i].variable = (onoff == FLAG_ON)))
static int
-find_minus_o_option (name)
- char *name;
+find_minus_o_option (char *name)
{
register int i;
}
int
-minus_o_option_value (name)
- char *name;
+minus_o_option_value (char *name)
{
register int i;
int *on_or_off;
#define MINUS_O_FORMAT "%-15s\t%s\n"
static void
-print_minus_o_option (name, value, pflag)
- char *name;
- int value, pflag;
+print_minus_o_option (char *name, int value, int pflag)
{
if (pflag == 0)
printf (MINUS_O_FORMAT, name, value ? on : off);
}
void
-list_minus_o_opts (mode, reusable)
- int mode, reusable;
+list_minus_o_opts (int mode, int reusable)
{
register int i;
int *on_or_off, value;
}
char **
-get_minus_o_opts ()
+get_minus_o_opts (void)
{
char **ret;
int i;
}
char *
-get_current_options ()
+get_current_options (void)
{
char *temp;
int i, posixopts;
}
void
-set_current_options (bitmap)
- const char *bitmap;
+set_current_options (const char *bitmap)
{
int i, v, cv, *on_or_off;
}
static int
-set_ignoreeof (on_or_off, option_name)
- int on_or_off;
- char *option_name;
+set_ignoreeof (int on_or_off, char *option_name)
{
ignoreeof = on_or_off == FLAG_ON;
unbind_variable_noref ("ignoreeof");
}
static int
-set_posix_mode (on_or_off, option_name)
- int on_or_off;
- char *option_name;
+set_posix_mode (int on_or_off, char *option_name)
{
/* short-circuit on no-op */
if ((on_or_off == FLAG_ON && posixly_correct) ||
#if defined (READLINE)
/* Magic. This code `knows' how readline handles rl_editing_mode. */
static int
-set_edit_mode (on_or_off, option_name)
- int on_or_off;
- char *option_name;
+set_edit_mode (int on_or_off, char *option_name)
{
int isemacs;
}
static int
-get_edit_mode (name)
- char *name;
+get_edit_mode (char *name)
{
return (*name == 'e' ? no_line_editing == 0 && rl_editing_mode == 1
: no_line_editing == 0 && rl_editing_mode == 0);
#if defined (HISTORY)
static int
-bash_set_history (on_or_off, option_name)
- int on_or_off;
- char *option_name;
+bash_set_history (int on_or_off, char *option_name)
{
if (on_or_off == FLAG_ON)
{
#endif
int
-set_minus_o_option (on_or_off, option_name)
- int on_or_off;
- char *option_name;
+set_minus_o_option (int on_or_off, char *option_name)
{
register int i;
}
static void
-print_all_shell_variables ()
+print_all_shell_variables (void)
{
SHELL_VAR **vars;
}
void
-set_shellopts ()
+set_shellopts (void)
{
char *value;
char tflag[N_O_OPTIONS];
}
void
-parse_shellopts (value)
- char *value;
+parse_shellopts (char *value)
{
char *vname;
int vptr;
}
void
-initialize_shell_options (no_shellopts)
- int no_shellopts;
+initialize_shell_options (int no_shellopts)
{
char *temp;
SHELL_VAR *var;
called from execute_cmd.c:initialize_subshell() when setting up a subshell
to run an executable shell script without a leading `#!'. */
void
-reset_shell_options ()
+reset_shell_options (void)
{
pipefail_opt = 0;
ignoreeof = 0;
then print out the values of the variables instead. If LIST contains
non-flags, then set $1 - $9 to the successive words of LIST. */
int
-set_builtin (list)
- WORD_LIST *list;
+set_builtin (WORD_LIST *list)
{
int on_or_off, flag_name, force_assignment, opts_changed, rv, r;
register char *arg;
#define NEXT_VARIABLE() any_failed++; list = list->next; continue;
int
-unset_builtin (list)
- WORD_LIST *list;
+unset_builtin (WORD_LIST *list)
{
int unset_function, unset_variable, unset_array, opt, nameref, any_failed;
int global_unset_func, global_unset_var, vflags, base_vflags, valid_id;
This file is setattr.def, from which is created setattr.c.
It implements the builtins "export" and "readonly", in Bash.
-Copyright (C) 1987-2021 Free Software Foundation, Inc.
+Copyright (C) 1987-2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
exported attribute from variables named in LIST. An argument of
-f indicates that the names present in LIST refer to functions. */
int
-export_builtin (list)
- register WORD_LIST *list;
+export_builtin (WORD_LIST *list)
{
return (set_or_show_attributes (list, att_exported, 0));
}
/* For each variable name in LIST, make that variable readonly. Given an
empty LIST, print out all existing readonly variables. */
int
-readonly_builtin (list)
- register WORD_LIST *list;
+readonly_builtin (WORD_LIST *list)
{
return (set_or_show_attributes (list, att_readonly, 0));
}
ATTRIBUTE. An arg of `-n' says to remove the attribute from the the
remaining names in LIST (doesn't work for readonly). */
int
-set_or_show_attributes (list, attribute, nodefs)
- register WORD_LIST *list;
- int attribute, nodefs;
+set_or_show_attributes (WORD_LIST *list, int attribute, int nodefs)
{
register SHELL_VAR *var;
int assign, undo, any_failed, assign_error, opt;
/* Show all variable variables (v == 1) or functions (v == 0) with
attributes. */
int
-show_all_var_attributes (v, nodefs)
- int v, nodefs;
+show_all_var_attributes (int v, int nodefs)
{
SHELL_VAR **variable_list, *var;
int any_failed;
/* Show all local variable variables with their attributes. This shows unset
local variables (all_local_variables called with 0 argument). */
int
-show_local_var_attributes (v, nodefs)
- int v, nodefs;
+show_local_var_attributes (int v, int nodefs)
{
SHELL_VAR **variable_list, *var;
int any_failed;
return (any_failed == 0 ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
}
+/* Fill in FLAGS with attribute characters */
int
-var_attribute_string (var, pattr, flags)
- SHELL_VAR *var;
- int pattr;
- char *flags; /* filled in with attributes */
+var_attribute_string (SHELL_VAR *var, int pattr, char *flags)
{
int i;
or `readonly') instead of `declare', and doesn't print function defs
when called by `export' or `readonly'. */
int
-show_var_attributes (var, pattr, nodefs)
- SHELL_VAR *var;
- int pattr, nodefs;
+show_var_attributes (SHELL_VAR *var, int pattr, int nodefs)
{
char flags[MAX_ATTRIBUTES], *x;
int i;
}
int
-show_name_attributes (name, nodefs)
- char *name;
- int nodefs;
+show_name_attributes (char *name, int nodefs)
{
SHELL_VAR *var;
}
int
-show_localname_attributes (name, nodefs)
- char *name;
- int nodefs;
+show_localname_attributes (char *name, int nodefs)
{
SHELL_VAR *var;
}
int
-show_func_attributes (name, nodefs)
- char *name;
- int nodefs;
+show_func_attributes (char *name, int nodefs)
{
SHELL_VAR *var;
}
void
-set_var_attribute (name, attribute, undo)
- char *name;
- int attribute, undo;
+set_var_attribute (char *name, int attribute, int undo)
{
SHELL_VAR *var, *tv, *v, *refvar;
char *tvalue;
This file is shift.def, from which is created shift.c.
It implements the builtin "shift" in Bash.
-Copyright (C) 1987-2020 Free Software Foundation, Inc.
+Copyright (C) 1987-2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
anything in it, it is a number which says where to start the
shifting. Return > 0 if `times' > $#, otherwise 0. */
int
-shift_builtin (list)
- WORD_LIST *list;
+shift_builtin (WORD_LIST *list)
{
intmax_t times;
int itimes, nargs;
#define PFLAG 0x10
int
-shopt_builtin (list)
- WORD_LIST *list;
+shopt_builtin (WORD_LIST *list)
{
int opt, flags, rval;
/* Reset the options managed by `shopt' to the values they would have at
shell startup. Variables from shopt_vars. */
void
-reset_shopt_options ()
+reset_shopt_options (void)
{
autocd = cdable_vars = cdspelling = 0;
check_hashed_filenames = CHECKHASH_DEFAULT;
}
static int
-find_shopt (name)
- char *name;
+find_shopt (char *name)
{
int i;
}
static void
-shopt_error (s)
- char *s;
+shopt_error (char *s)
{
builtin_error (_("%s: invalid shell option name"), s);
}
static int
-toggle_shopts (mode, list, quiet)
- int mode;
- WORD_LIST *list;
- int quiet;
+toggle_shopts (int mode, WORD_LIST *list, int quiet)
{
WORD_LIST *l;
int ind, rval;
}
static void
-print_shopt (name, val, flags)
- char *name;
- int val, flags;
+print_shopt (char *name, int val, int flags)
{
if (flags & PFLAG)
printf ("shopt %s %s\n", val ? "-s" : "-u", name);
/* List the values of all or any of the `shopt' options. Returns 0 if
all were listed or all variables queried were on; 1 otherwise. */
static int
-list_shopts (list, flags)
- WORD_LIST *list;
- int flags;
+list_shopts (WORD_LIST *list, int flags)
{
WORD_LIST *l;
int i, val, rval;
}
static int
-list_some_shopts (mode, flags)
- int mode, flags;
+list_some_shopts (int mode, int flags)
{
int val, i;
}
static int
-list_shopt_o_options (list, flags)
- WORD_LIST *list;
- int flags;
+list_shopt_o_options (WORD_LIST *list, int flags)
{
WORD_LIST *l;
int val, rval;
}
static int
-list_some_o_options (mode, flags)
- int mode, flags;
+list_some_o_options (int mode, int flags)
{
if ((flags & QFLAG) == 0)
list_minus_o_opts (mode, (flags & PFLAG));
}
static int
-set_shopt_o_options (mode, list, quiet)
- int mode;
- WORD_LIST *list;
- int quiet;
+set_shopt_o_options (int mode, WORD_LIST *list, int quiet)
{
WORD_LIST *l;
int rval;
/* If we set or unset interactive_comments with shopt, make sure the
change is reflected in $SHELLOPTS. */
static int
-set_shellopts_after_change (option_name, mode)
- char *option_name;
- int mode;
+set_shellopts_after_change (char *option_name, int mode)
{
set_shellopts ();
return (0);
}
static int
-shopt_set_debug_mode (option_name, mode)
- char *option_name;
- int mode;
+shopt_set_debug_mode (char *option_name, int mode)
{
#if defined (DEBUGGER)
error_trace_mode = function_trace_mode = debugging_mode;
}
static int
-shopt_set_expaliases (option_name, mode)
- char *option_name;
- int mode;
+shopt_set_expaliases (char *option_name, int mode)
{
expand_aliases = expaliases_flag;
return 0;
#if defined (EXTENDED_GLOB)
static int
-shopt_set_extglob (option_name, mode)
- char *option_name;
- int mode;
+shopt_set_extglob (char *option_name, int mode)
{
extended_glob = extglob_flag;
return 0;
#if defined (READLINE)
static int
-shopt_enable_hostname_completion (option_name, mode)
- char *option_name;
- int mode;
+shopt_enable_hostname_completion (char *option_name, int mode)
{
return (enable_hostname_completion (mode));
}
#endif
static int
-set_compatibility_level (option_name, mode)
- char *option_name;
- int mode;
+set_compatibility_level (char *option_name, int mode)
{
int ind, oldval;
char *rhs;
/* Set and unset the various compatibility options from the value of
shell_compatibility_level; used by sv_shcompat */
void
-set_compatibility_opts ()
+set_compatibility_opts (void)
{
shopt_compat31 = shopt_compat32 = 0;
shopt_compat40 = shopt_compat41 = shopt_compat42 = shopt_compat43 = 0;
#if defined (READLINE)
static int
-shopt_set_complete_direxpand (option_name, mode)
- char *option_name;
- int mode;
+shopt_set_complete_direxpand (char *option_name, int mode)
{
set_directory_hook ();
return 0;
/* Don't allow the value of restricted_shell to be modified. */
static int
-set_restricted_shell (option_name, mode)
- char *option_name;
- int mode;
+set_restricted_shell (char *option_name, int mode)
{
static int save_restricted = -1;
/* Not static so shell.c can call it to initialize shopt_login_shell */
int
-set_login_shell (option_name, mode)
- char *option_name;
- int mode;
+set_login_shell (char *option_name, int mode)
{
shopt_login_shell = login_shell != 0;
return (0);
}
char **
-get_shopt_options ()
+get_shopt_options (void)
{
char **ret;
int n, i;
* REUSABLE is 1 if we want to print output in a form that may be reused.
*/
int
-shopt_setopt (name, mode)
- char *name;
- int mode;
+shopt_setopt (char *name, int mode)
{
WORD_LIST *wl;
int r;
}
int
-shopt_listopt (name, reusable)
- char *name;
- int reusable;
+shopt_listopt (char *name, int reusable)
{
int i;
}
void
-set_bashopts ()
+set_bashopts (void)
{
char *value;
char tflag[N_SHOPT_OPTIONS];
}
void
-parse_bashopts (value)
- char *value;
+parse_bashopts (char *value)
{
char *vname;
int vptr, ind;
}
void
-initialize_bashopts (no_bashopts)
- int no_bashopts;
+initialize_bashopts (int no_bashopts)
{
char *temp;
SHELL_VAR *var;
#if defined (ARRAY_VARS)
static int
-set_assoc_expand (option_name, mode)
- char *option_name;
- int mode;
+set_assoc_expand (char *option_name, int mode)
{
#if 0 /* leave this disabled */
if (shell_compatibility_level <= 51)
not executing a shell function, we leave the new values alone and free
the saved values. */
static void
-maybe_pop_dollar_vars ()
+maybe_pop_dollar_vars (void)
{
if (variable_context == 0 && (dollar_vars_changed () & ARGS_SETBLTIN))
dispose_saved_dollar_vars ();
take place in there. So, I open the file, place it into a large string,
close the file, and then execute the string. */
int
-source_builtin (list)
- WORD_LIST *list;
+source_builtin (WORD_LIST *list)
{
int result;
char *filename, *debug_trap, *x;
/* Continue handler. */
static sighandler
-suspend_continue (sig)
- int sig;
+suspend_continue (int sig)
{
set_signal_handler (SIGCONT, old_cont);
#if 0
/* Suspending the shell. If -f is the arg, then do the suspend
no matter what. Otherwise, complain if a login shell. */
int
-suspend_builtin (list)
- WORD_LIST *list;
+suspend_builtin (WORD_LIST *list)
{
int opt, force;
This file is test.def, from which is created test.c.
It implements the builtin "test" in Bash.
-Copyright (C) 1987-2015 Free Software Foundation, Inc.
+Copyright (C) 1987-2015,2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
/* TEST/[ builtin. */
int
-test_builtin (list)
- WORD_LIST *list;
+test_builtin (WORD_LIST *list)
{
char **argv;
int argc, result;
This file is times.def, from which is created times.c.
It implements the builtin "times" in Bash.
-Copyright (C) 1987-2009 Free Software Foundation, Inc.
+Copyright (C) 1987-2009,2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
/* Print the totals for system and user time used. */
int
-times_builtin (list)
- WORD_LIST *list;
+times_builtin (WORD_LIST *list)
{
#if defined (HAVE_GETRUSAGE) && defined (HAVE_TIMEVAL) && defined (RUSAGE_SELF)
struct rusage self, kids;
#define IGNORE 2 /* Ignore this signal. */
int
-trap_builtin (list)
- WORD_LIST *list;
+trap_builtin (WORD_LIST *list)
{
int list_signal_names, display, result, opt;
}
static void
-showtrap (i, show_default)
- int i, show_default;
+showtrap (int i, int show_default)
{
char *t, *p, *sn;
int free_t;
}
static int
-display_traps (list, show_all)
- WORD_LIST *list;
- int show_all;
+display_traps (WORD_LIST *list, int show_all)
{
int result, i;
*/
int
-type_builtin (list)
- WORD_LIST *list;
+type_builtin (WORD_LIST *list)
{
int dflags, any_failed, opt;
WORD_LIST *this;
* return after finding it once.
*/
int
-describe_command (command, dflags)
- char *command;
- int dflags;
+describe_command (char *command, int dflags)
{
int found, i, found_file, f, all;
char *full_path, *x, *pathlist;
#if !defined (HAVE_RESOURCE) && !defined (HAVE_ULIMIT)
long
-ulimit (cmd, newlim)
- int cmd;
- long newlim;
+ulimit (int cmd, long newlim)
{
errno = EINVAL;
return -1;
#endif /* !HAVE_RESOURCE && !HAVE_ULIMIT */
static int
-_findlim (opt)
- int opt;
+_findlim (int opt)
{
register int i;
/* Report or set limits associated with certain per-process resources.
See the help documentation in builtins.c for a full description. */
int
-ulimit_builtin (list)
- register WORD_LIST *list;
+ulimit_builtin (WORD_LIST *list)
{
register char *s;
int c, limind, mode, opt, all_limits;
}
static int
-ulimit_internal (cmd, cmdarg, mode, multiple)
- int cmd;
- char *cmdarg;
- int mode, multiple;
+ulimit_internal (int cmd, char *cmdarg, int mode, int multiple)
{
int opt, limind, setting;
int block_factor;
}
static int
-get_limit (ind, softlim, hardlim)
- int ind;
- RLIMTYPE *softlim, *hardlim;
+get_limit (int ind, RLIMTYPE *softlim, RLIMTYPE *hardlim)
{
RLIMTYPE value;
#if defined (HAVE_RESOURCE)
}
static int
-set_limit (ind, newlim, mode)
- int ind;
- RLIMTYPE newlim;
- int mode;
+set_limit (int ind, RLIMTYPE newlim, int mode)
{
#if defined (HAVE_RESOURCE)
struct rlimit limit;
}
static int
-getmaxvm (softlim, hardlim)
- RLIMTYPE *softlim, *hardlim;
+getmaxvm (RLIMTYPE *softlim, RLIMTYPE *hardlim)
{
#if defined (HAVE_RESOURCE)
struct rlimit datalim, stacklim;
}
static int
-filesize(valuep)
- RLIMTYPE *valuep;
+filesize (RLIMTYPE *valuep)
{
#if !defined (HAVE_RESOURCE)
long result;
}
static int
-pipesize (valuep)
- RLIMTYPE *valuep;
+pipesize (RLIMTYPE *valuep)
{
#if defined (PIPE_BUF)
/* This is defined on Posix systems. */
}
static int
-getmaxuprc (valuep)
- RLIMTYPE *valuep;
+getmaxuprc (RLIMTYPE *valuep)
{
long maxchild;
}
static void
-print_all_limits (mode)
- int mode;
+print_all_limits (int mode)
{
register int i;
RLIMTYPE softlim, hardlim;
}
static void
-printone (limind, curlim, pdesc)
- int limind;
- RLIMTYPE curlim;
- int pdesc;
+printone (int limind, RLIMTYPE curlim, int pdesc)
{
char unitstr[64];
int factor;
*/
static int
-set_all_limits (mode, newlim)
- int mode;
- RLIMTYPE newlim;
+set_all_limits (int mode, RLIMTYPE newlim)
{
register int i;
int retval = 0;
/* Set or display the mask used by the system when creating files. Flag
of -S means display the umask in a symbolic mode. */
int
-umask_builtin (list)
- WORD_LIST *list;
+umask_builtin (WORD_LIST *list)
{
int print_symbolically, opt, umask_value, pflag;
mode_t umask_arg;
/* Print the umask in a symbolic form. In the output, a letter is
printed if the corresponding bit is clear in the umask. */
static void
-#if defined (__STDC__)
print_symbolic_umask (mode_t um)
-#else
-print_symbolic_umask (um)
- mode_t um;
-#endif
{
char ubits[4], gbits[4], obits[4]; /* u=rwx,g=rwx,o=rwx */
int i;
}
static inline mode_t
-copyuser (mask)
- mode_t mask;
+copyuser (mode_t mask)
{
return ((mask & S_IRUSR) ? S_IRUGO : 0) |
((mask & S_IWUSR) ? S_IWUGO : 0) |
}
static inline mode_t
-copygroup (mask)
- mode_t mask;
+copygroup (mode_t mask)
{
return ((mask & S_IRGRP) ? S_IRUGO : 0) |
((mask & S_IWGRP) ? S_IWUGO : 0) |
}
static inline mode_t
-copyother (mask)
- mode_t mask;
+copyother (mode_t mask)
{
return ((mask & S_IROTH) ? S_IRUGO : 0) |
((mask & S_IWOTH) ? S_IWUGO : 0) |
}
int
-parse_symbolic_mode (mode, initial_bits)
- char *mode;
- mode_t initial_bits;
+parse_symbolic_mode (char *mode, mode_t initial_bits)
{
char op, c;
mode_t who, perm, bits;
by chmod. If the -S argument is given, then print the umask in a
symbolic form. */
static int
-symbolic_umask (list)
- WORD_LIST *list;
+symbolic_umask (WORD_LIST *list)
{
mode_t um;
int bits;
while (0)
int
-wait_builtin (list)
- WORD_LIST *list;
+wait_builtin (WORD_LIST *list)
{
int status, code, opt, nflag, vflags, bindflags;
volatile int wflags;
J_WAITING, so wait -n knows which jobs to wait for. Return the number of
jobs we found. */
static int
-set_waitlist (list)
- WORD_LIST *list;
+set_waitlist (WORD_LIST *list)
{
sigset_t set, oset;
int job, r, njob;
/* Clean up after a call to wait -n jobs */
static void
-unset_waitlist ()
+unset_waitlist (void)
{
int i;
sigset_t set, oset;
/* error.c -- Functions for handling errors. */
-/* Copyright (C) 1993-2021 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
# include "bashhist.h"
#endif
-extern int executing_line_number PARAMS((void));
+extern int executing_line_number (void);
#if defined (JOB_CONTROL)
extern pid_t shell_pgrp;
-extern int give_terminal_to PARAMS((pid_t, int));
+extern int give_terminal_to (pid_t, int);
#endif /* JOB_CONTROL */
#if defined (ARRAY_VARS)
extern const char * const bash_badsub_errmsg;
#endif
-static void error_prolog PARAMS((int));
+static void error_prolog (int);
/* The current maintainer of the shell. You change this in the
Makefile. */
int gnu_error_format = 0;
static void
-error_prolog (print_lineno)
- int print_lineno;
+error_prolog (int print_lineno)
{
char *ename;
int line;
/* Return the name of the shell or the shell script for error reporting. */
char *
-get_name_for_error ()
+get_name_for_error (void)
{
char *name;
#if defined (ARRAY_VARS)
sys_error so the filename is not interpreted as a printf-style
format string. */
void
-file_error (filename)
- const char *filename;
+file_error (const char *filename)
{
report_error ("%s: %s", filename, strerror (errno));
}
void
-#if defined (PREFER_STDARG)
programming_error (const char *format, ...)
-#else
-programming_error (format, va_alist)
- const char *format;
- va_dcl
-#endif
{
va_list args;
char *h;
outside this file mostly to report substitution and expansion errors,
and for bad invocation options. */
void
-#if defined (PREFER_STDARG)
report_error (const char *format, ...)
-#else
-report_error (format, va_alist)
- const char *format;
- va_dcl
-#endif
{
va_list args;
}
void
-#if defined (PREFER_STDARG)
fatal_error (const char *format, ...)
-#else
-fatal_error (format, va_alist)
- const char *format;
- va_dcl
-#endif
{
va_list args;
}
void
-#if defined (PREFER_STDARG)
internal_error (const char *format, ...)
-#else
-internal_error (format, va_alist)
- const char *format;
- va_dcl
-#endif
{
va_list args;
}
void
-#if defined (PREFER_STDARG)
internal_warning (const char *format, ...)
-#else
-internal_warning (format, va_alist)
- const char *format;
- va_dcl
-#endif
{
va_list args;
}
void
-#if defined (PREFER_STDARG)
internal_inform (const char *format, ...)
-#else
-internal_inform (format, va_alist)
- const char *format;
- va_dcl
-#endif
{
va_list args;
}
void
-#if defined (PREFER_STDARG)
internal_debug (const char *format, ...)
-#else
-internal_debug (format, va_alist)
- const char *format;
- va_dcl
-#endif
{
#ifdef DEBUG
va_list args;
}
void
-#if defined (PREFER_STDARG)
sys_error (const char *format, ...)
-#else
-sys_error (format, va_alist)
- const char *format;
- va_dcl
-#endif
{
int e;
va_list args;
the input file name is inserted only if it is different from the
shell name. */
void
-#if defined (PREFER_STDARG)
parser_error (int lineno, const char *format, ...)
-#else
-parser_error (lineno, format, va_alist)
- int lineno;
- const char *format;
- va_dcl
-#endif
{
va_list args;
char *ename, *iname;
#ifdef DEBUG
/* This assumes ASCII and is suitable only for debugging */
char *
-strescape (str)
- const char *str;
+strescape (const char *str)
{
char *r, *result;
unsigned char *s;
}
void
-#if defined (PREFER_STDARG)
itrace (const char *format, ...)
-#else
-itrace (format, va_alist)
- const char *format;
- va_dcl
-#endif
{
va_list args;
/* A trace function for silent debugging -- doesn't require a control
terminal. */
void
-#if defined (PREFER_STDARG)
trace (const char *format, ...)
-#else
-trace (format, va_alist)
- const char *format;
- va_dcl
-#endif
{
va_list args;
static FILE *tracefp = (FILE *)NULL;
};
void
-command_error (func, code, e, flags)
- const char *func;
- int code, e, flags; /* flags currently unused */
+command_error (const char *func, int code, int e, int flags)
{
if (code > CMDERR_LAST)
code = CMDERR_DEFAULT;
}
char *
-command_errstr (code)
- int code;
+command_errstr (int code)
{
if (code > CMDERR_LAST)
code = CMDERR_DEFAULT;
#ifdef ARRAY_VARS
void
-err_badarraysub (s)
- const char *s;
+err_badarraysub (const char *s)
{
report_error ("%s: %s", s, _(bash_badsub_errmsg));
}
#endif
void
-err_unboundvar (s)
- const char *s;
+err_unboundvar (const char *s)
{
report_error (_("%s: unbound variable"), s);
}
void
-err_readonly (s)
- const char *s;
+err_readonly (const char *s)
{
report_error (_("%s: readonly variable"), s);
}
# include "bashhist.h"
#endif
-static void send_pwd_to_eterm PARAMS((void));
-static sighandler alrm_catcher PARAMS((int));
+static void send_pwd_to_eterm (void);
+static sighandler alrm_catcher (int);
/* Read and execute commands until EOF is reached. This assumes that
the input source has already been initialized. */
int
-reader_loop ()
+reader_loop (void)
{
int our_indirection_level;
COMMAND * volatile current_command;
/* Pretty print shell scripts */
int
-pretty_print_loop ()
+pretty_print_loop (void)
{
COMMAND *current_command;
char *command_to_print;
}
static sighandler
-alrm_catcher(i)
- int i;
+alrm_catcher(int i)
{
char *msg;
/* Send an escape sequence to emacs term mode to tell it the
current working directory. */
static void
-send_pwd_to_eterm ()
+send_pwd_to_eterm (void)
{
char *pwd, *f;
#if defined (ARRAY_VARS)
/* Caller ensures that A has a non-zero number of elements */
int
-execute_array_command (a, v)
- ARRAY *a;
- void *v;
+execute_array_command (ARRAY *a, void *v)
{
char *tag;
char **argv;
#endif
static void
-execute_prompt_command ()
+execute_prompt_command (void)
{
char *command_to_execute;
SHELL_VAR *pcv;
leaves the parsed command in the global variable GLOBAL_COMMAND.
This is where PROMPT_COMMAND is executed. */
int
-parse_command ()
+parse_command (void)
{
int r;
is left in the globval variable GLOBAL_COMMAND for use by reader_loop.
This is where the shell timeout code is executed. */
int
-read_command ()
+read_command (void)
{
SHELL_VAR *tmout_var;
int tmout_len, result;
extern char *glob_argv_flags;
#endif
-extern int close PARAMS((int));
+extern int close (int);
/* Static functions defined and used in this file. */
-static void close_pipes PARAMS((int, int));
-static void do_piping PARAMS((int, int));
-static void bind_lastarg PARAMS((char *));
-static int shell_control_structure PARAMS((enum command_type));
-static void cleanup_redirects PARAMS((REDIRECT *));
+static void close_pipes (int, int);
+static void do_piping (int, int);
+static void bind_lastarg (char *);
+static int shell_control_structure (enum command_type);
+static void cleanup_redirects (REDIRECT *);
#if defined (JOB_CONTROL)
-static int restore_signal_mask PARAMS((sigset_t *));
+static int restore_signal_mask (sigset_t *);
#endif
-static int builtin_status PARAMS((int));
+static int builtin_status (int);
-static int execute_for_command PARAMS((FOR_COM *));
+static int execute_for_command (FOR_COM *);
#if defined (SELECT_COMMAND)
-static int displen PARAMS((const char *));
-static int print_index_and_element PARAMS((int, int, WORD_LIST *));
-static void indent PARAMS((int, int));
-static void print_select_list PARAMS((WORD_LIST *, int, int, int));
-static char *select_query PARAMS((WORD_LIST *, int, char *, int));
-static int execute_select_command PARAMS((SELECT_COM *));
+static int displen (const char *);
+static int print_index_and_element (int, int, WORD_LIST *);
+static void indent (int, int);
+static void print_select_list (WORD_LIST *, int, int, int);
+static char *select_query (WORD_LIST *, int, char *, int);
+static int execute_select_command (SELECT_COM *);
#endif
#if defined (DPAREN_ARITHMETIC)
-static int execute_arith_command PARAMS((ARITH_COM *));
+static int execute_arith_command (ARITH_COM *);
#endif
#if defined (COND_COMMAND)
-static int execute_cond_node PARAMS((COND_COM *));
-static int execute_cond_command PARAMS((COND_COM *));
+static int execute_cond_node (COND_COM *);
+static int execute_cond_command (COND_COM *);
#endif
#if defined (COMMAND_TIMING)
-static int mkfmt PARAMS((char *, int, int, time_t, int));
-static void print_formatted_time PARAMS((FILE *, char *,
+static int mkfmt (char *, int, int, time_t, int);
+static void print_formatted_time (FILE *, char *,
time_t, int, time_t, int,
- time_t, int, int));
-static int time_command PARAMS((COMMAND *, int, int, int, struct fd_bitmap *));
+ time_t, int, int);
+static int time_command (COMMAND *, int, int, int, struct fd_bitmap *);
#endif
#if defined (ARITH_FOR_COMMAND)
-static intmax_t eval_arith_for_expr PARAMS((WORD_LIST *, int *));
-static int execute_arith_for_command PARAMS((ARITH_FOR_COM *));
-#endif
-static int execute_case_command PARAMS((CASE_COM *));
-static int execute_while_command PARAMS((WHILE_COM *));
-static int execute_until_command PARAMS((WHILE_COM *));
-static int execute_while_or_until PARAMS((WHILE_COM *, int));
-static int execute_if_command PARAMS((IF_COM *));
-static int execute_null_command PARAMS((REDIRECT *, int, int, int));
-static void fix_assignment_words PARAMS((WORD_LIST *));
-static void fix_arrayref_words PARAMS((WORD_LIST *));
-static int execute_simple_command PARAMS((SIMPLE_COM *, int, int, int, struct fd_bitmap *));
-static int execute_builtin PARAMS((sh_builtin_func_t *, WORD_LIST *, int, int));
-static int execute_function PARAMS((SHELL_VAR *, WORD_LIST *, int, struct fd_bitmap *, int, int));
-static int execute_builtin_or_function PARAMS((WORD_LIST *, sh_builtin_func_t *,
+static intmax_t eval_arith_for_expr (WORD_LIST *, int *);
+static int execute_arith_for_command (ARITH_FOR_COM *);
+#endif
+static int execute_case_command (CASE_COM *);
+static int execute_while_command (WHILE_COM *);
+static int execute_until_command (WHILE_COM *);
+static int execute_while_or_until (WHILE_COM *, int);
+static int execute_if_command (IF_COM *);
+static int execute_null_command (REDIRECT *, int, int, int);
+static void fix_assignment_words (WORD_LIST *);
+static void fix_arrayref_words (WORD_LIST *);
+static int execute_simple_command (SIMPLE_COM *, int, int, int, struct fd_bitmap *);
+static int execute_builtin (sh_builtin_func_t *, WORD_LIST *, int, int);
+static int execute_function (SHELL_VAR *, WORD_LIST *, int, struct fd_bitmap *, int, int);
+static int execute_builtin_or_function (WORD_LIST *, sh_builtin_func_t *,
SHELL_VAR *,
- REDIRECT *, struct fd_bitmap *, int));
-static void execute_subshell_builtin_or_function PARAMS((WORD_LIST *, REDIRECT *,
+ REDIRECT *, struct fd_bitmap *, int);
+static void execute_subshell_builtin_or_function (WORD_LIST *, REDIRECT *,
sh_builtin_func_t *,
SHELL_VAR *,
int, int, int,
struct fd_bitmap *,
- int));
-static int execute_disk_command PARAMS((WORD_LIST *, REDIRECT *, char *,
- int, int, int, struct fd_bitmap *, int));
+ int);
+static int execute_disk_command (WORD_LIST *, REDIRECT *, char *,
+ int, int, int, struct fd_bitmap *, int);
-static char *getinterp PARAMS((char *, int, int *));
-static void initialize_subshell PARAMS((void));
-static int execute_in_subshell PARAMS((COMMAND *, int, int, int, struct fd_bitmap *));
+static char *getinterp (char *, int, int *);
+static void initialize_subshell (void);
+static int execute_in_subshell (COMMAND *, int, int, int, struct fd_bitmap *);
#if defined (COPROCESS_SUPPORT)
-static void coproc_setstatus PARAMS((struct coproc *, int));
-static int execute_coproc PARAMS((COMMAND *, int, int, struct fd_bitmap *));
+static void coproc_setstatus (struct coproc *, int);
+static int execute_coproc (COMMAND *, int, int, struct fd_bitmap *);
#endif
-static int execute_pipeline PARAMS((COMMAND *, int, int, int, struct fd_bitmap *));
+static int execute_pipeline (COMMAND *, int, int, int, struct fd_bitmap *);
-static int execute_connection PARAMS((COMMAND *, int, int, int, struct fd_bitmap *));
+static int execute_connection (COMMAND *, int, int, int, struct fd_bitmap *);
-static int execute_intern_function PARAMS((WORD_DESC *, FUNCTION_DEF *));
+static int execute_intern_function (WORD_DESC *, FUNCTION_DEF *);
/* Set to 1 if fd 0 was the subject of redirection to a subshell. Global
so that reader_loop can set it to zero before executing a command. */
information from the shell to its children about file descriptors
to close. */
struct fd_bitmap *
-new_fd_bitmap (size)
- int size;
+new_fd_bitmap (int size)
{
struct fd_bitmap *ret;
}
void
-dispose_fd_bitmap (fdbp)
- struct fd_bitmap *fdbp;
+dispose_fd_bitmap (struct fd_bitmap *fdbp)
{
FREE (fdbp->bitmap);
free (fdbp);
}
void
-close_fd_bitmap (fdbp)
- struct fd_bitmap *fdbp;
+close_fd_bitmap (struct fd_bitmap *fdbp)
{
register int i;
/* Return the line number of the currently executing command. */
int
-executing_line_number ()
+executing_line_number (void)
{
if (executing && showing_function_line == 0 &&
(variable_context == 0 || interactive_shell == 0) &&
return values. Executing a command with nothing in it returns
EXECUTION_SUCCESS. */
int
-execute_command (command)
- COMMAND *command;
+execute_command (COMMAND *command)
{
struct fd_bitmap *bitmap;
int result;
/* Return 1 if TYPE is a shell control structure type. */
static int
-shell_control_structure (type)
- enum command_type type;
+shell_control_structure (enum command_type type)
{
switch (type)
{
/* A function to use to unwind_protect the redirection undo list
for loops. */
static void
-cleanup_redirects (list)
- REDIRECT *list;
+cleanup_redirects (REDIRECT *list)
{
do_redirections (list, RX_ACTIVE);
dispose_redirects (list);
}
void
-undo_partial_redirects ()
+undo_partial_redirects (void)
{
if (redirection_undo_list)
{
#if 0
/* Function to unwind_protect the redirections for functions and builtins. */
static void
-cleanup_func_redirects (list)
- REDIRECT *list;
+cleanup_func_redirects (REDIRECT *list)
{
do_redirections (list, RX_ACTIVE);
}
#endif
void
-dispose_exec_redirects ()
+dispose_exec_redirects (void)
{
if (exec_redirection_undo_list)
{
}
void
-dispose_partial_redirects ()
+dispose_partial_redirects (void)
{
if (redirection_undo_list)
{
/* A function to restore the signal mask to its proper value when the shell
is interrupted or errors occur while creating a pipeline. */
static int
-restore_signal_mask (set)
- sigset_t *set;
+restore_signal_mask (sigset_t *set)
{
return (sigprocmask (SIG_SETMASK, set, (sigset_t *)NULL));
}
#endif
void
-async_redirect_stdin ()
+async_redirect_stdin (void)
{
int fd;
return values. Executing a command with nothing in it returns
EXECUTION_SUCCESS. */
int
-execute_command_internal (command, asynchronous, pipe_in, pipe_out,
- fds_to_close)
- COMMAND *command;
- int asynchronous;
- int pipe_in, pipe_out;
- struct fd_bitmap *fds_to_close;
+execute_command_internal (COMMAND *command, int asynchronous, int pipe_in, int pipe_out, struct fd_bitmap *fds_to_close)
{
int exec_result, user_subshell, invert, ignore_return, was_error_trap, fork_flags;
REDIRECT *my_undo_list, *exec_undo_list;
#if defined (COMMAND_TIMING)
#if defined (HAVE_GETRUSAGE) && defined (HAVE_GETTIMEOFDAY)
-extern struct timeval *difftimeval PARAMS((struct timeval *, struct timeval *, struct timeval *));
-extern struct timeval *addtimeval PARAMS((struct timeval *, struct timeval *, struct timeval *));
-extern int timeval_to_cpu PARAMS((struct timeval *, struct timeval *, struct timeval *));
+extern struct timeval *difftimeval (struct timeval *, struct timeval *, struct timeval *);
+extern struct timeval *addtimeval (struct timeval *, struct timeval *, struct timeval *);
+extern int timeval_to_cpu (struct timeval *, struct timeval *, struct timeval *);
#endif
#define POSIX_TIMEFORMAT "real %2R\nuser %2U\nsys %2S"
/* Expand one `%'-prefixed escape sequence from a time format string. */
static int
-mkfmt (buf, prec, lng, sec, sec_fraction)
- char *buf;
- int prec, lng;
- time_t sec;
- int sec_fraction;
+mkfmt (char *buf, int prec, int lng, time_t sec, int sec_fraction)
{
time_t min;
char abuf[INT_STRLEN_BOUND(time_t) + 1];
the seconds and thousandths of a second of real, user, and system time,
resectively. */
static void
-print_formatted_time (fp, format, rs, rsf, us, usf, ss, ssf, cpu)
- FILE *fp;
- char *format;
- time_t rs;
- int rsf;
- time_t us;
- int usf;
- time_t ss;
- int ssf, cpu;
+print_formatted_time (FILE *fp, char *format,
+ time_t rs, int rsf, time_t us, int usf, time_t ss, int ssf,
+ int cpu)
{
int prec, lng, len;
char *str, *s, ts[INT_STRLEN_BOUND (time_t) + sizeof ("mSS.FFFF")];
}
static int
-time_command (command, asynchronous, pipe_in, pipe_out, fds_to_close)
- COMMAND *command;
- int asynchronous, pipe_in, pipe_out;
- struct fd_bitmap *fds_to_close;
+time_command (COMMAND *command, int asynchronous, int pipe_in, int pipe_out, struct fd_bitmap *fds_to_close)
{
int rv, posix_time, old_flags, nullcmd, code;
time_t rs, us, ss;
called after make_child and we must be running in the child process.
The caller will return or exit() immediately with the value this returns. */
static int
-execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close)
- COMMAND *command;
- int asynchronous;
- int pipe_in, pipe_out;
- struct fd_bitmap *fds_to_close;
+execute_in_subshell (COMMAND *command, int asynchronous, int pipe_in, int pipe_out, struct fd_bitmap *fds_to_close)
{
volatile int user_subshell, user_coproc, invert;
int return_code, function_value, should_redir_stdin, ois, result;
}
cplist_t;
-static struct cpelement *cpe_alloc PARAMS((struct coproc *));
-static void cpe_dispose PARAMS((struct cpelement *));
-static struct cpelement *cpl_add PARAMS((struct coproc *));
-static struct cpelement *cpl_delete PARAMS((pid_t));
-static void cpl_reap PARAMS((void));
-static void cpl_flush PARAMS((void));
-static void cpl_closeall PARAMS((void));
-static struct cpelement *cpl_search PARAMS((pid_t));
-static struct cpelement *cpl_searchbyname PARAMS((const char *));
-static void cpl_prune PARAMS((void));
+static struct cpelement *cpe_alloc (struct coproc *);
+static void cpe_dispose (struct cpelement *);
+static struct cpelement *cpl_add (struct coproc *);
+static struct cpelement *cpl_delete (pid_t);
+static void cpl_reap (void);
+static void cpl_flush (void);
+static void cpl_closeall (void);
+static struct cpelement *cpl_search (pid_t);
+static struct cpelement *cpl_searchbyname (const char *);
+static void cpl_prune (void);
-static void coproc_free PARAMS((struct coproc *));
+static void coproc_free (struct coproc *);
/* Will go away when there is fully-implemented support for multiple coprocs. */
Coproc sh_coproc = { 0, NO_PID, -1, -1, 0, 0, 0, 0, 0 };
/* Functions to manage the list of coprocs */
static struct cpelement *
-cpe_alloc (cp)
- Coproc *cp;
+cpe_alloc (Coproc *cp)
{
struct cpelement *cpe;
}
static void
-cpe_dispose (cpe)
- struct cpelement *cpe;
+cpe_dispose (struct cpelement *cpe)
{
free (cpe);
}
static struct cpelement *
-cpl_add (cp)
- Coproc *cp;
+cpl_add (Coproc *cp)
{
struct cpelement *cpe;
}
static struct cpelement *
-cpl_delete (pid)
- pid_t pid;
+cpl_delete (pid_t pid)
{
struct cpelement *prev, *p;
}
static void
-cpl_reap ()
+cpl_reap (void)
{
struct cpelement *p, *next, *nh, *nt;
/* Clear out the list of saved statuses */
static void
-cpl_flush ()
+cpl_flush (void)
{
struct cpelement *cpe, *p;
}
static void
-cpl_closeall ()
+cpl_closeall (void)
{
struct cpelement *cpe;
}
static void
-cpl_fdchk (fd)
- int fd;
+cpl_fdchk (int fd)
{
struct cpelement *cpe;
/* Search for PID in the list of coprocs; return the cpelement struct if
found. If not found, return NULL. */
static struct cpelement *
-cpl_search (pid)
- pid_t pid;
+cpl_search (pid_t pid)
{
struct cpelement *cpe;
/* Search for the coproc named NAME in the list of coprocs; return the
cpelement struct if found. If not found, return NULL. */
static struct cpelement *
-cpl_searchbyname (name)
- const char *name;
+cpl_searchbyname (const char *name)
{
struct cpelement *cp;
}
static pid_t
-cpl_firstactive ()
+cpl_firstactive (void)
{
struct cpelement *cpe;
#if 0
static void
-cpl_prune ()
+cpl_prune (void)
{
struct cpelement *cp;
package above). */
struct coproc *
-getcoprocbypid (pid)
- pid_t pid;
+getcoprocbypid (pid_t pid)
{
#if MULTIPLE_COPROCS
struct cpelement *p;
}
struct coproc *
-getcoprocbyname (name)
- const char *name;
+getcoprocbyname (const char *name)
{
#if MULTIPLE_COPROCS
struct cpelement *p;
}
void
-coproc_init (cp)
- struct coproc *cp;
+coproc_init (struct coproc *cp)
{
cp->c_name = 0;
cp->c_pid = NO_PID;
}
struct coproc *
-coproc_alloc (name, pid)
- char *name;
- pid_t pid;
+coproc_alloc (char *name, pid_t pid)
{
struct coproc *cp;
}
static void
-coproc_free (cp)
- struct coproc *cp;
+coproc_free (struct coproc *cp)
{
free (cp);
}
void
-coproc_dispose (cp)
- struct coproc *cp;
+coproc_dispose (struct coproc *cp)
{
sigset_t set, oset;
/* Placeholder for now. Will require changes for multiple coprocs */
void
-coproc_flush ()
+coproc_flush (void)
{
#if MULTIPLE_COPROCS
cpl_flush ();
}
void
-coproc_close (cp)
- struct coproc *cp;
+coproc_close (struct coproc *cp)
{
if (cp->c_rfd >= 0)
{
}
void
-coproc_closeall ()
+coproc_closeall (void)
{
#if MULTIPLE_COPROCS
cpl_closeall ();
}
void
-coproc_reap ()
+coproc_reap (void)
{
#if MULTIPLE_COPROCS
cpl_reap ();
}
void
-coproc_rclose (cp, fd)
- struct coproc *cp;
- int fd;
+coproc_rclose (struct coproc *cp, int fd)
{
if (cp->c_rfd >= 0 && cp->c_rfd == fd)
{
}
void
-coproc_wclose (cp, fd)
- struct coproc *cp;
- int fd;
+coproc_wclose (struct coproc *cp, int fd)
{
if (cp->c_wfd >= 0 && cp->c_wfd == fd)
{
}
void
-coproc_checkfd (cp, fd)
- struct coproc *cp;
- int fd;
+coproc_checkfd (struct coproc *cp, int fd)
{
int update;
}
void
-coproc_fdchk (fd)
- int fd;
+coproc_fdchk (int fd)
{
#if MULTIPLE_COPROCS
cpl_fdchk (fd);
}
void
-coproc_fdclose (cp, fd)
- struct coproc *cp;
- int fd;
+coproc_fdclose (struct coproc *cp, int fd)
{
coproc_rclose (cp, fd);
coproc_wclose (cp, fd);
}
void
-coproc_fdsave (cp)
- struct coproc *cp;
+coproc_fdsave (struct coproc *cp)
{
cp->c_rsave = cp->c_rfd;
cp->c_wsave = cp->c_wfd;
}
void
-coproc_fdrestore (cp)
- struct coproc *cp;
+coproc_fdrestore (struct coproc *cp)
{
cp->c_rfd = cp->c_rsave;
cp->c_wfd = cp->c_wsave;
}
static void
-coproc_setstatus (cp, status)
- struct coproc *cp;
- int status;
+coproc_setstatus (struct coproc *cp, int status)
{
cp->c_lock = 4;
cp->c_status = status;
}
void
-coproc_pidchk (pid, status)
- pid_t pid;
- int status;
+coproc_pidchk (pid_t pid, int status)
{
struct coproc *cp;
}
pid_t
-coproc_active ()
+coproc_active (void)
{
#if MULTIPLE_COPROCS
return (cpl_firstactive ());
#endif
}
void
-coproc_setvars (cp)
- struct coproc *cp;
+coproc_setvars (struct coproc *cp)
{
SHELL_VAR *v;
char *namevar, *t;
}
void
-coproc_unsetvars (cp)
- struct coproc *cp;
+coproc_unsetvars (struct coproc *cp)
{
int l;
char *namevar;
}
static int
-execute_coproc (command, pipe_in, pipe_out, fds_to_close)
- COMMAND *command;
- int pipe_in, pipe_out;
- struct fd_bitmap *fds_to_close;
+execute_coproc (COMMAND *command, int pipe_in, int pipe_out, struct fd_bitmap *fds_to_close)
{
int rpipe[2], wpipe[2], estat, invert;
pid_t coproc_pid;
/* If S == -1, it's a special value saying to close stdin */
static void
-restore_stdin (s)
- int s;
+restore_stdin (int s)
{
if (s == -1)
close (0);
/* Catch-all cleanup function for lastpipe code for unwind-protects */
static void
-lastpipe_cleanup (s)
- int s;
+lastpipe_cleanup (int s)
{
set_jobs_list_frozen (s);
}
static int
-execute_pipeline (command, asynchronous, pipe_in, pipe_out, fds_to_close)
- COMMAND *command;
- int asynchronous, pipe_in, pipe_out;
- struct fd_bitmap *fds_to_close;
+execute_pipeline (COMMAND *command, int asynchronous, int pipe_in, int pipe_out, struct fd_bitmap *fds_to_close)
{
int prev, fildes[2], new_bitmap_size, dummyfd, ignore_return, exec_result;
int lstdin, lastpipe_flag, lastpipe_jid, old_frozen, stdin_valid;
}
static int
-execute_connection (command, asynchronous, pipe_in, pipe_out, fds_to_close)
- COMMAND *command;
- int asynchronous, pipe_in, pipe_out;
- struct fd_bitmap *fds_to_close;
+execute_connection (COMMAND *command, int asynchronous, int pipe_in, int pipe_out, struct fd_bitmap *fds_to_close)
{
COMMAND *tc, *second;
int ignore_return, exec_result, was_error_trap, invert;
/* Execute a FOR command. The syntax is: FOR word_desc IN word_list;
DO command; DONE */
static int
-execute_for_command (for_command)
- FOR_COM *for_command;
+execute_for_command (FOR_COM *for_command)
{
register WORD_LIST *releaser, *list;
SHELL_VAR *v;
done
*/
static intmax_t
-eval_arith_for_expr (l, okp)
- WORD_LIST *l;
- int *okp;
+eval_arith_for_expr (WORD_LIST *l, int *okp)
{
WORD_LIST *new;
intmax_t expresult;
}
static int
-execute_arith_for_command (arith_for_command)
- ARITH_FOR_COM *arith_for_command;
+execute_arith_for_command (ARITH_FOR_COM *arith_for_command)
{
intmax_t expresult;
int expok, body_status, arith_lineno, save_lineno;
: 6)))))
static int
-displen (s)
- const char *s;
+displen (const char *s)
{
#if defined (HANDLE_MULTIBYTE)
wchar_t *wcstr;
}
static int
-print_index_and_element (len, ind, list)
- int len, ind;
- WORD_LIST *list;
+print_index_and_element (int len, int ind, WORD_LIST *list)
{
register WORD_LIST *l;
register int i;
}
static void
-indent (from, to)
- int from, to;
+indent (int from, int to)
{
while (from < to)
{
}
static void
-print_select_list (list, list_len, max_elem_len, indices_len)
- WORD_LIST *list;
- int list_len, max_elem_len, indices_len;
+print_select_list (WORD_LIST *list, int list_len, int max_elem_len, int indices_len)
{
int ind, row, elem_len, pos, cols, rows;
int first_column_indices_len, other_indices_len;
is read, return a null string. If a blank line is entered, or an invalid
number is entered, the loop is executed again. */
static char *
-select_query (list, list_len, prompt, print_menu)
- WORD_LIST *list;
- int list_len;
- char *prompt;
- int print_menu;
+select_query (WORD_LIST *list, int list_len, char *prompt, int print_menu)
{
int max_elem_len, indices_len, len, r, oe;
intmax_t reply;
Only `break' or `return' in command_list will terminate
the command. */
static int
-execute_select_command (select_command)
- SELECT_COM *select_command;
+execute_select_command (SELECT_COM *select_command)
{
WORD_LIST *releaser, *list;
SHELL_VAR *v;
some patterns to compare word_desc against, and an associated command to
execute. */
static int
-execute_case_command (case_command)
- CASE_COM *case_command;
+execute_case_command (CASE_COM *case_command)
{
register WORD_LIST *list;
WORD_LIST *wlist, *es;
Repeatedly execute action while executing test produces
EXECUTION_SUCCESS. */
static int
-execute_while_command (while_command)
- WHILE_COM *while_command;
+execute_while_command (WHILE_COM *while_command)
{
return (execute_while_or_until (while_command, CMD_WHILE));
}
/* UNTIL is just like WHILE except that the test result is negated. */
static int
-execute_until_command (while_command)
- WHILE_COM *while_command;
+execute_until_command (WHILE_COM *while_command)
{
return (execute_while_or_until (while_command, CMD_UNTIL));
}
be EXECUTION_SUCCESS if no commands in the body are executed, and
the status of the last command executed in the body otherwise. */
static int
-execute_while_or_until (while_command, type)
- WHILE_COM *while_command;
- int type;
+execute_while_or_until (WHILE_COM *while_command, int type)
{
int return_value, body_status;
IF also allows ELIF in the place of ELSE IF, but
the parser makes *that* stupidity transparent. */
static int
-execute_if_command (if_command)
- IF_COM *if_command;
+execute_if_command (IF_COM *if_command)
{
int return_value, save_line_number;
#if defined (DPAREN_ARITHMETIC)
static int
-execute_arith_command (arith_command)
- ARITH_COM *arith_command;
+execute_arith_command (ARITH_COM *arith_command)
{
int expok, save_line_number, retval, eflag;
intmax_t expresult;
/* XXX - can COND ever be NULL when this is called? */
static int
-execute_cond_node (cond)
- COND_COM *cond;
+execute_cond_node (COND_COM *cond)
{
int result, invert, patmatch, rmatch, arith, mode, mflags, ignore;
char *arg1, *arg2, *op;
}
static int
-execute_cond_command (cond_command)
- COND_COM *cond_command;
+execute_cond_command (COND_COM *cond_command)
{
int retval, save_line_number;
#endif /* COND_COMMAND */
static void
-bind_lastarg (arg)
- char *arg;
+bind_lastarg (char *arg)
{
SHELL_VAR *var;
to be run asynchronously. This handles all the side effects that are
supposed to take place. */
static int
-execute_null_command (redirects, pipe_in, pipe_out, async)
- REDIRECT *redirects;
- int pipe_in, pipe_out, async;
+execute_null_command (REDIRECT *redirects, int pipe_in, int pipe_out, int async)
{
int r;
int forcefork, fork_flags;
/* This is a hack to suppress word splitting for assignment statements
given as arguments to builtins with the ASSIGNMENT_BUILTIN flag set. */
static void
-fix_assignment_words (words)
- WORD_LIST *words;
+fix_assignment_words (WORD_LIST *words)
{
WORD_LIST *w, *wcmd;
struct builtin *b;
accepts them. This is intended to completely replace assoc_expand_once in
time. */
static void
-fix_arrayref_words (words)
- WORD_LIST *words;
+fix_arrayref_words (WORD_LIST *words)
{
WORD_LIST *w, *wcmd;
struct builtin *b;
any other options are supplied, or there is not a command_name, we punt
and return a zero value in *TYPEP without updating WORDS. */
static WORD_LIST *
-check_command_builtin (words, typep)
- WORD_LIST *words;
- int *typep;
+check_command_builtin (WORD_LIST *words, int *typep)
{
int type;
WORD_LIST *w;
/* Return 1 if the file found by searching $PATH for PATHNAME, defaulting
to PATHNAME, is a directory. Used by the autocd code below. */
static int
-is_dirname (pathname)
- char *pathname;
+is_dirname (char *pathname)
{
char *temp;
int ret;
real execution of commands here. Fork a process, set things up,
execute the command. */
static int
-execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
- SIMPLE_COM *simple_command;
- int pipe_in, pipe_out, async;
- struct fd_bitmap *fds_to_close;
+execute_simple_command (SIMPLE_COM *simple_command, int pipe_in, int pipe_out, int async, struct fd_bitmap *fds_to_close)
{
WORD_LIST *words, *lastword;
char *command_line, *lastarg, *temp;
/* Translate the special builtin exit statuses. We don't really need a
function for this; it's a placeholder for future work. */
static int
-builtin_status (result)
- int result;
+builtin_status (int result)
{
int r;
}
static int
-execute_builtin (builtin, words, flags, subshell)
- sh_builtin_func_t *builtin;
- WORD_LIST *words;
- int flags, subshell;
+execute_builtin (sh_builtin_func_t *builtin, WORD_LIST *words, int flags, int subshell)
{
int result, eval_unwind, ignexit_flag;
int isbltinenv, should_keep;
}
static void
-maybe_restore_getopt_state (gs)
- sh_getopt_state_t *gs;
+maybe_restore_getopt_state (sh_getopt_state_t *gs)
{
/* If we have a local copy of OPTIND and it's at the right (current)
context, then we restore getopt's internal state. If not, we just
#if defined (ARRAY_VARS)
void
-restore_funcarray_state (fa)
- struct func_array_state *fa;
+restore_funcarray_state (struct func_array_state *fa)
{
SHELL_VAR *nfv;
ARRAY *funcname_a;
#endif
static int
-execute_function (var, words, flags, fds_to_close, async, subshell)
- SHELL_VAR *var;
- WORD_LIST *words;
- int flags;
- struct fd_bitmap *fds_to_close;
- int async, subshell;
+execute_function (SHELL_VAR *var, WORD_LIST *words, int flags, struct fd_bitmap *fds_to_close, int async, int subshell)
{
int return_val, result, lineno;
COMMAND *tc, *fc, *save_current;
/* A convenience routine for use by other parts of the shell to execute
a particular shell function. */
int
-execute_shell_function (var, words)
- SHELL_VAR *var;
- WORD_LIST *words;
+execute_shell_function (SHELL_VAR *var, WORD_LIST *words)
{
int ret;
struct fd_bitmap *bitmap;
to the command, REDIRECTS specifies redirections to perform before the
command is executed. */
static void
-execute_subshell_builtin_or_function (words, redirects, builtin, var,
- pipe_in, pipe_out, async, fds_to_close,
- flags)
- WORD_LIST *words;
- REDIRECT *redirects;
- sh_builtin_func_t *builtin;
- SHELL_VAR *var;
- int pipe_in, pipe_out, async;
- struct fd_bitmap *fds_to_close;
- int flags;
+execute_subshell_builtin_or_function (WORD_LIST *words, REDIRECT *redirects,
+ sh_builtin_func_t *builtin, SHELL_VAR *var,
+ int pipe_in, int pipe_out, int async,
+ struct fd_bitmap *fds_to_close, int flags)
{
int result, r, funcvalue;
#if defined (JOB_CONTROL)
If BUILTIN is exec_builtin, the redirections specified in REDIRECTS are
not undone before this function returns. */
static int
-execute_builtin_or_function (words, builtin, var, redirects,
- fds_to_close, flags)
- WORD_LIST *words;
- sh_builtin_func_t *builtin;
- SHELL_VAR *var;
- REDIRECT *redirects;
- struct fd_bitmap *fds_to_close;
- int flags;
+execute_builtin_or_function (WORD_LIST *words,
+ sh_builtin_func_t *builtin, SHELL_VAR *var,
+ REDIRECT *redirects, struct fd_bitmap *fds_to_close,
+ int flags)
{
int result;
REDIRECT *saved_undo_list;
}
void
-setup_async_signals ()
+setup_async_signals (void)
{
#if defined (__BEOS__)
set_signal_handler (SIGHUP, SIG_IGN); /* they want csh-like behavior */
#endif
static int
-execute_disk_command (words, redirects, command_line, pipe_in, pipe_out,
- async, fds_to_close, cmdflags)
- WORD_LIST *words;
- REDIRECT *redirects;
- char *command_line;
- int pipe_in, pipe_out, async;
- struct fd_bitmap *fds_to_close;
- int cmdflags;
+execute_disk_command (WORD_LIST *words, REDIRECT *redirects, char *command_line,
+ int pipe_in, int pipe_out, int async,
+ struct fd_bitmap *fds_to_close, int cmdflags)
{
char *pathname, *command, **args, *p;
int nofork, stdpath, result, fork_flags;
#endif /* MSDOS */
static char *
-getinterp (sample, sample_len, endp)
- char *sample;
- int sample_len, *endp;
+getinterp (char *sample, int sample_len, int *endp)
{
register int i;
char *execname;
A single argument to the interpreter is allowed. */
static int
-execute_shell_script (sample, sample_len, command, args, env)
- char *sample;
- int sample_len;
- char *command;
- char **args, **env;
+execute_shell_script (char *sample, int sample_len,
+ char *command, char **args, char **env)
{
char *execname, *firstarg;
int i, start, size_increment, larry;
#endif /* !HAVE_HASH_BANG_EXEC */
static void
-initialize_subshell ()
+initialize_subshell (void)
{
#if defined (ALIAS)
/* Forget about any aliases that we knew of. We are in a subshell. */
/* Call execve (), handling interpreting shell scripts, and handling
exec failures. */
int
-shell_execve (command, args, env)
- char *command;
- char **args, **env;
+shell_execve (char *command, char **args, char **env)
{
int larray, i, fd;
char sample[HASH_BANG_BUFSIZ];
}
static int
-execute_intern_function (name, funcdef)
- WORD_DESC *name;
- FUNCTION_DEF *funcdef;
+execute_intern_function (WORD_DESC *name, FUNCTION_DEF *funcdef)
{
SHELL_VAR *var;
char *t;
#if defined (INCLUDE_UNUSED)
#if defined (PROCESS_SUBSTITUTION)
void
-close_all_files ()
+close_all_files (void)
{
register int i, fd_table_size;
#endif
static void
-close_pipes (in, out)
- int in, out;
+close_pipes (int in, int out)
{
if (in >= 0)
close (in);
}
static void
-dup_error (oldd, newd)
- int oldd, newd;
+dup_error (int oldd, int newd)
{
sys_error (_("cannot duplicate fd %d to fd %d"), oldd, newd);
}
/* Redirect input and output to be from and to the specified pipes.
NO_PIPE and REDIRECT_BOTH are handled correctly. */
static void
-do_piping (pipe_in, pipe_out)
- int pipe_in, pipe_out;
+do_piping (int pipe_in, int pipe_out)
{
if (pipe_in != NO_PIPE)
{
/* expr.c -- arithmetic expression evaluation. */
-/* Copyright (C) 1990-2021 Free Software Foundation, Inc.
+/* Copyright (C) 1990-2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
};
/* A structure defining a single expression context. */
-typedef struct {
+typedef struct
+{
int curtok, lasttok;
char *expression, *tp, *lasttp;
intmax_t tokval;
static struct lvalue curlval = {0, 0, 0, -1};
static struct lvalue lastlval = {0, 0, 0, -1};
-static int _is_arithop PARAMS((int));
-static void readtok PARAMS((void)); /* lexical analyzer */
+static int _is_arithop (int);
+static void readtok (void); /* lexical analyzer */
-static void init_lvalue PARAMS((struct lvalue *));
-static struct lvalue *alloc_lvalue PARAMS((void));
-static void free_lvalue PARAMS((struct lvalue *));
+static void init_lvalue (struct lvalue *);
+static struct lvalue *alloc_lvalue (void);
+static void free_lvalue (struct lvalue *);
-static intmax_t expr_streval PARAMS((char *, int, struct lvalue *));
-static intmax_t strlong PARAMS((char *));
-static void evalerror PARAMS((const char *));
+static intmax_t expr_streval (char *, int, struct lvalue *);
+static intmax_t strlong (char *);
+static void evalerror (const char *);
-static void pushexp PARAMS((void));
-static void popexp PARAMS((void));
-static void expr_unwind PARAMS((void));
-static void expr_bind_variable PARAMS((char *, char *));
+static void pushexp (void);
+static void popexp (void);
+static void expr_unwind (void);
+static void expr_bind_variable (char *, char *);
#if defined (ARRAY_VARS)
-static void expr_bind_array_element PARAMS((char *, arrayind_t, char *));
+static void expr_bind_array_element (char *, arrayind_t, char *);
#endif
-static intmax_t subexpr PARAMS((char *));
-
-static intmax_t expcomma PARAMS((void));
-static intmax_t expassign PARAMS((void));
-static intmax_t expcond PARAMS((void));
-static intmax_t explor PARAMS((void));
-static intmax_t expland PARAMS((void));
-static intmax_t expbor PARAMS((void));
-static intmax_t expbxor PARAMS((void));
-static intmax_t expband PARAMS((void));
-static intmax_t exp5 PARAMS((void));
-static intmax_t exp4 PARAMS((void));
-static intmax_t expshift PARAMS((void));
-static intmax_t exp3 PARAMS((void));
-static intmax_t expmuldiv PARAMS((void));
-static intmax_t exppower PARAMS((void));
-static intmax_t exp1 PARAMS((void));
-static intmax_t exp0 PARAMS((void));
+static intmax_t subexpr (char *);
+
+static intmax_t expcomma (void);
+static intmax_t expassign (void);
+static intmax_t expcond (void);
+static intmax_t explor (void);
+static intmax_t expland (void);
+static intmax_t expbor (void);
+static intmax_t expbxor (void);
+static intmax_t expband (void);
+static intmax_t expeq (void);
+static intmax_t expcompare (void);
+static intmax_t expshift (void);
+static intmax_t expaddsub (void);
+static intmax_t expmuldiv (void);
+static intmax_t exppower (void);
+static intmax_t expunary (void);
+static intmax_t exp0 (void);
/* Global var which contains the stack of expression contexts. */
static EXPR_CONTEXT **expr_stack;
/* Push and save away the contents of the globals describing the
current expression context. */
static void
-pushexp ()
+pushexp (void)
{
EXPR_CONTEXT *context;
/* Pop the the contents of the expression context stack into the
globals describing the current expression context. */
static void
-popexp ()
+popexp (void)
{
EXPR_CONTEXT *context;
}
static void
-expr_unwind ()
+expr_unwind (void)
{
while (--expr_depth > 0)
{
}
static void
-expr_bind_variable (lhs, rhs)
- char *lhs, *rhs;
+expr_bind_variable (char *lhs, char *rhs)
{
SHELL_VAR *v;
int aflags;
/* This is similar to the logic in arrayfunc.c:valid_array_reference when
you pass VA_NOEXPAND. */
static int
-expr_skipsubscript (vp, cp)
- char *vp, *cp;
+expr_skipsubscript (char *vp, char *cp)
{
int flags, isassoc;
SHELL_VAR *entry;
/* Rewrite tok, which is of the form vname[expression], to vname[ind], where
IND is the already-calculated value of expression. */
static void
-expr_bind_array_element (tok, ind, rhs)
- char *tok;
- arrayind_t ind;
- char *rhs;
+expr_bind_array_element (char *tok, arrayind_t ind, char *rhs)
{
char *lhs, *vname;
size_t llen;
safe to let the loop terminate when expr_depth == 0, without freeing up
any of the expr_depth[0] stuff. */
intmax_t
-evalexp (expr, flags, validp)
- char *expr;
- int flags;
- int *validp;
+evalexp (char *expr, int flags, int *validp)
{
intmax_t val;
int c;
}
static intmax_t
-subexpr (expr)
- char *expr;
+subexpr (char *expr)
{
intmax_t val;
char *p;
}
static intmax_t
-expcomma ()
+expcomma (void)
{
register intmax_t value;
}
static intmax_t
-expassign ()
+expassign (void)
{
register intmax_t value;
char *lhs, *rhs;
/* Conditional expression (expr?expr:expr) */
static intmax_t
-expcond ()
+expcond (void)
{
intmax_t cval, val1, val2, rval;
int set_noeval;
/* Logical OR. */
static intmax_t
-explor ()
+explor (void)
{
register intmax_t val1, val2;
int set_noeval;
/* Logical AND. */
static intmax_t
-expland ()
+expland (void)
{
register intmax_t val1, val2;
int set_noeval;
/* Bitwise OR. */
static intmax_t
-expbor ()
+expbor (void)
{
register intmax_t val1, val2;
/* Bitwise XOR. */
static intmax_t
-expbxor ()
+expbxor (void)
{
register intmax_t val1, val2;
/* Bitwise AND. */
static intmax_t
-expband ()
+expband (void)
{
register intmax_t val1, val2;
- val1 = exp5 ();
+ val1 = expeq ();
while (curtok == BAND)
{
readtok ();
- val2 = exp5 ();
+ val2 = expeq ();
val1 = val1 & val2;
lasttok = NUM;
}
}
static intmax_t
-exp5 ()
+expeq (void)
{
register intmax_t val1, val2;
- val1 = exp4 ();
+ val1 = expcompare ();
while ((curtok == EQEQ) || (curtok == NEQ))
{
int op = curtok;
readtok ();
- val2 = exp4 ();
+ val2 = expcompare ();
if (op == EQEQ)
val1 = (val1 == val2);
else if (op == NEQ)
}
static intmax_t
-exp4 ()
+expcompare (void)
{
register intmax_t val1, val2;
/* Left and right shifts. */
static intmax_t
-expshift ()
+expshift (void)
{
register intmax_t val1, val2;
- val1 = exp3 ();
+ val1 = expaddsub ();
while ((curtok == LSH) || (curtok == RSH))
{
int op = curtok;
readtok ();
- val2 = exp3 ();
+ val2 = expaddsub ();
if (op == LSH)
val1 = val1 << val2;
}
static intmax_t
-exp3 ()
+expaddsub (void)
{
register intmax_t val1, val2;
}
static intmax_t
-expmuldiv ()
+expmuldiv (void)
{
register intmax_t val1, val2;
#if defined (HAVE_IMAXDIV)
}
static intmax_t
-ipow (base, exp)
- intmax_t base, exp;
+ipow (intmax_t base, intmax_t exp)
{
intmax_t result;
}
static intmax_t
-exppower ()
+exppower (void)
{
register intmax_t val1, val2, c;
- val1 = exp1 ();
+ val1 = expunary ();
while (curtok == POWER)
{
readtok ();
}
static intmax_t
-exp1 ()
+expunary (void)
{
register intmax_t val;
if (curtok == NOT)
{
readtok ();
- val = !exp1 ();
+ val = !expunary ();
lasttok = NUM;
}
else if (curtok == BNOT)
{
readtok ();
- val = ~exp1 ();
+ val = ~expunary ();
lasttok = NUM;
}
else if (curtok == MINUS)
{
readtok ();
- val = - exp1 ();
+ val = - expunary ();
lasttok = NUM;
}
else if (curtok == PLUS)
{
readtok ();
- val = exp1 ();
+ val = expunary ();
lasttok = NUM;
}
else
}
static intmax_t
-exp0 ()
+exp0 (void)
{
- register intmax_t val = 0, v2;
+ intmax_t val, v2;
char *vincdec;
int stok;
EXPR_CONTEXT ec;
+ val = 0;
/* XXX - might need additional logic here to decide whether or not
pre-increment or pre-decrement is legal at this point. */
if (curtok == PREINC || curtok == PREDEC)
}
static void
-init_lvalue (lv)
- struct lvalue *lv;
+init_lvalue (struct lvalue *lv)
{
lv->tokstr = 0;
lv->tokvar = 0;
}
static struct lvalue *
-alloc_lvalue ()
+alloc_lvalue (void)
{
struct lvalue *lv;
}
static void
-free_lvalue (lv)
- struct lvalue *lv;
+free_lvalue (struct lvalue *lv)
{
free (lv); /* should be inlined */
}
static intmax_t
-expr_streval (tok, e, lvalue)
- char *tok;
- int e;
- struct lvalue *lvalue;
+expr_streval (char *tok, int e, struct lvalue *lvalue)
{
SHELL_VAR *v;
char *value;
}
static int
-_is_multiop (c)
- int c;
+_is_multiop (int c)
{
switch (c)
{
}
static int
-_is_arithop (c)
- int c;
+_is_arithop (int c)
{
switch (c)
{
Updates value of tp. May also set tokval (for number) or tokstr (for
string). */
static void
-readtok ()
+readtok (void)
{
register char *cp, *xp;
register unsigned char c, c1;
}
static void
-evalerror (msg)
- const char *msg;
+evalerror (const char *msg)
{
char *name, *t;
#define VALID_NUMCHAR(c) (ISALNUM(c) || ((c) == '_') || ((c) == '@'))
static intmax_t
-strlong (num)
- char *num;
+strlong (char *num)
{
register char *s;
register unsigned char c;
#if defined (EXPR_TEST)
void *
-xmalloc (n)
- int n;
+xmalloc (size_t n)
{
return (malloc (n));
}
void *
-xrealloc (s, n)
- char *s;
- int n;
+xrealloc (void *s, size_t n)
{
return (realloc (s, n));
}
procenv_t top_level;
-main (argc, argv)
- int argc;
- char **argv;
+main (int argc, char **argv)
{
register int i;
intmax_t v;
}
char *
-itos (n)
- intmax_t n;
+itos (intmax_t n)
{
return ("42");
}
extern char *strcreplace (char *, int, const char *, int);
extern void strip_leading (char *);
extern void strip_trailing (char *, int, int);
-extern void xbcopy (char *, char *, int);
+extern void xbcopy (char *, char *, size_t);
/* Functions from version.c. */
extern char *shell_version_string (void);
#endif
/* Static functions defined and used in this file. */
-static char *_find_user_command_internal PARAMS((const char *, int));
-static char *find_user_command_internal PARAMS((const char *, int));
-static char *find_user_command_in_path PARAMS((const char *, char *, int, int *));
-static char *find_in_path_element PARAMS((const char *, char *, int, int, struct stat *, int *));
-static char *find_absolute_program PARAMS((const char *, int));
+static char *_find_user_command_internal (const char *, int);
+static char *find_user_command_internal (const char *, int);
+static char *find_user_command_in_path (const char *, char *, int, int *);
+static char *find_in_path_element (const char *, char *, int, int, struct stat *, int *);
+static char *find_absolute_program (const char *, int);
-static char *get_next_path_element PARAMS((char *, int *));
+static char *get_next_path_element (char *, int *);
/* The file name which we would try to execute, except that it isn't
possible to execute it. This is the first file that matches the
};
void
-setup_exec_ignore (varname)
- char *varname;
+setup_exec_ignore (char *varname)
{
setup_ignore_patterns (&execignore);
}
static int
-exec_name_should_ignore (name)
- const char *name;
+exec_name_should_ignore (const char *name)
{
struct ign *p;
The EXECABLE bit is non-zero the file is executable.
Zero is returned if the file is not found. */
int
-file_status (name)
- const char *name;
+file_status (const char *name)
{
struct stat finfo;
int r;
executable file is; do not change this unless YOU know
what an executable file is. */
int
-executable_file (file)
- const char *file;
+executable_file (const char *file)
{
int s;
}
int
-is_directory (file)
- const char *file;
+is_directory (const char *file)
{
return (file_status (file) & FS_DIRECTORY);
}
int
-executable_or_directory (file)
- const char *file;
+executable_or_directory (const char *file)
{
int s;
couldn't be found. If a file is found that isn't executable,
and that is the only match, then return that. */
char *
-find_user_command (name)
- const char *name;
+find_user_command (const char *name)
{
return (find_user_command_internal (name, FS_EXEC_PREFERRED|FS_NODIRS));
}
returns the first readable file found; designed to be used to look
for shell scripts or files to source. */
char *
-find_path_file (name)
- const char *name;
+find_path_file (const char *name)
{
return (find_user_command_internal (name, FS_READABLE));
}
static char *
-_find_user_command_internal (name, flags)
- const char *name;
- int flags;
+_find_user_command_internal (const char *name, int flags)
{
char *path_list, *cmd;
SHELL_VAR *var;
}
static char *
-find_user_command_internal (name, flags)
- const char *name;
- int flags;
+find_user_command_internal (const char *name, int flags)
{
#ifdef __WIN32__
char *res, *dotexe;
the index is modified by this function.
Return the next element of PATH_LIST or NULL if there are no more. */
static char *
-get_next_path_element (path_list, path_index_pointer)
- char *path_list;
- int *path_index_pointer;
+get_next_path_element (char *path_list, int *path_index_pointer)
{
char *path;
environment and should use the Posix standard path.
Returns a newly-allocated string. */
char *
-search_for_command (pathname, flags)
- const char *pathname;
- int flags;
+search_for_command (const char *pathname, int flags)
{
char *hashed_file, *command, *path_list;
int temp_path, st;
}
char *
-user_command_matches (name, flags, state)
- const char *name;
- int flags, state;
+user_command_matches (const char *name, int flags, int state)
{
register int i;
int path_index, name_len;
}
static char *
-find_absolute_program (name, flags)
- const char *name;
- int flags;
+find_absolute_program (const char *name, int flags)
{
int st;
}
static char *
-find_in_path_element (name, path, flags, name_len, dotinfop, rflagsp)
- const char *name;
- char *path;
- int flags, name_len;
- struct stat *dotinfop;
- int *rflagsp;
+find_in_path_element (const char *name, char *path, int flags, int name_len, struct stat *dotinfop, int *rflagsp)
{
int status;
char *full_path, *xpath;
FS_NODIRS: Don't find any directories.
*/
static char *
-find_user_command_in_path (name, path_list, flags, rflagsp)
- const char *name;
- char *path_list;
- int flags, *rflagsp;
+find_user_command_in_path (const char *name, char *path_list, int flags, int *rflagsp)
{
char *full_path, *path;
int path_index, name_len, rflags;
/* External interface to find a command given a $PATH. Separate from
find_user_command_in_path to allow future customization. */
char *
-find_in_path (name, path_list, flags)
- const char *name;
- char *path_list;
- int flags;
+find_in_path (const char *name, char *path_list, int flags)
{
return (find_user_command_in_path (name, path_list, flags, (int *)0));
}
/* flags.c -- Everything about flags except the `set' command. That
is in builtins.c */
-/* Copyright (C) 1987-2021 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
#endif
#if defined (JOB_CONTROL)
-extern int set_job_control PARAMS((int));
+extern int set_job_control (int);
#endif
/* **************************************************************** */
char optflags[NUM_SHELL_FLAGS+4] = { '+' };
int *
-find_flag (name)
- int name;
+find_flag (int name)
{
int i;
for (i = 0; shell_flags[i].name; i++)
FLAG_ERROR if there is no flag FLAG. ON_OR_OFF must be either
FLAG_ON or FLAG_OFF. */
int
-change_flag (flag, on_or_off)
- int flag;
- int on_or_off;
+change_flag (int flag, int on_or_off)
{
int *value, old_value;
/* Return a string which is the names of all the currently
set shell flags. */
char *
-which_set_flags ()
+which_set_flags (void)
{
char *temp;
int i, string_index;
}
char *
-get_current_flags ()
+get_current_flags (void)
{
char *temp;
int i;
}
void
-set_current_flags (bitmap)
- const char *bitmap;
+set_current_flags (const char *bitmap)
{
int i;
}
void
-reset_shell_flags ()
+reset_shell_flags (void)
{
mark_modified_vars = disallow_filename_globbing = 0;
place_keywords_in_env = read_but_dont_execute = just_one_command = 0;
}
void
-initialize_flags ()
+initialize_flags (void)
{
register int i;
/* general.c -- Stuff that is used by all files. */
-/* Copyright (C) 1987-2021 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
# include <sys/cygwin.h>
#endif
-static char *bash_special_tilde_expansions PARAMS((char *));
-static int unquoted_tilde_word PARAMS((const char *));
-static void initialize_group_array PARAMS((void));
+static char *bash_special_tilde_expansions (char *);
+static int unquoted_tilde_word (const char *);
+static void initialize_group_array (void);
/* A standard error message to use when getcwd() returns NULL. */
const char * const bash_getcwd_errstr = N_("getcwd: cannot access parent directories");
static char *saved_posix_vars = 0;
void
-posix_initialize (on)
- int on;
+posix_initialize (int on)
{
/* Things that should be turned on when posix mode is enabled. */
if (on != 0)
}
int
-num_posix_options ()
+num_posix_options (void)
{
return ((sizeof (posix_vars) / sizeof (posix_vars[0])) - 1);
}
char *
-get_posix_options (bitmap)
- char *bitmap;
+get_posix_options (char *bitmap)
{
register int i;
#undef save_posix_options
void
-save_posix_options ()
+save_posix_options (void)
{
saved_posix_vars = get_posix_options (saved_posix_vars);
}
void
-set_posix_options (bitmap)
- const char *bitmap;
+set_posix_options (const char *bitmap)
{
register int i;
#if defined (RLIMTYPE)
RLIMTYPE
-string_to_rlimtype (s)
- char *s;
+string_to_rlimtype (char *s)
{
RLIMTYPE ret;
int neg;
}
void
-print_rlimtype (n, addnl)
- RLIMTYPE n;
- int addnl;
+print_rlimtype (RLIMTYPE n, int addnl)
{
char s[INT_STRLEN_BOUND (RLIMTYPE) + 1], *p;
/* Return non-zero if all of the characters in STRING are digits. */
int
-all_digits (string)
- const char *string;
+all_digits (const char *string)
{
register const char *s;
valid number. Stuff the converted number into RESULT if RESULT is
not null. */
int
-legal_number (string, result)
- const char *string;
- intmax_t *result;
+legal_number (const char *string, intmax_t *result)
{
intmax_t value;
char *ep;
solely of letters, digits, and underscores, and does not begin with a
digit. */
int
-legal_identifier (name)
- const char *name;
+legal_identifier (const char *name)
{
register const char *s;
unsigned char c;
be used to allow values to be stored and indirectly referenced, but
not used in assignments. */
int
-valid_nameref_value (name, flags)
- const char *name;
- int flags;
+valid_nameref_value (const char *name, int flags)
{
if (name == 0 || *name == 0)
return 0;
}
int
-check_selfref (name, value, flags)
- const char *name;
- char *value;
- int flags;
+check_selfref (const char *name, char *value, int flags)
{
char *t;
the word is checked to ensure that it consists of only letters,
digits, and underscores, and does not consist of all digits. */
int
-check_identifier (word, check_word)
- WORD_DESC *word;
- int check_word;
+check_identifier (WORD_DESC *word, int check_word)
{
if (word->flags & (W_HASDOLLAR|W_QUOTED)) /* XXX - HASDOLLAR? */
{
Posix mode, we require that STRING be a valid shell identifier. Not
used yet. */
int
-importable_function_name (string, len)
- const char *string;
- size_t len;
+importable_function_name (const char *string, size_t len)
{
if (absolute_program (string)) /* don't allow slash */
return 0;
}
int
-exportable_function_name (string)
- const char *string;
+exportable_function_name (const char *string)
{
if (absolute_program (string))
return 0;
essentially all characters except those which must be quoted to the
parser (which disqualifies them from alias expansion anyway) and `/'. */
int
-legal_alias_name (string, flags)
- const char *string;
- int flags;
+legal_alias_name (const char *string, int flags)
{
register const char *s;
and require an array subscript before the `=' to denote an assignment
statement. */
int
-assignment (string, flags)
- const char *string;
- int flags;
+assignment (const char *string, int flags)
{
register unsigned char c;
register int newi, indx;
}
int
-line_isblank (line)
- const char *line;
+line_isblank (const char *line)
{
register int i;
/* Make sure no-delay mode is not set on file descriptor FD. */
int
-sh_unset_nodelay_mode (fd)
- int fd;
+sh_unset_nodelay_mode (int fd)
{
int flags, bflags;
/* Just a wrapper for the define in include/filecntl.h */
int
-sh_setclexec (fd)
- int fd;
+sh_setclexec (int fd)
{
return (SET_CLOSE_ON_EXEC (fd));
}
/* Return 1 if file descriptor FD is valid; 0 otherwise. */
int
-sh_validfd (fd)
- int fd;
+sh_validfd (int fd)
{
return (fcntl (fd, F_GETFD, 0) >= 0);
}
int
-fd_ispipe (fd)
- int fd;
+fd_ispipe (int fd)
{
errno = 0;
return ((lseek (fd, 0L, SEEK_CUR) < 0) && (errno == ESPIPE));
#endif /* __BEOS__ */
void
-check_dev_tty ()
+check_dev_tty (void)
{
int tty_fd;
char *tty;
expensive. If non-NULL STP1 and STP2 point to stat structures
corresponding to PATH1 and PATH2, respectively. */
int
-same_file (path1, path2, stp1, stp2)
- const char *path1, *path2;
- struct stat *stp1, *stp2;
+same_file (const char *path1, const char *path2, struct stat *stp1, struct stat *stp2)
{
struct stat st1, st2;
file descriptors. If it's less than 20, we get the maximum value
available from getdtablesize(2). */
int
-move_to_high_fd (fd, check_new, maxfd)
- int fd, check_new, maxfd;
+move_to_high_fd (int fd, int check_new, int maxfd)
{
int script_fd, nfds, ignore;
All of the characters must be printable or whitespace. */
int
-check_binary_file (sample, sample_len)
- const char *sample;
- int sample_len;
+check_binary_file (const char *sample, int sample_len)
{
register int i;
int nline;
/* **************************************************************** */
int
-sh_openpipe (pv)
- int *pv;
+sh_openpipe (int *pv)
{
int r;
}
int
-sh_closepipe (pv)
- int *pv;
+sh_closepipe (int *pv)
{
if (pv[0] >= 0)
close (pv[0]);
/* **************************************************************** */
int
-file_exists (fn)
- const char *fn;
+file_exists (const char *fn)
{
struct stat sb;
}
int
-file_isdir (fn)
- const char *fn;
+file_isdir (const char *fn)
{
struct stat sb;
}
int
-file_iswdir (fn)
- const char *fn;
+file_iswdir (const char *fn)
{
return (file_isdir (fn) && sh_eaccess (fn, W_OK) == 0);
}
/* Return 1 if STRING is "." or "..", optionally followed by a directory
separator */
int
-path_dot_or_dotdot (string)
- const char *string;
+path_dot_or_dotdot (const char *string)
{
if (string == 0 || *string == '\0' || *string != '.')
return (0);
/* Return 1 if STRING contains an absolute pathname, else 0. Used by `cd'
to decide whether or not to look up a directory name in $CDPATH. */
int
-absolute_pathname (string)
- const char *string;
+absolute_pathname (const char *string)
{
if (string == 0 || *string == '\0')
return (0);
contains any slashes. This is used to decide whether or not to look
up through $PATH. */
int
-absolute_program (string)
- const char *string;
+absolute_program (const char *string)
{
return ((char *)mbschr (string, '/') != (char *)NULL);
}
returns a new string, even if STRING was an absolute pathname to
begin with. */
char *
-make_absolute (string, dot_path)
- const char *string, *dot_path;
+make_absolute (const char *string, const char *dot_path)
{
char *result;
/* Return the `basename' of the pathname in STRING (the stuff after the
last '/'). If STRING is `/', just return it. */
char *
-base_pathname (string)
- char *string;
+base_pathname (char *string)
{
char *p;
the current working directory prepended. A new string is
returned in either case. */
char *
-full_pathname (file)
- char *file;
+full_pathname (char *file)
{
char *ret;
/* Return a pretty pathname. If the first part of the pathname is
the same as $HOME, then replace that with `~'. */
char *
-polite_directory_format (name)
- char *name;
+polite_directory_format (char *name)
{
char *home;
int l;
keep any tilde prefix and PROMPT_DIRTRIM trailing directory components
and replace the intervening characters with `...' */
char *
-trim_pathname (name, maxlen)
- char *name;
- int maxlen;
+trim_pathname (char *name, int maxlen)
{
int nlen, ndirs;
intmax_t nskip;
than its argument. If FLAGS is non-zero, we are printing for portable
re-input and should single-quote filenames appropriately. */
char *
-printable_filename (fn, flags)
- char *fn;
- int flags;
+printable_filename (char *fn, int flags)
{
char *newf;
return the next one pointed to by (P_INDEX), or NULL if there are no more.
Advance (P_INDEX) to the character after the colon. */
char *
-extract_colon_unit (string, p_index)
- char *string;
- int *p_index;
+extract_colon_unit (char *string, int *p_index)
{
int i, start, len;
char *value;
/* **************************************************************** */
#if defined (PUSHD_AND_POPD)
-extern char *get_dirstack_from_string PARAMS((char *));
+extern char *get_dirstack_from_string (char *);
#endif
static char **bash_tilde_prefixes;
If PUSHD_AND_POPD is defined, ~[+-]N expands to directories from the
directory stack. */
static char *
-bash_special_tilde_expansions (text)
- char *text;
+bash_special_tilde_expansions (char *text)
{
char *result;
well as handling special tilde prefixes; `:~" and `=~' are indications
that we should do tilde expansion. */
void
-tilde_initialize ()
+tilde_initialize (void)
{
static int times_called = 0;
#define TILDE_END(c) ((c) == '\0' || (c) == '/' || (c) == ':')
static int
-unquoted_tilde_word (s)
- const char *s;
+unquoted_tilde_word (const char *s)
{
const char *r;
*LENP. FLAGS tells whether or not we're in an assignment context --
if so, `:' delimits the end of the tilde prefix as well. */
char *
-bash_tilde_find_word (s, flags, lenp)
- const char *s;
- int flags, *lenp;
+bash_tilde_find_word (const char *s, int flags, int *lenp)
{
const char *r;
char *ret;
ASSIGN_P is 2, we are expanding the rhs of an assignment statement,
so `=~' is not valid. */
char *
-bash_tilde_expand (s, assign_p)
- const char *s;
- int assign_p;
+bash_tilde_expand (const char *s, int assign_p)
{
int r;
char *ret;
#endif
static void
-initialize_group_array ()
+initialize_group_array (void)
{
register int i;
/* Return non-zero if GID is one that we have in our groups list. */
int
-#if defined (__STDC__) || defined ( _MINIX)
group_member (gid_t gid)
-#else
-group_member (gid)
- gid_t gid;
-#endif /* !__STDC__ && !_MINIX */
{
#if defined (HAVE_GETGROUPS)
register int i;
}
char **
-get_group_list (ngp)
- int *ngp;
+get_group_list (int *ngp)
{
static char **group_vector = (char **)NULL;
register int i;
}
int *
-get_group_array (ngp)
- int *ngp;
+get_group_array (int *ngp)
{
int i;
static int *group_iarray = (int *)NULL;
utilities. This uses Posix.2 configuration variables, if present. It
uses a value defined in config.h as a last resort. */
char *
-conf_standard_path ()
+conf_standard_path (void)
{
#if defined (_CS_PATH) && defined (HAVE_CONFSTR)
char *p;
}
int
-default_columns ()
+default_columns (void)
{
char *v;
int c;
/* hashcmd.c - functions for managing a hash table mapping command names to
full pathnames. */
-/* Copyright (C) 1997-2021 Free Software Foundation, Inc.
+/* Copyright (C) 1997-2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
HASH_TABLE *hashed_filenames = (HASH_TABLE *)NULL;
-static void phash_freedata PARAMS((PTR_T));
+static void phash_freedata (PTR_T);
void
-phash_create ()
+phash_create (void)
{
if (hashed_filenames == 0)
hashed_filenames = hash_create (FILENAME_HASH_BUCKETS);
}
static void
-phash_freedata (data)
- PTR_T data;
+phash_freedata (PTR_T data)
{
free (((PATH_DATA *)data)->path);
free (data);
}
void
-phash_flush ()
+phash_flush (void)
{
if (hashed_filenames)
hash_flush (hashed_filenames, phash_freedata);
/* Remove FILENAME from the table of hashed commands. */
int
-phash_remove (filename)
- const char *filename;
+phash_remove (const char *filename)
{
register BUCKET_CONTENTS *item;
in a directory in $PATH that is not an absolute pathname.
FOUND is the initial value for times_found. */
void
-phash_insert (filename, full_path, check_dot, found)
- char *filename, *full_path;
- int check_dot, found;
+phash_insert (char *filename, char *full_path, int check_dot, int found)
{
register BUCKET_CONTENTS *item;
returns a newly-allocated string; the caller is responsible
for freeing it. */
char *
-phash_search (filename)
- const char *filename;
+phash_search (const char *filename)
{
register BUCKET_CONTENTS *item;
char *path, *dotted_filename, *tail;
/* hashlib.c -- functions to manage and access hash tables for bash. */
-/* Copyright (C) 1987,1989,1991,1995,1998,2001,2003,2005,2006,2008,2009 Free Software Foundation, Inc.
+/* Copyright (C) 1987-1991,1995,1998,2001-2009,2020,2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
don't discard the upper 32 bits of the value, if present. */
#define HASH_BUCKET(s, t, h) (((h) = hash_string (s)) & ((t)->nbuckets - 1))
-static BUCKET_CONTENTS *copy_bucket_array PARAMS((BUCKET_CONTENTS *, sh_string_func_t *));
+static BUCKET_CONTENTS *copy_bucket_array (BUCKET_CONTENTS *, sh_string_func_t *);
-static void hash_rehash PARAMS((HASH_TABLE *, int));
-static void hash_grow PARAMS((HASH_TABLE *));
-static void hash_shrink PARAMS((HASH_TABLE *));
+static void hash_rehash (HASH_TABLE *, int);
+static void hash_grow (HASH_TABLE *);
+static void hash_shrink (HASH_TABLE *);
/* Make a new hash table with BUCKETS number of buckets. Initialize
each slot in the table to NULL. */
HASH_TABLE *
-hash_create (buckets)
- int buckets;
+hash_create (int buckets)
{
HASH_TABLE *new_table;
register int i;
}
int
-hash_size (table)
- HASH_TABLE *table;
+hash_size (HASH_TABLE *table)
{
return (HASH_ENTRIES(table));
}
+/* Copy a hash table bucket array. Call (*cpdata) to copy the data from
+ each element. */
static BUCKET_CONTENTS *
-copy_bucket_array (ba, cpdata)
- BUCKET_CONTENTS *ba;
- sh_string_func_t *cpdata; /* data copy function */
+copy_bucket_array (BUCKET_CONTENTS *ba, sh_string_func_t *cpdata)
{
BUCKET_CONTENTS *new_bucket, *n, *e;
}
static void
-hash_rehash (table, nsize)
- HASH_TABLE *table;
- int nsize;
+hash_rehash (HASH_TABLE *table, int nsize)
{
int osize, i, j;
BUCKET_CONTENTS **old_bucket_array, *item, *next;
}
static void
-hash_grow (table)
- HASH_TABLE *table;
+hash_grow (HASH_TABLE *table)
{
int nsize;
}
static void
-hash_shrink (table)
- HASH_TABLE *table;
+hash_shrink (HASH_TABLE *table)
{
int nsize;
hash_rehash (table, nsize);
}
+/* Copy an entire hash table. (*cpdata) copies the data in each element. */
HASH_TABLE *
-hash_copy (table, cpdata)
- HASH_TABLE *table;
- sh_string_func_t *cpdata;
+hash_copy (HASH_TABLE *table, sh_string_func_t *cpdata)
{
HASH_TABLE *new_table;
int i;
/* The `khash' check below requires that strings that compare equally with
strcmp hash to the same value. */
unsigned int
-hash_string (s)
- const char *s;
+hash_string (const char *s)
{
register unsigned int i;
for STRING. TABLE is a pointer to a HASH_TABLE. */
int
-hash_bucket (string, table)
- const char *string;
- HASH_TABLE *table;
+hash_bucket (const char *string, HASH_TABLE *table)
{
unsigned int h;
/* Return a pointer to the hashed item. If the HASH_CREATE flag is passed,
create a new hash table entry for STRING, otherwise return NULL. */
BUCKET_CONTENTS *
-hash_search (string, table, flags)
- const char *string;
- HASH_TABLE *table;
- int flags;
+hash_search (const char *string, HASH_TABLE *table, int flags)
{
BUCKET_CONTENTS *list;
int bucket;
The item removed is returned, so you can free its contents. If
the item isn't in this table NULL is returned. */
BUCKET_CONTENTS *
-hash_remove (string, table, flags)
- const char *string;
- HASH_TABLE *table;
- int flags;
+hash_remove (const char *string, HASH_TABLE *table, int flags)
{
int bucket;
BUCKET_CONTENTS *prev, *temp;
/* Create an entry for STRING, in TABLE. If the entry already
exists, then return it (unless the HASH_NOSRCH flag is set). */
BUCKET_CONTENTS *
-hash_insert (string, table, flags)
- char *string;
- HASH_TABLE *table;
- int flags;
+hash_insert (char *string, HASH_TABLE *table, int flags)
{
BUCKET_CONTENTS *item;
int bucket;
is a function to call to dispose of a hash item's data. Otherwise,
free() is called. */
void
-hash_flush (table, free_data)
- HASH_TABLE *table;
- sh_free_func_t *free_data;
+hash_flush (HASH_TABLE *table, sh_free_func_t *free_data)
{
int i;
register BUCKET_CONTENTS *bucket, *item;
/* Free the hash table pointed to by TABLE. */
void
-hash_dispose (table)
- HASH_TABLE *table;
+hash_dispose (HASH_TABLE *table)
{
free (table->bucket_array);
free (table);
}
+/* Call (*FUNC) for each element in TABLE. If FUNC returns < 0, abort the
+ walk. */
void
-hash_walk (table, func)
- HASH_TABLE *table;
- hash_wfunc *func;
+hash_walk (HASH_TABLE *table, hash_wfunc *func)
{
register int i;
BUCKET_CONTENTS *item;
#if defined (DEBUG) || defined (TEST_HASHING)
void
-hash_pstats (table, name)
- HASH_TABLE *table;
- char *name;
+hash_pstats (HASH_TABLE *table, char *name)
{
register int slot, bcount;
register BUCKET_CONTENTS *bc;
int running_trap = 0;
int
-signal_is_trapped (s)
- int s;
+signal_is_trapped (int s)
{
return (0);
}
}
int
-main ()
+main (int c, char **v)
{
char string[256];
int count = 0;
/* input.c -- functions to perform buffered input with synchronization. */
-/* Copyright (C) 1992-2021 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
# define X_EWOULDBLOCK -99
#endif
-extern void termsig_handler PARAMS((int));
+extern void termsig_handler (int);
/* Functions to handle reading input on systems that don't restart read(2)
if a signal is received. */
interrupted by a signal. We do the read ourselves, and restart it
if it returns EINTR. */
int
-getc_with_restart (stream)
- FILE *stream;
+getc_with_restart (FILE *stream)
{
unsigned char uc;
}
int
-ungetc_with_restart (c, stream)
- int c;
- FILE *stream;
+ungetc_with_restart (int c, FILE *stream)
{
if (local_index == 0 || c == EOF)
return EOF;
/* Make sure `buffers' has at least N elements. */
static void
-allocate_buffers (n)
- int n;
+allocate_buffers (int n)
{
register int i, orig_nbuffers;
/* Construct and return a BUFFERED_STREAM corresponding to file descriptor
FD, using BUFFER. */
static BUFFERED_STREAM *
-make_buffered_stream (fd, buffer, bufsize)
- int fd;
- char *buffer;
- size_t bufsize;
+make_buffered_stream (int fd, char *buffer, size_t bufsize)
{
BUFFERED_STREAM *bp;
/* Allocate a new BUFFERED_STREAM, copy BP to it, and return the new copy. */
static BUFFERED_STREAM *
-copy_buffered_stream (bp)
- BUFFERED_STREAM *bp;
+copy_buffered_stream (BUFFERED_STREAM *bp)
{
BUFFERED_STREAM *nbp;
}
int
-set_bash_input_fd (fd)
- int fd;
+set_bash_input_fd (int fd)
{
if (bash_input.type == st_bstream)
bash_input.location.buffered_fd = fd;
}
int
-fd_is_bash_input (fd)
- int fd;
+fd_is_bash_input (int fd)
{
if (bash_input.type == st_bstream && bash_input.location.buffered_fd == fd)
return 1;
NEW_FD is -1, a new file descriptor is allocated with fcntl. The new
file descriptor is returned on success, -1 on error. */
int
-save_bash_input (fd, new_fd)
- int fd, new_fd;
+save_bash_input (int fd, int new_fd)
{
int nfd;
fd 0, sync_buffered_stream is used instead, to cooperate with input
redirection (look at redir.c:add_undo_redirect()). */
int
-check_bash_input (fd)
- int fd;
+check_bash_input (int fd)
{
if (fd_is_bash_input (fd))
{
BUFFERS[fd1] is copied to BUFFERS[fd2]. This is called by the
redirect code for constructs like 4<&0 and 3</etc/rc.local. */
int
-duplicate_buffered_stream (fd1, fd2)
- int fd1, fd2;
+duplicate_buffered_stream (int fd1, int fd2)
{
int is_bash_input, m;
corresponding to it. If something is wrong and the file descriptor
is invalid, return a NULL stream. */
BUFFERED_STREAM *
-fd_to_buffered_stream (fd)
- int fd;
+fd_to_buffered_stream (int fd)
{
char *buffer;
size_t size;
/* Return a buffered stream corresponding to FILE, a file name. */
BUFFERED_STREAM *
-open_buffered_stream (file)
- char *file;
+open_buffered_stream (char *file)
{
int fd;
/* Deallocate a buffered stream and free up its resources. Make sure we
zero out the slot in BUFFERS that points to BP. */
void
-free_buffered_stream (bp)
- BUFFERED_STREAM *bp;
+free_buffered_stream (BUFFERED_STREAM *bp)
{
int n;
/* Close the file descriptor associated with BP, a buffered stream, and free
up the stream. Return the status of closing BP's file descriptor. */
int
-close_buffered_stream (bp)
- BUFFERED_STREAM *bp;
+close_buffered_stream (BUFFERED_STREAM *bp)
{
int fd;
/* Deallocate the buffered stream associated with file descriptor FD, and
close FD. Return the status of the close on FD. */
int
-close_buffered_fd (fd)
- int fd;
+close_buffered_fd (int fd)
{
if (fd < 0)
{
/* Make the BUFFERED_STREAM associated with buffers[FD] be BP, and return
the old BUFFERED_STREAM. */
BUFFERED_STREAM *
-set_buffered_stream (fd, bp)
- int fd;
- BUFFERED_STREAM *bp;
+set_buffered_stream (int fd, BUFFERED_STREAM *bp)
{
BUFFERED_STREAM *ret;
/* Read a buffer full of characters from BP, a buffered stream. */
static int
-b_fill_buffer (bp)
- BUFFERED_STREAM *bp;
+b_fill_buffer (BUFFERED_STREAM *bp)
{
ssize_t nr;
off_t o;
/* Push C back onto buffered stream BP. */
static int
-bufstream_ungetc(c, bp)
- int c;
- BUFFERED_STREAM *bp;
+bufstream_ungetc(int c, BUFFERED_STREAM *bp)
{
if (c == EOF || bp == 0 || bp->b_inputp == 0)
return (EOF);
/* Seek backwards on file BFD to synchronize what we've read so far
with the underlying file pointer. */
int
-sync_buffered_stream (bfd)
- int bfd;
+sync_buffered_stream (int bfd)
{
BUFFERED_STREAM *bp;
off_t chars_left;
}
int
-buffered_getchar ()
+buffered_getchar (void)
{
CHECK_TERMSIG;
}
int
-buffered_ungetchar (c)
- int c;
+buffered_ungetchar (int c)
{
return (bufstream_ungetc (c, buffers[bash_input.location.buffered_fd]));
}
/* Make input come from file descriptor BFD through a buffered stream. */
void
-with_input_from_buffered_stream (bfd, name)
- int bfd;
- char *name;
+with_input_from_buffered_stream (int bfd, char *name)
{
INPUT_STREAM location;
BUFFERED_STREAM *bp;
#if defined (TEST)
void *
-xmalloc(s)
-int s;
+xmalloc(size_t s)
{
return (malloc (s));
}
void *
-xrealloc(s, size)
-char *s;
-int size;
+xrealloc(char *s, size_t size)
{
if (!s)
return(malloc (size));
}
void
-init_yy_io ()
+init_yy_io (void)
{
}
-process(bp)
-BUFFERED_STREAM *bp;
+process(BUFFERED_STREAM *bp)
{
int c;
struct stat dsb; /* can be used from gdb */
/* imitate /bin/cat */
-main(argc, argv)
-int argc;
-char **argv;
+main(int argc, char **argv)
{
register int i;
BUFFERED_STREAM *bp;
#endif /* !errno */
#if !defined (HAVE_KILLPG)
-extern int killpg PARAMS((pid_t, int));
+extern int killpg (pid_t, int);
#endif
#if !DEFAULT_CHILD_MAX
/* The number of additional slots to allocate when we run out. */
#define JOB_SLOTS 8
-typedef int sh_job_map_func_t PARAMS((JOB *, int, int, int));
+typedef int sh_job_map_func_t (JOB *, int, int, int);
/* Variables used here but defined in other files. */
extern WORD_LIST *subst_assign_varlist;
extern SigHandler **original_signals;
-extern void set_original_signal PARAMS((int, SigHandler *));
+extern void set_original_signal (int, SigHandler *);
static struct jobstats zerojs = { -1L, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NO_JOB, NO_JOB, 0, 0 };
struct jobstats js = { -1L, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NO_JOB, NO_JOB, 0, 0 };
void debug_print_pgrps (void);
-static sighandler wait_sigint_handler PARAMS((int));
-static sighandler sigchld_handler PARAMS((int));
-static sighandler sigcont_sighandler PARAMS((int));
-static sighandler sigstop_sighandler PARAMS((int));
-
-static int waitchld PARAMS((pid_t, int));
-
-static PROCESS *find_pid_in_pipeline PARAMS((pid_t, PROCESS *, int));
-static PROCESS *find_pipeline PARAMS((pid_t, int, int *));
-static PROCESS *find_process PARAMS((pid_t, int, int *));
-
-static char *current_working_directory PARAMS((void));
-static char *job_working_directory PARAMS((void));
-static char *j_strsignal PARAMS((int));
-static char *printable_job_status PARAMS((int, PROCESS *, int));
-
-static PROCESS *find_last_proc PARAMS((int, int));
-static pid_t find_last_pid PARAMS((int, int));
-
-static int set_new_line_discipline PARAMS((int));
-static int map_over_jobs PARAMS((sh_job_map_func_t *, int, int));
-static int job_last_stopped PARAMS((int));
-static int job_last_running PARAMS((int));
-static int most_recent_job_in_state PARAMS((int, JOB_STATE));
-static int find_job PARAMS((pid_t, int, PROCESS **));
-static int print_job PARAMS((JOB *, int, int, int));
-static int process_exit_status PARAMS((WAIT));
-static int process_exit_signal PARAMS((WAIT));
-static int set_job_status_and_cleanup PARAMS((int));
-
-static WAIT job_signal_status PARAMS((int));
-static WAIT raw_job_exit_status PARAMS((int));
-
-static int job_killed_by_signal PARAMS((int));
-
-static void notify_of_job_status PARAMS((void));
-static void reset_job_indices PARAMS((void));
-static void cleanup_dead_jobs PARAMS((void));
-static int processes_in_job PARAMS((int));
-static void realloc_jobs_list PARAMS((void));
-static int compact_jobs_list PARAMS((int));
-static void add_process PARAMS((char *, pid_t));
-static void print_pipeline PARAMS((PROCESS *, int, int, FILE *));
-static void pretty_print_job PARAMS((int, int, FILE *));
-static void set_current_job PARAMS((int));
-static void reset_current PARAMS((void));
-static void set_job_running PARAMS((int));
-static void setjstatus PARAMS((int));
-static int maybe_give_terminal_to PARAMS((pid_t, pid_t, int));
-static void mark_all_jobs_as_dead PARAMS((void));
-static void mark_dead_jobs_as_notified PARAMS((int));
-static void restore_sigint_handler PARAMS((void));
+static sighandler wait_sigint_handler (int);
+static sighandler sigchld_handler (int);
+static sighandler sigcont_sighandler (int);
+static sighandler sigstop_sighandler (int);
+
+static int waitchld (pid_t, int);
+
+static PROCESS *find_pid_in_pipeline (pid_t, PROCESS *, int);
+static PROCESS *find_pipeline (pid_t, int, int *);
+static PROCESS *find_process (pid_t, int, int *);
+
+static char *current_working_directory (void);
+static char *job_working_directory (void);
+static char *j_strsignal (int);
+static char *printable_job_status (int, PROCESS *, int);
+
+static PROCESS *find_last_proc (int, int);
+static pid_t find_last_pid (int, int);
+
+static int set_new_line_discipline (int);
+static int map_over_jobs (sh_job_map_func_t *, int, int);
+static int job_last_stopped (int);
+static int job_last_running (int);
+static int most_recent_job_in_state (int, JOB_STATE);
+static int find_job (pid_t, int, PROCESS **);
+static int print_job (JOB *, int, int, int);
+static int process_exit_status (WAIT);
+static int process_exit_signal (WAIT);
+static int set_job_status_and_cleanup (int);
+
+static WAIT job_signal_status (int);
+static WAIT raw_job_exit_status (int);
+
+static int job_killed_by_signal (int);
+
+static void notify_of_job_status (void);
+static void reset_job_indices (void);
+static void cleanup_dead_jobs (void);
+static int processes_in_job (int);
+static void realloc_jobs_list (void);
+static int compact_jobs_list (int);
+static void add_process (char *, pid_t);
+static void print_pipeline (PROCESS *, int, int, FILE *);
+static void pretty_print_job (int, int, FILE *);
+static void set_current_job (int);
+static void reset_current (void);
+static void set_job_running (int);
+static void setjstatus (int);
+static int maybe_give_terminal_to (pid_t, pid_t, int);
+static void mark_all_jobs_as_dead (void);
+static void mark_dead_jobs_as_notified (int);
+static void restore_sigint_handler (void);
#if defined (PGRP_PIPE)
-static void pipe_read PARAMS((int *));
+static void pipe_read (int *);
#endif
/* Hash table manipulation */
-static ps_index_t *pshash_getbucket PARAMS((pid_t));
-static void pshash_delindex PARAMS((ps_index_t));
+static ps_index_t *pshash_getbucket (pid_t);
+static void pshash_delindex (ps_index_t);
/* Saved background process status management */
-static struct pidstat *bgp_add PARAMS((pid_t, int));
-static int bgp_delete PARAMS((pid_t));
-static void bgp_clear PARAMS((void));
-static int bgp_search PARAMS((pid_t));
+static struct pidstat *bgp_add (pid_t, int);
+static int bgp_delete (pid_t);
+static void bgp_clear (void);
+static int bgp_search (pid_t);
-static struct pipeline_saver *alloc_pipeline_saver PARAMS((void));
+static struct pipeline_saver *alloc_pipeline_saver (void);
-static ps_index_t bgp_getindex PARAMS((void));
-static void bgp_resize PARAMS((void)); /* XXX */
+static ps_index_t bgp_getindex (void);
+static void bgp_resize (void); /* XXX */
#if defined (ARRAY_VARS)
static int *pstatuses; /* list of pipeline statuses */
#define tcsetpgrp(fd, pgrp) ioctl ((fd), TIOCSPGRP, &(pgrp))
pid_t
-tcgetpgrp (fd)
- int fd;
+tcgetpgrp (int fd)
{
pid_t pgrp;
/* Initialize the global job stats structure and other bookkeeping variables */
void
-init_job_stats ()
+init_job_stats (void)
{
js = zerojs;
}
of the functions it calls. This is so that it can safely be called
from a signal handler. */
static char *
-current_working_directory ()
+current_working_directory (void)
{
char *dir;
static char d[PATH_MAX];
/* Return the working directory for the current process. */
static char *
-job_working_directory ()
+job_working_directory (void)
{
char *dir;
}
void
-making_children ()
+making_children (void)
{
if (already_making_children)
return;
}
void
-stop_making_children ()
+stop_making_children (void)
{
already_making_children = 0;
}
void
-cleanup_the_pipeline ()
+cleanup_the_pipeline (void)
{
PROCESS *disposer;
sigset_t set, oset;
/* Not used right now */
void
-discard_last_procsub_child ()
+discard_last_procsub_child (void)
{
PROCESS *disposer;
sigset_t set, oset;
}
static struct pipeline_saver *
-alloc_pipeline_saver ()
+alloc_pipeline_saver (void)
{
struct pipeline_saver *ret;
}
void
-save_pipeline (clear)
- int clear;
+save_pipeline (int clear)
{
sigset_t set, oset;
struct pipeline_saver *saver;
}
PROCESS *
-restore_pipeline (discard)
- int discard;
+restore_pipeline (int discard)
{
PROCESS *old_pipeline;
sigset_t set, oset;
/* Start building a pipeline. */
void
-start_pipeline ()
+start_pipeline (void)
{
if (the_pipeline)
{
DEFERRED is a command structure to be executed upon satisfactory
execution exit of this pipeline. */
int
-stop_pipeline (async, deferred)
- int async;
- COMMAND *deferred;
+stop_pipeline (int async, COMMAND *deferred)
{
register int i, j;
JOB *newjob;
/* The number of elements in bgpids.storage always has to be > js.c_childmax for
the circular buffer to work right. */
static void
-bgp_resize ()
+bgp_resize (void)
{
ps_index_t nsize, nsize_cur, nsize_max;
ps_index_t psi;
}
static ps_index_t
-bgp_getindex ()
+bgp_getindex (void)
{
if (bgpids.nalloc < (ps_index_t)js.c_childmax || bgpids.head >= bgpids.nalloc)
bgp_resize ();
}
static ps_index_t *
-pshash_getbucket (pid)
- pid_t pid;
+pshash_getbucket (pid_t pid)
{
unsigned long hash; /* XXX - u_bits32_t */
}
static struct pidstat *
-bgp_add (pid, status)
- pid_t pid;
- int status;
+bgp_add (pid_t pid, int status)
{
ps_index_t *bucket, psi;
struct pidstat *ps;
}
static void
-pshash_delindex (psi)
- ps_index_t psi;
+pshash_delindex (ps_index_t psi)
{
struct pidstat *ps;
ps_index_t *bucket;
}
static int
-bgp_delete (pid)
- pid_t pid;
+bgp_delete (pid_t pid)
{
ps_index_t psi, orig_psi;
/* Clear out the list of saved statuses */
static void
-bgp_clear ()
+bgp_clear (void)
{
if (bgpids.storage == 0 || bgpids.nalloc == 0)
return;
found. If not found, return -1. We hash to the right spot in pidstat_table
and follow the bucket chain to the end. */
static int
-bgp_search (pid)
- pid_t pid;
+bgp_search (pid_t pid)
{
ps_index_t psi, orig_psi;
#if 0
static void
-bgp_prune ()
+bgp_prune (void)
{
return;
}
/* External interface to bgp_add; takes care of blocking and unblocking
SIGCHLD. Not really used. */
void
-save_proc_status (pid, status)
- pid_t pid;
- int status;
+save_proc_status (pid_t pid, int status)
{
sigset_t set, oset;
eventually removed from the list and added to the bgpids table. */
static void
-procsub_free (p)
- PROCESS *p;
+procsub_free (PROCESS *p)
{
FREE (p->command);
free (p);
}
PROCESS *
-procsub_add (p)
- PROCESS *p;
+procsub_add (PROCESS *p)
{
sigset_t set, oset;
}
PROCESS *
-procsub_search (pid)
- pid_t pid;
+procsub_search (pid_t pid)
{
PROCESS *p;
sigset_t set, oset;
}
PROCESS *
-procsub_delete (pid)
- pid_t pid;
+procsub_delete (pid_t pid)
{
PROCESS *p, *prev;
sigset_t set, oset;
}
int
-procsub_waitpid (pid)
- pid_t pid;
+procsub_waitpid (pid_t pid)
{
PROCESS *p;
int r;
}
void
-procsub_waitall ()
+procsub_waitall (void)
{
PROCESS *p;
int r;
}
void
-procsub_clear ()
+procsub_clear (void)
{
PROCESS *p, *ps;
sigset_t set, oset;
/* Must be called with SIGCHLD blocked. */
void
-procsub_prune ()
+procsub_prune (void)
{
PROCESS *ohead, *oend, *ps, *p;
int onproc;
calling this. This wraps around, but the rest of the code does not. At
this point, it should not matter. */
static void
-reset_job_indices ()
+reset_job_indices (void)
{
int old;
/* Delete all DEAD jobs that the user had received notification about. */
static void
-cleanup_dead_jobs ()
+cleanup_dead_jobs (void)
{
register int i;
int os;
}
static int
-processes_in_job (job)
- int job;
+processes_in_job (int job)
{
int nproc;
register PROCESS *p;
}
static void
-delete_old_job (pid)
- pid_t pid;
+delete_old_job (pid_t pid)
{
PROCESS *p;
int job;
whose size is a multiple of JOB_SLOTS and can hold the current number of
jobs. Heuristics are used to minimize the number of new reallocs. */
static void
-realloc_jobs_list ()
+realloc_jobs_list (void)
{
sigset_t set, oset;
int nsize, i, j, ncur, nprev;
the list needs to be reallocated. The jobs array may be in new memory if
this returns > 0 and < js.j_jobslots. FLAGS is reserved for future use. */
static int
-compact_jobs_list (flags)
- int flags;
+compact_jobs_list (int flags)
{
if (js.j_jobslots == 0 || jobs_list_frozen)
return js.j_jobslots;
/* Delete the job at INDEX from the job list. Must be called
with SIGCHLD blocked. */
void
-delete_job (job_index, dflags)
- int job_index, dflags;
+delete_job (int job_index, int dflags)
{
register JOB *temp;
PROCESS *proc;
/* Must be called with SIGCHLD blocked. */
void
-nohup_job (job_index)
- int job_index;
+nohup_job (int job_index)
{
register JOB *temp;
/* Get rid of the data structure associated with a process chain. */
int
-discard_pipeline (chain)
- register PROCESS *chain;
+discard_pipeline (PROCESS *chain)
{
register PROCESS *this, *next;
int n;
NAME is the command string that will be exec'ed later.
PID is the process id of the child. */
static void
-add_process (name, pid)
- char *name;
- pid_t pid;
+add_process (char *name, pid_t pid)
{
PROCESS *t, *p;
/* Create a (dummy) PROCESS with NAME, PID, and STATUS, and make it the last
process in jobs[JID]->pipe. Used by the lastpipe code. */
void
-append_process (name, pid, status, jid)
- char *name;
- pid_t pid;
- int status;
- int jid;
+append_process (char *name, pid_t pid, int status, int jid)
{
PROCESS *t, *p;
/* Take the last job and make it the first job. Must be called with
SIGCHLD blocked. */
int
-rotate_the_pipeline ()
+rotate_the_pipeline (void)
{
PROCESS *p;
/* Reverse the order of the processes in the_pipeline. Must be called with
SIGCHLD blocked. */
int
-reverse_the_pipeline ()
+reverse_the_pipeline (void)
{
PROCESS *p, *n;
for map_over_jobs. FUNC is called with a JOB, arg1, arg2,
and INDEX. */
static int
-map_over_jobs (func, arg1, arg2)
- sh_job_map_func_t *func;
- int arg1, arg2;
+map_over_jobs (sh_job_map_func_t *func, int arg1, int arg2)
{
register int i;
int result;
/* Cause all the jobs in the current pipeline to exit. */
void
-terminate_current_pipeline ()
+terminate_current_pipeline (void)
{
if (pipeline_pgrp && pipeline_pgrp != shell_pgrp)
{
/* Cause all stopped jobs to exit. */
void
-terminate_stopped_jobs ()
+terminate_stopped_jobs (void)
{
register int i;
/* Cause all jobs, running or stopped, to receive a hangup signal. If
a job is marked J_NOHUP, don't send the SIGHUP. */
void
-hangup_all_jobs ()
+hangup_all_jobs (void)
{
register int i;
}
void
-kill_current_pipeline ()
+kill_current_pipeline (void)
{
stop_making_children ();
start_pipeline ();
}
static PROCESS *
-find_pid_in_pipeline (pid, pipeline, alive_only)
- pid_t pid;
- PROCESS *pipeline;
- int alive_only;
+find_pid_in_pipeline (pid_t pid, PROCESS *pipeline, int alive_only)
{
PROCESS *p;
/* Return the pipeline that PID belongs to. Note that the pipeline
doesn't have to belong to a job. Must be called with SIGCHLD blocked.
- If JOBP is non-null, return the index of the job containing PID. */
+ If JOBP is non-null, return the index of the job containing PID, or
+ NO_JOB if PID doesn't belong to an existing job. */
static PROCESS *
-find_pipeline (pid, alive_only, jobp)
- pid_t pid;
- int alive_only;
- int *jobp; /* index into jobs list or NO_JOB */
+find_pipeline (pid_t pid, int alive_only, int *jobp)
{
int job;
PROCESS *p;
}
/* Return the PROCESS * describing PID. If JOBP is non-null return the index
- into the jobs array of the job containing PID. Must be called with
- SIGCHLD blocked. */
+ into the jobs array of the job containing PID or NO_JOB. Must be called
+ with SIGCHLD blocked. */
static PROCESS *
-find_process (pid, alive_only, jobp)
- pid_t pid;
- int alive_only;
- int *jobp; /* index into jobs list or NO_JOB */
+find_process (pid_t pid, int alive_only, int *jobp)
{
PROCESS *p;
/* Return the job index that PID belongs to, or NO_JOB if it doesn't
belong to any job. Must be called with SIGCHLD blocked. */
static int
-find_job (pid, alive_only, procp)
- pid_t pid;
- int alive_only;
- PROCESS **procp;
+find_job (pid_t pid, int alive_only, PROCESS **procp)
{
register int i;
PROCESS *p;
/* Find a job given a PID. If BLOCK is non-zero, block SIGCHLD as
required by find_job. */
int
-get_job_by_pid (pid, block, procp)
- pid_t pid;
- int block;
- PROCESS **procp;
+get_job_by_pid (pid_t pid, int block, PROCESS **procp)
{
int job;
sigset_t set, oset;
/* Print descriptive information about the job with leader pid PID. */
void
-describe_pid (pid)
- pid_t pid;
+describe_pid (pid_t pid)
{
int job;
sigset_t set, oset;
}
static char *
-j_strsignal (s)
- int s;
+j_strsignal (int s)
{
char *x;
}
static char *
-printable_job_status (j, p, format)
- int j;
- PROCESS *p;
- int format;
+printable_job_status (int j, PROCESS *p, int format)
{
static char *temp;
int es;
If you're printing a pipeline that's not in the jobs array, like the
current pipeline as it's being created, pass -1 for JOB_INDEX */
static void
-print_pipeline (p, job_index, format, stream)
- PROCESS *p;
- int job_index, format;
- FILE *stream;
+print_pipeline (PROCESS *p, int job_index, int format, FILE *stream)
{
PROCESS *first, *last, *show;
int es, name_padding;
/* Print information to STREAM about jobs[JOB_INDEX] according to FORMAT.
Must be called with SIGCHLD blocked or queued with queue_sigchld */
static void
-pretty_print_job (job_index, format, stream)
- int job_index, format;
- FILE *stream;
+pretty_print_job (int job_index, int format, FILE *stream)
{
register PROCESS *p;
}
static int
-print_job (job, format, state, job_index)
- JOB *job;
- int format, state, job_index;
+print_job (JOB *job, int format, int state, int job_index)
{
if (state == -1 || (JOB_STATE)state == job->state)
pretty_print_job (job_index, format, stdout);
}
void
-list_one_job (job, format, ignore, job_index)
- JOB *job;
- int format, ignore, job_index;
+list_one_job (JOB *job, int format, int ignore, int job_index)
{
pretty_print_job (job_index, format, stdout);
cleanup_dead_jobs ();
}
void
-list_stopped_jobs (format)
- int format;
+list_stopped_jobs (int format)
{
cleanup_dead_jobs ();
map_over_jobs (print_job, format, (int)JSTOPPED);
}
void
-list_running_jobs (format)
- int format;
+list_running_jobs (int format)
{
cleanup_dead_jobs ();
map_over_jobs (print_job, format, (int)JRUNNING);
/* List jobs. If FORMAT is non-zero, then the long form of the information
is printed, else just a short version. */
void
-list_all_jobs (format)
- int format;
+list_all_jobs (int format)
{
cleanup_dead_jobs ();
map_over_jobs (print_job, format, -1);
anything else with it. ASYNC_P says what to do with the tty. If
non-zero, then don't give it away. */
pid_t
-make_child (command, flags)
- char *command;
- int flags;
+make_child (char *command, int flags)
{
int async_p, forksleep;
sigset_t set, oset, termset, chldset, oset_copy;
/* These two functions are called only in child processes. */
void
-ignore_tty_job_signals ()
+ignore_tty_job_signals (void)
{
set_signal_handler (SIGTSTP, SIG_IGN);
set_signal_handler (SIGTTIN, SIG_IGN);
SIG_IGN in the child. We can't rely on resetting traps, since the hard
ignored signals can't be trapped. */
void
-default_tty_job_signals ()
+default_tty_job_signals (void)
{
if (signal_is_trapped (SIGTSTP) == 0 && signal_is_hard_ignored (SIGTSTP))
set_signal_handler (SIGTSTP, SIG_IGN);
/* Called once in a parent process. */
void
-get_original_tty_job_signals ()
+get_original_tty_job_signals (void)
{
static int fetched = 0;
};
static void
-draino (fd, ospeed)
- int fd, ospeed;
+draino (int fd, int ospeed)
{
register int delay = ttspeeds[ospeed];
int n;
/* Fill the contents of shell_tty_info with the current tty info. */
int
-get_tty_state ()
+get_tty_state (void)
{
int tty;
/* Make the current tty use the state in shell_tty_info. */
int
-set_tty_state ()
+set_tty_state (void)
{
int tty;
process in that job's pipeline. This is the one whose exit status
counts. Must be called with SIGCHLD blocked or queued. */
static PROCESS *
-find_last_proc (job, block)
- int job;
- int block;
+find_last_proc (int job, int block)
{
register PROCESS *p;
sigset_t set, oset;
}
static pid_t
-find_last_pid (job, block)
- int job;
- int block;
+find_last_pid (int job, int block)
{
PROCESS *p;
we suppress the error message if PID isn't found. */
int
-wait_for_single_pid (pid, flags)
- pid_t pid;
- int flags;
+wait_for_single_pid (pid_t pid, int flags)
{
register PROCESS *child;
sigset_t set, oset;
/* Wait for all of the background processes started by this shell to finish. */
int
-wait_for_background_pids (ps)
- struct procstat *ps;
+wait_for_background_pids (struct procstat *ps)
{
register int i, r;
int any_stopped, check_async, njobs;
/* Clean up state after longjmp to wait_intr_buf */
void
-wait_sigint_cleanup ()
+wait_sigint_cleanup (void)
{
queue_sigchld = 0;
waiting_for_child = 0;
}
static void
-restore_sigint_handler ()
+restore_sigint_handler (void)
{
if (old_sigint_handler != INVALID_SIGNAL_HANDLER)
{
The `wait' builtin should be interruptible, but all others should be
effectively ignored (i.e. not cause the shell to exit). */
static sighandler
-wait_sigint_handler (sig)
- int sig;
+wait_sigint_handler (int sig)
{
SigHandler *sigint_handler;
}
static int
-process_exit_signal (status)
- WAIT status;
+process_exit_signal (WAIT status)
{
return (WIFSIGNALED (status) ? WTERMSIG (status) : 0);
}
static int
-process_exit_status (status)
- WAIT status;
+process_exit_status (WAIT status)
{
if (WIFSIGNALED (status))
return (128 + WTERMSIG (status));
}
static WAIT
-job_signal_status (job)
- int job;
+job_signal_status (int job)
{
register PROCESS *p;
WAIT s;
/* Return the exit status of the last process in the pipeline for job JOB.
This is the exit status of the entire job. */
static WAIT
-raw_job_exit_status (job)
- int job;
+raw_job_exit_status (int job)
{
register PROCESS *p;
int fail;
(rightmost) process in the job's pipeline, modified if the job was killed
by a signal or stopped. */
int
-job_exit_status (job)
- int job;
+job_exit_status (int job)
{
return (process_exit_status (raw_job_exit_status (job)));
}
int
-job_exit_signal (job)
- int job;
+job_exit_signal (int job)
{
return (process_exit_signal (raw_job_exit_status (job)));
}
static int
-job_killed_by_signal (job)
- int job;
+job_killed_by_signal (int job)
{
int termsig;
the jobs table. Returns -1 if waitchld() returns -1, indicating
that there are no unwaited-for child processes. */
int
-wait_for (pid, flags)
- pid_t pid;
- int flags;
+wait_for (pid_t pid, int flags)
{
int job, termination_state, r;
WAIT s;
includes JWAIT_FORCE, we wait for the job to terminate, no just change
state */
int
-wait_for_job (job, flags, ps)
- int job, flags;
- struct procstat *ps;
+wait_for_job (int job, int flags, struct procstat *ps)
{
pid_t pid;
int r, state;
is responsible for translating -1 into the right return value. RPID,
if non-null, gets the pid of the job's process leader. */
int
-wait_for_any_job (flags, ps)
- int flags;
- struct procstat *ps;
+wait_for_any_job (int flags, struct procstat *ps)
{
pid_t pid;
int i, r;
shell is not interactive, because the dead jobs are not marked
as notified. */
void
-notify_and_cleanup ()
+notify_and_cleanup (void)
{
if (jobs_list_frozen)
return;
/* Make dead jobs disappear from the jobs array without notification.
This is used when the shell is not interactive. */
void
-reap_dead_jobs ()
+reap_dead_jobs (void)
{
mark_dead_jobs_as_notified (0);
cleanup_dead_jobs ();
STATE. STATE can be JSTOPPED, JRUNNING. NO_JOB is returned if
there is no next recent job. */
static int
-most_recent_job_in_state (job, state)
- int job;
- JOB_STATE state;
+most_recent_job_in_state (int job, JOB_STATE state)
{
register int i, result;
sigset_t set, oset;
/* Return the newest *stopped* job older than JOB, or NO_JOB if not
found. */
static int
-job_last_stopped (job)
- int job;
+job_last_stopped (int job)
{
return (most_recent_job_in_state (job, JSTOPPED));
}
/* Return the newest *running* job older than JOB, or NO_JOB if not
found. */
static int
-job_last_running (job)
- int job;
+job_last_running (int job)
{
return (most_recent_job_in_state (job, JRUNNING));
}
/* Make JOB be the current job, and make previous be useful. Must be
called with SIGCHLD blocked. */
static void
-set_current_job (job)
- int job;
+set_current_job (int job)
{
int candidate;
next-newest running job is `-'. Must be called with SIGCHLD blocked. */
static void
-reset_current ()
+reset_current (void)
{
int candidate;
/* Set up the job structures so we know the job and its processes are
all running. */
static void
-set_job_running (job)
- int job;
+set_job_running (int job)
{
register PROCESS *p;
JOBS. Returns -1 if it is unable to start a job, and the return
status of the job otherwise. */
int
-start_job (job, foreground)
- int job, foreground;
+start_job (int job, int foreground)
{
register PROCESS *p;
int already_running;
job after giving it SIGNAL. Returns -1 on failure. If GROUP is non-null,
then kill the process group associated with PID. */
int
-kill_pid (pid, sig, group)
- pid_t pid;
- int sig, group;
+kill_pid (pid_t pid, int sig, int group)
{
register PROCESS *p;
int job, result, negative;
/* sigchld_handler () flushes at least one of the children that we are
waiting for. It gets run when we have gotten a SIGCHLD signal. */
static sighandler
-sigchld_handler (sig)
- int sig;
+sigchld_handler (int sig)
{
int n, oerrno;
the number of children reaped, or -1 if there are no unwaited-for child
processes. */
static int
-waitchld (wpid, block)
- pid_t wpid;
- int block;
+waitchld (pid_t wpid, int block)
{
WAIT status;
PROCESS *child;
Currently, the cleanup activity is restricted to handling any SIGINT
received while waiting for a foreground job to finish. */
static int
-set_job_status_and_cleanup (job)
- int job;
+set_job_status_and_cleanup (int job)
{
PROCESS *child;
int tstatus, job_state, any_stopped, any_tstped, call_set_current;
/* Build the array of values for the $PIPESTATUS variable from the set of
exit statuses of all processes in the job J. */
static void
-setjstatus (j)
- int j;
+setjstatus (int j)
{
#if defined (ARRAY_VARS)
register int i;
}
void
-run_sigchld_trap (nchild)
- int nchild;
+run_sigchld_trap (int nchild)
{
char *trap_command;
int i;
notification to stderr, and marks those printed as already
notified, thus making them candidates for cleanup. */
static void
-notify_of_job_status ()
+notify_of_job_status (void)
{
register int job, termsig;
char *dir;
/* Initialize the job control mechanism, and set up the tty stuff. */
int
-initialize_job_control (force)
- int force;
+initialize_job_control (int force)
{
pid_t t;
int t_errno, tty_sigs;
#ifdef DEBUG
void
-debug_print_pgrps ()
+debug_print_pgrps (void)
{
itrace("original_pgrp = %ld shell_pgrp = %ld terminal_pgrp = %ld",
(long)original_pgrp, (long)shell_pgrp, (long)terminal_pgrp);
/* Set the line discipline to the best this system has to offer.
Return -1 if this is not possible. */
static int
-set_new_line_discipline (tty)
- int tty;
+set_new_line_discipline (int tty)
{
#if defined (NEW_TTY_DRIVER)
int ldisc;
/* Setup this shell to handle C-C, etc. */
void
-initialize_job_signals ()
+initialize_job_signals (void)
{
if (interactive)
{
/* Here we handle CONT signals. */
static sighandler
-sigcont_sighandler (sig)
- int sig;
+sigcont_sighandler (int sig)
{
initialize_job_signals ();
set_signal_handler (SIGCONT, old_cont);
/* Here we handle stop signals while we are running not as a login shell. */
static sighandler
-sigstop_sighandler (sig)
- int sig;
+sigstop_sighandler (int sig)
{
set_signal_handler (SIGTSTP, old_tstp);
set_signal_handler (SIGTTOU, old_ttou);
/* Give the terminal to PGRP. */
int
-give_terminal_to (pgrp, force)
- pid_t pgrp;
- int force;
+give_terminal_to (pid_t pgrp, int force)
{
sigset_t set, oset;
int r, e;
/* Give terminal to NPGRP iff it's currently owned by OPGRP. FLAGS are the
flags to pass to give_terminal_to(). */
static int
-maybe_give_terminal_to (opgrp, npgrp, flags)
- pid_t opgrp, npgrp;
- int flags;
+maybe_give_terminal_to (pid_t opgrp, pid_t npgrp, int flags)
{
int tpgrp;
and functions with pipes are the two that spring to mind). If RUNNING_ONLY
is nonzero, only running jobs are removed from the table. */
void
-delete_all_jobs (running_only)
- int running_only;
+delete_all_jobs (int running_only)
{
register int i;
sigset_t set, oset;
/* Mark all jobs in the job array so that they don't get a SIGHUP when the
shell gets one. If RUNNING_ONLY is nonzero, mark only running jobs. */
void
-nohup_all_jobs (running_only)
- int running_only;
+nohup_all_jobs (int running_only)
{
register int i;
sigset_t set, oset;
}
int
-count_all_jobs ()
+count_all_jobs (void)
{
int i, n;
sigset_t set, oset;
}
static void
-mark_all_jobs_as_dead ()
+mark_all_jobs_as_dead (void)
{
register int i;
sigset_t set, oset;
status of the last CHILD_MAX jobs, so we count the number of dead
jobs and mark only enough as notified to save CHILD_MAX statuses. */
static void
-mark_dead_jobs_as_notified (force)
- int force;
+mark_dead_jobs_as_notified (int force)
{
register int i, ndead, ndeadproc;
sigset_t set, oset;
/* Here to allow other parts of the shell (like the trap stuff) to
freeze and unfreeze the jobs list. */
int
-freeze_jobs_list ()
+freeze_jobs_list (void)
{
int o;
}
void
-unfreeze_jobs_list ()
+unfreeze_jobs_list (void)
{
jobs_list_frozen = 0;
}
void
-set_jobs_list_frozen (s)
- int s;
+set_jobs_list_frozen (int s)
{
jobs_list_frozen = s;
}
-/* Allow or disallow job control to take place. Returns the old value
+/* Allow or disallow job control to take place. Returns the old value
of job_control. */
int
-set_job_control (arg)
- int arg;
+set_job_control (int arg)
{
int old;
/* Turn off all traces of job control. This is run by children of the shell
which are going to do shellsy things, like wait (), etc. */
void
-without_job_control ()
+without_job_control (void)
{
stop_making_children ();
start_pipeline ();
restore the original terminal process group. This is done
before the `exec' builtin calls shell_execve. */
void
-end_job_control ()
+end_job_control (void)
{
if (job_control)
terminate_stopped_jobs ();
/* Restart job control by closing shell tty and reinitializing. This is
called after an exec fails in an interactive shell and we do not exit. */
void
-restart_job_control ()
+restart_job_control (void)
{
if (shell_tty != -1)
close (shell_tty);
If the caller passes NCHILD as 0 or -1, this ends up setting it to
LMAXCHILD, which is initialized the first time through. */
void
-set_maxchild (nchild)
- int nchild;
+set_maxchild (int nchild)
{
static int lmaxchild = -1;
/* Set the handler to run when the shell receives a SIGCHLD signal. */
void
-set_sigchld_handler ()
+set_sigchld_handler (void)
{
set_signal_handler (SIGCHLD, sigchld_handler);
}
/* Read from the read end of a pipe. This is how the process group leader
blocks until all of the processes in a pipeline have been made. */
static void
-pipe_read (pp)
- int *pp;
+pipe_read (int *pp)
{
char ch;
/* Functional interface closes our local-to-job-control pipes. */
void
-close_pgrp_pipe ()
+close_pgrp_pipe (void)
{
sh_closepipe (pgrp_pipe);
}
void
-save_pgrp_pipe (p, clear)
- int *p;
- int clear;
+save_pgrp_pipe (int *p, int clear)
{
p[0] = pgrp_pipe[0];
p[1] = pgrp_pipe[1];
}
void
-restore_pgrp_pipe (p)
- int *p;
+restore_pgrp_pipe (int *p)
{
pgrp_pipe[0] = p[0];
pgrp_pipe[1] = p[1];
/* locale.c - Miscellaneous internationalization functions. */
-/* Copyright (C) 1996-2009,2012,2016-2021 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2009,2012,2016-2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
/* Called to reset all of the locale variables to their appropriate values
if (and only if) LC_ALL has not been assigned a value. */
-static int reset_locale_vars PARAMS((void));
+static int reset_locale_vars (void);
-static void locale_setblanks PARAMS((void));
-static int locale_isutf8 PARAMS((char *));
+static void locale_setblanks (void);
+static int locale_isutf8 (char *);
/* Set the value of default_locale and make the current locale the
system default locale. This should be called very early in main(). */
void
-set_default_locale ()
+set_default_locale (void)
{
#if defined (HAVE_SETLOCALE)
default_locale = setlocale (LC_ALL, "");
LC_TIME if they are not specified in the environment, but LC_ALL is. This
should be called from main() after parsing the environment. */
void
-set_default_locale_vars ()
+set_default_locale_vars (void)
{
char *val;
/* Set one of the locale categories (specified by VAR) to VALUE. Returns 1
if successful, 0 otherwise. */
int
-set_locale_var (var, value)
- char *var, *value;
+set_locale_var (char *var, char *value)
{
int r;
char *x;
reset_locale_vars() to reset any default values if LC_ALL is unset or
null. */
int
-set_lang (var, value)
- char *var, *value;
+set_lang (char *var, char *value)
{
FREE (lang);
if (value)
/* Set default values for LANG and LC_ALL. Default values for all other
locale-related variables depend on these. */
void
-set_default_lang ()
+set_default_lang (void)
{
char *v;
The precedence is as POSIX.2 specifies: LC_ALL has precedence over
the specific locale variables, and LANG, if set, is used as the default. */
char *
-get_locale_var (var)
- char *var;
+get_locale_var (char *var)
{
char *locale;
if (and only if) LC_ALL has not been assigned a value. DO NOT CALL THIS
IF LC_ALL HAS BEEN ASSIGNED A VALUE. */
static int
-reset_locale_vars ()
+reset_locale_vars (void)
{
char *t, *x;
#if defined (HAVE_SETLOCALE)
is not available, the passed string is returned unchanged. The
length of the translated string is returned in LENP, if non-null. */
char *
-localetrans (string, len, lenp)
- char *string;
- int len, *lenp;
+localetrans (char *string, int len, int *lenp)
{
char *locale, *t;
char *translated;
/* Change a bash string into a string suitable for inclusion in a `po' file.
This backslash-escapes `"' and `\' and changes newlines into \\\n"\n". */
char *
-mk_msgstr (string, foundnlp)
- char *string;
- int *foundnlp;
+mk_msgstr (char *string, int *foundnlp)
{
register int c, len;
char *result, *r, *s;
by the caller. The length of the translated string is returned in LENP,
if non-null. */
char *
-locale_expand (string, start, end, lineno, lenp)
- char *string;
- int start, end, lineno, *lenp;
+locale_expand (char *string, int start, int end, int lineno, int *lenp)
{
int len, tlen, foundnl;
char *temp, *t, *t2;
/* Set every character in the <blank> character class to be a shell break
character for the lexical analyzer when the locale changes. */
static void
-locale_setblanks ()
+locale_setblanks (void)
{
int x;
language[_territory][.codeset][@modifier][+special][,[sponsor][_revision]]
and return TRUE if the codeset is UTF-8 or utf8 */
static int
-locale_isutf8 (lspec)
- char *lspec;
+locale_isutf8 (char *lspec)
{
char *cp, *encoding;
#if defined (HAVE_LOCALECONV)
int
-locale_decpoint ()
+locale_decpoint (void)
{
struct lconv *lv;
#else
# undef locale_decpoint
int
-locale_decpoint ()
+locale_decpoint (void)
{
return '.';
}
/* mailcheck.c -- The check is in the mail... */
-/* Copyright (C) 1987-2020 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
extern time_t shell_start_time;
-extern int mailstat PARAMS((const char *, struct stat *));
+extern int mailstat (const char *, struct stat *);
typedef struct _fileinfo {
char *name;
/* Non-zero means warn if a mail file has been read since last checked. */
int mail_warning;
+static int find_mail_file (const char *);
+static void init_mail_file (int);
+static void update_mail_file (int);
+static int add_mail_file (char *, char *);
-static int find_mail_file PARAMS((char *));
-static void init_mail_file PARAMS((int));
-static void update_mail_file PARAMS((int));
-static int add_mail_file PARAMS((char *, char *));
+static FILEINFO *alloc_mail_file (char *, char *);
+static void dispose_mail_file (FILEINFO *);
-static FILEINFO *alloc_mail_file PARAMS((char *, char *));
-static void dispose_mail_file PARAMS((FILEINFO *));
+static int file_mod_date_changed (int);
+static int file_access_date_changed (int);
+static int file_has_grown (int);
-static int file_mod_date_changed PARAMS((int));
-static int file_access_date_changed PARAMS((int));
-static int file_has_grown PARAMS((int));
-
-static char *parse_mailpath_spec PARAMS((char *));
+static char *parse_mailpath_spec (char *);
/* Returns non-zero if it is time to check mail. */
int
-time_to_check_mail ()
+time_to_check_mail (void)
{
char *temp;
time_t now;
/* Okay, we have checked the mail. Perhaps I should make this function
go away. */
void
-reset_mail_timer ()
+reset_mail_timer (void)
{
last_time_mail_checked = NOW;
}
/* Locate a file in the list. Return index of
entry, or -1 if not found. */
static int
-find_mail_file (file)
- char *file;
+find_mail_file (const char *file)
{
register int i;
while (0)
static void
-init_mail_file (i)
- int i;
+init_mail_file (int i)
{
mailfiles[i]->access_time = mailfiles[i]->mod_time = last_time_mail_checked ? last_time_mail_checked : shell_start_time;
mailfiles[i]->file_size = 0;
}
static void
-update_mail_file (i)
- int i;
+update_mail_file (int i)
{
char *file;
struct stat finfo;
/* Add this file to the list of remembered files and return its index
in the list of mail files. */
static int
-add_mail_file (file, msg)
- char *file, *msg;
+add_mail_file (char *file, char *msg)
{
struct stat finfo;
char *filename;
/* Reset the existing mail files access and modification times to zero. */
void
-reset_mail_files ()
+reset_mail_files (void)
{
register int i;
}
static FILEINFO *
-alloc_mail_file (filename, msg)
- char *filename, *msg;
+alloc_mail_file (char *filename, char *msg)
{
FILEINFO *mf;
}
static void
-dispose_mail_file (mf)
- FILEINFO *mf;
+dispose_mail_file (FILEINFO *mf)
{
free (mf->name);
FREE (mf->msg);
/* Free the information that we have about the remembered mail files. */
void
-free_mail_files ()
+free_mail_files (void)
{
register int i;
}
void
-init_mail_dates ()
+init_mail_dates (void)
{
if (mailfiles == 0)
remember_mail_dates ();
accessed since modified. If the size has dropped to zero, reset
the cached mail file info. */
static int
-file_mod_date_changed (i)
- int i;
+file_mod_date_changed (int i)
{
time_t mtime;
struct stat finfo;
/* Return non-zero if FILE's access date has changed. */
static int
-file_access_date_changed (i)
- int i;
+file_access_date_changed (int i)
{
time_t atime;
struct stat finfo;
/* Return non-zero if FILE's size has increased. */
static int
-file_has_grown (i)
- int i;
+file_has_grown (int i)
{
off_t size;
struct stat finfo;
the first unquoted `?' or `%' to the end of the string. This is the
message to be printed when the file contents change. */
static char *
-parse_mailpath_spec (str)
- char *str;
+parse_mailpath_spec (char *str)
{
char *s;
int pass_next;
}
char *
-make_default_mailpath ()
+make_default_mailpath (void)
{
#if defined (DEFAULT_MAIL_DIRECTORY)
char *mp;
default value, which we randomly concoct from using Unix. */
void
-remember_mail_dates ()
+remember_mail_dates (void)
{
char *mailpaths;
char *mailfile, *mp;
mail file has been accessed since the last time we remembered, then
the message "The mail in <mailfile> has been read" is printed. */
void
-check_mail ()
+check_mail (void)
{
char *current_mail_file, *message;
int i, use_user_notification;
#define WDCACHESIZE 128
#define WLCACHESIZE 128
-static COMMAND *make_for_or_select PARAMS((enum command_type, WORD_DESC *, WORD_LIST *, COMMAND *, int));
+static COMMAND *make_for_or_select (enum command_type, WORD_DESC *, WORD_LIST *, COMMAND *, int);
#if defined (ARITH_FOR_COMMAND)
-static WORD_LIST *make_arith_for_expr PARAMS((char *));
+static WORD_LIST *make_arith_for_expr (char *);
#endif
-static COMMAND *make_until_or_while PARAMS((enum command_type, COMMAND *, COMMAND *));
+static COMMAND *make_until_or_while (enum command_type, COMMAND *, COMMAND *);
void
-cmd_init ()
+cmd_init (void)
{
ocache_create (wdcache, WORD_DESC, WDCACHESIZE);
ocache_create (wlcache, WORD_LIST, WLCACHESIZE);
}
WORD_DESC *
-alloc_word_desc ()
+alloc_word_desc (void)
{
WORD_DESC *temp;
}
WORD_DESC *
-make_bare_word (string)
- const char *string;
+make_bare_word (const char *string)
{
WORD_DESC *temp;
}
WORD_DESC *
-make_word_flags (w, string)
- WORD_DESC *w;
- const char *string;
+make_word_flags (WORD_DESC *w, const char *string)
{
register int i;
size_t slen;
}
WORD_DESC *
-make_word (string)
- const char *string;
+make_word (const char *string)
{
WORD_DESC *temp;
}
WORD_DESC *
-make_word_from_token (token)
- int token;
+make_word_from_token (int token)
{
char tokenizer[2];
}
WORD_LIST *
-make_word_list (word, wlink)
- WORD_DESC *word;
- WORD_LIST *wlink;
+make_word_list (WORD_DESC *word, WORD_LIST *wlink)
{
WORD_LIST *temp;
}
COMMAND *
-make_command (type, pointer)
- enum command_type type;
- SIMPLE_COM *pointer;
+make_command (enum command_type type, SIMPLE_COM *pointer)
{
COMMAND *temp;
}
COMMAND *
-command_connect (com1, com2, connector)
- COMMAND *com1, *com2;
- int connector;
+command_connect (COMMAND *com1, COMMAND *com2, int connector)
{
CONNECTION *temp;
}
static COMMAND *
-make_for_or_select (type, name, map_list, action, lineno)
- enum command_type type;
- WORD_DESC *name;
- WORD_LIST *map_list;
- COMMAND *action;
- int lineno;
+make_for_or_select (enum command_type type, WORD_DESC *name, WORD_LIST *map_list, COMMAND *action, int lineno)
{
FOR_COM *temp;
}
COMMAND *
-make_for_command (name, map_list, action, lineno)
- WORD_DESC *name;
- WORD_LIST *map_list;
- COMMAND *action;
- int lineno;
+make_for_command (WORD_DESC *name, WORD_LIST *map_list, COMMAND *action, int lineno)
{
return (make_for_or_select (cm_for, name, map_list, action, lineno));
}
COMMAND *
-make_select_command (name, map_list, action, lineno)
- WORD_DESC *name;
- WORD_LIST *map_list;
- COMMAND *action;
- int lineno;
+make_select_command (WORD_DESC *name, WORD_LIST *map_list, COMMAND *action, int lineno)
{
#if defined (SELECT_COMMAND)
return (make_for_or_select (cm_select, name, map_list, action, lineno));
#if defined (ARITH_FOR_COMMAND)
static WORD_LIST *
-make_arith_for_expr (s)
- char *s;
+make_arith_for_expr (char *s)
{
WORD_LIST *result;
WORD_DESC *wd;
because no other function in this file requires that the caller free
any arguments. */
COMMAND *
-make_arith_for_command (exprs, action, lineno)
- WORD_LIST *exprs;
- COMMAND *action;
- int lineno;
+make_arith_for_command (WORD_LIST *exprs, COMMAND *action, int lineno)
{
#if defined (ARITH_FOR_COMMAND)
ARITH_FOR_COM *temp;
}
COMMAND *
-make_group_command (command)
- COMMAND *command;
+make_group_command (COMMAND *command)
{
GROUP_COM *temp;
}
COMMAND *
-make_case_command (word, clauses, lineno)
- WORD_DESC *word;
- PATTERN_LIST *clauses;
- int lineno;
+make_case_command (WORD_DESC *word, PATTERN_LIST *clauses, int lineno)
{
CASE_COM *temp;
}
PATTERN_LIST *
-make_pattern_list (patterns, action)
- WORD_LIST *patterns;
- COMMAND *action;
+make_pattern_list (WORD_LIST *patterns, COMMAND *action)
{
PATTERN_LIST *temp;
}
COMMAND *
-make_if_command (test, true_case, false_case)
- COMMAND *test, *true_case, *false_case;
+make_if_command (COMMAND *test, COMMAND *true_case, COMMAND *false_case)
{
IF_COM *temp;
}
static COMMAND *
-make_until_or_while (which, test, action)
- enum command_type which;
- COMMAND *test, *action;
+make_until_or_while (enum command_type which, COMMAND *test, COMMAND *action)
{
WHILE_COM *temp;
}
COMMAND *
-make_while_command (test, action)
- COMMAND *test, *action;
+make_while_command (COMMAND *test, COMMAND *action)
{
return (make_until_or_while (cm_while, test, action));
}
COMMAND *
-make_until_command (test, action)
- COMMAND *test, *action;
+make_until_command (COMMAND *test, COMMAND *action)
{
return (make_until_or_while (cm_until, test, action));
}
COMMAND *
-make_arith_command (exp)
- WORD_LIST *exp;
+make_arith_command (WORD_LIST *exp)
{
#if defined (DPAREN_ARITHMETIC)
COMMAND *command;
#if defined (COND_COMMAND)
struct cond_com *
-make_cond_node (type, op, left, right)
- int type;
- WORD_DESC *op;
- struct cond_com *left, *right;
+make_cond_node (int type, WORD_DESC *op, struct cond_com *left, struct cond_com *right)
{
COND_COM *temp;
#endif
COMMAND *
-make_cond_command (cond_node)
- COND_COM *cond_node;
+make_cond_command (COND_COM *cond_node)
{
#if defined (COND_COMMAND)
COMMAND *command;
}
COMMAND *
-make_bare_simple_command ()
+make_bare_simple_command (void)
{
COMMAND *command;
SIMPLE_COM *temp;
/* Return a command which is the connection of the word or redirection
in ELEMENT, and the command * or NULL in COMMAND. */
COMMAND *
-make_simple_command (element, command)
- ELEMENT element;
- COMMAND *command;
+make_simple_command (ELEMENT element, COMMAND *command)
{
/* If we are starting from scratch, then make the initial command
structure. Also note that we have to fill in all the slots, since
the redirectee.word with the new input text. If <<- is on,
then remove leading TABS from each line. */
void
-make_here_document (temp, lineno)
- REDIRECT *temp;
- int lineno;
+make_here_document (REDIRECT *temp, int lineno)
{
int kill_leading, redir_len;
char *redir_word, *document, *full_line;
INSTRUCTION is the instruction type, SOURCE is a file descriptor,
and DEST is a file descriptor or a WORD_DESC *. */
REDIRECT *
-make_redirection (source, instruction, dest_and_filename, flags)
- REDIRECTEE source;
- enum r_instruction instruction;
- REDIRECTEE dest_and_filename;
- int flags;
+make_redirection (REDIRECTEE source, enum r_instruction instruction, REDIRECTEE dest_and_filename, int flags)
{
REDIRECT *temp;
WORD_DESC *w;
}
COMMAND *
-make_function_def (name, command, lineno, lstart)
- WORD_DESC *name;
- COMMAND *command;
- int lineno, lstart;
+make_function_def (WORD_DESC *name, COMMAND *command, int lineno, int lstart)
{
FUNCTION_DEF *temp;
#if defined (ARRAY_VARS)
}
COMMAND *
-make_subshell_command (command)
- COMMAND *command;
+make_subshell_command (COMMAND *command)
{
SUBSHELL_COM *temp;
}
COMMAND *
-make_coproc_command (name, command)
- char *name;
- COMMAND *command;
+make_coproc_command (char *name, COMMAND *command)
{
COPROC_COM *temp;
has just been parsed. It seems simpler to do this here the one
time then by any other method that I can think of. */
COMMAND *
-clean_simple_command (command)
- COMMAND *command;
+clean_simple_command (COMMAND *command)
{
if (command->type != cm_simple)
command_error ("clean_simple_command", CMDERR_BADTYPE, command->type, 0);
in the list. This is done only for lists connected by `;'; it makes
`;' bind `tighter' than `&'. */
COMMAND *
-connect_async_list (command, command2, connector)
- COMMAND *command, *command2;
- int connector;
+connect_async_list (COMMAND *command, COMMAND *command2, int connector)
{
COMMAND *t, *t1, *t2;
extern int errno;
#endif /* !errno */
-extern void set_original_signal PARAMS((int, SigHandler *));
+extern void set_original_signal (int, SigHandler *);
volatile pid_t last_made_pid = NO_PID;
volatile pid_t last_asynchronous_pid = NO_PID;
static long child_max = -1L;
-static void alloc_pid_list PARAMS((void));
-static int find_proc_slot PARAMS((pid_t));
-static int find_index_by_pid PARAMS((pid_t));
-static int find_status_by_pid PARAMS((pid_t));
-static int process_exit_status PARAMS((WAIT));
-static int find_termsig_by_pid PARAMS((pid_t));
-static int get_termsig PARAMS((WAIT));
-static void set_pid_status PARAMS((pid_t, WAIT));
-static void set_pid_flags PARAMS((pid_t, int));
-static void unset_pid_flags PARAMS((pid_t, int));
-static int get_pid_flags PARAMS((pid_t));
-static void add_pid PARAMS((pid_t, int));
-static void mark_dead_jobs_as_notified PARAMS((int));
-
-static sighandler wait_sigint_handler PARAMS((int));
-static char *j_strsignal PARAMS((int));
+static void alloc_pid_list (void);
+static int find_proc_slot (pid_t);
+static int find_index_by_pid (pid_t);
+static int find_status_by_pid (pid_t);
+static int process_exit_status (WAIT);
+static int find_termsig_by_pid (pid_t);
+static int get_termsig (WAIT);
+static void set_pid_status (pid_t, WAIT);
+static void set_pid_flags (pid_t, int);
+static void unset_pid_flags (pid_t, int);
+static int get_pid_flags (pid_t);
+static void add_pid (pid_t, int);
+static void mark_dead_jobs_as_notified (int);
+
+static sighandler wait_sigint_handler (int);
+static char *j_strsignal (int);
#if defined (HAVE_WAITPID)
-static void reap_zombie_children PARAMS((void));
+static void reap_zombie_children (void);
#endif
#if !defined (HAVE_SIGINTERRUPT) && defined (HAVE_POSIX_SIGNALS)
-static int siginterrupt PARAMS((int, int));
+static int siginterrupt (int, int);
#endif
-static void restore_sigint_handler PARAMS((void));
+static void restore_sigint_handler (void);
/* Allocate new, or grow existing PID_LIST. */
static void
-alloc_pid_list ()
+alloc_pid_list (void)
{
register int i;
int old = pid_list_size;
/* Return the offset within the PID_LIST array of an empty slot. This can
create new slots if all of the existing slots are taken. */
static int
-find_proc_slot (pid)
- pid_t pid;
+find_proc_slot (pid_t pid)
{
register int i;
/* Return the offset within the PID_LIST array of a slot containing PID,
or the value NO_PID if the pid wasn't found. */
static int
-find_index_by_pid (pid)
- pid_t pid;
+find_index_by_pid (pid_t pid)
{
register int i;
/* Return the status of PID as looked up in the PID_LIST array. A
return value of PROC_BAD indicates that PID wasn't found. */
static int
-find_status_by_pid (pid)
- pid_t pid;
+find_status_by_pid (pid_t pid)
{
int i;
}
static int
-process_exit_status (status)
- WAIT status;
+process_exit_status (WAIT status)
{
if (WIFSIGNALED (status))
return (128 + WTERMSIG (status));
/* Return the status of PID as looked up in the PID_LIST array. A
return value of PROC_BAD indicates that PID wasn't found. */
static int
-find_termsig_by_pid (pid)
- pid_t pid;
+find_termsig_by_pid (pid_t pid)
{
int i;
up PID in the pid array and set LAST_COMMAND_EXIT_SIGNAL appropriately
depending on its flags and exit status. */
static int
-get_termsig (status)
- WAIT status;
+get_termsig (WAIT status)
{
if (WIFSTOPPED (status) == 0 && WIFSIGNALED (status))
return (WTERMSIG (status));
/* Give PID the status value STATUS in the PID_LIST array. */
static void
-set_pid_status (pid, status)
- pid_t pid;
- WAIT status;
+set_pid_status (pid_t pid, WAIT status)
{
int slot;
/* Give PID the flags FLAGS in the PID_LIST array. */
static void
-set_pid_flags (pid, flags)
- pid_t pid;
- int flags;
+set_pid_flags (pid_t pid, int flags)
{
int slot;
/* Unset FLAGS for PID in the pid list */
static void
-unset_pid_flags (pid, flags)
- pid_t pid;
- int flags;
+unset_pid_flags (pid_t pid, int flags)
{
int slot;
/* Return the flags corresponding to PID in the PID_LIST array. */
static int
-get_pid_flags (pid)
- pid_t pid;
+get_pid_flags (pid_t pid)
{
int slot;
}
static void
-add_pid (pid, async)
- pid_t pid;
- int async;
+add_pid (pid_t pid, int async)
{
int slot;
}
static void
-mark_dead_jobs_as_notified (force)
- int force;
+mark_dead_jobs_as_notified (int force)
{
register int i, ndead;
/* Remove all dead, notified jobs from the pid_list. */
int
-cleanup_dead_jobs ()
+cleanup_dead_jobs (void)
{
register int i;
}
void
-reap_dead_jobs ()
+reap_dead_jobs (void)
{
mark_dead_jobs_as_notified (0);
cleanup_dead_jobs ();
/* Initialize the job control mechanism, and set up the tty stuff. */
int
-initialize_job_control (force)
- int force;
+initialize_job_control (int force)
{
shell_tty = fileno (stderr);
/* Setup this shell to handle C-C, etc. */
void
-initialize_job_signals ()
+initialize_job_signals (void)
{
set_signal_handler (SIGINT, sigint_sighandler);
/* Collect the status of all zombie children so that their system
resources can be deallocated. */
static void
-reap_zombie_children ()
+reap_zombie_children (void)
{
# if defined (WNOHANG)
pid_t pid;
#endif
static int
-siginterrupt (sig, flag)
- int sig, flag;
+siginterrupt (int sig, int flag)
{
struct sigaction act;
anything else with it. ASYNC_P says what to do with the tty. If
non-zero, then don't give it away. */
pid_t
-make_child (command, flags)
- char *command;
- int flags;
+make_child (char *command, int flags)
{
pid_t pid;
int async_p, forksleep;
}
void
-ignore_tty_job_signals ()
+ignore_tty_job_signals (void)
{
#if defined (SIGTSTP)
set_signal_handler (SIGTSTP, SIG_IGN);
}
void
-default_tty_job_signals ()
+default_tty_job_signals (void)
{
#if defined (SIGTSTP)
if (signal_is_trapped (SIGTSTP) == 0 && signal_is_hard_ignored (SIGTSTP))
/* Called once in a parent process. */
void
-get_original_tty_job_signals ()
+get_original_tty_job_signals (void)
{
static int fetched = 0;
/* Wait for a single pid (PID) and return its exit status. Called by
the wait builtin. */
int
-wait_for_single_pid (pid, flags)
- pid_t pid;
- int flags;
+wait_for_single_pid (pid_t pid, int flags)
{
pid_t got_pid;
WAIT status;
/* Wait for all of the shell's children to exit. Called by the `wait'
builtin. */
int
-wait_for_background_pids (ps)
- struct procstat *ps;
+wait_for_background_pids (struct procstat *ps)
{
pid_t got_pid;
WAIT status;
}
void
-wait_sigint_cleanup ()
+wait_sigint_cleanup (void)
{
}
static SigHandler *old_sigint_handler = INVALID_SIGNAL_HANDLER;
static void
-restore_sigint_handler ()
+restore_sigint_handler (void)
{
if (old_sigint_handler != INVALID_SIGNAL_HANDLER)
{
All interrupts are effectively ignored by the shell, but allowed to
kill a running job. */
static sighandler
-wait_sigint_handler (sig)
- int sig;
+wait_sigint_handler (int sig)
{
SigHandler *sigint_handler;
}
static char *
-j_strsignal (s)
- int s;
+j_strsignal (int s)
{
static char retcode_name_buffer[64] = { '\0' };
char *x;
/* Wait for pid (one of our children) to terminate. This is called only
by the execution code in execute_cmd.c. */
int
-wait_for (pid, flags)
- pid_t pid;
- int flags;
+wait_for (pid_t pid, int flags)
{
int return_val, pstatus;
pid_t got_pid;
/* Send PID SIGNAL. Returns -1 on failure, 0 on success. If GROUP is non-zero,
or PID is less than -1, then kill the process group associated with PID. */
int
-kill_pid (pid, signal, group)
- pid_t pid;
- int signal, group;
+kill_pid (pid_t pid, int signal, int group)
{
int result;
/* Fill the contents of shell_tty_info with the current tty info. */
int
-get_tty_state ()
+get_tty_state (void)
{
int tty;
/* Make the current tty use the state in shell_tty_info. */
int
-set_tty_state ()
+set_tty_state (void)
{
int tty;
/* Give the terminal to PGRP. */
int
-give_terminal_to (pgrp, force)
- pid_t pgrp;
- int force;
+give_terminal_to (pid_t pgrp, int force)
{
return 0;
}
/* Stop a pipeline. */
int
-stop_pipeline (async, ignore)
- int async;
- COMMAND *ignore;
+stop_pipeline (int async, COMMAND *ignore)
{
already_making_children = 0;
return 0;
}
void
-start_pipeline ()
+start_pipeline (void)
{
already_making_children = 1;
}
void
-stop_making_children ()
+stop_making_children (void)
{
already_making_children = 0;
}
/* The name is kind of a misnomer, but it's what the job control code uses. */
void
-without_job_control ()
+without_job_control (void)
{
stop_making_children ();
last_made_pid = NO_PID; /* XXX */
}
int
-get_job_by_pid (pid, block, ignore)
- pid_t pid;
- int block;
- PROCESS **ignore;
+get_job_by_pid (pid_t pid, int block, PROCESS **ignore)
{
int i;
/* Print descriptive information about the job with leader pid PID. */
void
-describe_pid (pid)
- pid_t pid;
+describe_pid (pid_t pid)
{
fprintf (stderr, "%ld\n", (long) pid);
}
int
-freeze_jobs_list ()
+freeze_jobs_list (void)
{
return 0;
}
void
-unfreeze_jobs_list ()
+unfreeze_jobs_list (void)
{
}
void
-set_jobs_list_frozen (s)
- int s;
+set_jobs_list_frozen (int s)
{
}
int
-count_all_jobs ()
+count_all_jobs (void)
{
return 0;
}
#if defined (JOB_CONTROL)
# include "jobs.h"
#else
-extern int cleanup_dead_jobs PARAMS((void));
+extern int cleanup_dead_jobs (void);
#endif /* JOB_CONTROL */
#if defined (ALIAS)
/* **************************************************************** */
#ifdef DEBUG
-static void debug_parser PARAMS((int));
+static void debug_parser (int);
#endif
-static int yy_getc PARAMS((void));
-static int yy_ungetc PARAMS((int));
+static int yy_getc (void);
+static int yy_ungetc (int);
#if defined (READLINE)
-static int yy_readline_get PARAMS((void));
-static int yy_readline_unget PARAMS((int));
+static int yy_readline_get (void);
+static int yy_readline_unget (int);
#endif
-static int yy_string_get PARAMS((void));
-static int yy_string_unget PARAMS((int));
-static int yy_stream_get PARAMS((void));
-static int yy_stream_unget PARAMS((int));
+static int yy_string_get (void);
+static int yy_string_unget (int);
+static int yy_stream_get (void);
+static int yy_stream_unget (int);
-static int shell_getc PARAMS((int));
-static void shell_ungetc PARAMS((int));
-static void discard_until PARAMS((int));
+static int shell_getc (int);
+static void shell_ungetc (int);
+static void discard_until (int);
-static void push_string PARAMS((char *, int, alias_t *));
-static void pop_string PARAMS((void));
-static void free_string_list PARAMS((void));
+static void push_string (char *, int, alias_t *);
+static void pop_string (void);
+static void free_string_list (void);
-static char *read_a_line PARAMS((int));
+static char *read_a_line (int);
-static int reserved_word_acceptable PARAMS((int));
-static int yylex PARAMS((void));
+static int reserved_word_acceptable (int);
+static int yylex (void);
-static void push_heredoc PARAMS((REDIRECT *));
-static char *mk_alexpansion PARAMS((char *));
-static int alias_expand_token PARAMS((char *));
-static int time_command_acceptable PARAMS((void));
-static int special_case_tokens PARAMS((char *));
-static int read_token PARAMS((int));
-static char *parse_matched_pair PARAMS((int, int, int, int *, int));
-static char *parse_comsub PARAMS((int, int, int, int *, int));
+static void push_heredoc (REDIRECT *);
+static char *mk_alexpansion (char *);
+static int alias_expand_token (char *);
+static int time_command_acceptable (void);
+static int special_case_tokens (char *);
+static int read_token (int);
+static char *parse_matched_pair (int, int, int, int *, int);
+static char *parse_comsub (int, int, int, int *, int);
#if defined (ARRAY_VARS)
-static char *parse_compound_assignment PARAMS((int *));
+static char *parse_compound_assignment (int *);
#endif
#if defined (DPAREN_ARITHMETIC) || defined (ARITH_FOR_COMMAND)
-static int parse_dparen PARAMS((int));
-static int parse_arith_cmd PARAMS((char **, int));
+static int parse_dparen (int);
+static int parse_arith_cmd (char **, int);
#endif
#if defined (COND_COMMAND)
-static void cond_error PARAMS((void));
-static COND_COM *cond_expr PARAMS((void));
-static COND_COM *cond_or PARAMS((void));
-static COND_COM *cond_and PARAMS((void));
-static COND_COM *cond_term PARAMS((void));
-static int cond_skip_newlines PARAMS((void));
-static COMMAND *parse_cond_command PARAMS((void));
+static void cond_error (void);
+static COND_COM *cond_expr (void);
+static COND_COM *cond_or (void);
+static COND_COM *cond_and (void);
+static COND_COM *cond_term (void);
+static int cond_skip_newlines (void);
+static COMMAND *parse_cond_command (void);
#endif
#if defined (ARRAY_VARS)
-static int token_is_assignment PARAMS((char *, int));
-static int token_is_ident PARAMS((char *, int));
+static int token_is_assignment (char *, int);
+static int token_is_ident (char *, int);
#endif
-static int read_token_word PARAMS((int));
-static void discard_parser_constructs PARAMS((int));
+static int read_token_word (int);
+static void discard_parser_constructs (int);
-static char *error_token_from_token PARAMS((int));
-static char *error_token_from_text PARAMS((void));
-static void print_offending_line PARAMS((void));
-static void report_syntax_error PARAMS((char *));
+static char *error_token_from_token (int);
+static char *error_token_from_text (void);
+static void print_offending_line (void);
+static void report_syntax_error (char *);
-static void handle_eof_input_unit PARAMS((void));
-static void prompt_again PARAMS((int));
+static void handle_eof_input_unit (void);
+static void prompt_again (int);
#if 0
-static void reset_readline_prompt PARAMS((void));
+static void reset_readline_prompt (void);
#endif
-static void print_prompt PARAMS((void));
+static void print_prompt (void);
#if defined (HANDLE_MULTIBYTE)
-static void set_line_mbstate PARAMS((void));
+static void set_line_mbstate (void);
static char *shell_input_line_property = NULL;
static size_t shell_input_line_propsize = 0;
#else
# define set_line_mbstate()
#endif
-extern int yyerror PARAMS((const char *));
+extern int yyerror (const char *);
#ifdef DEBUG
extern int yydebug;
#ifdef DEBUG
static void
-debug_parser (i)
- int i;
+debug_parser (int i)
{
#if YYDEBUG != 0
yydebug = i;
/* Unconditionally returns end-of-file. */
int
-return_EOF ()
+return_EOF (void)
{
return (EOF);
}
/* Set all of the fields in BASH_INPUT to NULL. Free bash_input.name if it
is non-null, avoiding a memory leak. */
void
-initialize_bash_input ()
+initialize_bash_input (void)
{
bash_input.type = st_none;
FREE (bash_input.name);
/* Set the contents of the current bash input stream from
GET, UNGET, TYPE, NAME, and LOCATION. */
void
-init_yy_io (get, unget, type, name, location)
- sh_cget_func_t *get;
- sh_cunget_func_t *unget;
- enum stream_type type;
- const char *name;
- INPUT_STREAM location;
+init_yy_io (sh_cget_func_t *get, sh_cunget_func_t *unget, enum stream_type type, const char *name, INPUT_STREAM location)
{
bash_input.type = type;
FREE (bash_input.name);
}
char *
-yy_input_name ()
+yy_input_name (void)
{
return (bash_input.name ? bash_input.name : "stdin");
}
/* Call this to get the next character of input. */
static int
-yy_getc ()
+yy_getc (void)
{
return (*(bash_input.getter)) ();
}
/* Call this to unget C. That is, to make C the next character
to be read. */
static int
-yy_ungetc (c)
- int c;
+yy_ungetc (int c)
{
return (*(bash_input.ungetter)) (c);
}
#if defined (BUFFERED_INPUT)
#ifdef INCLUDE_UNUSED
int
-input_file_descriptor ()
+input_file_descriptor (void)
{
switch (bash_input.type)
{
int current_readline_line_index = 0;
static int
-yy_readline_get ()
+yy_readline_get (void)
{
SigHandler *old_sigint;
int line_len;
}
static int
-yy_readline_unget (c)
- int c;
+yy_readline_unget (int c)
{
if (current_readline_line_index && current_readline_line)
current_readline_line[--current_readline_line_index] = c;
}
void
-with_input_from_stdin ()
+with_input_from_stdin (void)
{
INPUT_STREAM location;
embed a newline in the middle of the line it collects, which the parser
will interpret as a line break and command delimiter. */
int
-parser_will_prompt ()
+parser_will_prompt (void)
{
return (current_readline_line == 0 || current_readline_line[current_readline_line_index] == 0);
}
#else /* !READLINE */
void
-with_input_from_stdin ()
+with_input_from_stdin (void)
{
with_input_from_stream (stdin, "stdin");
}
/* **************************************************************** */
static int
-yy_string_get ()
+yy_string_get (void)
{
register char *string;
register unsigned char c;
}
static int
-yy_string_unget (c)
- int c;
+yy_string_unget (int c)
{
*(--bash_input.location.string) = c;
return (c);
}
void
-with_input_from_string (string, name)
- char *string;
- const char *name;
+with_input_from_string (char *string, const char *name)
{
INPUT_STREAM location;
that number of characters, so it points to the last character actually
consumed by the parser. */
void
-rewind_input_string ()
+rewind_input_string (void)
{
int xchars;
We will need to restart it ourselves. */
static int
-yy_stream_get ()
+yy_stream_get (void)
{
int result;
}
static int
-yy_stream_unget (c)
- int c;
+yy_stream_unget (int c)
{
return (ungetc_with_restart (c, bash_input.location.file));
}
void
-with_input_from_stream (stream, name)
- FILE *stream;
- const char *name;
+with_input_from_stream (FILE *stream, const char *name)
{
INPUT_STREAM location;
STREAM_SAVER *stream_list = (STREAM_SAVER *)NULL;
void
-push_stream (reset_lineno)
- int reset_lineno;
+push_stream (int reset_lineno)
{
STREAM_SAVER *saver = (STREAM_SAVER *)xmalloc (sizeof (STREAM_SAVER));
}
void
-pop_stream ()
+pop_stream (void)
{
if (!stream_list)
EOF_Reached = 1;
/* Return 1 if a stream of type TYPE is saved on the stack. */
int
-stream_on_stack (type)
- enum stream_type type;
+stream_on_stack (enum stream_type type)
{
register STREAM_SAVER *s;
/* Save the current token state and return it in a malloced array. */
int *
-save_token_state ()
+save_token_state (void)
{
int *ret;
}
void
-restore_token_state (ts)
- int *ts;
+restore_token_state (int *ts)
{
if (ts == 0)
return;
* into S; it is saved and used to prevent infinite recursive expansion.
*/
static void
-push_string (s, expand, ap)
- char *s;
- int expand;
- alias_t *ap;
+push_string (char *s, int expand, alias_t *ap)
{
STRING_SAVER *temp = (STRING_SAVER *)xmalloc (sizeof (STRING_SAVER));
* and needs to return to the original input line.
*/
static void
-pop_string ()
+pop_string (void)
{
STRING_SAVER *t;
}
static void
-free_string_list ()
+free_string_list (void)
{
register STRING_SAVER *t, *t1;
}
void
-free_pushed_string_input ()
+free_pushed_string_input (void)
{
#if defined (ALIAS) || defined (DPAREN_ARITHMETIC)
free_string_list ();
}
int
-parser_expanding_alias ()
+parser_expanding_alias (void)
{
return (expanding_alias ());
}
void
-parser_save_alias ()
+parser_save_alias (void)
{
#if defined (ALIAS) || defined (DPAREN_ARITHMETIC)
push_string ((char *)NULL, 0, (alias_t *)NULL);
}
void
-parser_restore_alias ()
+parser_restore_alias (void)
{
#if defined (ALIAS) || defined (DPAREN_ARITHMETIC)
if (pushed_string_list)
/* Before freeing AP, make sure that there aren't any cases of pointer
aliasing that could cause us to reference freed memory later on. */
void
-clear_string_list_expander (ap)
- alias_t *ap;
+clear_string_list_expander (alias_t *ap)
{
register STRING_SAVER *t;
#endif
void
-clear_shell_input_line ()
+clear_shell_input_line (void)
{
if (shell_input_line)
shell_input_line[shell_input_line_index = 0] = '\0';
is non-zero, we remove unquoted \<newline> pairs. This is used by
read_secondary_line to read here documents. */
static char *
-read_a_line (remove_quoted_newline)
- int remove_quoted_newline;
+read_a_line (int remove_quoted_newline)
{
static char *line_buffer = (char *)NULL;
static int buffer_size = 0;
newlines quoted with backslashes while reading the line. It is
non-zero unless the delimiter of the here document was quoted. */
char *
-read_secondary_line (remove_quoted_newline)
- int remove_quoted_newline;
+read_secondary_line (int remove_quoted_newline)
{
char *ret;
int n, c;
static int unquoted_backslash = 0;
static int
-shell_getc (remove_quoted_newline)
- int remove_quoted_newline;
+shell_getc (int remove_quoted_newline)
{
register int i;
int c, truncating, last_was_backslash;
to change when manipulating shell_input_line. The define for
last_shell_getc_is_singlebyte should take care of it, though. */
static void
-shell_ungetc (c)
- int c;
+shell_ungetc (int c)
{
if (shell_input_line && shell_input_line_index)
shell_input_line[--shell_input_line_index] = c;
/* Push S back into shell_input_line; updating shell_input_line_index */
void
-shell_ungets (s)
- char *s;
+shell_ungets (char *s)
{
size_t slen, chars_left;
}
char *
-parser_remaining_input ()
+parser_remaining_input (void)
{
if (shell_input_line == 0)
return 0;
#ifdef INCLUDE_UNUSED
/* Back the input pointer up by one, effectively `ungetting' a character. */
static void
-shell_ungetchar ()
+shell_ungetchar (void)
{
if (shell_input_line && shell_input_line_index)
shell_input_line_index--;
/* Discard input until CHARACTER is seen, then push that character back
onto the input stream. */
static void
-discard_until (character)
- int character;
+discard_until (int character)
{
int c;
}
void
-execute_variable_command (command, vname)
- char *command, *vname;
+execute_variable_command (char *command, char *vname)
{
char *last_lastarg;
sh_parser_state_t ps;
}
void
-push_token (x)
- int x;
+push_token (int x)
{
two_tokens_ago = token_before_that;
token_before_that = last_read_token;
/* Function for yyparse to call. yylex keeps track of
the last two tokens read, and calls read_token. */
static int
-yylex ()
+yylex (void)
{
if (interactive && (current_token == 0 || current_token == '\n'))
{
static int expecting_in_token;
static void
-push_heredoc (r)
- REDIRECT *r;
+push_heredoc (REDIRECT *r)
{
if (need_here_doc >= HEREDOC_MAX)
{
}
void
-gather_here_documents ()
+gather_here_documents (void)
{
int r;
In a pattern list in a case statement (parser_state & PST_CASEPAT). */
static char *
-mk_alexpansion (s)
- char *s;
+mk_alexpansion (char *s)
{
int l;
char *r;
}
static int
-alias_expand_token (tokstr)
- char *tokstr;
+alias_expand_token (char *tokstr)
{
char *expanded;
alias_t *ap;
#endif /* ALIAS */
static int
-time_command_acceptable ()
+time_command_acceptable (void)
{
#if defined (COMMAND_TIMING)
int i;
*/
static int
-special_case_tokens (tokstr)
- char *tokstr;
+special_case_tokens (char *tokstr)
{
/* Posix grammar rule 6 */
if ((last_read_token == WORD) &&
/* Called from shell.c when Control-C is typed at top level. Or
by the error rule at top level. */
void
-reset_parser ()
+reset_parser (void)
{
dstack.delimiter_depth = 0; /* No delimiters found so far. */
open_brace_count = 0;
}
void
-reset_readahead_token ()
+reset_readahead_token (void)
{
if (token_to_read == '\n')
token_to_read = 0;
/* Read the next token. Command can be READ (normal operation) or
RESET (to normalize state). */
static int
-read_token (command)
- int command;
+read_token (int command)
{
int character; /* Current character. */
int peek_char; /* Temporary look-ahead character. */
static char matched_pair_error;
+/* QC == `"' if this construct is within double quotes */
static char *
-parse_matched_pair (qc, open, close, lenp, flags)
- int qc; /* `"' if this construct is within double quotes */
- int open, close;
- int *lenp, flags;
+parse_matched_pair (int qc, int open, int close, int *lenp, int flags)
{
int count, ch, prevch, tflags;
int nestlen, ttranslen, start_lineno;
#if defined (DEBUG)
static void
-dump_tflags (flags)
- int flags;
+dump_tflags (int flags)
{
int f;
#endif
/* Parse a $(...) command substitution. This reads input from the current
- input stream. */
+ input stream. QC == `"' if this construct is within double quotes */
static char *
-parse_comsub (qc, open, close, lenp, flags)
- int qc; /* `"' if this construct is within double quotes */
- int open, close;
- int *lenp, flags;
+parse_comsub (int qc, int open, int close, int *lenp, int flags)
{
int peekc, r;
int start_lineno, local_extglob, was_extpat;
called by the word expansion code and so does not have to reset as much
parser state before calling yyparse(). */
char *
-xparse_dolparen (base, string, indp, flags)
- char *base;
- char *string;
- int *indp;
- int flags;
+xparse_dolparen (char *base, char *string, int *indp, int flags)
{
sh_parser_state_t ps;
sh_input_line_state_t ls;
substitution to a COMMAND *. This is called from command_substitute() and
has the same parser state constraints as xparse_dolparen(). */
COMMAND *
-parse_string_to_command (string, flags)
- char *string;
- int flags;
+parse_string_to_command (char *string, int flags)
{
sh_parser_state_t ps;
sh_input_line_state_t ls;
the parsed token, -1 on error, or -2 if we didn't do anything and
should just go on. */
static int
-parse_dparen (c)
- int c;
+parse_dparen (int c)
{
int cmdtyp, sline;
char *wval;
allocated buffer and make *ep point to that buffer. Return -1 on an
error, for example EOF. */
static int
-parse_arith_cmd (ep, adddq)
- char **ep;
- int adddq;
+parse_arith_cmd (char **ep, int adddq)
{
int exp_lineno, rval, c;
char *ttok, *tokstr;
#if defined (COND_COMMAND)
static void
-cond_error ()
+cond_error (void)
{
char *etext;
}
static COND_COM *
-cond_expr ()
+cond_expr (void)
{
return (cond_or ());
}
static COND_COM *
-cond_or ()
+cond_or (void)
{
COND_COM *l, *r;
}
static COND_COM *
-cond_and ()
+cond_and (void)
{
COND_COM *l, *r;
}
static int
-cond_skip_newlines ()
+cond_skip_newlines (void)
{
while ((cond_token = read_token (READ)) == '\n')
{
do { cond_token = COND_ERROR; return ((COND_COM *)NULL); } while (0)
static COND_COM *
-cond_term ()
+cond_term (void)
{
WORD_DESC *op;
COND_COM *term, *tleft, *tright;
/* This is kind of bogus -- we slip a mini recursive-descent parser in
here to handle the conditional statement syntax. */
static COMMAND *
-parse_cond_command ()
+parse_cond_command (void)
{
COND_COM *cexp;
substitution that will reallocate atoken. We don't want to write beyond
the end of an allocated buffer. */
static int
-token_is_assignment (t, i)
- char *t;
- int i;
+token_is_assignment (char *t, int i)
{
int r;
char *atoken;
/* XXX - possible changes here for `+=' */
static int
-token_is_ident (t, i)
- char *t;
- int i;
+token_is_ident (char *t, int i)
{
unsigned char c;
int r;
#endif
static int
-read_token_word (character)
- int character;
+read_token_word (int character)
{
/* The value for YYLVAL when a WORD is read. */
WORD_DESC *the_word;
/* Return 1 if TOKSYM is a token that after being read would allow
a reserved word to be seen, else 0. */
-static int
-reserved_word_acceptable (toksym)
- int toksym;
+static inline int
+reserved_word_acceptable (int toksym)
{
switch (toksym)
{
/* Return the index of TOKEN in the alist of reserved words, or -1 if
TOKEN is not a shell reserved word. */
int
-find_reserved_word (tokstr)
- char *tokstr;
+find_reserved_word (char *tokstr)
{
int i;
for (i = 0; word_token_alist[i].word; i++)
/* An interface to let the rest of the shell (primarily the completion
system) know what the parser is expecting. */
int
-parser_in_command_position ()
+parser_in_command_position (void)
{
return (command_token_position (last_read_token));
}
the new prompt string is gets propagated to readline's local prompt
variable. */
static void
-reset_readline_prompt ()
+reset_readline_prompt (void)
{
char *temp_prompt;
history entry. LINE is the line we're about to add; it helps
make some more intelligent decisions in certain cases. */
char *
-history_delimiting_chars (line)
- const char *line;
+history_delimiting_chars (const char *line)
{
static int last_was_heredoc = 0; /* was the last entry the start of a here document? */
register int i;
/* Issue a prompt, or prepare to issue a prompt when the next character
is read. */
static void
-prompt_again (force)
- int force;
+prompt_again (int force)
{
char *temp_prompt;
}
int
-get_current_prompt_level ()
+get_current_prompt_level (void)
{
return ((current_prompt_string && current_prompt_string == ps2_prompt) ? 2 : 1);
}
void
-set_current_prompt_level (x)
- int x;
+set_current_prompt_level (int x)
{
prompt_string_pointer = (x == 2) ? &ps2_prompt : &ps1_prompt;
current_prompt_string = *prompt_string_pointer;
}
static void
-print_prompt ()
+print_prompt (void)
{
fprintf (stderr, "%s", current_decoded_prompt);
fflush (stderr);
the first line of a potentially multi-line command, so we compensate
here by returning one fewer when appropriate. */
static int
-prompt_history_number (pmt)
- char *pmt;
+prompt_history_number (char *pmt)
{
int ret;
*/
#define PROMPT_GROWTH 48
char *
-decode_prompt_string (string)
- char *string;
+decode_prompt_string (char *string)
{
WORD_LIST *list;
char *result, *t, *orig_string;
/* Report a syntax error, and restart the parser. Call here for fatal
errors. */
int
-yyerror (msg)
- const char *msg;
+yyerror (const char *msg)
{
if ((parser_state & PST_NOERROR) == 0)
report_syntax_error ((char *)NULL);
}
static char *
-error_token_from_token (tok)
- int tok;
+error_token_from_token (int tok)
{
char *t;
}
static char *
-error_token_from_text ()
+error_token_from_text (void)
{
char *msg, *t;
int token_end, i;
}
static void
-print_offending_line ()
+print_offending_line (void)
{
char *msg;
int token_end;
then place it in MESSAGE, otherwise pass NULL and this will figure
out an appropriate message for you. */
static void
-report_syntax_error (message)
- char *message;
+report_syntax_error (char *message)
{
char *msg, *p;
to throw away the information about where the allocated objects live.
(dispose_command () will actually free the command.) */
static void
-discard_parser_constructs (error_p)
- int error_p;
+discard_parser_constructs (int error_p)
{
}
Otherwise, if ignoreeof is set, and we haven't done this the
required number of times in a row, print a message. */
static void
-handle_eof_input_unit ()
+handle_eof_input_unit (void)
{
if (interactive)
{
/* Take a string and run it through the shell parser, returning the
resultant word list. Used by compound array assignment. */
WORD_LIST *
-parse_string_to_word_list (s, flags, whom)
- char *s;
- int flags;
- const char *whom;
+parse_string_to_word_list (char *s, int flags, const char *whom)
{
WORD_LIST *wl;
int tok, orig_current_token, orig_line_number;
}
static char *
-parse_compound_assignment (retlenp)
- int *retlenp;
+parse_compound_assignment (int *retlenp)
{
WORD_LIST *wl, *rl;
int tok, orig_line_number, assignok;
************************************************/
sh_parser_state_t *
-save_parser_state (ps)
- sh_parser_state_t *ps;
+save_parser_state (sh_parser_state_t *ps)
{
if (ps == 0)
ps = (sh_parser_state_t *)xmalloc (sizeof (sh_parser_state_t));
}
void
-restore_parser_state (ps)
- sh_parser_state_t *ps;
+restore_parser_state (sh_parser_state_t *ps)
{
int i;
}
sh_input_line_state_t *
-save_input_line_state (ls)
- sh_input_line_state_t *ls;
+save_input_line_state (sh_input_line_state_t *ls)
{
if (ls == 0)
ls = (sh_input_line_state_t *)xmalloc (sizeof (sh_input_line_state_t));
}
void
-restore_input_line_state (ls)
- sh_input_line_state_t *ls;
+restore_input_line_state (sh_input_line_state_t *ls)
{
FREE (shell_input_line);
shell_input_line = ls->input_line;
#define MAX_PROPSIZE 32768
static void
-set_line_mbstate ()
+set_line_mbstate (void)
{
int c;
size_t i, previ, len;
/* pathexp.c -- The shell interface to the globbing library. */
-/* Copyright (C) 1995-2020 Free Software Foundation, Inc.
+/* Copyright (C) 1995-2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
#include <glob/strmatch.h>
-static int glob_name_is_acceptable PARAMS((const char *));
-static void ignore_globbed_names PARAMS((char **, sh_ignore_func_t *));
-static char *split_ignorespec PARAMS((char *, int *));
+static int glob_name_is_acceptable (const char *);
+static void ignore_globbed_names (char **, sh_ignore_func_t *);
+static char *split_ignorespec (char *, int *);
#include <glob/glob.h>
it implements the rules in Posix 2.13.3, specifically that an unquoted
slash cannot appear in a bracket expression. */
int
-unquoted_glob_pattern_p (string)
- register char *string;
+unquoted_glob_pattern_p (char *string)
{
register int c;
char *send;
/* Return 1 if C is a character that is `special' in a POSIX ERE and needs to
be quoted to match itself. */
static inline int
-ere_char (c)
- int c;
+ere_char (int c)
{
switch (c)
{
/* This is only used to determine whether to backslash-quote a character. */
int
-glob_char_p (s)
- const char *s;
+glob_char_p (const char *s)
{
switch (*s)
{
performed. QGLOB_REGEXP means we're quoting for a Posix ERE (for
[[ string =~ pat ]]) and that requires some special handling. */
char *
-quote_string_for_globbing (pathname, qflags)
- const char *pathname;
- int qflags;
+quote_string_for_globbing (const char *pathname, int qflags)
{
char *temp;
register int i, j;
}
char *
-quote_globbing_chars (string)
- const char *string;
+quote_globbing_chars (const char *string)
{
size_t slen;
char *temp, *t;
/* Call the glob library to do globbing on PATHNAME. */
char **
-shell_glob_filename (pathname, qflags)
- const char *pathname;
- int qflags;
+shell_glob_filename (const char *pathname, int qflags)
{
char *temp, **results;
int gflags, quoted_pattern;
has changed. If GLOBIGNORE is being unset, we also need to disable
the globbing of filenames beginning with a `.'. */
void
-setup_glob_ignore (name)
- char *name;
+setup_glob_ignore (char *name)
{
char *v;
}
int
-should_ignore_glob_matches ()
+should_ignore_glob_matches (void)
{
return globignore.num_ignores;
}
/* Return 0 if NAME matches a pattern in the globignore.ignores list. */
static int
-glob_name_is_acceptable (name)
- const char *name;
+glob_name_is_acceptable (const char *name)
{
struct ign *p;
char *n;
be removed from NAMES. */
static void
-ignore_globbed_names (names, name_func)
- char **names;
- sh_ignore_func_t *name_func;
+ignore_globbed_names (char **names, sh_ignore_func_t *name_func)
{
char **newnames;
int n, i;
}
void
-ignore_glob_matches (names)
- char **names;
+ignore_glob_matches (char **names)
{
if (globignore.num_ignores == 0)
return;
}
static char *
-split_ignorespec (s, ip)
- char *s;
- int *ip;
+split_ignorespec (char *s, int *ip)
{
char *t;
int n, i;
}
void
-setup_ignore_patterns (ivp)
- struct ignorevar *ivp;
+setup_ignore_patterns (struct ignorevar *ivp)
{
int numitems, maxitems, ptr;
char *colon_bit, *this_ignoreval;
numitems = maxitems = ptr = 0;
-#if 0
- while (colon_bit = extract_colon_unit (this_ignoreval, &ptr))
-#else
while (colon_bit = split_ignorespec (this_ignoreval, &ptr))
-#endif
{
if (numitems + 1 >= maxitems)
{
/* pcomplete.c - functions to generate lists of matches for programmable completion. */
-/* Copyright (C) 1999-2021 Free Software Foundation, Inc.
+/* Copyright (C) 1999-2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
typedef SHELL_VAR **SVFUNC ();
#ifndef HAVE_STRPBRK
-extern char *strpbrk PARAMS((char *, char *));
+extern char *strpbrk (char *, char *);
#endif
extern STRING_INT_ALIST word_token_alist[];
extern char *signal_names[];
#if defined (DEBUG)
-#if defined (PREFER_STDARG)
static void debug_printf (const char *, ...) __attribute__((__format__ (printf, 1, 2)));
-#endif
#endif /* DEBUG */
-static int it_init_joblist PARAMS((ITEMLIST *, int));
-
-static int it_init_aliases PARAMS((ITEMLIST *));
-static int it_init_arrayvars PARAMS((ITEMLIST *));
-static int it_init_bindings PARAMS((ITEMLIST *));
-static int it_init_builtins PARAMS((ITEMLIST *));
-static int it_init_disabled PARAMS((ITEMLIST *));
-static int it_init_enabled PARAMS((ITEMLIST *));
-static int it_init_exported PARAMS((ITEMLIST *));
-static int it_init_functions PARAMS((ITEMLIST *));
-static int it_init_helptopics PARAMS((ITEMLIST *));
-static int it_init_hostnames PARAMS((ITEMLIST *));
-static int it_init_jobs PARAMS((ITEMLIST *));
-static int it_init_running PARAMS((ITEMLIST *));
-static int it_init_stopped PARAMS((ITEMLIST *));
-static int it_init_keywords PARAMS((ITEMLIST *));
-static int it_init_signals PARAMS((ITEMLIST *));
-static int it_init_variables PARAMS((ITEMLIST *));
-static int it_init_setopts PARAMS((ITEMLIST *));
-static int it_init_shopts PARAMS((ITEMLIST *));
-
-static int shouldexp_filterpat PARAMS((char *));
-static char *preproc_filterpat PARAMS((char *, const char *));
-
-static void init_itemlist_from_varlist PARAMS((ITEMLIST *, SVFUNC *));
-
-static STRINGLIST *gen_matches_from_itemlist PARAMS((ITEMLIST *, const char *));
-static STRINGLIST *gen_action_completions PARAMS((COMPSPEC *, const char *));
-static STRINGLIST *gen_globpat_matches PARAMS((COMPSPEC *, const char *));
-static STRINGLIST *gen_wordlist_matches PARAMS((COMPSPEC *, const char *));
-static STRINGLIST *gen_shell_function_matches PARAMS((COMPSPEC *, const char *,
+static int it_init_joblist (ITEMLIST *, int);
+
+static int it_init_aliases (ITEMLIST *);
+static int it_init_arrayvars (ITEMLIST *);
+static int it_init_bindings (ITEMLIST *);
+static int it_init_builtins (ITEMLIST *);
+static int it_init_disabled (ITEMLIST *);
+static int it_init_enabled (ITEMLIST *);
+static int it_init_exported (ITEMLIST *);
+static int it_init_functions (ITEMLIST *);
+static int it_init_helptopics (ITEMLIST *);
+static int it_init_hostnames (ITEMLIST *);
+static int it_init_jobs (ITEMLIST *);
+static int it_init_running (ITEMLIST *);
+static int it_init_stopped (ITEMLIST *);
+static int it_init_keywords (ITEMLIST *);
+static int it_init_signals (ITEMLIST *);
+static int it_init_variables (ITEMLIST *);
+static int it_init_setopts (ITEMLIST *);
+static int it_init_shopts (ITEMLIST *);
+
+static int shouldexp_filterpat (char *);
+static char *preproc_filterpat (char *, const char *);
+
+static void init_itemlist_from_varlist (ITEMLIST *, SVFUNC *);
+
+static STRINGLIST *gen_matches_from_itemlist (ITEMLIST *, const char *);
+static STRINGLIST *gen_action_completions (COMPSPEC *, const char *);
+static STRINGLIST *gen_globpat_matches (COMPSPEC *, const char *);
+static STRINGLIST *gen_wordlist_matches (COMPSPEC *, const char *);
+static STRINGLIST *gen_shell_function_matches (COMPSPEC *, const char *,
const char *,
char *, int, WORD_LIST *,
- int, int, int *));
-static STRINGLIST *gen_command_matches PARAMS((COMPSPEC *, const char *,
+ int, int, int *);
+static STRINGLIST *gen_command_matches (COMPSPEC *, const char *,
const char *,
char *, int, WORD_LIST *,
- int, int));
+ int, int);
-static STRINGLIST *gen_progcomp_completions PARAMS((const char *, const char *,
+static STRINGLIST *gen_progcomp_completions (const char *, const char *,
const char *,
int, int, int *, int *,
- COMPSPEC **));
+ COMPSPEC **);
-static char *pcomp_filename_completion_function PARAMS((const char *, int));
+static char *pcomp_filename_completion_function (const char *, int);
#if defined (ARRAY_VARS)
-static SHELL_VAR *bind_comp_words PARAMS((WORD_LIST *));
+static SHELL_VAR *bind_comp_words (WORD_LIST *);
#endif
-static void bind_compfunc_variables PARAMS((char *, int, WORD_LIST *, int, int));
-static void unbind_compfunc_variables PARAMS((int));
-static WORD_LIST *build_arg_list PARAMS((char *, const char *, const char *, WORD_LIST *, int));
-static WORD_LIST *command_line_to_word_list PARAMS((char *, int, int, int *, int *));
+static void bind_compfunc_variables (char *, int, WORD_LIST *, int, int);
+static void unbind_compfunc_variables (int);
+static WORD_LIST *build_arg_list (char *, const char *, const char *, WORD_LIST *, int);
+static WORD_LIST *command_line_to_word_list (char *, int, int, int *, int *);
static int compgen_compspec = 0; /* are we generating completions for compgen? */
#ifdef DEBUG
/* Debugging code */
static void
-#if defined (PREFER_STDARG)
debug_printf (const char *format, ...)
-#else
-debug_printf (format, va_alist)
- const char *format;
- va_dcl
-#endif
{
va_list args;
/* Functions to manage the item lists */
void
-set_itemlist_dirty (it)
- ITEMLIST *it;
+set_itemlist_dirty (ITEMLIST *it)
{
it->flags |= LIST_DIRTY;
}
void
-initialize_itemlist (itp)
- ITEMLIST *itp;
+initialize_itemlist (ITEMLIST *itp)
{
(*itp->list_getter) (itp);
itp->flags |= LIST_INITIALIZED;
}
void
-clean_itemlist (itp)
- ITEMLIST *itp;
+clean_itemlist (ITEMLIST *itp)
{
STRINGLIST *sl;
itp->flags &= ~(LIST_DONTFREE|LIST_DONTFREEMEMBERS|LIST_INITIALIZED|LIST_DIRTY);
}
-
static int
-shouldexp_filterpat (s)
- char *s;
+shouldexp_filterpat (char *s)
{
register char *p;
quote a `&' and inhibit substitution. Returns a new string. This just
calls stringlib.c:strcreplace(). */
static char *
-preproc_filterpat (pat, text)
- char *pat;
- const char *text;
+preproc_filterpat (char *pat, const char *text)
{
char *ret;
a new STRINGLIST with the matching members of SL *copied*. Any
non-matching members of SL->list are *freed*. */
STRINGLIST *
-filter_stringlist (sl, filterpat, text)
- STRINGLIST *sl;
- char *filterpat;
- const char *text;
+filter_stringlist (STRINGLIST *sl, char *filterpat, const char *text)
{
int i, m, not;
STRINGLIST *ret;
This understands how rl_completion_matches sets matches[0] (the lcd of the
strings in the list, unless it's the only match). */
STRINGLIST *
-completions_to_stringlist (matches)
- char **matches;
+completions_to_stringlist (char **matches)
{
STRINGLIST *sl;
int mlen, i, n;
The caller is responsible for setting ITP->flags correctly. */
static int
-it_init_aliases (itp)
- ITEMLIST *itp;
+it_init_aliases (ITEMLIST *itp)
{
#ifdef ALIAS
alias_t **alias_list;
}
static void
-init_itemlist_from_varlist (itp, svfunc)
- ITEMLIST *itp;
- SVFUNC *svfunc;
+init_itemlist_from_varlist (ITEMLIST *itp, SVFUNC *svfunc)
{
SHELL_VAR **vlist;
STRINGLIST *sl;
}
static int
-it_init_arrayvars (itp)
- ITEMLIST *itp;
+it_init_arrayvars (ITEMLIST *itp)
{
#if defined (ARRAY_VARS)
init_itemlist_from_varlist (itp, all_array_variables);
}
static int
-it_init_bindings (itp)
- ITEMLIST *itp;
+it_init_bindings (ITEMLIST *itp)
{
char **blist;
STRINGLIST *sl;
}
static int
-it_init_builtins (itp)
- ITEMLIST *itp;
+it_init_builtins (ITEMLIST *itp)
{
STRINGLIST *sl;
register int i, n;
}
static int
-it_init_enabled (itp)
- ITEMLIST *itp;
+it_init_enabled (ITEMLIST *itp)
{
STRINGLIST *sl;
register int i, n;
}
static int
-it_init_disabled (itp)
- ITEMLIST *itp;
+it_init_disabled (ITEMLIST *itp)
{
STRINGLIST *sl;
register int i, n;
}
static int
-it_init_exported (itp)
- ITEMLIST *itp;
+it_init_exported (ITEMLIST *itp)
{
init_itemlist_from_varlist (itp, all_exported_variables);
return 0;
}
static int
-it_init_functions (itp)
- ITEMLIST *itp;
+it_init_functions (ITEMLIST *itp)
{
init_itemlist_from_varlist (itp, all_visible_functions);
return 0;
/* Like it_init_builtins, but includes everything the help builtin looks at,
not just builtins with an active implementing function. */
static int
-it_init_helptopics (itp)
- ITEMLIST *itp;
+it_init_helptopics (ITEMLIST *itp)
{
STRINGLIST *sl;
register int i, n;
}
static int
-it_init_hostnames (itp)
- ITEMLIST *itp;
+it_init_hostnames (ITEMLIST *itp)
{
STRINGLIST *sl;
}
static int
-it_init_joblist (itp, jstate)
- ITEMLIST *itp;
- int jstate;
+it_init_joblist (ITEMLIST *itp, int jstate)
{
#if defined (JOB_CONTROL)
STRINGLIST *sl;
}
static int
-it_init_jobs (itp)
- ITEMLIST *itp;
+it_init_jobs (ITEMLIST *itp)
{
return (it_init_joblist (itp, -1));
}
static int
-it_init_running (itp)
- ITEMLIST *itp;
+it_init_running (ITEMLIST *itp)
{
return (it_init_joblist (itp, 0));
}
static int
-it_init_stopped (itp)
- ITEMLIST *itp;
+it_init_stopped (ITEMLIST *itp)
{
return (it_init_joblist (itp, 1));
}
static int
-it_init_keywords (itp)
- ITEMLIST *itp;
+it_init_keywords (ITEMLIST *itp)
{
STRINGLIST *sl;
register int i, n;
}
static int
-it_init_signals (itp)
- ITEMLIST *itp;
+it_init_signals (ITEMLIST *itp)
{
STRINGLIST *sl;
}
static int
-it_init_variables (itp)
- ITEMLIST *itp;
+it_init_variables (ITEMLIST *itp)
{
init_itemlist_from_varlist (itp, all_visible_variables);
return 0;
}
static int
-it_init_setopts (itp)
- ITEMLIST *itp;
+it_init_setopts (ITEMLIST *itp)
{
STRINGLIST *sl;
}
static int
-it_init_shopts (itp)
- ITEMLIST *itp;
+it_init_shopts (ITEMLIST *itp)
{
STRINGLIST *sl;
new one before trying the match. TEXT is dequoted before attempting a
match. */
static STRINGLIST *
-gen_matches_from_itemlist (itp, text)
- ITEMLIST *itp;
- const char *text;
+gen_matches_from_itemlist (ITEMLIST *itp, const char *text)
{
STRINGLIST *ret, *sl;
int tlen, i, n;
/* A wrapper for rl_filename_completion_function that dequotes the filename
before attempting completions. */
static char *
-pcomp_filename_completion_function (text, state)
- const char *text;
- int state;
+pcomp_filename_completion_function (const char *text, int state)
{
static char *dfn; /* dequoted filename */
int iscompgen, iscompleting;
/* Functions to generate lists of matches from the actions member of CS. */
static STRINGLIST *
-gen_action_completions (cs, text)
- COMPSPEC *cs;
- const char *text;
+gen_action_completions (COMPSPEC *cs, const char *text)
{
STRINGLIST *ret, *tmatches;
char **cmatches; /* from rl_completion_matches ... */
to use TEXT, we should call quote_string_for_globbing before the call to
glob_filename (in which case we could use shell_glob_filename). */
static STRINGLIST *
-gen_globpat_matches (cs, text)
- COMPSPEC *cs;
- const char *text;
+gen_globpat_matches (COMPSPEC *cs, const char *text)
{
STRINGLIST *sl;
int gflags;
/* Perform the shell word expansions on CS->words and return the results.
Again, this ignores TEXT. */
static STRINGLIST *
-gen_wordlist_matches (cs, text)
- COMPSPEC *cs;
- const char *text;
+gen_wordlist_matches (COMPSPEC *cs, const char *text)
{
WORD_LIST *l, *l2;
STRINGLIST *sl;
#ifdef ARRAY_VARS
static SHELL_VAR *
-bind_comp_words (lwords)
- WORD_LIST *lwords;
+bind_comp_words (WORD_LIST *lwords)
{
SHELL_VAR *v;
#endif /* ARRAY_VARS */
static void
-bind_compfunc_variables (line, ind, lwords, cw, exported)
- char *line;
- int ind;
- WORD_LIST *lwords;
- int cw, exported;
+bind_compfunc_variables (char *line, int ind, WORD_LIST *lwords, int cw, int exported)
{
char ibuf[INT_STRLEN_BOUND(int) + 1];
char *value;
}
static void
-unbind_compfunc_variables (exported)
- int exported;
+unbind_compfunc_variables (int exported)
{
unbind_variable_noref ("COMP_LINE");
unbind_variable_noref ("COMP_POINT");
make do with the COMP_LINE and COMP_POINT variables. */
static WORD_LIST *
-build_arg_list (cmd, cname, text, lwords, ind)
- char *cmd;
- const char *cname;
- const char *text;
- WORD_LIST *lwords;
- int ind;
+build_arg_list (char *cmd, const char *cname, const char *text, WORD_LIST *lwords, int ind)
{
WORD_LIST *ret, *cl, *l;
WORD_DESC *w;
variable, this does nothing if arrays are not compiled into the shell. */
static STRINGLIST *
-gen_shell_function_matches (cs, cmd, text, line, ind, lwords, nw, cw, foundp)
- COMPSPEC *cs;
- const char *cmd;
- const char *text;
- char *line;
- int ind;
- WORD_LIST *lwords;
- int nw, cw;
- int *foundp;
+gen_shell_function_matches (COMPSPEC *cs, const char *cmd, const char *text,
+ char *line, int ind, WORD_LIST *lwords,
+ int nw, int cw, int *foundp)
{
char *funcname;
STRINGLIST *sl;
STRINGLIST from the results and return it. */
static STRINGLIST *
-gen_command_matches (cs, cmd, text, line, ind, lwords, nw, cw)
- COMPSPEC *cs;
- const char *cmd;
- const char *text;
- char *line;
- int ind;
- WORD_LIST *lwords;
- int nw, cw;
+gen_command_matches (COMPSPEC *cs, const char *cmd, const char *text,
+ char *line, int ind, WORD_LIST *lwords,
+ int nw, int cw)
{
char *csbuf, *cscmd, *t;
int cmdlen, cmdsize, n, ws, we;
}
static WORD_LIST *
-command_line_to_word_list (line, llen, sentinel, nwp, cwp)
- char *line;
- int llen, sentinel, *nwp, *cwp;
+command_line_to_word_list (char *line, int llen, int sentinel, int *nwp, int *cwp)
{
WORD_LIST *ret;
const char *delims;
-#if 0
- delims = "()<>;&| \t\n"; /* shell metacharacters break words */
-#else
delims = rl_completer_word_break_characters;
-#endif
ret = split_at_delims (line, llen, delims, sentinel, SD_NOQUOTEDELIM|SD_COMPLETE, nwp, cwp);
return (ret);
}
/* Evaluate COMPSPEC *cs and return all matches for WORD. */
STRINGLIST *
-gen_compspec_completions (cs, cmd, word, start, end, foundp)
- COMPSPEC *cs;
- const char *cmd;
- const char *word;
- int start, end;
- int *foundp;
+gen_compspec_completions (COMPSPEC *cs, const char *cmd, const char *word,
+ int start, int end, int *foundp)
{
STRINGLIST *ret, *tmatches;
char *line;
}
void
-pcomp_set_readline_variables (flags, nval)
- int flags, nval;
+pcomp_set_readline_variables (int flags, int nval)
{
/* If the user specified that the compspec returns filenames, make
sure that readline knows it. */
/* Set or unset FLAGS in the options word of the current compspec.
SET_OR_UNSET is 1 for setting, 0 for unsetting. */
void
-pcomp_set_compspec_options (cs, flags, set_or_unset)
- COMPSPEC *cs;
- int flags, set_or_unset;
+pcomp_set_compspec_options (COMPSPEC *cs, int flags, int set_or_unset)
{
if (cs == 0 && ((cs = pcomp_curcs) == 0))
return;
}
static STRINGLIST *
-gen_progcomp_completions (ocmd, cmd, word, start, end, foundp, retryp, lastcs)
- const char *ocmd;
- const char *cmd;
- const char *word;
- int start, end;
- int *foundp, *retryp;
- COMPSPEC **lastcs;
+gen_progcomp_completions (const char *ocmd, const char *cmd, const char *word,
+ int start, int end, int *foundp, int *retryp,
+ COMPSPEC **lastcs)
{
COMPSPEC *cs, *oldcs;
const char *oldcmd, *oldtxt;
bound the command currently being completed in pcomp_line (usually
rl_line_buffer). */
char **
-programmable_completions (cmd, word, start, end, foundp)
- const char *cmd;
- const char *word;
- int start, end, *foundp;
+programmable_completions (const char *cmd, const char *word,
+ int start, int end, int *foundp)
{
COMPSPEC *lastcs;
STRINGLIST *ret;
extern int progcomp_size (void);
extern int progcomp_insert (char *, COMPSPEC *);
-extern int progcomp_remove (char *);
+extern int progcomp_remove (const char *);
extern COMPSPEC *progcomp_search (const char *);
/* pcomplib.c - library functions for programmable completion. */
-/* Copyright (C) 1999-2021 Free Software Foundation, Inc.
+/* Copyright (C) 1999-2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
HASH_TABLE *prog_completes = (HASH_TABLE *)NULL;
-static void free_progcomp PARAMS((PTR_T));
+static void free_progcomp (PTR_T);
COMPSPEC *
-compspec_create ()
+compspec_create (void)
{
COMPSPEC *ret;
}
void
-compspec_dispose (cs)
- COMPSPEC *cs;
+compspec_dispose (COMPSPEC *cs)
{
cs->refcount--;
if (cs->refcount == 0)
}
COMPSPEC *
-compspec_copy (cs)
- COMPSPEC *cs;
+compspec_copy (COMPSPEC *cs)
{
COMPSPEC *new;
}
void
-progcomp_create ()
+progcomp_create (void)
{
if (prog_completes == 0)
prog_completes = hash_create (COMPLETE_HASH_BUCKETS);
}
int
-progcomp_size ()
+progcomp_size (void)
{
return (HASH_ENTRIES (prog_completes));
}
static void
-free_progcomp (data)
- PTR_T data;
+free_progcomp (PTR_T data)
{
COMPSPEC *cs;
}
void
-progcomp_flush ()
+progcomp_flush (void)
{
if (prog_completes)
hash_flush (prog_completes, free_progcomp);
}
void
-progcomp_dispose ()
+progcomp_dispose (void)
{
if (prog_completes)
hash_dispose (prog_completes);
}
int
-progcomp_remove (cmd)
- char *cmd;
+progcomp_remove (const char *cmd)
{
register BUCKET_CONTENTS *item;
}
int
-progcomp_insert (cmd, cs)
- char *cmd;
- COMPSPEC *cs;
+progcomp_insert (char *cmd, COMPSPEC *cs)
{
register BUCKET_CONTENTS *item;
}
COMPSPEC *
-progcomp_search (cmd)
- const char *cmd;
+progcomp_search (const char *cmd)
{
register BUCKET_CONTENTS *item;
COMPSPEC *cs;
}
void
-progcomp_walk (pfunc)
- hash_wfunc *pfunc;
+progcomp_walk (hash_wfunc *pfunc)
{
if (prog_completes == 0 || pfunc == 0 || HASH_ENTRIES (prog_completes) == 0)
return;
#include "builtins/common.h"
#if !HAVE_DECL_PRINTF
-extern int printf PARAMS((const char *, ...)); /* Yuck. Double yuck. */
+extern int printf (const char *, ...); /* Yuck. Double yuck. */
#endif
static int indentation;
static int indentation_amount = 4;
-#if defined (PREFER_STDARG)
-typedef void PFUNC PARAMS((const char *, ...));
-
-static void cprintf PARAMS((const char *, ...)) __attribute__((__format__ (printf, 1, 2)));
-static void xprintf PARAMS((const char *, ...)) __attribute__((__format__ (printf, 1, 2)));
-#else
-#define PFUNC VFunction
-static void cprintf ();
-static void xprintf ();
-#endif
-
-static void reset_locals PARAMS((void));
-static void newline PARAMS((char *));
-static void indent PARAMS((int));
-static void semicolon PARAMS((void));
-static void the_printed_command_resize PARAMS((int));
-
-static void make_command_string_internal PARAMS((COMMAND *));
-static void _print_word_list PARAMS((WORD_LIST *, char *, PFUNC *));
-static void command_print_word_list PARAMS((WORD_LIST *, char *));
-static void print_case_clauses PARAMS((PATTERN_LIST *));
-static void print_redirection_list PARAMS((REDIRECT *));
-static void print_redirection PARAMS((REDIRECT *));
-static void print_heredoc_header PARAMS((REDIRECT *));
-static void print_heredoc_body PARAMS((REDIRECT *));
-static void print_heredocs PARAMS((REDIRECT *));
-static void print_heredoc_bodies PARAMS((REDIRECT *));
-static void print_deferred_heredocs PARAMS((const char *));
-
-static void print_for_command PARAMS((FOR_COM *));
+typedef void PFUNC (const char *, ...);
+
+static void cprintf (const char *, ...) __attribute__((__format__ (printf, 1, 2)));
+static void xprintf (const char *, ...) __attribute__((__format__ (printf, 1, 2)));
+
+static void reset_locals (void);
+static void newline (char *);
+static void indent (int);
+static void semicolon (void);
+static void the_printed_command_resize (int);
+
+static void make_command_string_internal (COMMAND *);
+static void _print_word_list (WORD_LIST *, char *, PFUNC *);
+static void command_print_word_list (WORD_LIST *, char *);
+static void print_case_clauses (PATTERN_LIST *);
+static void print_redirection_list (REDIRECT *);
+static void print_redirection (REDIRECT *);
+static void print_heredoc_header (REDIRECT *);
+static void print_heredoc_body (REDIRECT *);
+static void print_heredocs (REDIRECT *);
+static void print_heredoc_bodies (REDIRECT *);
+static void print_deferred_heredocs (const char *);
+
+static void print_for_command (FOR_COM *);
#if defined (ARITH_FOR_COMMAND)
-static void print_arith_for_command PARAMS((ARITH_FOR_COM *));
+static void print_arith_for_command (ARITH_FOR_COM *);
#endif
#if defined (SELECT_COMMAND)
-static void print_select_command PARAMS((SELECT_COM *));
+static void print_select_command (SELECT_COM *);
#endif
-static void print_group_command PARAMS((GROUP_COM *));
-static void print_case_command PARAMS((CASE_COM *));
-static void print_while_command PARAMS((WHILE_COM *));
-static void print_until_command PARAMS((WHILE_COM *));
-static void print_until_or_while PARAMS((WHILE_COM *, char *));
-static void print_if_command PARAMS((IF_COM *));
+static void print_group_command (GROUP_COM *);
+static void print_case_command (CASE_COM *);
+static void print_while_command (WHILE_COM *);
+static void print_until_command (WHILE_COM *);
+static void print_until_or_while (WHILE_COM *, char *);
+static void print_if_command (IF_COM *);
#if defined (COND_COMMAND)
-static void print_cond_node PARAMS((COND_COM *));
+static void print_cond_node (COND_COM *);
#endif
-static void print_function_def PARAMS((FUNCTION_DEF *));
+static void print_function_def (FUNCTION_DEF *);
#define PRINTED_COMMAND_INITIAL_SIZE 64
#define PRINTED_COMMAND_GROW_SIZE 128
/* Print COMMAND (a command tree) on standard output. */
void
-print_command (command)
- COMMAND *command;
+print_command (COMMAND *command)
{
command_string_index = 0;
printf ("%s", make_command_string (command));
not consed, so you have to do that yourself if you want it to
remain around. */
char *
-make_command_string (command)
- COMMAND *command;
+make_command_string (COMMAND *command)
{
command_string_index = was_heredoc = 0;
deferred_heredocs = 0;
back into an external representation without turning newlines into `;'.
Placeholder for other changes, if any are necessary. */
char *
-print_comsub (command)
- COMMAND *command;
+print_comsub (COMMAND *command)
{
char *ret;
/* The internal function. This is the real workhorse. */
static void
-make_command_string_internal (command)
- COMMAND *command;
+make_command_string_internal (COMMAND *command)
{
char s[3];
}
static void
-_print_word_list (list, separator, pfunc)
- WORD_LIST *list;
- char *separator;
- PFUNC *pfunc;
+_print_word_list (WORD_LIST *list, char *separator, PFUNC *pfunc)
{
WORD_LIST *w;
}
void
-print_word_list (list, separator)
- WORD_LIST *list;
- char *separator;
+print_word_list (WORD_LIST *list, char *separator)
{
_print_word_list (list, separator, xprintf);
}
void
-xtrace_set (fd, fp)
- int fd;
- FILE *fp;
+xtrace_set (int fd, FILE *fp)
{
if (fd >= 0 && sh_validfd (fd) == 0)
{
}
void
-xtrace_init ()
+xtrace_init (void)
{
xtrace_set (-1, stderr);
}
void
-xtrace_reset ()
+xtrace_reset (void)
{
if (xtrace_fd >= 0 && xtrace_fp)
{
}
void
-xtrace_fdchk (fd)
- int fd;
+xtrace_fdchk (int fd)
{
if (fd == xtrace_fd)
xtrace_reset ();
/* Return a string denoting what our indirection level is. */
char *
-indirection_level_string ()
+indirection_level_string (void)
{
register int i, j;
char *ps4;
}
void
-xtrace_print_assignment (name, value, assign_list, xflags)
- char *name, *value;
- int assign_list, xflags;
+xtrace_print_assignment (char *name, char *value, int assign_list, int xflags)
{
char *nval;
quoting the words because they haven't been expanded yet. XTFLAGS&1 means to
print $PS4; XTFLAGS&2 means to suppress quoting the words in LIST. */
void
-xtrace_print_word_list (list, xtflags)
- WORD_LIST *list;
- int xtflags;
+xtrace_print_word_list (WORD_LIST *list, int xtflags)
{
WORD_LIST *w;
char *t, *x;
}
static void
-command_print_word_list (list, separator)
- WORD_LIST *list;
- char *separator;
+command_print_word_list (WORD_LIST *list, char *separator)
{
_print_word_list (list, separator, cprintf);
}
void
-print_for_command_head (for_command)
- FOR_COM *for_command;
+print_for_command_head (FOR_COM *for_command)
{
cprintf ("for %s in ", for_command->name->word);
command_print_word_list (for_command->map_list, " ");
}
void
-xtrace_print_for_command_head (for_command)
- FOR_COM *for_command;
+xtrace_print_for_command_head (FOR_COM *for_command)
{
CHECK_XTRACE_FP;
fprintf (xtrace_fp, "%s", indirection_level_string ());
}
static void
-print_for_command (for_command)
- FOR_COM *for_command;
+print_for_command (FOR_COM *for_command)
{
print_for_command_head (for_command);
cprintf (";");
#if defined (ARITH_FOR_COMMAND)
static void
-print_arith_for_command (arith_for_command)
- ARITH_FOR_COM *arith_for_command;
+print_arith_for_command (ARITH_FOR_COM *arith_for_command)
{
cprintf ("for ((");
command_print_word_list (arith_for_command->init, " ");
#if defined (SELECT_COMMAND)
void
-print_select_command_head (select_command)
- SELECT_COM *select_command;
+print_select_command_head (SELECT_COM *select_command)
{
cprintf ("select %s in ", select_command->name->word);
command_print_word_list (select_command->map_list, " ");
}
void
-xtrace_print_select_command_head (select_command)
- SELECT_COM *select_command;
+xtrace_print_select_command_head (SELECT_COM *select_command)
{
CHECK_XTRACE_FP;
fprintf (xtrace_fp, "%s", indirection_level_string ());
}
static void
-print_select_command (select_command)
- SELECT_COM *select_command;
+print_select_command (SELECT_COM *select_command)
{
print_select_command_head (select_command);
#endif /* SELECT_COMMAND */
static void
-print_group_command (group_command)
- GROUP_COM *group_command;
+print_group_command (GROUP_COM *group_command)
{
group_command_nesting++;
cprintf ("{ ");
}
void
-print_case_command_head (case_command)
- CASE_COM *case_command;
+print_case_command_head (CASE_COM *case_command)
{
cprintf ("case %s in ", case_command->word->word);
}
void
-xtrace_print_case_command_head (case_command)
- CASE_COM *case_command;
+xtrace_print_case_command_head (CASE_COM *case_command)
{
CHECK_XTRACE_FP;
fprintf (xtrace_fp, "%s", indirection_level_string ());
}
static void
-print_case_command (case_command)
- CASE_COM *case_command;
+print_case_command (CASE_COM *case_command)
{
print_case_command_head (case_command);
}
static void
-print_case_clauses (clauses)
- PATTERN_LIST *clauses;
+print_case_clauses (PATTERN_LIST *clauses)
{
indentation += indentation_amount;
while (clauses)
}
static void
-print_while_command (while_command)
- WHILE_COM *while_command;
+print_while_command (WHILE_COM *while_command)
{
print_until_or_while (while_command, "while");
}
static void
-print_until_command (while_command)
- WHILE_COM *while_command;
+print_until_command (WHILE_COM *while_command)
{
print_until_or_while (while_command, "until");
}
static void
-print_until_or_while (while_command, which)
- WHILE_COM *while_command;
- char *which;
+print_until_or_while (WHILE_COM *while_command, char *which)
{
cprintf ("%s ", which);
skip_this_indent++;
}
static void
-print_if_command (if_command)
- IF_COM *if_command;
+print_if_command (IF_COM *if_command)
{
cprintf ("if ");
skip_this_indent++;
#if defined (DPAREN_ARITHMETIC) || defined (ARITH_FOR_COMMAND)
void
-print_arith_command (arith_cmd_list)
- WORD_LIST *arith_cmd_list;
+print_arith_command (WORD_LIST *arith_cmd_list)
{
cprintf ("((");
command_print_word_list (arith_cmd_list, " ");
#if defined (COND_COMMAND)
static void
-print_cond_node (cond)
- COND_COM *cond;
+print_cond_node (COND_COM *cond)
{
if (cond->flags & CMD_INVERT_RETURN)
cprintf ("! ");
}
void
-print_cond_command (cond)
- COND_COM *cond;
+print_cond_command (COND_COM *cond)
{
cprintf ("[[ ");
print_cond_node (cond);
#ifdef DEBUG
void
-debug_print_word_list (s, list, sep)
- char *s;
- WORD_LIST *list;
- char *sep;
+debug_print_word_list (char *s, WORD_LIST *list, char *sep)
{
WORD_LIST *w;
}
void
-debug_print_cond_command (cond)
- COND_COM *cond;
+debug_print_cond_command (COND_COM *cond)
{
fprintf (stderr, "DEBUG: ");
command_string_index = 0;
#endif
void
-xtrace_print_cond_term (type, invert, op, arg1, arg2)
- int type, invert;
- WORD_DESC *op;
- char *arg1, *arg2;
+xtrace_print_cond_term (int type, int invert, WORD_DESC *op, char *arg1, char *arg2)
{
CHECK_XTRACE_FP;
command_string_index = 0;
#if defined (DPAREN_ARITHMETIC) || defined (ARITH_FOR_COMMAND)
/* A function to print the words of an arithmetic command when set -x is on. */
void
-xtrace_print_arith_cmd (list)
- WORD_LIST *list;
+xtrace_print_arith_cmd (WORD_LIST *list)
{
WORD_LIST *w;
#endif
void
-print_simple_command (simple_command)
- SIMPLE_COM *simple_command;
+print_simple_command (SIMPLE_COM *simple_command)
{
if (simple_command->words)
command_print_word_list (simple_command->words, " ");
}
static void
-print_heredocs (heredocs)
- REDIRECT *heredocs;
+print_heredocs (REDIRECT *heredocs)
{
REDIRECT *hdtail;
}
static void
-print_heredoc_bodies (heredocs)
- REDIRECT *heredocs;
+print_heredoc_bodies (REDIRECT *heredocs)
{
REDIRECT *hdtail;
if it's a `;', but we use it to note not to print an extra space after the
last heredoc body and newline. */
static void
-print_deferred_heredocs (cstring)
- const char *cstring;
+print_deferred_heredocs (const char *cstring)
{
/* We now print the heredoc headers in print_redirection_list */
if (cstring && cstring[0] && (cstring[0] != ';' || cstring[1]))
}
static void
-print_redirection_list (redirects)
- REDIRECT *redirects;
+print_redirection_list (REDIRECT *redirects)
{
REDIRECT *heredocs, *hdtail, *newredir;
char *rw;
}
static void
-print_heredoc_header (redirect)
- REDIRECT *redirect;
+print_heredoc_header (REDIRECT *redirect)
{
int kill_leading;
char *x;
}
static void
-print_heredoc_body (redirect)
- REDIRECT *redirect;
+print_heredoc_body (REDIRECT *redirect)
{
/* Here doc body */
cprintf ("%s%s", redirect->redirectee.filename->word, redirect->here_doc_eof);
}
static void
-print_redirection (redirect)
- REDIRECT *redirect;
+print_redirection (REDIRECT *redirect)
{
int redirector, redir_fd;
WORD_DESC *redirectee, *redir_word;
}
static void
-reset_locals ()
+reset_locals (void)
{
inside_function_def = 0;
indentation = 0;
}
static void
-print_function_def (func)
- FUNCTION_DEF *func;
+print_function_def (FUNCTION_DEF *func)
{
COMMAND *cmdcopy;
REDIRECT *func_redirects;
flags&FUNC_EXTERNAL means convert from internal to external form
*/
char *
-named_function_string (name, command, flags)
- char *name;
- COMMAND *command;
- int flags;
+named_function_string (char *name, COMMAND *command, int flags)
{
char *result;
int old_indent, old_amount;
if (name && *name)
{
- if (find_reserved_word (name) >= 0)
+ if (find_reserved_word (name) >= 0) /* check valid identifier too? */
cprintf ("function ");
cprintf ("%s ", name);
}
}
static void
-newline (string)
- char *string;
+newline (char *string)
{
cprintf ("\n");
indent (indentation);
static int indentation_size;
static void
-indent (amount)
- int amount;
+indent (int amount)
{
register int i;
}
static void
-semicolon ()
+semicolon (void)
{
if (command_string_index > 0 &&
(the_printed_command[command_string_index - 1] == '&' ||
/* How to make the string. */
static void
-#if defined (PREFER_STDARG)
cprintf (const char *control, ...)
-#else
-cprintf (control, va_alist)
- const char *control;
- va_dcl
-#endif
{
register const char *s;
char char_arg[2], *argp, intbuf[INT_STRLEN_BOUND (unsigned int) + 1];
/* Ensure that there is enough space to stuff LENGTH characters into
THE_PRINTED_COMMAND. */
static void
-the_printed_command_resize (length)
- int length;
+the_printed_command_resize (int length)
{
if (the_printed_command == 0)
{
also available.'' */
static void
-#if defined (PREFER_STDARG)
xprintf (const char *format, ...)
-#else
-xprintf (format, va_alist)
- const char *format;
- va_dcl
-#endif
{
va_list args;
/* redir.c -- Functions to perform input and output redirection. */
-/* Copyright (C) 1997-2021 Free Software Foundation, Inc.
+/* Copyright (C) 1997-2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
extern REDIRECT *exec_redirection_undo_list;
/* Static functions defined and used in this file. */
-static void add_exec_redirect PARAMS((REDIRECT *));
-static int add_undo_redirect PARAMS((int, enum r_instruction, int));
-static int add_undo_close_redirect PARAMS((int));
-static int expandable_redirection_filename PARAMS((REDIRECT *));
-static int stdin_redirection PARAMS((enum r_instruction, int));
-static int undoablefd PARAMS((int));
-static int do_redirection_internal PARAMS((REDIRECT *, int, char **));
+static void add_exec_redirect (REDIRECT *);
+static int add_undo_redirect (int, enum r_instruction, int);
+static int add_undo_close_redirect (int);
+static int expandable_redirection_filename (REDIRECT *);
+static int stdin_redirection (enum r_instruction, int);
+static int undoablefd (int);
+static int do_redirection_internal (REDIRECT *, int, char **);
-static char *heredoc_expand PARAMS((WORD_DESC *, enum r_instruction, size_t *));
-static int heredoc_write PARAMS((int, char *, size_t));
-static int here_document_to_fd PARAMS((WORD_DESC *, enum r_instruction));
+static char *heredoc_expand (WORD_DESC *, enum r_instruction, size_t *);
+static int heredoc_write (int, char *, size_t);
+static int here_document_to_fd (WORD_DESC *, enum r_instruction);
-static int redir_special_open PARAMS((int, char *, int, int, enum r_instruction));
-static int noclobber_open PARAMS((char *, int, int, enum r_instruction));
-static int redir_open PARAMS((char *, int, int, enum r_instruction));
+static int redir_special_open (int, char *, int, int, enum r_instruction);
+static int noclobber_open (char *, int, int, enum r_instruction);
+static int redir_open (char *, int, int, enum r_instruction);
-static int redir_varassign PARAMS((REDIRECT *, int));
-static int redir_varvalue PARAMS((REDIRECT *));
+static int redir_varassign (REDIRECT *, int);
+static int redir_varvalue (REDIRECT *);
/* Spare redirector used when translating [N]>&WORD[-] or [N]<&WORD[-] to
a new redirection and when creating the redirection undo list. */
} while (0)
void
-redirection_error (temp, error, fn)
- REDIRECT *temp;
- int error;
- char *fn; /* already-expanded filename */
+redirection_error (REDIRECT *temp, int error, char *fn)
{
char *filename, *allocname;
int oflags;
is non-zero, file descriptors opened in do_redirection () have their
close-on-exec flag set. */
int
-do_redirections (list, flags)
- REDIRECT *list;
- int flags;
+do_redirections (REDIRECT *list, int flags)
{
int error;
REDIRECT *temp;
/* Return non-zero if the redirection pointed to by REDIRECT has a
redirectee.filename that can be expanded. */
static int
-expandable_redirection_filename (redirect)
- REDIRECT *redirect;
+expandable_redirection_filename (REDIRECT *redirect)
{
switch (redirect->instruction)
{
/* Expand the word in WORD returning a string. If WORD expands to
multiple words (or no words), then return NULL. */
char *
-redirection_expand (word)
- WORD_DESC *word;
+redirection_expand (WORD_DESC *word)
{
char *result;
WORD_LIST *tlist1, *tlist2;
descriptor is specified. In particular, it adds a newline to the end of
a here-string to preserve previous semantics. */
static char *
-heredoc_expand (redirectee, ri, lenp)
- WORD_DESC *redirectee;
- enum r_instruction ri;
- size_t *lenp;
+heredoc_expand (WORD_DESC *redirectee, enum r_instruction ri, size_t *lenp)
{
char *document;
size_t dlen;
/* Write HEREDOC (of length HDLEN) to FD, returning 0 on success and ERRNO on
error. Don't handle interrupts. */
static int
-heredoc_write (fd, heredoc, herelen)
- int fd;
- char *heredoc;
- size_t herelen;
+heredoc_write (int fd, char *heredoc, size_t herelen)
{
ssize_t nw;
int e;
pointed to by REDIRECTEE, and return a file descriptor open for reading
to it. Return -1 on any error, and make sure errno is set appropriately. */
static int
-here_document_to_fd (redirectee, ri)
- WORD_DESC *redirectee;
- enum r_instruction ri;
+here_document_to_fd (WORD_DESC *redirectee, enum r_instruction ri)
{
char *filename;
int r, fd, fd2, herepipe[2];
};
static int
-redir_special_open (spec, filename, flags, mode, ri)
- int spec;
- char *filename;
- int flags, mode;
- enum r_instruction ri;
+redir_special_open (int spec, char *filename, int flags, int mode, enum r_instruction ri)
{
int fd;
#if !defined (HAVE_DEV_FD)
race conditions and avoiding the problem where the file is replaced
between the stat(2) and open(2). */
static int
-noclobber_open (filename, flags, mode, ri)
- char *filename;
- int flags, mode;
- enum r_instruction ri;
+noclobber_open (char *filename, int flags, int mode, enum r_instruction ri)
{
int r, fd;
struct stat finfo, finfo2;
}
static int
-redir_open (filename, flags, mode, ri)
- char *filename;
- int flags, mode;
- enum r_instruction ri;
+redir_open (char *filename, int flags, int mode, enum r_instruction ri)
{
int fd, r, e;
}
static int
-undoablefd (fd)
- int fd;
+undoablefd (int fd)
{
int clexec;
close-on-exec. FNP, if non-null is a pointer to a location where the
expanded filename is stored. The caller will free it. */
static int
-do_redirection_internal (redirect, flags, fnp)
- REDIRECT *redirect;
- int flags;
- char **fnp;
+do_redirection_internal (REDIRECT *redirect, int flags, char **fnp)
{
WORD_DESC *redirectee;
int redir_fd, fd, redirector, r, oflags;
puts the process over its fd limit, causing fcntl to fail, we try
again with SHELL_FD_BASE. Return 0 on success, -1 on error. */
static int
-add_undo_redirect (fd, ri, fdbase)
- int fd;
- enum r_instruction ri;
- int fdbase;
+add_undo_redirect (int fd, enum r_instruction ri, int fdbase)
{
int new_fd, clexec_flag, savefd_flag;
REDIRECT *new_redirect, *closer, *dummy_redirect;
/* Set up to close FD when we are finished with the current command
and its redirections. Return 0 on success, -1 on error. */
static int
-add_undo_close_redirect (fd)
- int fd;
+add_undo_close_redirect (int fd)
{
REDIRECT *closer;
REDIRECTEE sd;
}
static void
-add_exec_redirect (dummy_redirect)
- REDIRECT *dummy_redirect;
+add_exec_redirect (REDIRECT *dummy_redirect)
{
dummy_redirect->next = exec_redirection_undo_list;
exec_redirection_undo_list = dummy_redirect;
/* Return 1 if the redirection specified by RI and REDIRECTOR alters the
standard input. */
static int
-stdin_redirection (ri, redirector)
- enum r_instruction ri;
- int redirector;
+stdin_redirection (enum r_instruction ri, int redirector)
{
switch (ri)
{
/* Return non-zero if any of the redirections in REDIRS alter the standard
input. */
int
-stdin_redirects (redirs)
- REDIRECT *redirs;
+stdin_redirects (REDIRECT *redirs)
{
REDIRECT *rp;
int n;
}
/* bind_var_to_int handles array references */
static int
-redir_varassign (redir, fd)
- REDIRECT *redir;
- int fd;
+redir_varassign (REDIRECT *redir, int fd)
{
WORD_DESC *w;
SHELL_VAR *v;
/* Handles {array[ind]} for redirection words */
static int
-redir_varvalue (redir)
- REDIRECT *redir;
+redir_varvalue (REDIRECT *redir)
{
SHELL_VAR *v;
char *val, *w;
/* shell.c -- GNU's idea of the POSIX shell specification. */
-/* Copyright (C) 1987-2021 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
#include "jobs.h"
#else
extern int running_in_background;
-extern int initialize_job_control PARAMS((int));
-extern int get_tty_state PARAMS((void));
+extern int initialize_job_control (int);
+extern int get_tty_state (void);
#endif /* JOB_CONTROL */
#include "input.h"
static STRING_INT_ALIST *shopt_alist;
static int shopt_ind = 0, shopt_len = 0;
-static int parse_long_options PARAMS((char **, int, int));
-static int parse_shell_options PARAMS((char **, int, int));
-static int bind_args PARAMS((char **, int, int, int));
+static int parse_long_options (char **, int, int);
+static int parse_shell_options (char **, int, int);
+static int bind_args (char **, int, int, int);
-static void start_debugger PARAMS((void));
+static void start_debugger (void);
-static void add_shopt_to_alist PARAMS((char *, int));
-static void run_shopt_alist PARAMS((void));
+static void add_shopt_to_alist (char *, int);
+static void run_shopt_alist (void);
-static void execute_env_file PARAMS((char *));
-static void run_startup_files PARAMS((void));
-static int open_shell_script PARAMS((char *));
-static void set_bash_input PARAMS((void));
-static int run_one_command PARAMS((char *));
+static void execute_env_file (char *);
+static void run_startup_files (void);
+static int open_shell_script (char *);
+static void set_bash_input (void);
+static int run_one_command (char *);
#if defined (WORDEXP_OPTION)
-static int run_wordexp PARAMS((char *));
+static int run_wordexp (char *);
#endif
-static int uidget PARAMS((void));
+static int uidget (void);
-static void set_option_defaults PARAMS((void));
-static void reset_option_defaults PARAMS((void));
+static void set_option_defaults (void);
+static void reset_option_defaults (void);
-static void init_interactive PARAMS((void));
-static void init_noninteractive PARAMS((void));
-static void init_interactive_script PARAMS((void));
+static void init_interactive (void);
+static void init_noninteractive (void);
+static void init_interactive_script (void);
-static void set_shell_name PARAMS((char *));
-static void shell_initialize PARAMS((void));
-static void shell_reinitialize PARAMS((void));
+static void set_shell_name (char *);
+static void shell_initialize (void);
+static void shell_reinitialize (void);
-static void show_shell_usage PARAMS((FILE *, int));
+static void show_shell_usage (FILE *, int);
#ifdef __CYGWIN__
static void
-_cygwin32_check_tmp ()
+_cygwin32_check_tmp (void)
{
struct stat sb;
#if defined (NO_MAIN_ENV_ARG)
/* systems without third argument to main() */
int
-main (argc, argv)
- int argc;
- char **argv;
+main (int argc, char **argv)
#else /* !NO_MAIN_ENV_ARG */
int
-main (argc, argv, env)
- int argc;
- char **argv, **env;
+main (int argc, char **argv, char **env)
#endif /* !NO_MAIN_ENV_ARG */
{
register int i;
}
static int
-parse_long_options (argv, arg_start, arg_end)
- char **argv;
- int arg_start, arg_end;
+parse_long_options (char **argv, int arg_start, int arg_end)
{
int arg_index, longarg, i;
char *arg_string;
}
static int
-parse_shell_options (argv, arg_start, arg_end)
- char **argv;
- int arg_start, arg_end;
+parse_shell_options (char **argv, int arg_start, int arg_end)
{
int arg_index;
int arg_character, on_or_off, next_arg, i;
/* Exit the shell with status S. */
void
-exit_shell (s)
- int s;
+exit_shell (int s)
{
fflush (stdout); /* XXX */
fflush (stderr);
/* A wrapper for exit that (optionally) can do other things, like malloc
statistics tracing. */
void
-sh_exit (s)
- int s;
+sh_exit (int s)
{
#if defined (MALLOC_DEBUG) && defined (USING_BASH_MALLOC)
if (malloc_trace_at_exit && (subshell_environment & (SUBSHELL_COMSUB|SUBSHELL_PROCSUB)) == 0)
do any more cleanup, since a subshell is created as an exact copy of its
parent. */
void
-subshell_exit (s)
- int s;
+subshell_exit (int s)
{
fflush (stdout);
fflush (stderr);
}
void
-set_exit_status (s)
- int s;
+set_exit_status (int s)
{
set_pipestatus_from_exit (last_command_exit_value = s);
}
*/
static void
-execute_env_file (env_file)
- char *env_file;
+execute_env_file (char *env_file)
{
char *fn;
}
static void
-run_startup_files ()
+run_startup_files (void)
{
#if defined (JOB_CONTROL)
int old_job_control;
value of `restricted'. Don't actually do anything, just return a
boolean value. */
int
-shell_is_restricted (name)
- char *name;
+shell_is_restricted (char *name)
{
char *temp;
Do this also if `restricted' is already set to 1; maybe the shell was
started with -r. */
int
-maybe_make_restricted (name)
- char *name;
+maybe_make_restricted (char *name)
{
char *temp;
/* Fetch the current set of uids and gids and return 1 if we're running
setuid or setgid. */
static int
-uidget ()
+uidget (void)
{
uid_t u;
}
void
-disable_priv_mode ()
+disable_priv_mode (void)
{
int e;
#if defined (WORDEXP_OPTION)
static int
-run_wordexp (words)
- char *words;
+run_wordexp (char *words)
{
int code, nw, nb;
WORD_LIST *wl, *tl, *result;
/* Run one command, given as the argument to the -c option. Tell
parse_and_execute not to fork for a simple command. */
static int
-run_one_command (command)
- char *command;
+run_one_command (char *command)
{
int code;
#endif /* ONESHOT */
static int
-bind_args (argv, arg_start, arg_end, start_index)
- char **argv;
- int arg_start, arg_end, start_index;
+bind_args (char **argv, int arg_start, int arg_end, int start_index)
{
register int i;
WORD_LIST *args, *tl;
}
void
-unbind_args ()
+unbind_args (void)
{
remember_args ((WORD_LIST *)NULL, 1);
pop_args (); /* Reset BASH_ARGV and BASH_ARGC */
}
static void
-start_debugger ()
+start_debugger (void)
{
#if defined (DEBUGGER) && defined (DEBUGGER_START_FILE)
int old_errexit;
}
static int
-open_shell_script (script_name)
- char *script_name;
+open_shell_script (char *script_name)
{
int fd, e, fd_is_tty;
char *filename, *path_filename, *t;
/* Initialize the input routines for the parser. */
static void
-set_bash_input ()
+set_bash_input (void)
{
/* Make sure the fd from which we are reading input is not in
no-delay mode. */
is non-zero, we close default_buffered_input even if it's the standard
input (fd 0). */
void
-unset_bash_input (check_zero)
- int check_zero;
+unset_bash_input (int check_zero)
{
#if defined (BUFFERED_INPUT)
if ((check_zero && default_buffered_input >= 0) ||
#endif
static void
-set_shell_name (argv0)
- char *argv0;
+set_shell_name (char *argv0)
{
/* Here's a hack. If the name of this shell is "sh", then don't do
any startup files; just try to be more like /bin/sh. */
them after the call to list_minus_o_options (). */
/* XXX - could also do this for histexp_flag, jobs_m_flag */
static void
-set_option_defaults ()
+set_option_defaults (void)
{
#if defined (HISTORY)
enable_history_list = 0;
}
static void
-reset_option_defaults ()
+reset_option_defaults (void)
{
#if defined (HISTORY)
enable_history_list = -1;
}
static void
-init_interactive ()
+init_interactive (void)
{
expand_aliases = expaliases_flag = 1;
interactive_shell = startup_state = interactive = 1;
}
static void
-init_noninteractive ()
+init_noninteractive (void)
{
#if defined (HISTORY)
if (enable_history_list == -1) /* set default */
}
static void
-init_interactive_script ()
+init_interactive_script (void)
{
#if defined (HISTORY)
if (enable_history_list == -1)
}
void
-get_current_user_info ()
+get_current_user_info (void)
{
struct passwd *entry;
/* Do whatever is necessary to initialize the shell.
Put new initializations in here. */
static void
-shell_initialize ()
+shell_initialize (void)
{
char hostname[256];
int should_be_restricted;
had some initialization performed. This is supposed to reset the world
back to a pristine state, as if we had been exec'ed. */
static void
-shell_reinitialize ()
+shell_reinitialize (void)
{
/* The default shell prompts. */
primary_prompt = PPROMPT;
}
static void
-show_shell_usage (fp, extra)
- FILE *fp;
- int extra;
+show_shell_usage (FILE *fp, int extra)
{
int i;
char *set_opts, *s, *t;
}
static void
-add_shopt_to_alist (opt, on_or_off)
- char *opt;
- int on_or_off;
+add_shopt_to_alist (char *opt, int on_or_off)
{
if (shopt_ind >= shopt_len)
{
}
static void
-run_shopt_alist ()
+run_shopt_alist (void)
{
register int i;
#if defined (HAVE_UNISTD_H)
# ifdef _MINIX
-# include <sys/types.h>
+initialize_shell_signals (# include <sys/types.h>
# endif
# include <unistd.h>
#endif
# include "bashhist.h"
#endif
-extern void initialize_siglist PARAMS((void));
-extern void set_original_signal PARAMS((int, SigHandler *));
+extern void initialize_siglist (void);
+extern void set_original_signal (int, SigHandler *);
#if !defined (JOB_CONTROL)
-extern void initialize_job_signals PARAMS((void));
+extern void initialize_job_signals (void);
#endif
/* Non-zero after SIGINT. */
static SigHandler *old_winch = (SigHandler *)SIG_DFL;
#endif
-static void initialize_shell_signals PARAMS((void));
-static void kill_shell PARAMS((int));
+static void initialize_shell_signals (void);
+static void kill_shell (int);
void
-initialize_signals (reinit)
- int reinit;
+initialize_signals (int reinit)
{
initialize_shell_signals ();
initialize_job_signals ();
this when a trap is defined for EXIT (0) or when trap is run
to display signal dispositions. */
void
-initialize_terminating_signals ()
+initialize_terminating_signals (void)
{
register int i;
#if defined (HAVE_POSIX_SIGNALS)
}
static void
-initialize_shell_signals ()
+initialize_shell_signals (void)
{
if (interactive)
initialize_terminating_signals ();
}
void
-reset_terminating_signals ()
+reset_terminating_signals (void)
{
register int i;
#if defined (HAVE_POSIX_SIGNALS)
jump_to_top_level from a builtin command context. XXX - might want to
also call reset_parser here. */
void
-top_level_cleanup ()
+top_level_cleanup (void)
{
/* Clean up string parser environment. */
while (parse_and_execute_level)
/* What to do when we've been interrupted, and it is safe to handle it. */
void
-throw_to_top_level ()
+throw_to_top_level (void)
{
int print_newline = 0;
/* This is just here to isolate the longjmp calls. */
void
-jump_to_top_level (value)
- int value;
+jump_to_top_level (int value)
{
sh_longjmp (top_level, value);
}
void
-restore_sigmask ()
+restore_sigmask (void)
{
#if defined (JOB_CONTROL) || defined (HAVE_POSIX_SIGNALS)
sigprocmask (SIG_SETMASK, &top_level_mask, (sigset_t *)NULL);
static int handling_termsig = 0;
sighandler
-termsig_sighandler (sig)
- int sig;
+termsig_sighandler (int sig)
{
/* If we get called twice with the same signal before handling it,
terminate right away. */
}
void
-termsig_handler (sig)
- int sig;
+termsig_handler (int sig)
{
/* Simple semaphore to keep this function from being executed multiple
times. Since we no longer are running as a signal handler, we don't
}
static void
-kill_shell (sig)
- int sig;
+kill_shell (int sig)
{
int i, core;
sigset_t mask;
/* What we really do when SIGINT occurs. */
sighandler
-sigint_sighandler (sig)
- int sig;
+sigint_sighandler (int sig)
{
#if defined (MUST_REINSTALL_SIGHANDLERS)
signal (sig, sigint_sighandler);
#if defined (SIGWINCH)
sighandler
-sigwinch_sighandler (sig)
- int sig;
+sigwinch_sighandler (int sig)
{
#if defined (MUST_REINSTALL_SIGHANDLERS)
set_signal_handler (SIGWINCH, sigwinch_sighandler);
#endif /* SIGWINCH */
void
-set_sigwinch_handler ()
+set_sigwinch_handler (void)
{
#if defined (SIGWINCH)
old_winch = set_signal_handler (SIGWINCH, sigwinch_sighandler);
}
void
-unset_sigwinch_handler ()
+unset_sigwinch_handler (void)
{
#if defined (SIGWINCH)
set_signal_handler (SIGWINCH, old_winch);
}
sighandler
-sigterm_sighandler (sig)
- int sig;
+sigterm_sighandler (int sig)
{
sigterm_received = 1; /* XXX - counter? */
SIGRETURN (0);
#if !defined (HAVE_POSIX_SIGNALS)
/* Perform OPERATION on NEWSET, perhaps leaving information in OLDSET. */
-sigprocmask (operation, newset, oldset)
- int operation, *newset, *oldset;
+sigprocmask (int operation, int *newset, int *oldset)
{
int old, new;
#endif
SigHandler *
-set_signal_handler (sig, handler)
- int sig;
- SigHandler *handler;
+set_signal_handler (int sig, SigHandler *handler)
{
struct sigaction act, oact;
/* siglist.c -- signal list for those machines that don't have one. */
-/* Copyright (C) 1989-2021 Free Software Foundation, Inc.
+/* Copyright (C) 1989-2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
char *sys_siglist[NSIG];
void
-initialize_siglist ()
+initialize_siglist (void)
{
register int i;
/* stringlib.c - Miscellaneous string functions. */
-/* Copyright (C) 1996-2009 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2009,2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
/* Find STRING in ALIST, a list of string key/int value pairs. If FLAGS
is 1, STRING is treated as a pattern and matched using strmatch. */
int
-find_string_in_alist (string, alist, flags)
- char *string;
- STRING_INT_ALIST *alist;
- int flags;
+find_string_in_alist (char *string, STRING_INT_ALIST *alist, int flags)
{
register int i;
int r;
corresponding string. Allocates memory for the returned
string. FLAGS is currently ignored, but reserved. */
char *
-find_token_in_alist (token, alist, flags)
- int token;
- STRING_INT_ALIST *alist;
- int flags;
+find_token_in_alist (int token, STRING_INT_ALIST *alist, int flags)
{
register int i;
}
int
-find_index_in_alist (string, alist, flags)
- char *string;
- STRING_INT_ALIST *alist;
- int flags;
+find_index_in_alist (char *string, STRING_INT_ALIST *alist, int flags)
{
register int i;
int r;
/* Cons a new string from STRING starting at START and ending at END,
not including END. */
char *
-substring (string, start, end)
- const char *string;
- int start, end;
+substring (const char *string, int start, int end)
{
register int len;
register char *result;
replace all occurrences, otherwise replace only the first.
This returns a new string; the caller should free it. */
char *
-strsub (string, pat, rep, global)
- char *string, *pat, *rep;
- int global;
+strsub (char *string, char *pat, char *rep, int global)
{
size_t patlen, replen, templen, tempsize, i;
int repl;
globbing. Backslash may be used to quote C. If (FLAGS & 2) we allow
backslash to escape backslash as well. */
char *
-strcreplace (string, c, text, flags)
- char *string;
- int c;
- const char *text;
- int flags;
+strcreplace (char *string, int c, const char *text, int flags)
{
char *ret, *p, *r, *t;
size_t len, rlen, ind, tlen;
/* Remove all leading whitespace from STRING. This includes
newlines. STRING should be terminated with a zero. */
void
-strip_leading (string)
- char *string;
+strip_leading (char *string)
{
char *start = string;
newlines. If NEWLINES_ONLY is non-zero, only trailing newlines
are removed. STRING should be terminated with a zero. */
void
-strip_trailing (string, len, newlines_only)
- char *string;
- int len;
- int newlines_only;
+strip_trailing (char *string, int len, int newlines_only)
{
while (len >= 0)
{
/* A wrapper for bcopy that can be prototyped in general.h */
void
-xbcopy (s, d, n)
- char *s, *d;
- int n;
+xbcopy (char *s, char *d, size_t n)
{
FASTCOPY (s, d, n);
}
/* An expansion function that takes a string and a quoted flag and returns
a WORD_LIST *. Used as the type of the third argument to
expand_string_if_necessary(). */
-typedef WORD_LIST *EXPFUNC PARAMS((char *, int));
+typedef WORD_LIST *EXPFUNC (char *, int);
/* Process ID of the last command executed within command substitution. */
pid_t last_command_subst_pid = NO_PID;
#endif
#if !defined (HAVE_WCSDUP) && defined (HANDLE_MULTIBYTE)
-extern wchar_t *wcsdup PARAMS((const wchar_t *));
+extern wchar_t *wcsdup (const wchar_t *);
#endif
#if 0
without any leading variable assignments. */
static WORD_LIST *garglist = (WORD_LIST *)NULL;
-static char *quoted_substring PARAMS((char *, int, int));
-static int quoted_strlen PARAMS((char *));
-static char *quoted_strchr PARAMS((char *, int, int));
+static char *quoted_substring (char *, int, int);
+static int quoted_strlen (char *);
+static char *quoted_strchr (char *, int, int);
-static char *expand_string_if_necessary PARAMS((char *, int, EXPFUNC *));
-static inline char *expand_string_to_string_internal PARAMS((char *, int, EXPFUNC *));
-static WORD_LIST *call_expand_word_internal PARAMS((WORD_DESC *, int, int, int *, int *));
-static WORD_LIST *expand_string_internal PARAMS((char *, int));
-static WORD_LIST *expand_string_leave_quoted PARAMS((char *, int));
-static WORD_LIST *expand_string_for_rhs PARAMS((char *, int, int, int, int *, int *));
-static WORD_LIST *expand_string_for_pat PARAMS((char *, int, int *, int *));
+static char *expand_string_if_necessary (char *, int, EXPFUNC *);
+static inline char *expand_string_to_string_internal (char *, int, EXPFUNC *);
+static WORD_LIST *call_expand_word_internal (WORD_DESC *, int, int, int *, int *);
+static WORD_LIST *expand_string_internal (char *, int);
+static WORD_LIST *expand_string_leave_quoted (char *, int);
+static WORD_LIST *expand_string_for_rhs (char *, int, int, int, int *, int *);
+static WORD_LIST *expand_string_for_pat (char *, int, int *, int *);
-static char *quote_escapes_internal PARAMS((const char *, int));
+static char *quote_escapes_internal (const char *, int);
-static WORD_LIST *list_quote_escapes PARAMS((WORD_LIST *));
-static WORD_LIST *list_dequote_escapes PARAMS((WORD_LIST *));
+static WORD_LIST *list_quote_escapes (WORD_LIST *);
+static WORD_LIST *list_dequote_escapes (WORD_LIST *);
-static char *make_quoted_char PARAMS((int));
-static WORD_LIST *quote_list PARAMS((WORD_LIST *));
+static char *make_quoted_char (int);
+static WORD_LIST *quote_list (WORD_LIST *);
-static int unquoted_substring PARAMS((char *, char *));
-static int unquoted_member PARAMS((int, char *));
+static int unquoted_substring (char *, char *);
+static int unquoted_member (int, char *);
#if defined (ARRAY_VARS)
-static SHELL_VAR *do_compound_assignment PARAMS((char *, char *, int));
+static SHELL_VAR *do_compound_assignment (char *, char *, int);
#endif
-static int do_assignment_internal PARAMS((const WORD_DESC *, int));
+static int do_assignment_internal (const WORD_DESC *, int);
-static char *string_extract_verbatim PARAMS((char *, size_t, int *, char *, int));
-static char *string_extract PARAMS((char *, int *, char *, int));
-static char *string_extract_double_quoted PARAMS((char *, int *, int));
-static inline char *string_extract_single_quoted PARAMS((char *, int *, int));
-static inline int skip_single_quoted PARAMS((const char *, size_t, int, int));
-static int skip_double_quoted PARAMS((char *, size_t, int, int));
-static char *extract_delimited_string PARAMS((char *, int *, char *, char *, char *, int));
-static char *extract_heredoc_dolbrace_string PARAMS((char *, int *, int, int));
-static char *extract_dollar_brace_string PARAMS((char *, int *, int, int));
-static int skip_matched_pair PARAMS((const char *, int, int, int, int));
+static char *string_extract_verbatim (char *, size_t, int *, char *, int);
+static char *string_extract (char *, int *, char *, int);
+static char *string_extract_double_quoted (char *, int *, int);
+static inline char *string_extract_single_quoted (char *, int *, int);
+static inline int skip_single_quoted (const char *, size_t, int, int);
+static int skip_double_quoted (char *, size_t, int, int);
+static char *extract_delimited_string (char *, int *, char *, char *, char *, int);
+static char *extract_heredoc_dolbrace_string (char *, int *, int, int);
+static char *extract_dollar_brace_string (char *, int *, int, int);
+static int skip_matched_pair (const char *, int, int, int, int);
-static char *pos_params PARAMS((char *, int, int, int, int));
+static char *pos_params (char *, int, int, int, int);
-static unsigned char *mb_getcharlens PARAMS((char *, int));
+static unsigned char *mb_getcharlens (char *, int);
-static char *remove_upattern PARAMS((char *, char *, int));
+static char *remove_upattern (char *, char *, int);
#if defined (HANDLE_MULTIBYTE)
-static wchar_t *remove_wpattern PARAMS((wchar_t *, size_t, wchar_t *, int));
+static wchar_t *remove_wpattern (wchar_t *, size_t, wchar_t *, int);
#endif
-static char *remove_pattern PARAMS((char *, char *, int));
+static char *remove_pattern (char *, char *, int);
-static int match_upattern PARAMS((char *, char *, int, char **, char **));
+static int match_upattern (char *, char *, int, char **, char **);
#if defined (HANDLE_MULTIBYTE)
-static int match_wpattern PARAMS((wchar_t *, char **, size_t, wchar_t *, int, char **, char **));
-#endif
-static int match_pattern PARAMS((char *, char *, int, char **, char **));
-static int getpatspec PARAMS((int, char *));
-static char *getpattern PARAMS((char *, int, int));
-static char *variable_remove_pattern PARAMS((char *, char *, int, int));
-static char *list_remove_pattern PARAMS((WORD_LIST *, char *, int, int, int));
-static char *parameter_list_remove_pattern PARAMS((int, char *, int, int));
+static int match_wpattern (wchar_t *, char **, size_t, wchar_t *, int, char **, char **);
+#endif
+static int match_pattern (char *, char *, int, char **, char **);
+static int getpatspec (int, char *);
+static char *getpattern (char *, int, int);
+static char *variable_remove_pattern (char *, char *, int, int);
+static char *list_remove_pattern (WORD_LIST *, char *, int, int, int);
+static char *parameter_list_remove_pattern (int, char *, int, int);
#ifdef ARRAY_VARS
-static char *array_remove_pattern PARAMS((SHELL_VAR *, char *, int, int, int));
+static char *array_remove_pattern (SHELL_VAR *, char *, int, int, int);
#endif
-static char *parameter_brace_remove_pattern PARAMS((char *, char *, array_eltstate_t *, char *, int, int, int));
+static char *parameter_brace_remove_pattern (char *, char *, array_eltstate_t *, char *, int, int, int);
-static char *string_var_assignment PARAMS((SHELL_VAR *, char *));
+static char *string_var_assignment (SHELL_VAR *, char *);
#if defined (ARRAY_VARS)
-static char *array_var_assignment PARAMS((SHELL_VAR *, int, int, int));
+static char *array_var_assignment (SHELL_VAR *, int, int, int);
#endif
-static char *pos_params_assignment PARAMS((WORD_LIST *, int, int));
-static char *string_transform PARAMS((int, SHELL_VAR *, char *));
-static char *list_transform PARAMS((int, SHELL_VAR *, WORD_LIST *, int, int));
-static char *parameter_list_transform PARAMS((int, int, int));
+static char *pos_params_assignment (WORD_LIST *, int, int);
+static char *string_transform (int, SHELL_VAR *, char *);
+static char *list_transform (int, SHELL_VAR *, WORD_LIST *, int, int);
+static char *parameter_list_transform (int, int, int);
#if defined ARRAY_VARS
-static char *array_transform PARAMS((int, SHELL_VAR *, int, int));
+static char *array_transform (int, SHELL_VAR *, int, int);
#endif
-static char *parameter_brace_transform PARAMS((char *, char *, array_eltstate_t *, char *, int, int, int, int));
-static int valid_parameter_transform PARAMS((char *));
+static char *parameter_brace_transform (char *, char *, array_eltstate_t *, char *, int, int, int, int);
+static int valid_parameter_transform (char *);
-static char *process_substitute PARAMS((char *, int));
+static char *process_substitute (char *, int);
-static char *optimize_cat_file PARAMS((REDIRECT *, int, int, int *));
-static char *read_comsub PARAMS((int, int, int, int *));
+static char *optimize_cat_file (REDIRECT *, int, int, int *);
+static char *read_comsub (int, int, int, int *);
#ifdef ARRAY_VARS
-static arrayind_t array_length_reference PARAMS((char *));
+static arrayind_t array_length_reference (char *);
#endif
-static int valid_brace_expansion_word PARAMS((char *, int));
-static int chk_atstar PARAMS((char *, int, int, int *, int *));
-static int chk_arithsub PARAMS((const char *, int));
+static int valid_brace_expansion_word (char *, int);
+static int chk_atstar (char *, int, int, int *, int *);
+static int chk_arithsub (const char *, int);
-static WORD_DESC *parameter_brace_expand_word PARAMS((char *, int, int, int, array_eltstate_t *));
-static char *parameter_brace_find_indir PARAMS((char *, int, int, int));
-static WORD_DESC *parameter_brace_expand_indir PARAMS((char *, int, int, int, int *, int *));
-static WORD_DESC *parameter_brace_expand_rhs PARAMS((char *, char *, int, int, int, int *, int *));
-static void parameter_brace_expand_error PARAMS((char *, char *, int));
+static WORD_DESC *parameter_brace_expand_word (char *, int, int, int, array_eltstate_t *);
+static char *parameter_brace_find_indir (char *, int, int, int);
+static WORD_DESC *parameter_brace_expand_indir (char *, int, int, int, int *, int *);
+static WORD_DESC *parameter_brace_expand_rhs (char *, char *, int, int, int, int *, int *);
+static void parameter_brace_expand_error (char *, char *, int);
-static int valid_length_expression PARAMS((char *));
-static intmax_t parameter_brace_expand_length PARAMS((char *));
+static int valid_length_expression (char *);
+static intmax_t parameter_brace_expand_length (char *);
-static char *skiparith PARAMS((char *, int));
-static int verify_substring_values PARAMS((SHELL_VAR *, char *, char *, int, intmax_t *, intmax_t *));
-static int get_var_and_type PARAMS((char *, char *, array_eltstate_t *, int, int, SHELL_VAR **, char **));
-static char *mb_substring PARAMS((char *, int, int));
-static char *parameter_brace_substring PARAMS((char *, char *, array_eltstate_t *, char *, int, int, int));
+static char *skiparith (char *, int);
+static int verify_substring_values (SHELL_VAR *, char *, char *, int, intmax_t *, intmax_t *);
+static int get_var_and_type (char *, char *, array_eltstate_t *, int, int, SHELL_VAR **, char **);
+static char *mb_substring (char *, int, int);
+static char *parameter_brace_substring (char *, char *, array_eltstate_t *, char *, int, int, int);
-static int shouldexp_replacement PARAMS((char *));
+static int shouldexp_replacement (char *);
-static char *pos_params_pat_subst PARAMS((char *, char *, char *, int));
+static char *pos_params_pat_subst (char *, char *, char *, int);
-static char *expand_string_for_patsub PARAMS((char *, int));
-static char *parameter_brace_patsub PARAMS((char *, char *, array_eltstate_t *, char *, int, int, int));
+static char *expand_string_for_patsub (char *, int);
+static char *parameter_brace_patsub (char *, char *, array_eltstate_t *, char *, int, int, int);
-static char *pos_params_casemod PARAMS((char *, char *, int, int));
-static char *parameter_brace_casemod PARAMS((char *, char *, array_eltstate_t *, int, char *, int, int, int));
+static char *pos_params_casemod (char *, char *, int, int);
+static char *parameter_brace_casemod (char *, char *, array_eltstate_t *, int, char *, int, int, int);
-static WORD_DESC *parameter_brace_expand PARAMS((char *, int *, int, int, int *, int *));
-static WORD_DESC *param_expand PARAMS((char *, int *, int, int *, int *, int *, int *, int));
+static WORD_DESC *parameter_brace_expand (char *, int *, int, int, int *, int *);
+static WORD_DESC *param_expand (char *, int *, int, int *, int *, int *, int *, int);
-static WORD_LIST *expand_word_internal PARAMS((WORD_DESC *, int, int, int *, int *));
+static WORD_LIST *expand_word_internal (WORD_DESC *, int, int, int *, int *);
-static WORD_LIST *word_list_split PARAMS((WORD_LIST *));
+static WORD_LIST *word_list_split (WORD_LIST *);
-static void exp_jump_to_top_level PARAMS((int));
+static void exp_jump_to_top_level (int);
-static WORD_LIST *separate_out_assignments PARAMS((WORD_LIST *));
-static WORD_LIST *glob_expand_word_list PARAMS((WORD_LIST *, int));
+static WORD_LIST *separate_out_assignments (WORD_LIST *);
+static WORD_LIST *glob_expand_word_list (WORD_LIST *, int);
#ifdef BRACE_EXPANSION
-static WORD_LIST *brace_expand_word_list PARAMS((WORD_LIST *, int));
+static WORD_LIST *brace_expand_word_list (WORD_LIST *, int);
#endif
#if defined (ARRAY_VARS)
-static int make_internal_declare PARAMS((char *, char *, char *));
-static void expand_compound_assignment_word PARAMS((WORD_LIST *, int));
-static WORD_LIST *expand_declaration_argument PARAMS((WORD_LIST *, WORD_LIST *));
+static int make_internal_declare (char *, char *, char *);
+static void expand_compound_assignment_word (WORD_LIST *, int);
+static WORD_LIST *expand_declaration_argument (WORD_LIST *, WORD_LIST *);
#endif
-static WORD_LIST *shell_expand_word_list PARAMS((WORD_LIST *, int));
-static WORD_LIST *expand_word_list_internal PARAMS((WORD_LIST *, int));
+static WORD_LIST *shell_expand_word_list (WORD_LIST *, int);
+static WORD_LIST *expand_word_list_internal (WORD_LIST *, int);
-static int do_assignment_statements PARAMS((WORD_LIST *, char *, int));
+static int do_assignment_statements (WORD_LIST *, char *, int);
/* **************************************************************** */
/* */
#if defined (DEBUG)
void
-dump_word_flags (flags)
- int flags;
+dump_word_flags (int flags)
{
int f;
#ifdef INCLUDE_UNUSED
static char *
-quoted_substring (string, start, end)
- char *string;
- int start, end;
+quoted_substring (char *string, int start, int end)
{
register int len, l;
register char *result, *s, *r;
#ifdef INCLUDE_UNUSED
/* Return the length of S, skipping over quoted characters */
static int
-quoted_strlen (s)
- char *s;
+quoted_strlen (char *s)
{
register char *p;
int i;
characters are skipped. If (FLAGS & ST_CTLESC) is non-zero, characters
escaped with CTLESC are skipped. */
static char *
-quoted_strchr (s, c, flags)
- char *s;
- int c, flags;
+quoted_strchr (char *s, int c, int flags)
{
register char *p;
/* Return 1 if CHARACTER appears in an unquoted portion of
STRING. Return 0 otherwise. CHARACTER must be a single-byte character. */
static int
-unquoted_member (character, string)
- int character;
- char *string;
+unquoted_member (int character, char *string)
{
size_t slen;
int sindex, c;
/* Return 1 if SUBSTR appears in an unquoted portion of STRING. */
static int
-unquoted_substring (substr, string)
- char *substr, *string;
+unquoted_substring (char *substr, char *string)
{
size_t slen;
int sindex, c, sublen;
case nothing happens. Gets rid of SOURCE by freeing it.
Returns TARGET in case the location has changed. */
INLINE char *
-sub_append_string (source, target, indx, size)
- char *source, *target;
- size_t *indx;
- size_t *size;
+sub_append_string (char *source, char *target, size_t *indx, size_t *size)
{
if (source)
{
/* Append the textual representation of NUMBER to TARGET.
INDX and SIZE are as in SUB_APPEND_STRING. */
char *
-sub_append_number (number, target, indx, size)
- intmax_t number;
- char *target;
- size_t *indx;
- size_t *size;
+sub_append_number (intmax_t number, char *target, size_t *indx, size_t *size)
{
char *temp;
update SINDEX. If (flags & SX_REQMATCH) is non-zero, the string must
contain a closing character from CHARLIST. */
static char *
-string_extract (string, sindex, charlist, flags)
- char *string;
- int *sindex;
- char *charlist;
- int flags;
+string_extract (char *string, int *sindex, char *charlist, int flags)
{
register int c, i;
int found;
Backslashes between the embedded double quotes are processed. If STRIPDQ
is zero, an unquoted `"' terminates the string. */
static char *
-string_extract_double_quoted (string, sindex, flags)
- char *string;
- int *sindex, flags;
+string_extract_double_quoted (char *string, int *sindex, int flags)
{
size_t slen;
char *send;
/* This should really be another option to string_extract_double_quoted. */
static int
-skip_double_quoted (string, slen, sind, flags)
- char *string;
- size_t slen;
- int sind;
- int flags;
+skip_double_quoted (char *string, size_t slen, int sind, int flags)
{
int c, i;
char *ret;
the closing single quote. ALLOWESC allows the single quote to be quoted by
a backslash; it's not used yet. */
static inline char *
-string_extract_single_quoted (string, sindex, allowesc)
- char *string;
- int *sindex;
- int allowesc;
+string_extract_single_quoted (char *string, int *sindex, int allowesc)
{
register int i;
size_t slen;
that we are splitting out words for completion and have encountered a $'...'
string, which allows backslash-escaped single quotes. */
static inline int
-skip_single_quoted (string, slen, sind, flags)
- const char *string;
- size_t slen;
- int sind;
- int flags;
+skip_single_quoted (const char *string, size_t slen, int sind, int flags)
{
register int c;
DECLARE_MBSTATE;
/* Just like string_extract, but doesn't hack backslashes or any of
that other stuff. Obeys CTLESC quoting. Used to do splitting on $IFS. */
static char *
-string_extract_verbatim (string, slen, sindex, charlist, flags)
- char *string;
- size_t slen;
- int *sindex;
- char *charlist;
- int flags;
+string_extract_verbatim (char *string, size_t slen, int *sindex, char *charlist, int flags)
{
register int i;
#if defined (HANDLE_MULTIBYTE)
Make (SINDEX) get the position of the matching ")". )
XFLAGS is additional flags to pass to other extraction functions. */
char *
-extract_command_subst (string, sindex, xflags)
- char *string;
- int *sindex;
- int xflags;
+extract_command_subst (char *string, int *sindex, int xflags)
{
char *ret;
Start extracting at (SINDEX) as if we had just seen "$[".
Make (SINDEX) get the position of the matching "]". */
char *
-extract_arithmetic_subst (string, sindex)
- char *string;
- int *sindex;
+extract_arithmetic_subst (char *string, int *sindex)
{
return (extract_delimited_string (string, sindex, "$[", "[", "]", 0)); /*]*/
}
Start extracting at (SINDEX) as if we had just seen "<(".
Make (SINDEX) get the position of the matching ")". */ /*))*/
char *
-extract_process_subst (string, starter, sindex, xflags)
- char *string;
- char *starter;
- int *sindex;
- int xflags;
+extract_process_subst (char *string, char *starter, int *sindex, int xflags)
{
#if 0
/* XXX - check xflags&SX_COMPLETE here? */
each caller verifies that the last character in STRING is a right paren,
we don't even need to call extract_delimited_string. */
char *
-extract_array_assignment_list (string, sindex)
- char *string;
- int *sindex;
+extract_array_assignment_list (char *string, int *sindex)
{
int slen;
char *ret;
contains a character string that can also match CLOSER and thus
needs to be skipped. */
static char *
-extract_delimited_string (string, sindex, opener, alt_opener, closer, flags)
- char *string;
- int *sindex;
- char *opener, *alt_opener, *closer;
- int flags;
+extract_delimited_string (char *string, int *sindex, char *opener, char *alt_opener, char *closer, int flags)
{
int i, c, si;
size_t slen;
This needs to match the logic in parse.y:parse_matched_pair so we get
consistent behavior between here-documents and double-quoted strings. */
static char *
-extract_heredoc_dolbrace_string (string, sindex, quoted, flags)
- char *string;
- int *sindex, quoted, flags;
+extract_heredoc_dolbrace_string (char *string, int *sindex, int quoted, int flags)
{
register int i, c;
size_t slen, tlen, result_index, result_size;
occurs inside double quotes. */
/* XXX -- this is very similar to extract_delimited_string -- XXX */
static char *
-extract_dollar_brace_string (string, sindex, quoted, flags)
- char *string;
- int *sindex, quoted, flags;
+extract_dollar_brace_string (char *string, int *sindex, int quoted, int flags)
{
register int i, c;
size_t slen;
/* Remove backslashes which are quoting backquotes from STRING. Modifies
STRING, and returns a pointer to it. */
char *
-de_backslash (string, qflags)
- char *string;
- int qflags;
+de_backslash (char *string, int qflags)
{
register size_t slen;
register int i, j, prev_i;
/*UNUSED*/
/* Replace instances of \! in a string with !. */
void
-unquote_bang (string)
- char *string;
+unquote_bang (char *string)
{
register int i, j;
register char *temp;
arrayfunc.c:assign_compound_array_list()) or during execution by a builtin
which has already undergone word expansion. */
static int
-skip_matched_pair (string, start, open, close, flags)
- const char *string;
- int start, open, close, flags;
+skip_matched_pair (const char *string, int start, int open, int close, int flags)
{
int i, pass_next, backq, si, c, count, oldjmp;
size_t slen;
character past the open bracket; FLAGS & 2 == 0 means that STRING[START]
points to the open bracket. skip_matched_pair knows how to deal with this. */
int
-skipsubscript (string, start, flags)
- const char *string;
- int start, flags;
+skipsubscript (const char *string, int start, int flags)
{
return (skip_matched_pair (string, start, '[', ']', flags));
}
a lot of shell syntax. It's very similar to skip_double_quoted and other
functions of that ilk. */
int
-skip_to_delim (string, start, delims, flags)
- char *string;
- int start;
- char *delims;
- int flags;
+skip_to_delim (char *string, int start, char *delims, int flags)
{
int i, pass_next, backq, dquote, si, c, oldjmp;
int invert, skipquote, skipcmd, noprocsub, completeflag;
down version of skip_to_delims. The essential difference is that this
resets the quoting state when starting a command substitution */
int
-skip_to_histexp (string, start, delims, flags)
- char *string;
- int start;
- char *delims;
- int flags;
+skip_to_histexp (char *string, int start, char *delims, int flags)
{
int i, pass_next, backq, dquote, c, oldjmp;
int histexp_comsub, histexp_backq, old_dquote;
rl_completer_quote_characters. */
int
-char_is_quoted (string, eindex)
- char *string;
- int eindex;
+char_is_quoted (char *string, int eindex)
{
int i, pass_next, c, oldjmp;
size_t slen;
}
int
-unclosed_pair (string, eindex, openstr)
- char *string;
- int eindex;
- char *openstr;
+unclosed_pair (char *string, int eindex, char *openstr)
{
int i, pass_next, openc, olen;
size_t slen;
the index of the word containing SENTINEL. Non-whitespace chars in
DELIMS delimit separate fields. This is used by programmable completion. */
WORD_LIST *
-split_at_delims (string, slen, delims, sentinel, flags, nwp, cwp)
- char *string;
- int slen;
- const char *delims;
- int sentinel, flags;
- int *nwp, *cwp;
+split_at_delims (char *string, int slen, const char *delims, int sentinel, int flags, int *nwp, int *cwp)
{
int ts, te, i, nw, cw, ifs_split, dflags;
char *token, *d, *d2;
/* UNUSED */
/* Extract the name of the variable to bind to from the assignment string. */
char *
-assignment_name (string)
- char *string;
+assignment_name (char *string)
{
int offset;
char *temp;
/* Return a single string of all the words in LIST. SEP is the separator
to put between individual elements of LIST in the output string. */
char *
-string_list_internal (list, sep)
- WORD_LIST *list;
- char *sep;
+string_list_internal (WORD_LIST *list, char *sep)
{
register WORD_LIST *t;
char *result, *r;
/* Return a single string of all the words present in LIST, separating
each word with a space. */
char *
-string_list (list)
- WORD_LIST *list;
+string_list (WORD_LIST *list)
{
return (string_list_internal (list, " "));
}
the multibyte complications. If LENP is non-null, it is set to the
length of the returned string. */
char *
-ifs_firstchar (lenp)
- int *lenp;
+ifs_firstchar (int *lenp)
{
char *ret;
int len;
/* Posix interpretation 888 changes this when IFS is null by specifying
that when unquoted, this expands to separate arguments */
char *
-string_list_dollar_star (list, quoted, flags)
- WORD_LIST *list;
- int quoted, flags;
+string_list_dollar_star (WORD_LIST *list, int quoted, int flags)
{
char *ret;
#if defined (HANDLE_MULTIBYTE)
one that we didn't handle before is assignment statement arguments to
declaration builtins like `declare'. */
char *
-string_list_dollar_at (list, quoted, flags)
- WORD_LIST *list;
- int quoted;
- int flags;
+string_list_dollar_at (WORD_LIST *list, int quoted, int flags)
{
char *ifs, *ret;
#if defined (HANDLE_MULTIBYTE)
/* This needs to fully understand the additional contexts where word
splitting does not occur (W_ASSIGNRHS, etc.) */
char *
-string_list_pos_params (pchar, list, quoted, pflags)
- int pchar;
- WORD_LIST *list;
- int quoted, pflags;
+string_list_pos_params (int pchar, WORD_LIST *list, int quoted, int pflags)
{
char *ret;
WORD_LIST *tlist;
: ifs_whitespace (c))
WORD_LIST *
-list_string (string, separators, quoted)
- register char *string, *separators;
- int quoted;
+list_string (char *string, char *separators, int quoted)
{
WORD_LIST *result;
WORD_DESC *t;
STRING is quoted or if there are no separator characters. We use the
Posix definition of whitespace as a member of the space character
class in the current locale. */
-#if 0
- if (!quoted || !separators || !*separators)
-#else
/* issep() requires that separators be non-null, and always returns 0 if
separator is the empty string, so don't bother if we get an empty string
for separators. We already returned NULL above if STRING is empty. */
if (!quoted && separators && *separators)
-#endif
{
for (s = string; *s && issep (*s) && ifs_whitespace (*s); s++);
#define islocalsep(c) (local_cmap[(unsigned char)(c)] != 0)
char *
-get_word_from_string (stringp, separators, endptr)
- char **stringp, *separators, **endptr;
+get_word_from_string (char **stringp, char *separators, char **endptr)
{
register char *s;
char *current_word;
Only let CTLESC escape a white space character if SAW_ESCAPE is
non-zero. */
char *
-strip_trailing_ifs_whitespace (string, separators, saw_escape)
- char *string, *separators;
- int saw_escape;
+strip_trailing_ifs_whitespace (char *string, char *separators, int saw_escape)
{
char *s;
/* Split STRING into words at whitespace. Obeys shell-style quoting with
backslashes, single and double quotes. */
WORD_LIST *
-list_string_with_quotes (string)
- char *string;
+list_string_with_quotes (char *string)
{
WORD_LIST *list;
char *token, *s;
#if defined (ARRAY_VARS)
static SHELL_VAR *
-do_compound_assignment (name, value, flags)
- char *name, *value;
- int flags;
+do_compound_assignment (char *name, char *value, int flags)
{
SHELL_VAR *v;
int mklocal, mkassoc, mkglobal, chklocal;
expansion on the right-hand side. Perform tilde expansion in any
case. Do not perform word splitting on the result of expansion. */
static int
-do_assignment_internal (word, expand)
- const WORD_DESC *word;
- int expand;
+do_assignment_internal (const WORD_DESC *word, int expand)
{
int offset, appendop, assign_list, aflags, retval;
char *name, *value, *temp;
/* Perform the assignment statement in STRING, and expand the
right side by doing tilde, command and parameter expansion. */
int
-do_assignment (string)
- char *string;
+do_assignment (char *string)
{
WORD_DESC td;
}
int
-do_word_assignment (word, flags)
- WORD_DESC *word;
- int flags;
+do_word_assignment (WORD_DESC *word, int flags)
{
return do_assignment_internal (word, 1);
}
of the `=', and bind it to the left side. Do not perform any word
expansions on the right hand side. */
int
-do_assignment_no_expand (string)
- char *string;
+do_assignment_no_expand (char *string)
{
WORD_DESC td;
/* Return the word list that corresponds to `$*'. */
WORD_LIST *
-list_rest_of_args ()
+list_rest_of_args (void)
{
register WORD_LIST *list, *args;
int i;
/* Return the value of a positional parameter. This handles values > 10. */
char *
-get_dollar_var_value (ind)
- intmax_t ind;
+get_dollar_var_value (intmax_t ind)
{
char *temp;
WORD_LIST *p;
and the rest_of_args. If DOLLAR_STAR is 1, then obey the special
case of "$*" with respect to IFS. */
char *
-string_rest_of_args (dollar_star)
- int dollar_star;
+string_rest_of_args (int dollar_star)
{
register WORD_LIST *list;
char *string;
Q_HERE_DOCUMENT or Q_DOUBLE_QUOTES, this returns a quoted list, otherwise
no quoting chars are added. */
static char *
-pos_params (string, start, end, quoted, pflags)
- char *string;
- int start, end, quoted, pflags;
+pos_params (char *string, int start, int end, int quoted, int pflags)
{
WORD_LIST *save, *params, *h, *t;
char *ret;
then call FUNC to expand STRING; otherwise just perform quote
removal if necessary. This returns a new string. */
static char *
-expand_string_if_necessary (string, quoted, func)
- char *string;
- int quoted;
- EXPFUNC *func;
+expand_string_if_necessary (char *string, int quoted, EXPFUNC *func)
{
WORD_LIST *list;
size_t slen;
}
static inline char *
-expand_string_to_string_internal (string, quoted, func)
- char *string;
- int quoted;
- EXPFUNC *func;
+expand_string_to_string_internal (char *string, int quoted, EXPFUNC *func)
{
WORD_LIST *list;
char *ret;
}
char *
-expand_string_to_string (string, quoted)
- char *string;
- int quoted;
+expand_string_to_string (char *string, int quoted)
{
return (expand_string_to_string_internal (string, quoted, expand_string));
}
char *
-expand_string_unsplit_to_string (string, quoted)
- char *string;
- int quoted;
+expand_string_unsplit_to_string (char *string, int quoted)
{
return (expand_string_to_string_internal (string, quoted, expand_string_unsplit));
}
char *
-expand_assignment_string_to_string (string, quoted)
- char *string;
- int quoted;
+expand_assignment_string_to_string (char *string, int quoted)
{
return (expand_string_to_string_internal (string, quoted, expand_string_assignment));
}
or a backslash into a backslash. The output of this function must eventually
be processed by strcreplace(). */
static char *
-quote_string_for_repl (string, flags)
- char *string;
- int flags;
+quote_string_for_repl (char *string, int flags)
{
size_t slen;
char *result, *t;
backslash escapes before CTLESC-quoted backslash and `& if
patsub_replacement is enabled. */
static char *
-expand_string_for_patsub (string, quoted)
- char *string;
- int quoted;
+expand_string_for_patsub (char *string, int quoted)
{
WORD_LIST *value;
char *ret, *t;
}
char *
-expand_arith_string (string, quoted)
- char *string;
- int quoted;
+expand_arith_string (char *string, int quoted)
{
WORD_DESC td;
WORD_LIST *list, *tlist;
#if defined (COND_COMMAND)
/* Just remove backslashes in STRING. Returns a new string. */
char *
-remove_backslashes (string)
- char *string;
+remove_backslashes (char *string)
{
char *r, *ret, *s;
any case, since we don't perform word splitting, we need to do quoted
null character removal. */
char *
-cond_expand_word (w, special)
- WORD_DESC *w;
- int special;
+cond_expand_word (WORD_DESC *w, int special)
{
char *r, *p;
WORD_LIST *l;
FLAGS argument is 1 if this function should treat CTLESC as a quote
character (e.g., for here-documents) or not (e.g., for shell_expand_line). */
char *
-expand_string_dollar_quote (string, flags)
- char *string;
- int flags;
+expand_string_dollar_quote (char *string, int flags)
{
size_t slen, retind, retsize;
int sindex, c, translen, peekc, news;
A convenience function for functions that don't want to handle
any errors or free any memory before aborting. */
static WORD_LIST *
-call_expand_word_internal (w, q, i, c, e)
- WORD_DESC *w;
- int q, i, *c, *e;
+call_expand_word_internal (WORD_DESC *w, int q, int i, int *c, int *e)
{
WORD_LIST *result;
Since this does not perform word splitting, it leaves quoted nulls
in the result. */
static WORD_LIST *
-expand_string_internal (string, quoted)
- char *string;
- int quoted;
+expand_string_internal (char *string, int quoted)
{
WORD_DESC td;
WORD_LIST *tresult;
remove_quoted_nulls () is in here because word splitting normally
takes care of quote removal. */
WORD_LIST *
-expand_string_unsplit (string, quoted)
- char *string;
- int quoted;
+expand_string_unsplit (char *string, int quoted)
{
WORD_LIST *value;
/* Expand the rhs of an assignment statement */
WORD_LIST *
-expand_string_assignment (string, quoted)
- char *string;
- int quoted;
+expand_string_assignment (char *string, int quoted)
{
WORD_DESC td;
WORD_LIST *value;
passed string when an error occurs. Might want to trap other calls
to jump_to_top_level here so we don't endlessly loop. */
WORD_LIST *
-expand_prompt_string (string, quoted, wflags)
- char *string;
- int quoted;
- int wflags;
+expand_prompt_string (char *string, int quoted, int wflags)
{
WORD_LIST *value;
WORD_DESC td;
things like ${1+"$@"}. This does parameter expansion, command
substitution, arithmetic expansion, and word splitting. */
static WORD_LIST *
-expand_string_leave_quoted (string, quoted)
- char *string;
- int quoted;
+expand_string_leave_quoted (char *string, int quoted)
{
WORD_LIST *tlist;
WORD_LIST *tresult;
/* This does not perform word splitting or dequote the WORD_LIST
it returns. */
static WORD_LIST *
-expand_string_for_rhs (string, quoted, op, pflags, dollar_at_p, expanded_p)
- char *string;
- int quoted, op, pflags;
- int *dollar_at_p, *expanded_p;
+expand_string_for_rhs (char *string, int quoted, int op, int pflags, int *dollar_at_p, int *expanded_p)
{
WORD_DESC td;
WORD_LIST *tresult;
/* This does not perform word splitting or dequote the WORD_LIST
it returns and it treats $* as if it were quoted. */
static WORD_LIST *
-expand_string_for_pat (string, quoted, dollar_at_p, expanded_p)
- char *string;
- int quoted, *dollar_at_p, *expanded_p;
+expand_string_for_pat (char *string, int quoted, int *dollar_at_p, int *expanded_p)
{
WORD_DESC td;
WORD_LIST *tresult;
does parameter expansion, command substitution, arithmetic expansion,
and word splitting. Dequote the resultant WORD_LIST before returning. */
WORD_LIST *
-expand_string (string, quoted)
- char *string;
- int quoted;
+expand_string (char *string, int quoted)
{
WORD_LIST *result;
word splitting, and quote removal. */
WORD_LIST *
-expand_word (word, quoted)
- WORD_DESC *word;
- int quoted;
+expand_word (WORD_DESC *word, int quoted)
{
WORD_LIST *result, *tresult;
does parameter expansion, command substitution, arithmetic expansion,
and quote removal. */
WORD_LIST *
-expand_word_unsplit (word, quoted)
- WORD_DESC *word;
- int quoted;
+expand_word_unsplit (WORD_DESC *word, int quoted)
{
WORD_LIST *result;
quote removal on the result. Virtually identical to expand_word_unsplit;
could be combined if implementations don't diverge. */
WORD_LIST *
-expand_word_leave_quoted (word, quoted)
- WORD_DESC *word;
- int quoted;
+expand_word_leave_quoted (WORD_DESC *word, int quoted)
{
WORD_LIST *result;
and there is a CTLESC or CTLNUL in IFS, we need to quote CTLESC and CTLNUL,
respectively, to prevent them from being removed as part of dequoting. */
static char *
-quote_escapes_internal (string, flags)
- const char *string;
- int flags;
+quote_escapes_internal (const char *string, int flags)
{
const char *s, *send;
char *t, *result;
}
char *
-quote_escapes (string)
- const char *string;
+quote_escapes (const char *string)
{
return (quote_escapes_internal (string, 0));
}
char *
-quote_rhs (string)
- const char *string;
+quote_rhs (const char *string)
{
return (quote_escapes_internal (string, PF_NOSPLIT2));
}
static WORD_LIST *
-list_quote_escapes (list)
- WORD_LIST *list;
+list_quote_escapes (WORD_LIST *list)
{
register WORD_LIST *w;
char *t;
Also used by parts of the pattern substitution code. */
char *
-dequote_escapes (string)
- const char *string;
+dequote_escapes (const char *string)
{
const char *s, *send;
char *t, *result;
#if defined (INCLUDE_UNUSED)
static WORD_LIST *
-list_dequote_escapes (list)
- WORD_LIST *list;
+list_dequote_escapes (WORD_LIST *list)
{
register WORD_LIST *w;
char *t;
This turns "" into QUOTED_NULL, so the W_HASQUOTEDNULL flag needs to be
set in any resultant WORD_DESC where this value is the word. */
static char *
-make_quoted_char (c)
- int c;
+make_quoted_char (int c)
{
char *temp;
the W_HASQUOTEDNULL flag needs to be set in any resultant WORD_DESC where
this value is the word. */
char *
-quote_string (string)
- char *string;
+quote_string (char *string)
{
register char *t;
size_t slen;
/* De-quote quoted characters in STRING. */
char *
-dequote_string (string)
- char *string;
+dequote_string (char *string)
{
register char *s, *t;
size_t slen;
/* Quote the entire WORD_LIST list. */
static WORD_LIST *
-quote_list (list)
- WORD_LIST *list;
+quote_list (WORD_LIST *list)
{
register WORD_LIST *w;
char *t;
}
WORD_DESC *
-dequote_word (word)
- WORD_DESC *word;
+dequote_word (WORD_DESC *word)
{
register char *s;
/* De-quote quoted characters in each word in LIST. */
WORD_LIST *
-dequote_list (list)
- WORD_LIST *list;
+dequote_list (WORD_LIST *list)
{
register char *s;
register WORD_LIST *tlist;
/* Remove CTLESC protecting a CTLESC or CTLNUL in place. Return the passed
string. */
char *
-remove_quoted_escapes (string)
- char *string;
+remove_quoted_escapes (char *string)
{
char *t;
if no word splitting takes place. This returns newly-allocated memory,
so callers can use it to replace savestring(). */
char *
-remove_quoted_ifs (string)
- char *string;
+remove_quoted_ifs (char *string)
{
register size_t slen;
register int i, j;
}
char *
-remove_quoted_nulls (string)
- char *string;
+remove_quoted_nulls (char *string)
{
register size_t slen;
register int i, j, prev_i;
/* Perform quoted null character removal on each element of LIST.
This modifies LIST. */
void
-word_list_remove_quoted_nulls (list)
- WORD_LIST *list;
+word_list_remove_quoted_nulls (WORD_LIST *list)
{
register WORD_LIST *t;
#if defined (HANDLE_MULTIBYTE)
# ifdef INCLUDE_UNUSED
static unsigned char *
-mb_getcharlens (string, len)
- char *string;
- int len;
+mb_getcharlens (char *string, int len)
{
int i, offset, last;
unsigned char *ret;
/* Returns its first argument if nothing matched; new memory otherwise */
static char *
-remove_upattern (param, pattern, op)
- char *param, *pattern;
- int op;
+remove_upattern (char *param, char *pattern, int op)
{
register size_t len;
register char *end;
#if defined (HANDLE_MULTIBYTE)
/* Returns its first argument if nothing matched; new memory otherwise */
static wchar_t *
-remove_wpattern (wparam, wstrlen, wpattern, op)
- wchar_t *wparam;
- size_t wstrlen;
- wchar_t *wpattern;
- int op;
+remove_wpattern (wchar_t *wparam, size_t wstrlen, wchar_t *wpattern, int op)
{
wchar_t wc, *ret;
int n;
#endif /* HANDLE_MULTIBYTE */
static char *
-remove_pattern (param, pattern, op)
- char *param, *pattern;
- int op;
+remove_pattern (char *param, char *pattern, int op)
{
char *xret;
MATCH_BEG and MATCH_END anchor the match at the beginning and end
of the string, respectively. The longest match is returned. */
static int
-match_upattern (string, pat, mtype, sp, ep)
- char *string, *pat;
- int mtype;
- char **sp, **ep;
+match_upattern (char *string, char *pat, int mtype, char **sp, char **ep)
{
int c, mlen;
size_t len;
This returns 1 in case of a successful match, 0 otherwise. Wide
character version. */
static int
-match_wpattern (wstring, indices, wstrlen, wpat, mtype, sp, ep)
- wchar_t *wstring;
- char **indices;
- size_t wstrlen;
- wchar_t *wpat;
- int mtype;
- char **sp, **ep;
+match_wpattern (wchar_t *wstring, char **indices, size_t wstrlen, wchar_t *wpat,
+ int mtype, char **sp, char **ep)
{
wchar_t wc, *wp, *nwpat, *wp1;
size_t len;
#endif /* HANDLE_MULTIBYTE */
static int
-match_pattern (string, pat, mtype, sp, ep)
- char *string, *pat;
- int mtype;
- char **sp, **ep;
+match_pattern (char *string, char *pat, int mtype, char **sp, char **ep)
{
#if defined (HANDLE_MULTIBYTE)
int ret;
}
static int
-getpatspec (c, value)
- int c;
- char *value;
+getpatspec (int c, char *value)
{
if (c == '#')
return ((*value == '#') ? RP_LONG_LEFT : RP_SHORT_LEFT);
special pattern characters quoted. For example, the `*' in the
following retains its special meaning: "${foo#'*'}". */
static char *
-getpattern (value, quoted, expandpat)
- char *value;
- int quoted, expandpat;
+getpattern (char *value, int quoted, int expandpat)
{
char *pat, *tword;
WORD_LIST *l;
/* Handle removing a pattern from a string as a result of ${name%[%]value}
or ${name#[#]value}. */
static char *
-variable_remove_pattern (value, pattern, patspec, quoted)
- char *value, *pattern;
- int patspec, quoted;
+variable_remove_pattern (char *value, char *pattern, int patspec, int quoted)
{
char *tword;
#endif
static char *
-list_remove_pattern (list, pattern, patspec, itype, quoted)
- WORD_LIST *list;
- char *pattern;
- int patspec, itype, quoted;
+list_remove_pattern (WORD_LIST *list, char *pattern, int patspec, int itype, int quoted)
{
WORD_LIST *new, *l;
WORD_DESC *w;
}
static char *
-parameter_list_remove_pattern (itype, pattern, patspec, quoted)
- int itype;
- char *pattern;
- int patspec, quoted;
+parameter_list_remove_pattern (int itype, char *pattern, int patspec, int quoted)
{
char *ret;
WORD_LIST *list;
}
#if defined (ARRAY_VARS)
+/* STARSUB is so we can figure out how it's indexed */
static char *
-array_remove_pattern (var, pattern, patspec, starsub, quoted)
- SHELL_VAR *var;
- char *pattern;
- int patspec;
- int starsub; /* so we can figure out how it's indexed */
- int quoted;
+array_remove_pattern (SHELL_VAR *var, char *pattern, int patspec, int starsub, int quoted)
{
ARRAY *a;
HASH_TABLE *h;
#endif /* ARRAY_VARS */
static char *
-parameter_brace_remove_pattern (varname, value, estatep, patstr, rtype, quoted, flags)
- char *varname, *value;
- array_eltstate_t *estatep;
- char *patstr;
- int rtype, quoted, flags;
+parameter_brace_remove_pattern (char *varname, char *value,
+ array_eltstate_t *estatep, char *patstr,
+ int rtype, int quoted, int flags)
{
int vtype, patspec, starsub;
char *temp1, *val, *pattern, *oname;
#if defined (PROCESS_SUBSTITUTION)
-static void reap_some_procsubs PARAMS((int));
-
/*****************************************************************/
/* */
/* Hacking Process Substitution */
/* */
/*****************************************************************/
+static void reap_some_procsubs (int);
+
#if !defined (HAVE_DEV_FD)
/* Named pipes must be removed explicitly with `unlink'. This keeps a list
of FIFOs the shell has open. unlink_fifo_list will walk the list and
static int fifo_list_size;
void
-clear_fifo_list ()
+clear_fifo_list (void)
{
int i;
}
void *
-copy_fifo_list (sizep)
- int *sizep;
+copy_fifo_list (int *sizep)
{
if (sizep)
*sizep = 0;
}
static void
-add_fifo_list (pathname)
- char *pathname;
+add_fifo_list (char *pathname)
{
int osize, i;
}
void
-unlink_fifo (i)
- int i;
+unlink_fifo (int i)
{
if ((fifo_list[i].proc == (pid_t)-1) || (fifo_list[i].proc > 0 && (kill(fifo_list[i].proc, 0) == -1)))
{
}
void
-unlink_fifo_list ()
+unlink_fifo_list (void)
{
int saved, i, j;
}
void
-unlink_all_fifos ()
+unlink_all_fifos (void)
{
int i, fd;
everything in fifo_list. LSIZE is the number of elements in LIST, in
case it's larger than fifo_list_size (size of fifo_list). */
void
-close_new_fifos (list, lsize)
- void *list;
- int lsize;
+close_new_fifos (void *list, int lsize)
{
int i;
char *plist;
}
int
-find_procsub_child (pid)
- pid_t pid;
+find_procsub_child (pid_t pid)
{
int i;
}
void
-set_procsub_status (ind, pid, status)
- int ind;
- pid_t pid;
- int status;
+set_procsub_status (int ind, pid_t pid, int status)
{
if (ind >= 0 && ind < nfifo)
fifo_list[ind].proc = (pid_t)-1; /* sentinel */
/* If we've marked the process for this procsub as dead, close the
associated file descriptor and delete the FIFO. */
static void
-reap_some_procsubs (max)
- int max;
+reap_some_procsubs (int max)
{
int i;
}
void
-reap_procsubs ()
+reap_procsubs (void)
{
reap_some_procsubs (nfifo);
}
#if 0
/* UNUSED */
void
-wait_procsubs ()
+wait_procsubs (void)
{
int i, r;
#endif
int
-fifos_pending ()
+fifos_pending (void)
{
return nfifo;
}
int
-num_fifos ()
+num_fifos (void)
{
return nfifo;
}
static char *
-make_named_pipe ()
+make_named_pipe (void)
{
char *tname;
static int totfds; /* The highest possible number of open files. */
void
-clear_fifo (i)
- int i;
+clear_fifo (int i)
{
if (dev_fd_list[i])
{
}
void
-clear_fifo_list ()
+clear_fifo_list (void)
{
register int i;
}
void *
-copy_fifo_list (sizep)
- int *sizep;
+copy_fifo_list (int *sizep)
{
void *ret;
}
static void
-add_fifo_list (fd)
- int fd;
+add_fifo_list (int fd)
{
if (dev_fd_list == 0 || fd >= totfds)
{
}
int
-fifos_pending ()
+fifos_pending (void)
{
return 0; /* used for cleanup; not needed with /dev/fd */
}
int
-num_fifos ()
+num_fifos (void)
{
return nfds;
}
void
-unlink_fifo (fd)
- int fd;
+unlink_fifo (int fd)
{
if (dev_fd_list[fd])
{
}
void
-unlink_fifo_list ()
+unlink_fifo_list (void)
{
register int i;
}
void
-unlink_all_fifos ()
+unlink_all_fifos (void)
{
unlink_fifo_list ();
}
LSIZE is the number of elements in LIST, in case it's larger than
totfds (size of dev_fd_list). */
void
-close_new_fifos (list, lsize)
- void *list;
- int lsize;
+close_new_fifos (void *list, int lsize)
{
int i;
pid_t *plist;
}
int
-find_procsub_child (pid)
- pid_t pid;
+find_procsub_child (pid_t pid)
{
int i;
}
void
-set_procsub_status (ind, pid, status)
- int ind;
- pid_t pid;
- int status;
+set_procsub_status (int ind, pid_t pid, int status)
{
if (ind >= 0 && ind < totfds)
dev_fd_list[ind] = (pid_t)-1; /* sentinel */
/* If we've marked the process for this procsub as dead, close the
associated file descriptor. */
static void
-reap_some_procsubs (max)
- int max;
+reap_some_procsubs (int max)
{
int i;
}
void
-reap_procsubs ()
+reap_procsubs (void)
{
reap_some_procsubs (totfds);
}
#if 0
/* UNUSED */
void
-wait_procsubs ()
+wait_procsubs (void)
{
int i, r;
#endif
#if defined (NOTDEF)
-print_dev_fd_list ()
+print_dev_fd_list (void)
{
register int i;
#endif /* NOTDEF */
static char *
-make_dev_fd_filename (fd)
- int fd;
+make_dev_fd_filename (int fd)
{
char *ret, intbuf[INT_STRLEN_BOUND (int) + 1], *p;
file descriptor to fd 1 in the child. The parent does the opposite. */
static char *
-process_substitute (string, open_for_read_in_child)
- char *string;
- int open_for_read_in_child;
+process_substitute (char *string, int open_for_read_in_child)
{
char *pathname;
int fd, result, rc, function_value;
#define COMSUB_PIPEBUF 4096
static char *
-optimize_cat_file (r, quoted, flags, flagp)
- REDIRECT *r;
- int quoted, flags, *flagp;
+optimize_cat_file (REDIRECT *r, int quoted, int flags, int *flagp)
{
char *ret;
int fd;
}
static char *
-read_comsub (fd, quoted, flags, rflag)
- int fd, quoted, flags;
- int *rflag;
+read_comsub (int fd, int quoted, int flags, int *rflag)
{
char *istring, buf[COMSUB_PIPEBUF], *bufp;
int c, tflag, skip_ctlesc, skip_ctlnul;
/* Perform command substitution on STRING. This returns a WORD_DESC * with the
contained string possibly quoted. */
WORD_DESC *
-command_substitute (string, quoted, flags)
- char *string;
- int quoted;
- int flags;
+command_substitute (char *string, int quoted, int flags)
{
pid_t pid, old_pid, old_pipeline_pgrp, old_async_pid;
char *istring, *s;
#if defined (ARRAY_VARS)
static arrayind_t
-array_length_reference (s)
- char *s;
+array_length_reference (char *s)
{
int len;
arrayind_t ind;
#endif /* ARRAY_VARS */
static int
-valid_brace_expansion_word (name, var_is_special)
- char *name;
- int var_is_special;
+valid_brace_expansion_word (char *name, int var_is_special)
{
if (DIGIT (*name) && all_digits (name))
return 1;
}
static int
-chk_atstar (name, quoted, pflags, quoted_dollar_atp, contains_dollar_at)
- char *name;
- int quoted, pflags;
- int *quoted_dollar_atp, *contains_dollar_at;
+chk_atstar (char *name, int quoted, int pflags, int *quoted_dollar_atp, int *contains_dollar_at)
{
char *temp1;
the shell, e.g., "@", "$", "*", etc. QUOTED, if non-zero, means that
NAME was found inside of a double-quoted expression. */
static WORD_DESC *
-parameter_brace_expand_word (name, var_is_special, quoted, pflags, estatep)
- char *name;
- int var_is_special, quoted, pflags;
- array_eltstate_t *estatep;
+parameter_brace_expand_word (char *name, int var_is_special, int quoted, int pflags, array_eltstate_t *estatep)
{
WORD_DESC *ret;
char *temp, *tt;
}
static char *
-parameter_brace_find_indir (name, var_is_special, quoted, find_nameref)
- char *name;
- int var_is_special, quoted, find_nameref;
+parameter_brace_find_indir (char *name, int var_is_special, int quoted, int find_nameref)
{
char *temp, *t;
WORD_DESC *w;
/* Expand an indirect reference to a variable: ${!NAME} expands to the
value of the variable whose name is the value of NAME. */
static WORD_DESC *
-parameter_brace_expand_indir (name, var_is_special, quoted, pflags, quoted_dollar_atp, contains_dollar_at)
- char *name;
- int var_is_special, quoted, pflags;
- int *quoted_dollar_atp, *contains_dollar_at;
+parameter_brace_expand_indir (char *name, int var_is_special, int quoted, int pflags, int *quoted_dollar_atp, int *contains_dollar_at)
{
char *t;
WORD_DESC *w;
"-", "+", or "=". QUOTED is true if the entire brace expression occurs
between double quotes. */
static WORD_DESC *
-parameter_brace_expand_rhs (name, value, op, quoted, pflags, qdollaratp, hasdollarat)
- char *name, *value;
- int op, quoted, pflags, *qdollaratp, *hasdollarat;
+parameter_brace_expand_rhs (char *name, char *value,
+ int op, int quoted, int pflags,
+ int *qdollaratp, int *hasdollarat)
{
WORD_DESC *w;
WORD_LIST *l, *tl;
used as the error message to print, otherwise a standard message is
printed. */
static void
-parameter_brace_expand_error (name, value, check_null)
- char *name, *value;
- int check_null;
+parameter_brace_expand_error (char *name, char *value, int check_null)
{
WORD_LIST *l;
char *temp;
/* Return 1 if NAME is something for which parameter_brace_expand_length is
OK to do. */
static int
-valid_length_expression (name)
- char *name;
+valid_length_expression (char *name)
{
return (name[1] == '\0' || /* ${#} */
((sh_syntaxtab[(unsigned char) name[1]] & CSPECVAR) && name[2] == '\0') || /* special param */
/* Handle the parameter brace expansion that requires us to return the
length of a parameter. */
static intmax_t
-parameter_brace_expand_length (name)
- char *name;
+parameter_brace_expand_length (char *name)
{
char *t, *newname;
intmax_t number, arg_index;
*/
static char *
-skiparith (substr, delim)
- char *substr;
- int delim;
+skiparith (char *substr, int delim)
{
int i;
char delims[2];
Return value is 1 if both values were OK, 0 if there was a problem
with an invalid expression, or -1 if the values were out of range. */
static int
-verify_substring_values (v, value, substr, vtype, e1p, e2p)
- SHELL_VAR *v;
- char *value, *substr;
- int vtype;
- intmax_t *e1p, *e2p;
+verify_substring_values (SHELL_VAR *v, char *value, char *substr, int vtype,
+ intmax_t *e1p, intmax_t *e2p)
{
char *t, *temp1, *temp2;
arrayind_t len;
characters in the value are quoted with CTLESC and takes appropriate
steps. For convenience, *VALP is set to the dequoted VALUE. */
static int
-get_var_and_type (varname, value, estatep, quoted, flags, varp, valp)
- char *varname, *value;
- array_eltstate_t *estatep;
- int quoted, flags;
- SHELL_VAR **varp;
- char **valp;
+get_var_and_type (char *varname, char *value, array_eltstate_t *estatep, int quoted, int flags,
+ SHELL_VAR **varp, char **valp)
{
int vtype, want_indir;
char *temp, *vname;
/***********************************************************/
static char *
-string_var_assignment (v, s)
- SHELL_VAR *v;
- char *s;
+string_var_assignment (SHELL_VAR *v, char *s)
{
char flags[MAX_ATTRIBUTES], *ret, *val;
int i;
#if defined (ARRAY_VARS)
static char *
-array_var_assignment (v, itype, quoted, atype)
- SHELL_VAR *v;
- int itype, quoted, atype;
+array_var_assignment (SHELL_VAR *v, int itype, int quoted, int atype)
{
char *ret, *val, flags[MAX_ATTRIBUTES];
int i;
#endif
static char *
-pos_params_assignment (list, itype, quoted)
- WORD_LIST *list;
- int itype;
- int quoted;
+pos_params_assignment (WORD_LIST *list, int itype, int quoted)
{
char *temp, *ret;
}
static char *
-string_transform (xc, v, s)
- int xc;
- SHELL_VAR *v;
- char *s;
+string_transform (int xc, SHELL_VAR *v, char *s)
{
char *ret, flags[MAX_ATTRIBUTES], *t;
int i;
}
static char *
-list_transform (xc, v, list, itype, quoted)
- int xc;
- SHELL_VAR *v;
- WORD_LIST *list;
- int itype, quoted;
+list_transform (int xc, SHELL_VAR *v, WORD_LIST *list, int itype, int quoted)
{
WORD_LIST *new, *l;
WORD_DESC *w;
}
static char *
-parameter_list_transform (xc, itype, quoted)
- int xc;
- int itype;
- int quoted;
+parameter_list_transform (int xc, int itype, int quoted)
{
char *ret;
WORD_LIST *list;
}
#if defined (ARRAY_VARS)
+/* STARSUB so we can figure out how it's indexed */
static char *
-array_transform (xc, var, starsub, quoted)
- int xc;
- SHELL_VAR *var;
- int starsub; /* so we can figure out how it's indexed */
- int quoted;
+array_transform (int xc, SHELL_VAR *var, int starsub, int quoted)
{
ARRAY *a;
HASH_TABLE *h;
}
#endif /* ARRAY_VARS */
-static int
-valid_parameter_transform (xform)
- char *xform;
+static inline int
+valid_parameter_transform (char *xform)
{
if (xform[1])
return 0;
}
static char *
-parameter_brace_transform (varname, value, estatep, xform, rtype, quoted, pflags, flags)
- char *varname, *value;
- array_eltstate_t *estatep;
- char *xform;
- int rtype, quoted, pflags, flags;
+parameter_brace_transform (char *varname, char *value, array_eltstate_t *estatep,
+ char *xform, int rtype, int quoted, int pflags, int flags)
{
int vtype, xc, starsub;
char *temp1, *val, *oname;
multibyte character) positions that require calculation.
Used by the ${param:offset[:length]} expansion. */
static char *
-mb_substring (string, s, e)
- char *string;
- int s, e;
+mb_substring (char *string, int s, int e)
{
char *tt;
int start, stop, i;
VARNAME. If VARNAME is an array variable, use the array elements. */
static char *
-parameter_brace_substring (varname, value, estatep, substr, quoted, pflags, flags)
- char *varname, *value;
- array_eltstate_t *estatep;
- char *substr;
- int quoted, pflags, flags;
+parameter_brace_substring (char *varname, char *value, array_eltstate_t *estatep,
+ char *substr, int quoted, int pflags, int flags)
{
intmax_t e1, e2;
int vtype, r, starsub;
/****************************************************************/
static int
-shouldexp_replacement (s)
- char *s;
+shouldexp_replacement (char *s)
{
size_t slen;
int sindex, c;
}
char *
-pat_subst (string, pat, rep, mflags)
- char *string, *pat, *rep;
- int mflags;
+pat_subst (char *string, char *pat, char *rep, int mflags)
{
char *ret, *s, *e, *str, *rstr, *mstr, *send;
int rptr, mtype, rxpand, mlen;
/* Do pattern match and replacement on the positional parameters. */
static char *
-pos_params_pat_subst (string, pat, rep, mflags)
- char *string, *pat, *rep;
- int mflags;
+pos_params_pat_subst (char *string, char *pat, char *rep, int mflags)
{
WORD_LIST *save, *params;
WORD_DESC *w;
and the string to substitute. QUOTED is a flags word containing
the type of quoting currently in effect. */
static char *
-parameter_brace_patsub (varname, value, estatep, patsub, quoted, pflags, flags)
- char *varname, *value;
- array_eltstate_t *estatep;
- char *patsub;
- int quoted, pflags, flags;
+parameter_brace_patsub (char *varname, char *value, array_eltstate_t *estatep,
+ char *patsub, int quoted, int pflags, int flags)
{
int vtype, mflags, starsub, delim;
char *val, *temp, *pat, *rep, *p, *lpatsub, *tt, *oname;
/* Do case modification on the positional parameters. */
static char *
-pos_params_modcase (string, pat, modop, mflags)
- char *string, *pat;
- int modop;
- int mflags;
+pos_params_modcase (char *string, char *pat, int modop, int mflags)
{
WORD_LIST *save, *params;
WORD_DESC *w;
to perform. QUOTED is a flags word containing the type of quoting
currently in effect. */
static char *
-parameter_brace_casemod (varname, value, estatep, modspec, patspec, quoted, pflags, flags)
- char *varname, *value;
- array_eltstate_t *estatep;
- int modspec;
- char *patspec;
- int quoted, pflags, flags;
+parameter_brace_casemod (char *varname, char *value, array_eltstate_t *estatep,
+ int modspec, char *patspec, int quoted, int pflags, int flags)
{
int vtype, starsub, modop, mflags, x;
char *val, *temp, *pat, *p, *lpat, *tt, *oname;
means that this must not be an arithmetic expression, though the parser
will not accept it without a balanced total number of parens. */
static int
-chk_arithsub (s, len)
- const char *s;
- int len;
+chk_arithsub (const char *s, int len)
{
int i, count;
DECLARE_MBSTATE;
/* ${[#][!]name[[:][^[^]][,[,]]#[#]%[%]-=?+[word][:e1[:e2]]]} */
static WORD_DESC *
-parameter_brace_expand (string, indexp, quoted, pflags, quoted_dollar_atp, contains_dollar_at)
- char *string;
- int *indexp, quoted, pflags, *quoted_dollar_atp, *contains_dollar_at;
+parameter_brace_expand (char *string, int *indexp, int quoted, int pflags, int *quoted_dollar_atp, int *contains_dollar_at)
{
int check_nullness, var_is_set, var_is_null, var_is_special;
int want_substring, want_indir, want_patsub, want_casemod, want_attributes;
the braces are used, parameter_brace_expand() does the work,
possibly calling param_expand recursively. */
static WORD_DESC *
-param_expand (string, sindex, quoted, expanded_something,
- contains_dollar_at, quoted_dollar_at_p, had_quoted_null_p,
- pflags)
- char *string;
- int *sindex, quoted, *expanded_something, *contains_dollar_at;
- int *quoted_dollar_at_p, *had_quoted_null_p, pflags;
+param_expand (char *string, int *sindex, int quoted,
+ int *expanded_something, int *contains_dollar_at, int *quoted_dollar_at_p,
+ int *had_quoted_null_p, int pflags)
{
char *temp, *temp1, uerror[3], *savecmd;
int zindex, t_index, expok, eflag;
/* Run an array subscript through the appropriate word expansions. */
char *
-expand_subscript_string (string, quoted)
- char *string;
- int quoted;
+expand_subscript_string (char *string, int quoted)
{
WORD_DESC td;
WORD_LIST *tlist;
only expand it once, we quote the characters that would start another
expansion and the bracket characters that are special to array subscripts. */
static char *
-expand_array_subscript (string, sindex, quoted, flags)
- char *string;
- int *sindex;
- int quoted, flags;
+expand_array_subscript (char *string, int *sindex, int quoted, int flags)
{
char *ret, *exp, *t;
size_t slen;
#endif
void
-invalidate_cached_quoted_dollar_at ()
+invalidate_cached_quoted_dollar_at (void)
{
dispose_words (cached_quoted_dollar_at);
cached_quoted_dollar_at = 0;
#define WHOLLY_QUOTED 2
static WORD_LIST *
-expand_word_internal (word, quoted, isexp, contains_dollar_at, expanded_something)
- WORD_DESC *word;
- int quoted, isexp;
- int *contains_dollar_at;
- int *expanded_something;
+expand_word_internal (WORD_DESC *word, int quoted, int isexp, int *contains_dollar_at, int *expanded_something)
{
WORD_LIST *list;
WORD_DESC *tword;
/* Perform quote removal on STRING. If QUOTED > 0, assume we are obeying the
backslash quoting rules for within double quotes or a here document. */
char *
-string_quote_removal (string, quoted)
- char *string;
- int quoted;
+string_quote_removal (char *string, int quoted)
{
size_t slen;
char *r, *result_string, *temp, *send;
/* Perform quote removal on word WORD. This allocates and returns a new
WORD_DESC *. */
WORD_DESC *
-word_quote_removal (word, quoted)
- WORD_DESC *word;
- int quoted;
+word_quote_removal (WORD_DESC *word, int quoted)
{
WORD_DESC *w;
char *t;
the members of the list are treated as if they are surrounded by
double quotes. Return a new list, or NULL if LIST is NULL. */
WORD_LIST *
-word_list_quote_removal (list, quoted)
- WORD_LIST *list;
- int quoted;
+word_list_quote_removal (WORD_LIST *list, int quoted)
{
WORD_LIST *result, *t, *tresult, *e;
for (t = list, result = (WORD_LIST *)NULL; t; t = t->next)
{
tresult = make_word_list (word_quote_removal (t->word, quoted), (WORD_LIST *)NULL);
-#if 0
- result = (WORD_LIST *) list_append (result, tresult);
-#else
if (result == 0)
result = e = tresult;
else
while (e->next)
e = e->next;
}
-#endif
}
return (result);
}
*******************************************/
void
-setifs (v)
- SHELL_VAR *v;
+setifs (SHELL_VAR *v)
{
char *t;
unsigned char uc;
}
char *
-getifs ()
+getifs (void)
{
return ifs_value;
}
is not quoted. list_string () performs quote removal for us, even if we
don't do any splitting. */
WORD_LIST *
-word_split (w, ifs_chars)
- WORD_DESC *w;
- char *ifs_chars;
+word_split (WORD_DESC *w, char *ifs_chars)
{
WORD_LIST *result;
/* Perform word splitting on LIST and return the RESULT. It is possible
to return (WORD_LIST *)NULL. */
static WORD_LIST *
-word_list_split (list)
- WORD_LIST *list;
+word_list_split (WORD_LIST *list)
{
WORD_LIST *result, *t, *tresult, *e;
WORD_DESC *w;
/* Do any word-expansion-specific cleanup and jump to top_level */
static void
-exp_jump_to_top_level (v)
- int v;
+exp_jump_to_top_level (int v)
{
set_pipestatus_from_exit (last_command_exit_value);
variable assignments and other environment assignments are placed
on SUBST_ASSIGN_VARLIST. */
static WORD_LIST *
-separate_out_assignments (tlist)
- WORD_LIST *tlist;
+separate_out_assignments (WORD_LIST *tlist)
{
register WORD_LIST *vp, *lp;
variable assignments. */
WORD_LIST *
-expand_words (list)
- WORD_LIST *list;
+expand_words (WORD_LIST *list)
{
return (expand_word_list_internal (list, WEXP_ALL));
}
/* Same as expand_words (), but doesn't hack variable or environment
variables. */
WORD_LIST *
-expand_words_no_vars (list)
- WORD_LIST *list;
+expand_words_no_vars (WORD_LIST *list)
{
return (expand_word_list_internal (list, WEXP_NOVARS));
}
WORD_LIST *
-expand_words_shellexp (list)
- WORD_LIST *list;
+expand_words_shellexp (WORD_LIST *list)
{
return (expand_word_list_internal (list, WEXP_SHELLEXP));
}
static WORD_LIST *
-glob_expand_word_list (tlist, eflags)
- WORD_LIST *tlist;
- int eflags;
+glob_expand_word_list (WORD_LIST *tlist, int eflags)
{
char **glob_array, *temp_string;
register int glob_index;
#if defined (BRACE_EXPANSION)
static WORD_LIST *
-brace_expand_word_list (tlist, eflags)
- WORD_LIST *tlist;
- int eflags;
+brace_expand_word_list (WORD_LIST *tlist, int eflags)
{
register char **expansions;
char *temp_string;
the list of options to supply to `declare'. CMD is the declaration command
we are expanding right now; it's unused currently. */
static int
-make_internal_declare (word, option, cmd)
- char *word;
- char *option;
- char *cmd;
+make_internal_declare (char *word, char *option, char *cmd)
{
int t, r;
WORD_LIST *wl;
['expanded-ind']='expanded-value'. */
static WORD_LIST *
-expand_oneword (value, flags)
- char *value;
- int flags;
+expand_oneword (char *value, int flags)
{
WORD_LIST *l, *nl;
char *t;
handling, see expand_oneword() above. The return value is
NAME[+]=( expanded-and-quoted-VALUE ). */
static void
-expand_compound_assignment_word (tlist, flags)
- WORD_LIST *tlist;
- int flags;
+expand_compound_assignment_word (WORD_LIST *tlist, int flags)
{
WORD_LIST *l;
int wlen, oind, t;
etc.) even though the word is single-quoted so all that needs to happen is
quote removal. */
static WORD_LIST *
-expand_declaration_argument (tlist, wcmd)
- WORD_LIST *tlist, *wcmd;
+expand_declaration_argument (WORD_LIST *tlist, WORD_LIST *wcmd)
{
char opts[16], omap[128];
int t, opti, oind, skip, inheriting;
#endif /* ARRAY_VARS */
static WORD_LIST *
-shell_expand_word_list (tlist, eflags)
- WORD_LIST *tlist;
- int eflags;
+shell_expand_word_list (WORD_LIST *tlist, int eflags)
{
WORD_LIST *expanded, *orig_list, *new_list, *next, *temp_list, *wcmd;
int expanded_something, has_dollar_at;
If COMMAND == NULL, is_nullcmd usually == 1. Follow the POSIX rules for
variable assignment errors. */
static int
-do_assignment_statements (varlist, command, is_nullcmd)
- WORD_LIST *varlist;
- char *command;
- int is_nullcmd;
+do_assignment_statements (WORD_LIST *varlist, char *command, int is_nullcmd)
{
WORD_LIST *temp_list;
char *savecmd;
with W_NOBRACE set do not undergo brace expansion (see
brace_expand_word_list above). */
static WORD_LIST *
-expand_word_list_internal (list, eflags)
- WORD_LIST *list;
- int eflags;
+expand_word_list_internal (WORD_LIST *list, int eflags)
{
WORD_LIST *new_list, *temp_list;
/* Modified to run with the GNU shell Apr 25, 1988 by bfox. */
-/* Copyright (C) 1987-2021 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
#define test_exit(val) \
do { test_error_return = val; sh_longjmp (test_exit_buf, 1); } while (0)
-extern int sh_stat PARAMS((const char *, struct stat *));
+extern int sh_stat (const char *, struct stat *);
static int pos; /* The offset of the current argument in ARGV. */
static int argc; /* The number of arguments present in ARGV. */
static char **argv; /* The argument list. */
static int noeval;
-static void test_syntax_error PARAMS((char *, char *)) __attribute__((__noreturn__));
-static void beyond PARAMS((void)) __attribute__((__noreturn__));
-static void integer_expected_error PARAMS((char *)) __attribute__((__noreturn__));
+static void test_syntax_error (char *, char *) __attribute__((__noreturn__));
+static void beyond (void) __attribute__((__noreturn__));
+static void integer_expected_error (char *) __attribute__((__noreturn__));
-static int unary_operator PARAMS((void));
-static int binary_operator PARAMS((void));
-static int two_arguments PARAMS((void));
-static int three_arguments PARAMS((void));
-static int posixtest PARAMS((void));
+static int unary_operator (void);
+static int binary_operator (void);
+static int two_arguments (void);
+static int three_arguments (void);
+static int posixtest (void);
-static int expr PARAMS((void));
-static int term PARAMS((void));
-static int and PARAMS((void));
-static int or PARAMS((void));
+static int expr (void);
+static int term (void);
+static int and (void);
+static int or (void);
-static int filecomp PARAMS((char *, char *, int));
-static int arithcomp PARAMS((char *, char *, int, int));
-static int patcomp PARAMS((char *, char *, int));
+static int filecomp (char *, char *, int);
+static int arithcomp (char *, char *, int, int);
+static int patcomp (char *, char *, int);
static void
-test_syntax_error (format, arg)
- char *format, *arg;
+test_syntax_error (char *format, char *arg)
{
builtin_error (format, arg);
test_exit (TEST_ERREXIT_STATUS);
* error condition)
*/
static void
-beyond ()
+beyond (void)
{
test_syntax_error (_("argument expected"), (char *)NULL);
}
/* Syntax error for when an integer argument was expected, but
something else was found. */
static void
-integer_expected_error (pch)
- char *pch;
+integer_expected_error (char *pch)
{
test_syntax_error (_("%s: integer expected"), pch);
}
* or
*/
static int
-expr ()
+expr (void)
{
if (pos >= argc)
beyond ();
* and '-o' or
*/
static int
-or ()
+or (void)
{
int value, v2;
* term '-a' and
*/
static int
-and ()
+and (void)
{
int value, v2;
* positive and negative integers
*/
static int
-term ()
+term (void)
{
int value;
}
static int
-stat_mtime (fn, st, ts)
- char *fn;
- struct stat *st;
- struct timespec *ts;
+stat_mtime (char *fn, struct stat *st, struct timespec *ts)
{
int r;
}
static int
-filecomp (s, t, op)
- char *s, *t;
- int op;
+filecomp (char *s, char *t, int op)
{
struct stat st1, st2;
struct timespec ts1, ts2;
}
static int
-arithcomp (s, t, op, flags)
- char *s, *t;
- int op, flags;
+arithcomp (char *s, char *t, int op, int flags)
{
intmax_t l, r;
int expok;
}
static int
-patcomp (string, pat, op)
- char *string, *pat;
- int op;
+patcomp (char *string, char *pat, int op)
{
int m;
}
int
-binary_test (op, arg1, arg2, flags)
- char *op, *arg1, *arg2;
- int flags;
+binary_test (char *op, char *arg1, char *arg2, int flags)
{
int patmatch;
return (FALSE); /* should never get here */
}
-
static int
-binary_operator ()
+binary_operator (void)
{
int value;
char *w;
}
static int
-unary_operator ()
+unary_operator (void)
{
char *op;
intmax_t r;
}
int
-unary_test (op, arg, flags)
- char *op, *arg;
- int flags;
+unary_test (char *op, char *arg, int flags)
{
intmax_t r;
struct stat stat_buf;
/* Return TRUE if OP is one of the test command's binary operators. */
int
-test_binop (op)
- char *op;
+test_binop (char *op)
{
if (op[0] == '=' && op[1] == '\0')
return (1); /* '=' */
/* Return non-zero if OP is one of the test command's unary operators. */
int
-test_unop (op)
- char *op;
+test_unop (char *op)
{
if (op[0] != '-' || (op[1] && op[2] != 0))
return (0);
}
static int
-two_arguments ()
+two_arguments (void)
{
if (argv[pos][0] == '!' && argv[pos][1] == '\0')
return (argv[pos + 1][0] == '\0');
#define ONE_ARG_TEST(s) ((s)[0] != '\0')
static int
-three_arguments ()
+three_arguments (void)
{
int value;
/* This is an implementation of a Posix.2 proposal by David Korn. */
static int
-posixtest ()
+posixtest (void)
{
int value;
* test expr
*/
int
-test_command (margc, margv)
- int margc;
- char **margv;
+test_command (int margc, char **margv)
{
int value;
int code;
GETORIGSIG(sig)
void
-initialize_traps ()
+initialize_traps (void)
{
register int i;
#ifdef DEBUG
/* Return a printable representation of the trap handler for SIG. */
static char *
-trap_handler_string (sig)
- int sig;
+trap_handler_string (int sig)
{
if (trap_list[sig] == (char *)DEFAULT_SIG)
return "DEFAULT_SIG";
/* Return the print name of this signal. */
char *
-signal_name (sig)
- int sig;
+signal_name (int sig)
{
char *ret;
then (int)2 is returned. Return NO_SIG if STRING doesn't
contain a valid signal descriptor. */
int
-decode_signal (string, flags)
- char *string;
- int flags;
+decode_signal (char *string, int flags)
{
intmax_t sig;
char *name;
static int catch_flag;
void
-run_pending_traps ()
+run_pending_traps (void)
{
register int sig;
int x;
/* Set the private state variables noting that we received a signal SIG
for which we have a trap set. */
void
-set_trap_state (sig)
- int sig;
+set_trap_state (int sig)
{
catch_flag = 1;
pending_traps[sig]++;
}
sighandler
-trap_handler (sig)
- int sig;
+trap_handler (int sig)
{
int oerrno;
}
int
-next_pending_trap (start)
- int start;
+next_pending_trap (int start)
{
register int i;
}
int
-first_pending_trap ()
+first_pending_trap (void)
{
return (next_pending_trap (1));
}
/* Return > 0 if any of the "real" signals (not fake signals like EXIT) are
trapped. */
int
-any_signals_trapped ()
+any_signals_trapped (void)
{
register int i;
}
void
-clear_pending_traps ()
+clear_pending_traps (void)
{
register int i;
}
void
-check_signals ()
+check_signals (void)
{
/* Add any other shell timeouts here */
check_read_timeout (); /* set by the read builtin */
/* Convenience functions the rest of the shell can use */
void
-check_signals_and_traps ()
+check_signals_and_traps (void)
{
check_signals ();
#ifdef INCLUDE_UNUSED
/* Make COMMAND_STRING be executed when SIGCHLD is caught. */
void
-set_sigchld_trap (command_string)
- char *command_string;
+set_sigchld_trap (char *command_string)
{
set_signal (SIGCHLD, command_string);
}
reset the disposition to the default and not have the original signal
accidentally restored, undoing the user's command. */
void
-maybe_set_sigchld_trap (command_string)
- char *command_string;
+maybe_set_sigchld_trap (char *command_string)
{
if ((sigmodes[SIGCHLD] & SIG_TRAPPED) == 0 && trap_list[SIGCHLD] == (char *)IMPOSSIBLE_TRAP_HANDLER)
set_signal (SIGCHLD, command_string);
as a sentinel in run_sigchld_trap and maybe_set_sigchld_trap to see whether
or not a SIGCHLD trap handler reset SIGCHLD disposition to the default. */
void
-set_impossible_sigchld_trap ()
+set_impossible_sigchld_trap (void)
{
restore_default_signal (SIGCHLD);
change_signal (SIGCHLD, (char *)IMPOSSIBLE_TRAP_HANDLER);
pending_traps[SIGCHLD] by that amount. This allows us to still run the
SIGCHLD trap once for each exited child. */
void
-queue_sigchld_trap (nchild)
- int nchild;
+queue_sigchld_trap (int nchild)
{
if (nchild > 0)
{
/* Set a trap for SIG only if SIG is not already trapped. */
static inline void
-trap_if_untrapped (sig, command)
- int sig;
- char *command;
+trap_if_untrapped (int sig, char *command)
{
if ((sigmodes[sig] & SIG_TRAPPED) == 0)
set_signal (sig, command);
}
void
-set_debug_trap (command)
- char *command;
+set_debug_trap (char *command)
{
set_signal (DEBUG_TRAP, command);
}
SIG_TRAPPED will be set and we don't bother restoring the original trap string.
This is used by both functions and the source builtin. */
void
-maybe_set_debug_trap (command)
- char *command;
+maybe_set_debug_trap (char *command)
{
trap_if_untrapped (DEBUG_TRAP, command);
}
void
-set_error_trap (command)
- char *command;
+set_error_trap (char *command)
{
set_signal (ERROR_TRAP, command);
}
void
-maybe_set_error_trap (command)
- char *command;
+maybe_set_error_trap (char *command)
{
trap_if_untrapped (ERROR_TRAP, command);
}
void
-set_return_trap (command)
- char *command;
+set_return_trap (char *command)
{
set_signal (RETURN_TRAP, command);
}
void
-maybe_set_return_trap (command)
- char *command;
+maybe_set_return_trap (char *command)
{
trap_if_untrapped (RETURN_TRAP, command);
}
#ifdef INCLUDE_UNUSED
void
-set_sigint_trap (command)
- char *command;
+set_sigint_trap (char *command)
{
set_signal (SIGINT, command);
}
things, like waiting for command substitution or executing commands
in explicit subshells ( ( cmd ) ), can catch interrupts properly. */
SigHandler *
-set_sigint_handler ()
+set_sigint_handler (void)
{
if (sigmodes[SIGINT] & SIG_HARD_IGNORE)
return ((SigHandler *)SIG_IGN);
return ((SigHandler *)set_signal_handler (SIGINT, trap_handler));
/* The signal is not trapped, so set the handler to the shell's special
- interrupt handler. */
+ interrupt handler. Make sure this agrees with code in sig.c and
+ builtins/trap.def */
else if (interactive) /* XXX - was interactive_shell */
return (set_signal_handler (SIGINT, sigint_sighandler));
else
/* Return the correct handler for signal SIG according to the values in
sigmodes[SIG]. */
SigHandler *
-trap_to_sighandler (sig)
- int sig;
+trap_to_sighandler (int sig)
{
if (sigmodes[sig] & (SIG_IGNORED|SIG_HARD_IGNORE))
return (SIG_IGN);
/* Set SIG to call STRING as a command. */
void
-set_signal (sig, string)
- int sig;
- char *string;
+set_signal (int sig, char *string)
{
sigset_t set, oset;
}
static void
-free_trap_command (sig)
- int sig;
+free_trap_command (int sig)
{
if ((sigmodes[sig] & SIG_TRAPPED) && trap_list[sig] &&
(trap_list[sig] != (char *)IGNORE_SIG) &&
/* If SIG has a string assigned to it, get rid of it. Then give it
VALUE. */
static void
-change_signal (sig, value)
- int sig;
- char *value;
+change_signal (int sig, char *value)
{
if ((sigmodes[sig] & SIG_INPROGRESS) == 0)
free_trap_command (sig);
}
void
-get_original_signal (sig)
- int sig;
+get_original_signal (int sig)
{
/* If we aren't sure the of the original value, then get it. */
if (sig > 0 && sig < NSIG && original_signals[sig] == (SigHandler *)IMPOSSIBLE_TRAP_HANDLER)
}
void
-get_all_original_signals ()
+get_all_original_signals (void)
{
register int i;
}
void
-set_original_signal (sig, handler)
- int sig;
- SigHandler *handler;
+set_original_signal (int sig, SigHandler *handler)
{
if (sig > 0 && sig < NSIG && original_signals[sig] == (SigHandler *)IMPOSSIBLE_TRAP_HANDLER)
SETORIGSIG (sig, handler);
from trap_builtin (), which takes care to restore the handlers for
the signals the shell treats specially. */
void
-restore_default_signal (sig)
- int sig;
+restore_default_signal (int sig)
{
if (SPECIAL_TRAP (sig))
{
/* Make this signal be ignored. */
void
-ignore_signal (sig)
- int sig;
+ignore_signal (int sig)
{
if (SPECIAL_TRAP (sig) && ((sigmodes[sig] & SIG_IGNORED) == 0))
{
the command to be executed includes an "exit". This is why we have
to provide our own place for top_level to jump to. */
int
-run_exit_trap ()
+run_exit_trap (void)
{
char *trap_command;
int code, function_code, retval;
}
void
-run_trap_cleanup (sig)
- int sig;
+run_trap_cleanup (int sig)
{
/* XXX - should we clean up trap_list[sig] == IMPOSSIBLE_TRAP_HANDLER? */
sigmodes[sig] &= ~(SIG_INPROGRESS|SIG_CHANGED);
/* Run a trap command for SIG. SIG is one of the signals the shell treats
specially. Returns the exit status of the executed trap command list. */
static int
-_run_trap_internal (sig, tag)
- int sig;
- char *tag;
+_run_trap_internal (int sig, char *tag)
{
char *trap_command, *old_trap;
int trap_exit_value;
}
int
-run_debug_trap ()
+run_debug_trap (void)
{
int trap_exit_value, old_verbose;
pid_t save_pgrp;
}
void
-run_error_trap ()
+run_error_trap (void)
{
if ((sigmodes[ERROR_TRAP] & SIG_TRAPPED) && ((sigmodes[ERROR_TRAP] & SIG_IGNORED) == 0) && (sigmodes[ERROR_TRAP] & SIG_INPROGRESS) == 0)
_run_trap_internal (ERROR_TRAP, "error trap");
}
void
-run_return_trap ()
+run_return_trap (void)
{
int old_exit_value;
/* Run a trap set on SIGINT. This is called from throw_to_top_level (), and
declared here to localize the trap functions. */
+/* WILL_THROW indicates whether we're run from throw_to_top_level */
void
-run_interrupt_trap (will_throw)
- int will_throw; /* from throw_to_top_level? */
+run_interrupt_trap (int will_throw)
{
if (will_throw && running_trap > 0)
run_trap_cleanup (running_trap - 1);
reset_or_restore_signal_handlers and not change the disposition of signals
that are set to be ignored. */
void
-free_trap_strings ()
+free_trap_strings (void)
{
register int i;
/* Free a trap command string associated with SIG without changing signal
disposition. Intended to be called from free_trap_strings() */
static void
-free_trap_string (sig)
- int sig;
+free_trap_string (int sig)
{
change_signal (sig, (char *)DEFAULT_SIG);
sigmodes[sig] &= ~SIG_TRAPPED; /* XXX - SIG_INPROGRESS? */
/* Reset the handler for SIG to the original value but leave the trap string
in place. */
static void
-reset_signal (sig)
- int sig;
+reset_signal (int sig)
{
set_signal_handler (sig, original_signals[sig]);
sigmodes[sig] &= ~SIG_TRAPPED; /* XXX - SIG_INPROGRESS? */
/* Set the handler signal SIG to the original and free any trap
command associated with it. */
static void
-restore_signal (sig)
- int sig;
+restore_signal (int sig)
{
set_signal_handler (sig, original_signals[sig]);
change_signal (sig, (char *)DEFAULT_SIG);
}
static void
-reset_or_restore_signal_handlers (reset)
- sh_resetsig_func_t *reset;
+reset_or_restore_signal_handlers (sh_resetsig_func_t *reset)
{
register int i;
trap strings. Called by the command substitution code and other places
that create a "subshell environment". */
void
-reset_signal_handlers ()
+reset_signal_handlers (void)
{
reset_or_restore_signal_handlers (reset_signal);
}
ignored with trap '' SIGNAL should be ignored, so we make sure that they
are. Called by child processes after they are forked. */
void
-restore_original_signals ()
+restore_original_signals (void)
{
reset_or_restore_signal_handlers (restore_signal);
}
/* Change the flags associated with signal SIG without changing the trap
string. The string is TRAP_LIST[SIG] if we need it. */
static void
-reinit_trap (sig)
- int sig;
+reinit_trap (int sig)
{
sigmodes[sig] |= SIG_TRAPPED;
if (trap_list[sig] == (char *)IGNORE_SIG)
leaves the trap strings in place. This understands how reset_signal_handlers
works. */
void
-restore_traps ()
+restore_traps (void)
{
char *trapstr;
int i;
/* If a trap handler exists for signal SIG, then call it; otherwise just
return failure. Returns 1 if it called the trap handler. */
int
-maybe_call_trap_handler (sig)
- int sig;
+maybe_call_trap_handler (int sig)
{
/* Call the trap handler for SIG if the signal is trapped and not ignored. */
if ((sigmodes[sig] & SIG_TRAPPED) && ((sigmodes[sig] & SIG_IGNORED) == 0))
}
int
-signal_is_trapped (sig)
- int sig;
+signal_is_trapped (int sig)
{
return (sigmodes[sig] & SIG_TRAPPED);
}
int
-signal_is_pending (sig)
- int sig;
+signal_is_pending (int sig)
{
return (pending_traps[sig]);
}
int
-signal_is_special (sig)
- int sig;
+signal_is_special (int sig)
{
return (sigmodes[sig] & SIG_SPECIAL);
}
int
-signal_is_ignored (sig)
- int sig;
+signal_is_ignored (int sig)
{
return (sigmodes[sig] & SIG_IGNORED);
}
int
-signal_is_hard_ignored (sig)
- int sig;
+signal_is_hard_ignored (int sig)
{
return (sigmodes[sig] & SIG_HARD_IGNORE);
}
void
-set_signal_hard_ignored (sig)
- int sig;
+set_signal_hard_ignored (int sig)
{
sigmodes[sig] |= SIG_HARD_IGNORE;
original_signals[sig] = SIG_IGN;
}
void
-set_signal_ignored (sig)
- int sig;
+set_signal_ignored (int sig)
{
original_signals[sig] = SIG_IGN;
}
int
-signal_in_progress (sig)
- int sig;
+signal_in_progress (int sig)
{
return (sigmodes[sig] & SIG_INPROGRESS);
}
#if 0 /* unused */
int
-block_trapped_signals (maskp, omaskp)
- sigset_t *maskp;
- sigset_t *omaskp;
+block_trapped_signals (sigset_t *maskp, sigset_t *omaskp)
{
int i;
}
int
-unblock_trapped_signals (maskp)
- sigset_t *maskp;
+unblock_trapped_signals (sigset_t *maskp)
{
return (sigprocmask (SIG_SETMASK, maskp, 0));
}
/* I can't stand it anymore! Please can't we just write the
whole Unix system in lisp or something? */
-/* Copyright (C) 1987-2021 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
} sv;
} UNWIND_ELT;
-static void without_interrupts PARAMS((VFunction *, char *, char *));
-static void unwind_frame_discard_internal PARAMS((char *, char *));
-static void unwind_frame_run_internal PARAMS((char *, char *));
-static void add_unwind_protect_internal PARAMS((Function *, char *));
-static void remove_unwind_protect_internal PARAMS((char *, char *));
-static void run_unwind_protects_internal PARAMS((char *, char *));
-static void clear_unwind_protects_internal PARAMS((char *, char *));
-static inline void restore_variable PARAMS((SAVED_VAR *));
-static void unwind_protect_mem_internal PARAMS((char *, char *));
+static void without_interrupts (VFunction *, char *, char *);
+static void unwind_frame_discard_internal (char *, char *);
+static void unwind_frame_run_internal (char *, char *);
+static void add_unwind_protect_internal (Function *, char *);
+static void remove_unwind_protect_internal (char *, char *);
+static void run_unwind_protects_internal (char *, char *);
+static void clear_unwind_protects_internal (char *, char *);
+static inline void restore_variable (SAVED_VAR *);
+static void unwind_protect_mem_internal (char *, char *);
static UNWIND_ELT *unwind_protect_list = (UNWIND_ELT *)NULL;
#endif
void
-uwp_init ()
+uwp_init (void)
{
ocache_create (uwcache, UNWIND_ELT, UWCACHESIZE);
}
/* Run a function without interrupts. This relies on the fact that the
FUNCTION cannot call QUIT (). */
static void
-without_interrupts (function, arg1, arg2)
- VFunction *function;
- char *arg1, *arg2;
+without_interrupts (VFunction *function, char *arg1, char *arg2)
{
(*function)(arg1, arg2);
}
/* Start the beginning of a region. */
void
-begin_unwind_frame (tag)
- char *tag;
+begin_unwind_frame (char *tag)
{
add_unwind_protect ((Function *)NULL, tag);
}
/* Discard the unwind protects back to TAG. */
void
-discard_unwind_frame (tag)
- char *tag;
+discard_unwind_frame (char *tag)
{
if (unwind_protect_list)
without_interrupts (unwind_frame_discard_internal, tag, (char *)NULL);
/* Run the unwind protects back to TAG. */
void
-run_unwind_frame (tag)
- char *tag;
+run_unwind_frame (char *tag)
{
if (unwind_protect_list)
without_interrupts (unwind_frame_run_internal, tag, (char *)NULL);
/* Add the function CLEANUP with ARG to the list of unwindable things. */
void
-add_unwind_protect (cleanup, arg)
- Function *cleanup;
- char *arg;
+add_unwind_protect (Function *cleanup, char *arg)
{
without_interrupts (add_unwind_protect_internal, (char *)cleanup, arg);
}
/* Remove the top unwind protect from the list. */
void
-remove_unwind_protect ()
+remove_unwind_protect (void)
{
if (unwind_protect_list)
without_interrupts
/* Run the list of cleanup functions in unwind_protect_list. */
void
-run_unwind_protects ()
+run_unwind_protects (void)
{
if (unwind_protect_list)
without_interrupts
/* Erase the unwind-protect list. If flags is 1, free the elements. */
void
-clear_unwind_protect_list (flags)
- int flags;
+clear_unwind_protect_list (int flags)
{
char *flag;
}
int
-have_unwind_protects ()
+have_unwind_protects (void)
{
return (unwind_protect_list != 0);
}
int
-unwind_protect_tag_on_stack (tag)
- const char *tag;
+unwind_protect_tag_on_stack (const char *tag)
{
UNWIND_ELT *elt;
/* **************************************************************** */
static void
-add_unwind_protect_internal (cleanup, arg)
- Function *cleanup;
- char *arg;
+add_unwind_protect_internal (Function *cleanup, char *arg)
{
UNWIND_ELT *elt;
}
static void
-remove_unwind_protect_internal (ignore1, ignore2)
- char *ignore1, *ignore2;
+remove_unwind_protect_internal (char *ignore1, char *ignore2)
{
UNWIND_ELT *elt;
}
static void
-run_unwind_protects_internal (ignore1, ignore2)
- char *ignore1, *ignore2;
+run_unwind_protects_internal (char *ignore1, char *ignore2)
{
unwind_frame_run_internal ((char *) NULL, (char *) NULL);
}
static void
-clear_unwind_protects_internal (flag, ignore)
- char *flag, *ignore;
+clear_unwind_protects_internal (char *flag, char *ignore)
{
if (flag)
{
}
static void
-unwind_frame_discard_internal (tag, ignore)
- char *tag, *ignore;
+unwind_frame_discard_internal (char *tag, char *ignore)
{
UNWIND_ELT *elt;
int found;
sv->desired_setting is a block of memory SIZE bytes long holding the
value itself. This block of memory is copied back into the variable. */
static inline void
-restore_variable (sv)
- SAVED_VAR *sv;
+restore_variable (SAVED_VAR *sv)
{
FASTCOPY (sv->desired_setting, sv->variable, sv->size);
}
static void
-unwind_frame_run_internal (tag, ignore)
- char *tag, *ignore;
+unwind_frame_run_internal (char *tag, char *ignore)
{
UNWIND_ELT *elt;
int found;
}
static void
-unwind_protect_mem_internal (var, psize)
- char *var;
- char *psize;
+unwind_protect_mem_internal (char *var, char *psize)
{
int size, allocated;
UNWIND_ELT *elt;
are run. VAR is a pointer to the variable. SIZE is the size in
bytes of VAR. */
void
-unwind_protect_mem (var, size)
- char *var;
- int size;
+unwind_protect_mem (char *var, int size)
{
without_interrupts (unwind_protect_mem_internal, var, (char *) &size);
}
#include <stdio.h>
void
-print_unwind_protect_tags ()
+print_unwind_protect_tags (void)
{
UNWIND_ELT *elt;
static VAR_CONTEXT *last_context_searched;
/* Some forward declarations. */
-static void create_variable_tables PARAMS((void));
-
-static void set_machine_vars PARAMS((void));
-static void set_home_var PARAMS((void));
-static void set_shell_var PARAMS((void));
-static char *get_bash_name PARAMS((void));
-static void initialize_shell_level PARAMS((void));
-static void uidset PARAMS((void));
+static void create_variable_tables (void);
+
+static void set_machine_vars (void);
+static void set_home_var (void);
+static void set_shell_var (void);
+static char *get_bash_name (void);
+static void initialize_shell_level (void);
+static void uidset (void);
#if defined (ARRAY_VARS)
-static void make_vers_array PARAMS((void));
+static void make_vers_array (void);
#endif
-static SHELL_VAR *null_assign PARAMS((SHELL_VAR *, char *, arrayind_t, char *));
+static SHELL_VAR *null_assign (SHELL_VAR *, char *, arrayind_t, char *);
#if defined (ARRAY_VARS)
-static SHELL_VAR *null_array_assign PARAMS((SHELL_VAR *, char *, arrayind_t, char *));
+static SHELL_VAR *null_array_assign (SHELL_VAR *, char *, arrayind_t, char *);
#endif
-static SHELL_VAR *get_self PARAMS((SHELL_VAR *));
+static SHELL_VAR *get_self (SHELL_VAR *);
#if defined (ARRAY_VARS)
-static SHELL_VAR *init_dynamic_array_var PARAMS((char *, sh_var_value_func_t *, sh_var_assign_func_t *, int));
-static SHELL_VAR *init_dynamic_assoc_var PARAMS((char *, sh_var_value_func_t *, sh_var_assign_func_t *, int));
+static SHELL_VAR *init_dynamic_array_var (char *, sh_var_value_func_t *, sh_var_assign_func_t *, int);
+static SHELL_VAR *init_dynamic_assoc_var (char *, sh_var_value_func_t *, sh_var_assign_func_t *, int);
#endif
static inline SHELL_VAR *set_int_value (SHELL_VAR *, intmax_t, int);
static inline SHELL_VAR *set_string_value (SHELL_VAR *, const char *, int);
-static SHELL_VAR *assign_seconds PARAMS((SHELL_VAR *, char *, arrayind_t, char *));
-static SHELL_VAR *get_seconds PARAMS((SHELL_VAR *));
-static SHELL_VAR *init_seconds_var PARAMS((void));
+static SHELL_VAR *assign_seconds (SHELL_VAR *, char *, arrayind_t, char *);
+static SHELL_VAR *get_seconds (SHELL_VAR *);
+static SHELL_VAR *init_seconds_var (void);
-static SHELL_VAR *assign_random PARAMS((SHELL_VAR *, char *, arrayind_t, char *));
-static SHELL_VAR *get_random PARAMS((SHELL_VAR *));
+static SHELL_VAR *assign_random (SHELL_VAR *, char *, arrayind_t, char *);
+static SHELL_VAR *get_random (SHELL_VAR *);
-static SHELL_VAR *get_urandom PARAMS((SHELL_VAR *));
+static SHELL_VAR *get_urandom (SHELL_VAR *);
-static SHELL_VAR *assign_lineno PARAMS((SHELL_VAR *, char *, arrayind_t, char *));
-static SHELL_VAR *get_lineno PARAMS((SHELL_VAR *));
+static SHELL_VAR *assign_lineno (SHELL_VAR *, char *, arrayind_t, char *);
+static SHELL_VAR *get_lineno (SHELL_VAR *);
-static SHELL_VAR *assign_subshell PARAMS((SHELL_VAR *, char *, arrayind_t, char *));
-static SHELL_VAR *get_subshell PARAMS((SHELL_VAR *));
+static SHELL_VAR *assign_subshell (SHELL_VAR *, char *, arrayind_t, char *);
+static SHELL_VAR *get_subshell (SHELL_VAR *);
-static SHELL_VAR *get_epochseconds PARAMS((SHELL_VAR *));
-static SHELL_VAR *get_epochrealtime PARAMS((SHELL_VAR *));
+static SHELL_VAR *get_epochseconds (SHELL_VAR *);
+static SHELL_VAR *get_epochrealtime (SHELL_VAR *);
-static SHELL_VAR *get_bashpid PARAMS((SHELL_VAR *));
+static SHELL_VAR *get_bashpid (SHELL_VAR *);
-static SHELL_VAR *get_bash_argv0 PARAMS((SHELL_VAR *));
-static SHELL_VAR *assign_bash_argv0 PARAMS((SHELL_VAR *, char *, arrayind_t, char *));
-static void set_argv0 PARAMS((void));
+static SHELL_VAR *get_bash_argv0 (SHELL_VAR *);
+static SHELL_VAR *assign_bash_argv0 (SHELL_VAR *, char *, arrayind_t, char *);
+static void set_argv0 (void);
#if defined (HISTORY)
-static SHELL_VAR *get_histcmd PARAMS((SHELL_VAR *));
+static SHELL_VAR *get_histcmd (SHELL_VAR *);
#endif
#if defined (READLINE)
-static SHELL_VAR *get_comp_wordbreaks PARAMS((SHELL_VAR *));
-static SHELL_VAR *assign_comp_wordbreaks PARAMS((SHELL_VAR *, char *, arrayind_t, char *));
+static SHELL_VAR *get_comp_wordbreaks (SHELL_VAR *);
+static SHELL_VAR *assign_comp_wordbreaks (SHELL_VAR *, char *, arrayind_t, char *);
#endif
#if defined (PUSHD_AND_POPD) && defined (ARRAY_VARS)
-static SHELL_VAR *assign_dirstack PARAMS((SHELL_VAR *, char *, arrayind_t, char *));
-static SHELL_VAR *get_dirstack PARAMS((SHELL_VAR *));
+static SHELL_VAR *assign_dirstack (SHELL_VAR *, char *, arrayind_t, char *);
+static SHELL_VAR *get_dirstack (SHELL_VAR *);
#endif
#if defined (ARRAY_VARS)
-static SHELL_VAR *get_groupset PARAMS((SHELL_VAR *));
+static SHELL_VAR *get_groupset (SHELL_VAR *);
# if defined (DEBUGGER)
-static SHELL_VAR *get_bashargcv PARAMS((SHELL_VAR *));
+static SHELL_VAR *get_bashargcv (SHELL_VAR *);
# endif
-static SHELL_VAR *build_hashcmd PARAMS((SHELL_VAR *));
-static SHELL_VAR *get_hashcmd PARAMS((SHELL_VAR *));
-static SHELL_VAR *assign_hashcmd PARAMS((SHELL_VAR *, char *, arrayind_t, char *));
+static SHELL_VAR *build_hashcmd (SHELL_VAR *);
+static SHELL_VAR *get_hashcmd (SHELL_VAR *);
+static SHELL_VAR *assign_hashcmd (SHELL_VAR *, char *, arrayind_t, char *);
# if defined (ALIAS)
-static SHELL_VAR *build_aliasvar PARAMS((SHELL_VAR *));
-static SHELL_VAR *get_aliasvar PARAMS((SHELL_VAR *));
-static SHELL_VAR *assign_aliasvar PARAMS((SHELL_VAR *, char *, arrayind_t, char *));
+static SHELL_VAR *build_aliasvar (SHELL_VAR *);
+static SHELL_VAR *get_aliasvar (SHELL_VAR *);
+static SHELL_VAR *assign_aliasvar (SHELL_VAR *, char *, arrayind_t, char *);
# endif
#endif
-static SHELL_VAR *get_funcname PARAMS((SHELL_VAR *));
-static SHELL_VAR *init_funcname_var PARAMS((void));
+static SHELL_VAR *get_funcname (SHELL_VAR *);
+static SHELL_VAR *init_funcname_var (void);
-static void initialize_dynamic_variables PARAMS((void));
+static void initialize_dynamic_variables (void);
-static SHELL_VAR *bind_invalid_envvar PARAMS((const char *, char *, int));
+static SHELL_VAR *bind_invalid_envvar (const char *, char *, int);
-static int var_sametype PARAMS((SHELL_VAR *, SHELL_VAR *));
+static int var_sametype (SHELL_VAR *, SHELL_VAR *);
-static SHELL_VAR *hash_lookup PARAMS((const char *, HASH_TABLE *));
-static SHELL_VAR *new_shell_variable PARAMS((const char *));
-static SHELL_VAR *make_new_variable PARAMS((const char *, HASH_TABLE *));
-static SHELL_VAR *bind_variable_internal PARAMS((const char *, char *, HASH_TABLE *, int, int));
+static SHELL_VAR *hash_lookup (const char *, HASH_TABLE *);
+static SHELL_VAR *new_shell_variable (const char *);
+static SHELL_VAR *make_new_variable (const char *, HASH_TABLE *);
+static SHELL_VAR *bind_variable_internal (const char *, char *, HASH_TABLE *, int, int);
-static void dispose_variable_value PARAMS((SHELL_VAR *));
-static void free_variable_hash_data PARAMS((PTR_T));
+static void dispose_variable_value (SHELL_VAR *);
+static void free_variable_hash_data (PTR_T);
-static VARLIST *vlist_alloc PARAMS((int));
-static VARLIST *vlist_realloc PARAMS((VARLIST *, int));
-static void vlist_add PARAMS((VARLIST *, SHELL_VAR *, int));
+static VARLIST *vlist_alloc (int);
+static VARLIST *vlist_realloc (VARLIST *, int);
+static void vlist_add (VARLIST *, SHELL_VAR *, int);
-static void flatten PARAMS((HASH_TABLE *, sh_var_map_func_t *, VARLIST *, int));
+static void flatten (HASH_TABLE *, sh_var_map_func_t *, VARLIST *, int);
-static int qsort_var_comp PARAMS((SHELL_VAR **, SHELL_VAR **));
+static int qsort_var_comp (SHELL_VAR **, SHELL_VAR **);
-static SHELL_VAR **vapply PARAMS((sh_var_map_func_t *));
-static SHELL_VAR **fapply PARAMS((sh_var_map_func_t *));
+static SHELL_VAR **vapply (sh_var_map_func_t *);
+static SHELL_VAR **fapply (sh_var_map_func_t *);
-static int visible_var PARAMS((SHELL_VAR *));
-static int visible_and_exported PARAMS((SHELL_VAR *));
-static int export_environment_candidate PARAMS((SHELL_VAR *));
-static int local_and_exported PARAMS((SHELL_VAR *));
-static int visible_variable_in_context PARAMS((SHELL_VAR *));
-static int variable_in_context PARAMS((SHELL_VAR *));
+static int visible_var (SHELL_VAR *);
+static int visible_and_exported (SHELL_VAR *);
+static int export_environment_candidate (SHELL_VAR *);
+static int local_and_exported (SHELL_VAR *);
+static int visible_variable_in_context (SHELL_VAR *);
+static int variable_in_context (SHELL_VAR *);
#if defined (ARRAY_VARS)
-static int visible_array_vars PARAMS((SHELL_VAR *));
+static int visible_array_vars (SHELL_VAR *);
#endif
-static SHELL_VAR *find_variable_internal PARAMS((const char *, int));
+static SHELL_VAR *find_variable_internal (const char *, int);
-static SHELL_VAR *find_nameref_at_context PARAMS((SHELL_VAR *, VAR_CONTEXT *));
-static SHELL_VAR *find_variable_nameref_context PARAMS((SHELL_VAR *, VAR_CONTEXT *, VAR_CONTEXT **));
-static SHELL_VAR *find_variable_last_nameref_context PARAMS((SHELL_VAR *, VAR_CONTEXT *, VAR_CONTEXT **));
+static SHELL_VAR *find_nameref_at_context (SHELL_VAR *, VAR_CONTEXT *);
+static SHELL_VAR *find_variable_nameref_context (SHELL_VAR *, VAR_CONTEXT *, VAR_CONTEXT **);
+static SHELL_VAR *find_variable_last_nameref_context (SHELL_VAR *, VAR_CONTEXT *, VAR_CONTEXT **);
-static SHELL_VAR *bind_tempenv_variable PARAMS((const char *, char *));
-static void push_posix_temp_var PARAMS((PTR_T));
-static void push_temp_var PARAMS((PTR_T));
-static void propagate_temp_var PARAMS((PTR_T));
-static void dispose_temporary_env PARAMS((sh_free_func_t *));
+static SHELL_VAR *bind_tempenv_variable (const char *, char *);
+static void push_posix_temp_var (PTR_T);
+static void push_temp_var (PTR_T);
+static void propagate_temp_var (PTR_T);
+static void dispose_temporary_env (sh_free_func_t *);
-static inline char *mk_env_string PARAMS((const char *, const char *, int));
-static char **make_env_array_from_var_list PARAMS((SHELL_VAR **));
-static char **make_var_export_array PARAMS((VAR_CONTEXT *));
-static char **make_func_export_array PARAMS((void));
-static void add_temp_array_to_env PARAMS((char **, int, int));
+static inline char *mk_env_string (const char *, const char *, int);
+static char **make_env_array_from_var_list (SHELL_VAR **);
+static char **make_var_export_array (VAR_CONTEXT *);
+static char **make_func_export_array (void);
+static void add_temp_array_to_env (char **, int, int);
-static int n_shell_variables PARAMS((void));
-static int set_context PARAMS((SHELL_VAR *));
+static int n_shell_variables (void);
+static int set_context (SHELL_VAR *);
-static void push_func_var PARAMS((PTR_T));
-static void push_builtin_var PARAMS((PTR_T));
-static void push_exported_var PARAMS((PTR_T));
+static void push_func_var (PTR_T);
+static void push_builtin_var (PTR_T);
+static void push_exported_var (PTR_T);
-static void delete_local_contexts PARAMS((VAR_CONTEXT *));
+static void delete_local_contexts (VAR_CONTEXT *);
/* This needs to be looked at again. */
-static inline void push_posix_tempvar_internal PARAMS((SHELL_VAR *, int));
+static inline void push_posix_tempvar_internal (SHELL_VAR *, int);
-static inline int find_special_var PARAMS((const char *));
+static inline int find_special_var (const char *);
static void
-create_variable_tables ()
+create_variable_tables (void)
{
if (shell_variables == 0)
{
If PRIVMODE is nonzero, don't import functions from ENV or
parse $SHELLOPTS. */
void
-initialize_shell_variables (env, privmode)
- char **env;
- int privmode;
+initialize_shell_variables (char **env, int privmode)
{
char *name, *string, *temp_string;
int c, char_index, string_index, string_length, ro;
/* **************************************************************** */
static void
-set_machine_vars ()
+set_machine_vars (void)
{
SHELL_VAR *temp_var;
/* This function is not static so the tilde and readline libraries can
use it. */
char *
-sh_get_home_dir ()
+sh_get_home_dir (void)
{
if (current_user.home_dir == 0)
get_current_user_info ();
}
static void
-set_home_var ()
+set_home_var (void)
{
SHELL_VAR *temp_var;
/* Set $SHELL to the user's login shell if it is not already set. Call
get_current_user_info if we haven't already fetched the shell. */
static void
-set_shell_var ()
+set_shell_var (void)
{
SHELL_VAR *temp_var;
}
static char *
-get_bash_name ()
+get_bash_name (void)
{
char *name;
}
void
-adjust_shell_level (change)
- int change;
+adjust_shell_level (int change)
{
char new_level[5], *old_SHLVL;
intmax_t old_level;
}
static void
-initialize_shell_level ()
+initialize_shell_level (void)
{
adjust_shell_level (1);
}
that's not the same string as $PWD, set PWD=$HOME. */
void
-set_pwd ()
+set_pwd (void)
{
SHELL_VAR *temp_var, *home_var;
char *temp_string, *home_string, *current_dir;
/* Make a variable $PPID, which holds the pid of the shell's parent. */
void
-set_ppid ()
+set_ppid (void)
{
char namebuf[INT_STRLEN_BOUND(pid_t) + 1], *name;
SHELL_VAR *temp_var;
}
static void
-uidset ()
+uidset (void)
{
char buff[INT_STRLEN_BOUND(uid_t) + 1], *b;
register SHELL_VAR *v;
#if defined (ARRAY_VARS)
static void
-make_vers_array ()
+make_vers_array (void)
{
SHELL_VAR *vv;
ARRAY *av;
/* Set the environment variables $LINES and $COLUMNS in response to
a window size change. */
void
-sh_set_lines_and_columns (lines, cols)
- int lines, cols;
+sh_set_lines_and_columns (int lines, int cols)
{
char val[INT_STRLEN_BOUND(int) + 1], *v;
/* Print LIST (a list of shell variables) to stdout in such a way that
they can be read back in. */
void
-print_var_list (list)
- register SHELL_VAR **list;
+print_var_list (SHELL_VAR **list)
{
register int i;
register SHELL_VAR *var;
/* Print LIST (a list of shell functions) to stdout in such a way that
they can be read back in. */
void
-print_func_list (list)
- register SHELL_VAR **list;
+print_func_list (SHELL_VAR **list)
{
register int i;
register SHELL_VAR *var;
output, but the variable is printed in such a way that
it can be read back in. */
void
-print_assignment (var)
- SHELL_VAR *var;
+print_assignment (SHELL_VAR *var)
{
if (var_isset (var) == 0)
return;
and the value contains shell metacharacters, quote the value
in such a way that it can be read back in. */
void
-print_var_value (var, quote)
- SHELL_VAR *var;
- int quote;
+print_var_value (SHELL_VAR *var, int quote)
{
char *t;
/* Print the function cell of VAR, a shell variable. Do not
print the name, nor leading/trailing newline. */
void
-print_var_function (var)
- SHELL_VAR *var;
+print_var_function (SHELL_VAR *var)
{
char *x;
while (0)
static SHELL_VAR *
-null_assign (self, value, unused, key)
- SHELL_VAR *self;
- char *value;
- arrayind_t unused;
- char *key;
+null_assign (SHELL_VAR *self, char *value, arrayind_t unused, char *key)
{
return (self);
}
#if defined (ARRAY_VARS)
static SHELL_VAR *
-null_array_assign (self, value, ind, key)
- SHELL_VAR *self;
- char *value;
- arrayind_t ind;
- char *key;
+null_array_assign (SHELL_VAR *self, char *value, arrayind_t ind, char *key)
{
return (self);
}
/* Degenerate `dynamic_value' function; just returns what's passed without
manipulation. */
static SHELL_VAR *
-get_self (self)
- SHELL_VAR *self;
+get_self (SHELL_VAR *self)
{
return (self);
}
/* A generic dynamic array variable initializer. Initialize array variable
NAME with dynamic value function GETFUNC and assignment function SETFUNC. */
static SHELL_VAR *
-init_dynamic_array_var (name, getfunc, setfunc, attrs)
- char *name;
- sh_var_value_func_t *getfunc;
- sh_var_assign_func_t *setfunc;
- int attrs;
+init_dynamic_array_var (char *name, sh_var_value_func_t *getfunc, sh_var_assign_func_t *setfunc, int attrs)
{
SHELL_VAR *v;
}
static SHELL_VAR *
-init_dynamic_assoc_var (name, getfunc, setfunc, attrs)
- char *name;
- sh_var_value_func_t *getfunc;
- sh_var_assign_func_t *setfunc;
- int attrs;
+init_dynamic_assoc_var (char *name, sh_var_value_func_t *getfunc, sh_var_assign_func_t *setfunc, int attrs)
{
SHELL_VAR *v;
static intmax_t seconds_value_assigned;
static SHELL_VAR *
-assign_seconds (self, value, unused, key)
- SHELL_VAR *self;
- char *value;
- arrayind_t unused;
- char *key;
+assign_seconds (SHELL_VAR *self, char *value, arrayind_t unused, char *key)
{
intmax_t nval;
int expok;
}
static SHELL_VAR *
-get_seconds (var)
- SHELL_VAR *var;
+get_seconds (SHELL_VAR *var)
{
time_t time_since_start;
struct timeval tv;
}
static SHELL_VAR *
-init_seconds_var ()
+init_seconds_var (void)
{
SHELL_VAR *v;
static int seeded_subshell = 0;
static SHELL_VAR *
-assign_random (self, value, unused, key)
- SHELL_VAR *self;
- char *value;
- arrayind_t unused;
- char *key;
+assign_random (SHELL_VAR *self, char *value, arrayind_t unused, char *key)
{
intmax_t seedval;
int expok;
}
int
-get_random_number ()
+get_random_number (void)
{
int rv, pid;
}
static SHELL_VAR *
-get_random (var)
- SHELL_VAR *var;
+get_random (SHELL_VAR *var)
{
int rv;
}
static SHELL_VAR *
-get_urandom (var)
- SHELL_VAR *var;
+get_urandom (SHELL_VAR *var)
{
u_bits32_t rv;
}
static SHELL_VAR *
-assign_lineno (var, value, unused, key)
- SHELL_VAR *var;
- char *value;
- arrayind_t unused;
- char *key;
+assign_lineno (SHELL_VAR *var, char *value, arrayind_t unused, char *key)
{
intmax_t new_value;
/* Function which returns the current line number. */
static SHELL_VAR *
-get_lineno (var)
- SHELL_VAR *var;
+get_lineno (SHELL_VAR *var)
{
int ln;
}
static SHELL_VAR *
-assign_subshell (var, value, unused, key)
- SHELL_VAR *var;
- char *value;
- arrayind_t unused;
- char *key;
+assign_subshell (SHELL_VAR *var, char *value, arrayind_t unused, char *key)
{
intmax_t new_value;
}
static SHELL_VAR *
-get_subshell (var)
- SHELL_VAR *var;
+get_subshell (SHELL_VAR *var)
{
return (set_int_value (var, subshell_level, 0));
}
static SHELL_VAR *
-get_epochseconds (var)
- SHELL_VAR *var;
+get_epochseconds (SHELL_VAR *var)
{
intmax_t now;
}
static SHELL_VAR *
-get_epochrealtime (var)
- SHELL_VAR *var;
+get_epochrealtime (SHELL_VAR *var)
{
char buf[32];
struct timeval tv;
}
static SHELL_VAR *
-get_bashpid (var)
- SHELL_VAR *var;
+get_bashpid (SHELL_VAR *var)
{
int pid;
}
static SHELL_VAR *
-get_bash_argv0 (var)
- SHELL_VAR *var;
+get_bash_argv0 (SHELL_VAR *var)
{
return (set_string_value (var, dollar_vars[0], 0));
}
static char *static_shell_name = 0;
static SHELL_VAR *
-assign_bash_argv0 (var, value, unused, key)
- SHELL_VAR *var;
- char *value;
- arrayind_t unused;
- char *key;
+assign_bash_argv0 (SHELL_VAR *var, char *value, arrayind_t unused, char *key)
{
size_t vlen;
}
static void
-set_argv0 ()
+set_argv0 (void)
{
SHELL_VAR *v;
}
static SHELL_VAR *
-get_bash_command (var)
- SHELL_VAR *var;
+get_bash_command (SHELL_VAR *var)
{
char *p;
#if defined (HISTORY)
static SHELL_VAR *
-get_histcmd (var)
- SHELL_VAR *var;
+get_histcmd (SHELL_VAR *var)
{
int n;
#if defined (READLINE)
/* When this function returns, VAR->value points to malloced memory. */
static SHELL_VAR *
-get_comp_wordbreaks (var)
- SHELL_VAR *var;
+get_comp_wordbreaks (SHELL_VAR *var)
{
/* If we don't have anything yet, assign a default value. */
if (rl_completer_word_break_characters == 0 && bash_readline_initialized == 0)
/* When this function returns, rl_completer_word_break_characters points to
malloced memory. */
static SHELL_VAR *
-assign_comp_wordbreaks (self, value, unused, key)
- SHELL_VAR *self;
- char *value;
- arrayind_t unused;
- char *key;
+assign_comp_wordbreaks (SHELL_VAR *self, char *value, arrayind_t unused, char *key)
{
if (rl_completer_word_break_characters &&
rl_completer_word_break_characters != rl_basic_word_break_characters)
#if defined (PUSHD_AND_POPD) && defined (ARRAY_VARS)
static SHELL_VAR *
-assign_dirstack (self, value, ind, key)
- SHELL_VAR *self;
- char *value;
- arrayind_t ind;
- char *key;
+assign_dirstack (SHELL_VAR *self, char *value, arrayind_t ind, char *key)
{
set_dirstack_element (ind, 1, value);
return self;
}
static SHELL_VAR *
-get_dirstack (self)
- SHELL_VAR *self;
+get_dirstack (SHELL_VAR *self)
{
ARRAY *a;
WORD_LIST *l;
/* We don't want to initialize the group set with a call to getgroups()
unless we're asked to, but we only want to do it once. */
static SHELL_VAR *
-get_groupset (self)
- SHELL_VAR *self;
+get_groupset (SHELL_VAR *self)
{
register int i;
int ng;
# if defined (DEBUGGER)
static SHELL_VAR *
-get_bashargcv (self)
- SHELL_VAR *self;
+get_bashargcv (SHELL_VAR *self)
{
static int self_semaphore = 0;
# endif
static SHELL_VAR *
-build_hashcmd (self)
- SHELL_VAR *self;
+build_hashcmd (SHELL_VAR *self)
{
HASH_TABLE *h;
int i;
}
static SHELL_VAR *
-get_hashcmd (self)
- SHELL_VAR *self;
+get_hashcmd (SHELL_VAR *self)
{
build_hashcmd (self);
return (self);
}
static SHELL_VAR *
-assign_hashcmd (self, value, ind, key)
- SHELL_VAR *self;
- char *value;
- arrayind_t ind;
- char *key;
+assign_hashcmd (SHELL_VAR *self, char *value, arrayind_t ind, char *key)
{
#if defined (RESTRICTED_SHELL)
char *full_path;
#if defined (ALIAS)
static SHELL_VAR *
-build_aliasvar (self)
- SHELL_VAR *self;
+build_aliasvar (SHELL_VAR *self)
{
HASH_TABLE *h;
int i;
}
static SHELL_VAR *
-get_aliasvar (self)
- SHELL_VAR *self;
+get_aliasvar (SHELL_VAR *self)
{
build_aliasvar (self);
return (self);
}
static SHELL_VAR *
-assign_aliasvar (self, value, ind, key)
- SHELL_VAR *self;
- char *value;
- arrayind_t ind;
- char *key;
+assign_aliasvar (SHELL_VAR *self, char *value, arrayind_t ind, char *key)
{
if (legal_alias_name (key, 0) == 0)
{
/* If ARRAY_VARS is not defined, this just returns the name of any
currently-executing function. If we have arrays, it's a call stack. */
static SHELL_VAR *
-get_funcname (self)
- SHELL_VAR *self;
+get_funcname (SHELL_VAR *self)
{
#if ! defined (ARRAY_VARS)
if (variable_context && this_shell_function)
}
void
-make_funcname_visible (on_or_off)
- int on_or_off;
+make_funcname_visible (int on_or_off)
{
SHELL_VAR *v;
}
static SHELL_VAR *
-init_funcname_var ()
+init_funcname_var (void)
{
SHELL_VAR *v;
}
static void
-initialize_dynamic_variables ()
+initialize_dynamic_variables (void)
{
SHELL_VAR *v;
#if 0 /* not yet */
int
-var_isset (var)
- SHELL_VAR *var;
+var_isset (SHELL_VAR *var)
{
return (var->value != 0);
}
int
-var_isunset (var)
- SHELL_VAR *var;
+var_isunset (SHELL_VAR *var)
{
return (var->value == 0);
}
of interest (either variables or functions). */
static SHELL_VAR *
-hash_lookup (name, hashed_vars)
- const char *name;
- HASH_TABLE *hashed_vars;
+hash_lookup (const char *name, HASH_TABLE *hashed_vars)
{
BUCKET_CONTENTS *bucket;
}
SHELL_VAR *
-var_lookup (name, vcontext)
- const char *name;
- VAR_CONTEXT *vcontext;
+var_lookup (const char *name, VAR_CONTEXT *vcontext)
{
VAR_CONTEXT *vc;
SHELL_VAR *v;
*/
SHELL_VAR *
-find_variable_internal (name, flags)
- const char *name;
- int flags;
+find_variable_internal (const char *name, int flags)
{
SHELL_VAR *var;
int search_tempenv, force_tempenv;
/* Look up and resolve the chain of nameref variables starting at V all the
way to NULL or non-nameref. */
SHELL_VAR *
-find_variable_nameref (v)
- SHELL_VAR *v;
+find_variable_nameref (SHELL_VAR *v)
{
int level, flags;
char *newname;
/* Resolve the chain of nameref variables for NAME. XXX - could change later */
SHELL_VAR *
-find_variable_last_nameref (name, vflags)
- const char *name;
- int vflags;
+find_variable_last_nameref (const char *name, int vflags)
{
SHELL_VAR *v, *nv;
char *newname;
/* Resolve the chain of nameref variables for NAME. XXX - could change later */
SHELL_VAR *
-find_global_variable_last_nameref (name, vflags)
- const char *name;
- int vflags;
+find_global_variable_last_nameref (const char *name, int vflags)
{
SHELL_VAR *v, *nv;
char *newname;
}
static SHELL_VAR *
-find_nameref_at_context (v, vc)
- SHELL_VAR *v;
- VAR_CONTEXT *vc;
+find_nameref_at_context (SHELL_VAR *v, VAR_CONTEXT *vc)
{
SHELL_VAR *nv, *nv2;
char *newname;
nameref resolution (so the bind_variable_internal can use the correct
variable context and hash table). */
static SHELL_VAR *
-find_variable_nameref_context (v, vc, nvcp)
- SHELL_VAR *v;
- VAR_CONTEXT *vc;
- VAR_CONTEXT **nvcp;
+find_variable_nameref_context (SHELL_VAR *v, VAR_CONTEXT *vc, VAR_CONTEXT **nvcp)
{
SHELL_VAR *nv, *nv2;
VAR_CONTEXT *nvc;
nameref resolution (so the bind_variable_internal can use the correct
variable context and hash table). */
static SHELL_VAR *
-find_variable_last_nameref_context (v, vc, nvcp)
- SHELL_VAR *v;
- VAR_CONTEXT *vc;
- VAR_CONTEXT **nvcp;
+find_variable_last_nameref_context (SHELL_VAR *v, VAR_CONTEXT *vc, VAR_CONTEXT **nvcp)
{
SHELL_VAR *nv, *nv2;
VAR_CONTEXT *nvc;
}
SHELL_VAR *
-find_variable_nameref_for_create (name, flags)
- const char *name;
- int flags;
+find_variable_nameref_for_create (const char *name, int flags)
{
SHELL_VAR *var;
}
SHELL_VAR *
-find_variable_nameref_for_assignment (name, flags)
- const char *name;
- int flags;
+find_variable_nameref_for_assignment (const char *name, int flags)
{
SHELL_VAR *var;
function, but dealing strictly with names. This takes assignment flags
so it can deal with the various assignment modes used by `declare'. */
char *
-nameref_transform_name (name, flags)
- char *name;
- int flags;
+nameref_transform_name (char *name, int flags)
{
SHELL_VAR *v;
char *newname;
/* Find a variable, forcing a search of the temporary environment first */
SHELL_VAR *
-find_variable_tempenv (name)
- const char *name;
+find_variable_tempenv (const char *name)
{
SHELL_VAR *var;
/* Find a variable, not forcing a search of the temporary environment first */
SHELL_VAR *
-find_variable_notempenv (name)
- const char *name;
+find_variable_notempenv (const char *name)
{
SHELL_VAR *var;
}
SHELL_VAR *
-find_global_variable (name)
- const char *name;
+find_global_variable (const char *name)
{
SHELL_VAR *var;
}
SHELL_VAR *
-find_global_variable_noref (name)
- const char *name;
+find_global_variable_noref (const char *name)
{
SHELL_VAR *var;
}
SHELL_VAR *
-find_shell_variable (name)
- const char *name;
+find_shell_variable (const char *name)
{
SHELL_VAR *var;
/* Look up the variable entry named NAME. Returns the entry or NULL. */
SHELL_VAR *
-find_variable (name)
- const char *name;
+find_variable (const char *name)
{
SHELL_VAR *v;
int flags;
one found without att_invisible set; return 0 if no non-invisible instances
found. */
SHELL_VAR *
-find_variable_no_invisible (name)
- const char *name;
+find_variable_no_invisible (const char *name)
{
SHELL_VAR *v;
int flags;
/* Find the first instance of NAME in the variable context chain; return first
one found even if att_invisible set. */
SHELL_VAR *
-find_variable_for_assignment (name)
- const char *name;
+find_variable_for_assignment (const char *name)
{
SHELL_VAR *v;
int flags;
}
SHELL_VAR *
-find_variable_noref (name)
- const char *name;
+find_variable_noref (const char *name)
{
SHELL_VAR *v;
int flags;
/* Look up the function entry whose name matches STRING.
Returns the entry or NULL. */
SHELL_VAR *
-find_function (name)
- const char *name;
+find_function (const char *name)
{
return (hash_lookup (name, shell_functions));
}
/* Find the function definition for the shell function named NAME. Returns
the entry or NULL. */
FUNCTION_DEF *
-find_function_def (name)
- const char *name;
+find_function_def (const char *name)
{
#if defined (DEBUGGER)
return ((FUNCTION_DEF *)hash_lookup (name, shell_function_defs));
leak in practice. Since functions and variables have separate name
spaces, returns NULL if var_name is a shell function only. */
char *
-get_string_value (var_name)
- const char *var_name;
+get_string_value (const char *name)
{
SHELL_VAR *var;
- var = find_variable (var_name);
+ var = find_variable (name);
return ((var) ? get_variable_value (var) : (char *)NULL);
}
/* This is present for use by the tilde and readline libraries. */
char *
-sh_get_env_value (v)
- const char *v;
+sh_get_env_value (const char *v)
{
return get_string_value (v);
}
/* */
/* **************************************************************** */
-static int
-var_sametype (v1, v2)
- SHELL_VAR *v1;
- SHELL_VAR *v2;
+static inline int
+var_sametype (SHELL_VAR *v1, SHELL_VAR *v2)
{
if (v1 == 0 || v2 == 0)
return 0;
}
int
-validate_inherited_value (var, type)
- SHELL_VAR *var;
- int type;
+validate_inherited_value (SHELL_VAR *var, int type)
{
#if defined (ARRAY_VARS)
if (type == att_array && assoc_p (var))
/* Set NAME to VALUE if NAME has no value. */
SHELL_VAR *
-set_if_not (name, value)
- char *name, *value;
+set_if_not (char *name, char *value)
{
SHELL_VAR *v;
/* Create a local variable referenced by NAME. */
SHELL_VAR *
-make_local_variable (name, flags)
- const char *name;
- int flags;
+make_local_variable (const char *name, int flags)
{
SHELL_VAR *new_var, *old_var, *old_ref;
VAR_CONTEXT *vc;
/* Create a new shell variable with name NAME. */
static SHELL_VAR *
-new_shell_variable (name)
- const char *name;
+new_shell_variable (const char *name)
{
SHELL_VAR *entry;
/* Create a new shell variable with name NAME and add it to the hash table
TABLE. */
static SHELL_VAR *
-make_new_variable (name, table)
- const char *name;
- HASH_TABLE *table;
+make_new_variable (const char *name, HASH_TABLE *table)
{
SHELL_VAR *entry;
BUCKET_CONTENTS *elt;
#if defined (ARRAY_VARS)
SHELL_VAR *
-make_new_array_variable (name)
- char *name;
+make_new_array_variable (char *name)
{
SHELL_VAR *entry;
ARRAY *array;
}
SHELL_VAR *
-make_local_array_variable (name, flags)
- char *name;
- int flags;
+make_local_array_variable (char *name, int flags)
{
SHELL_VAR *var;
ARRAY *array;
}
SHELL_VAR *
-make_new_assoc_variable (name)
- char *name;
+make_new_assoc_variable (char *name)
{
SHELL_VAR *entry;
HASH_TABLE *hash;
}
SHELL_VAR *
-make_local_assoc_variable (name, flags)
- char *name;
- int flags;
+make_local_assoc_variable (char *name, int flags)
{
SHELL_VAR *var;
HASH_TABLE *hash;
#endif
char *
-make_variable_value (var, value, flags)
- SHELL_VAR *var;
- char *value;
- int flags;
+make_variable_value (SHELL_VAR *var, char *value, int flags)
{
char *retval, *oval;
intmax_t lval, rval;
/* If we can optimize appending to string variables, say so */
static int
-can_optimize_assignment (entry, value, aflags)
- SHELL_VAR *entry;
- char *value;
- int aflags;
+can_optimize_assignment (SHELL_VAR *entry, char *value, int aflags)
{
if ((aflags & ASS_APPEND) == 0)
return 0;
/* right now we optimize appends to string variables */
static SHELL_VAR *
-optimized_assignment (entry, value, aflags)
- SHELL_VAR *entry;
- char *value;
- int aflags;
+optimized_assignment (SHELL_VAR *entry, char *value, int aflags)
{
size_t len, vlen;
char *v, *new;
temporary environment (but usually is not). HFLAGS controls how NAME
is looked up in TABLE; AFLAGS controls how VALUE is assigned */
static SHELL_VAR *
-bind_variable_internal (name, value, table, hflags, aflags)
- const char *name;
- char *value;
- HASH_TABLE *table;
- int hflags, aflags;
+bind_variable_internal (const char *name, char *value, HASH_TABLE *table, int hflags, int aflags)
{
char *newval, *tname;
SHELL_VAR *entry, *tentry;
first, then we bind into shell_variables. */
SHELL_VAR *
-bind_variable (name, value, flags)
- const char *name;
- char *value;
- int flags;
+bind_variable (const char *name, char *value, int flags)
{
SHELL_VAR *v, *nv;
VAR_CONTEXT *vc, *nvc;
}
SHELL_VAR *
-bind_global_variable (name, value, flags)
- const char *name;
- char *value;
- int flags;
+bind_global_variable (const char *name, char *value, int flags)
{
if (shell_variables == 0)
create_variable_tables ();
}
static SHELL_VAR *
-bind_invalid_envvar (name, value, flags)
- const char *name;
- char *value;
- int flags;
+bind_invalid_envvar (const char *name, char *value, int aflags)
{
if (invalid_env == 0)
invalid_env = hash_create (64); /* XXX */
- return (bind_variable_internal (name, value, invalid_env, HASH_NOSRCH, flags));
+ return (bind_variable_internal (name, value, invalid_env, HASH_NOSRCH, aflags));
}
/* Make VAR, a simple shell variable, have value VALUE. Once assigned a
all modified variables should be exported, mark the variable for export
and note that the export environment needs to be recreated. */
SHELL_VAR *
-bind_variable_value (var, value, aflags)
- SHELL_VAR *var;
- char *value;
- int aflags;
+bind_variable_value (SHELL_VAR *var, char *value, int aflags)
{
char *t;
int invis;
variable we set here, then turn it back on after binding as necessary. */
SHELL_VAR *
-bind_int_variable (lhs, rhs, flags)
- char *lhs, *rhs;
- int flags;
+bind_int_variable (char *lhs, char *rhs, int flags)
{
register SHELL_VAR *v;
int isint, isarr, implicitarray, vflags, avflags;
}
SHELL_VAR *
-bind_var_to_int (var, val, flags)
- char *var;
- intmax_t val;
- int flags;
+bind_var_to_int (char *var, intmax_t val, int flags)
{
char ibuf[INT_STRLEN_BOUND (intmax_t) + 1], *p;
/* Do a function binding to a variable. You pass the name and
the command to bind to. This conses the name and command. */
SHELL_VAR *
-bind_function (name, value)
- const char *name;
- COMMAND *value;
+bind_function (const char *name, COMMAND *value)
{
SHELL_VAR *entry;
If (FLAGS & 1), overwrite any existing definition. If FLAGS == 0, leave
any existing definition alone. */
void
-bind_function_def (name, value, flags)
- const char *name;
- FUNCTION_DEF *value;
- int flags;
+bind_function_def (const char *name, FUNCTION_DEF *value, int flags)
{
FUNCTION_DEF *entry;
BUCKET_CONTENTS *elt;
responsible for moving the main temporary env to one of the other
temporary environments. The expansion code in subst.c calls this. */
int
-assign_in_env (word, flags)
- WORD_DESC *word;
- int flags;
+assign_in_env (WORD_DESC *word, int flags)
{
int offset, aflags;
char *name, *temp, *value, *newname;
#ifdef INCLUDE_UNUSED
/* Copy VAR to a new data structure and return that structure. */
SHELL_VAR *
-copy_variable (var)
- SHELL_VAR *var;
+copy_variable (SHELL_VAR *var)
{
SHELL_VAR *copy = (SHELL_VAR *)NULL;
/* Dispose of the information attached to VAR. */
static void
-dispose_variable_value (var)
- SHELL_VAR *var;
+dispose_variable_value (SHELL_VAR *var)
{
if (function_p (var))
dispose_command (function_cell (var));
}
void
-dispose_variable (var)
- SHELL_VAR *var;
+dispose_variable (SHELL_VAR *var)
{
if (var == 0)
return;
/* Unset the shell variable referenced by NAME. Unsetting a nameref variable
unsets the variable it resolves to but leaves the nameref alone. */
int
-unbind_variable (name)
- const char *name;
+unbind_variable (const char *name)
{
SHELL_VAR *v, *nv;
int r;
/* Unbind NAME, where NAME is assumed to be a nameref variable */
int
-unbind_nameref (name)
- const char *name;
+unbind_nameref (const char *name)
{
SHELL_VAR *v;
/* Unbind the first instance of NAME, whether it's a nameref or not */
int
-unbind_variable_noref (name)
- const char *name;
+unbind_variable_noref (const char *name)
{
SHELL_VAR *v;
}
int
-unbind_global_variable (name)
- const char *name;
+unbind_global_variable (const char *name)
{
SHELL_VAR *v, *nv;
int r;
}
int
-unbind_global_variable_noref (name)
- const char *name;
+unbind_global_variable_noref (const char *name)
{
SHELL_VAR *v;
}
int
-check_unbind_variable (name)
- const char *name;
+check_unbind_variable (const char *name)
{
SHELL_VAR *v;
/* Unset the shell function named NAME. */
int
-unbind_func (name)
- const char *name;
+unbind_func (const char *name)
{
BUCKET_CONTENTS *elt;
SHELL_VAR *func;
#if defined (DEBUGGER)
int
-unbind_function_def (name)
- const char *name;
+unbind_function_def (const char *name)
{
BUCKET_CONTENTS *elt;
FUNCTION_DEF *funcdef;
#endif /* DEBUGGER */
int
-delete_var (name, vc)
- const char *name;
- VAR_CONTEXT *vc;
+delete_var (const char *name, VAR_CONTEXT *vc)
{
BUCKET_CONTENTS *elt;
SHELL_VAR *old_var;
shell_variables or shell_functions).
Returns non-zero if the variable couldn't be found. */
int
-makunbound (name, vc)
- const char *name;
- VAR_CONTEXT *vc;
+makunbound (const char *name, VAR_CONTEXT *vc)
{
BUCKET_CONTENTS *elt, *new_elt;
SHELL_VAR *old_var;
/* Get rid of all of the variables in the current context. */
void
-kill_all_local_variables ()
+kill_all_local_variables (void)
{
VAR_CONTEXT *vc;
}
static void
-free_variable_hash_data (data)
- PTR_T data;
+free_variable_hash_data (PTR_T data)
{
SHELL_VAR *var;
/* Delete the entire contents of the hash table. */
void
-delete_all_variables (hashed_vars)
- HASH_TABLE *hashed_vars;
+delete_all_variables (HASH_TABLE *hashed_vars)
{
hash_flush (hashed_vars, free_variable_hash_data);
}
/* Make the variable associated with NAME be readonly.
If NAME does not exist yet, create it. */
void
-set_var_read_only (name)
- char *name;
+set_var_read_only (char *name)
{
SHELL_VAR *entry;
/* Make the function associated with NAME be readonly.
If NAME does not exist, we just punt, like auto_export code below. */
void
-set_func_read_only (name)
- const char *name;
+set_func_read_only (const char *name)
{
SHELL_VAR *entry;
/* Make the variable associated with NAME be auto-exported.
If NAME does not exist yet, create it. */
void
-set_var_auto_export (name)
- char *name;
+set_var_auto_export (char *name)
{
SHELL_VAR *entry;
/* Make the function associated with NAME be auto-exported. */
void
-set_func_auto_export (name)
- const char *name;
+set_func_auto_export (const char *name)
{
SHELL_VAR *entry;
/* **************************************************************** */
static VARLIST *
-vlist_alloc (nentries)
- int nentries;
+vlist_alloc (int nentries)
{
VARLIST *vlist;
}
static VARLIST *
-vlist_realloc (vlist, n)
- VARLIST *vlist;
- int n;
+vlist_realloc (VARLIST *vlist, int n)
{
if (vlist == 0)
return (vlist = vlist_alloc (n));
}
static void
-vlist_add (vlist, var, flags)
- VARLIST *vlist;
- SHELL_VAR *var;
- int flags;
+vlist_add (VARLIST *vlist, SHELL_VAR *var, int flags)
{
register int i;
variables for which FUNCTION returns a non-zero value. A NULL value
for FUNCTION means to use all variables. */
SHELL_VAR **
-map_over (function, vc)
- sh_var_map_func_t *function;
- VAR_CONTEXT *vc;
+map_over (sh_var_map_func_t *function, VAR_CONTEXT *vc)
{
VAR_CONTEXT *v;
VARLIST *vlist;
}
SHELL_VAR **
-map_over_funcs (function)
- sh_var_map_func_t *function;
+map_over_funcs (sh_var_map_func_t *function)
{
VARLIST *vlist;
SHELL_VAR **ret;
NULL, FUNC is applied to each SHELL_VAR in VAR_HASH_TABLE. If VLIST
and FUNC are both NULL, nothing happens. */
static void
-flatten (var_hash_table, func, vlist, flags)
- HASH_TABLE *var_hash_table;
- sh_var_map_func_t *func;
- VARLIST *vlist;
- int flags;
+flatten (HASH_TABLE *var_hash_table, sh_var_map_func_t *func, VARLIST *vlist, int flags)
{
register int i;
register BUCKET_CONTENTS *tlist;
}
void
-sort_variables (array)
- SHELL_VAR **array;
+sort_variables (SHELL_VAR **array)
{
qsort (array, strvec_len ((char **)array), sizeof (SHELL_VAR *), (QSFUNC *)qsort_var_comp);
}
static int
-qsort_var_comp (var1, var2)
- SHELL_VAR **var1, **var2;
+qsort_var_comp (SHELL_VAR **var1, SHELL_VAR **var2)
{
int result;
/* Apply FUNC to each variable in SHELL_VARIABLES, adding each one for
which FUNC succeeds to an array of SHELL_VAR *s. Returns the array. */
static SHELL_VAR **
-vapply (func)
- sh_var_map_func_t *func;
+vapply (sh_var_map_func_t *func)
{
SHELL_VAR **list;
/* Apply FUNC to each variable in SHELL_FUNCTIONS, adding each one for
which FUNC succeeds to an array of SHELL_VAR *s. Returns the array. */
static SHELL_VAR **
-fapply (func)
- sh_var_map_func_t *func;
+fapply (sh_var_map_func_t *func)
{
SHELL_VAR **list;
/* Create a NULL terminated array of all the shell variables. */
SHELL_VAR **
-all_shell_variables ()
+all_shell_variables (void)
{
return (vapply ((sh_var_map_func_t *)NULL));
}
/* Create a NULL terminated array of all the shell functions. */
SHELL_VAR **
-all_shell_functions ()
+all_shell_functions (void)
{
return (fapply ((sh_var_map_func_t *)NULL));
}
static int
-visible_var (var)
- SHELL_VAR *var;
+visible_var (SHELL_VAR *var)
{
return (invisible_p (var) == 0);
}
SHELL_VAR **
-all_visible_functions ()
+all_visible_functions (void)
{
return (fapply (visible_var));
}
SHELL_VAR **
-all_visible_variables ()
+all_visible_variables (void)
{
return (vapply (visible_var));
}
/* Return non-zero if the variable VAR is visible and exported. Array
variables cannot be exported. */
static int
-visible_and_exported (var)
- SHELL_VAR *var;
+visible_and_exported (SHELL_VAR *var)
{
return (invisible_p (var) == 0 && exported_p (var));
}
with the export attribute or invalid variables inherited from the initial
environment and simply passed through. */
static int
-export_environment_candidate (var)
- SHELL_VAR *var;
+export_environment_candidate (SHELL_VAR *var)
{
return (exported_p (var) && (invisible_p (var) == 0 || imported_p (var)));
}
/* Return non-zero if VAR is a local variable in the current context and
is exported. */
static int
-local_and_exported (var)
- SHELL_VAR *var;
+local_and_exported (SHELL_VAR *var)
{
return (invisible_p (var) == 0 && local_p (var) && var->context == variable_context && exported_p (var));
}
SHELL_VAR **
-all_exported_variables ()
+all_exported_variables (void)
{
return (vapply (visible_and_exported));
}
SHELL_VAR **
-local_exported_variables ()
+local_exported_variables (void)
{
return (vapply (local_and_exported));
}
static int
-variable_in_context (var)
- SHELL_VAR *var;
+variable_in_context (SHELL_VAR *var)
{
return (local_p (var) && var->context == variable_context);
}
static int
-visible_variable_in_context (var)
- SHELL_VAR *var;
+visible_variable_in_context (SHELL_VAR *var)
{
return (invisible_p (var) == 0 && local_p (var) && var->context == variable_context);
}
SHELL_VAR **
-all_local_variables (visible_only)
- int visible_only;
+all_local_variables (int visible_only)
{
VARLIST *vlist;
SHELL_VAR **ret;
#if defined (ARRAY_VARS)
/* Return non-zero if the variable VAR is visible and an array. */
static int
-visible_array_vars (var)
- SHELL_VAR *var;
+visible_array_vars (SHELL_VAR *var)
{
return (invisible_p (var) == 0 && (array_p (var) || assoc_p (var)));
}
SHELL_VAR **
-all_array_variables ()
+all_array_variables (void)
{
return (vapply (visible_array_vars));
}
#endif /* ARRAY_VARS */
char **
-all_variables_matching_prefix (prefix)
- const char *prefix;
+all_variables_matching_prefix (const char *prefix)
{
SHELL_VAR **varlist;
char **rlist;
/* Make variable NAME have VALUE in the temporary environment. */
static SHELL_VAR *
-bind_tempenv_variable (name, value)
- const char *name;
- char *value;
+bind_tempenv_variable (const char *name, char *value)
{
SHELL_VAR *var;
/* Find a variable in the temporary environment that is named NAME.
Return the SHELL_VAR *, or NULL if not found. */
SHELL_VAR *
-find_tempenv_variable (name)
- const char *name;
+find_tempenv_variable (const char *name)
{
return (temporary_env ? hash_lookup (name, temporary_env) : (SHELL_VAR *)NULL);
}
is called from merge_temporary_env, which is only called when in posix
mode. */
static void
-push_posix_temp_var (data)
- PTR_T data;
+push_posix_temp_var (PTR_T data)
{
SHELL_VAR *var, *v;
HASH_TABLE *binding_table;
we can create variables in the current scope.
*/
static void
-push_temp_var (data)
- PTR_T data;
+push_temp_var (PTR_T data)
{
SHELL_VAR *var, *v;
HASH_TABLE *binding_table;
taking a variable like `var=value declare -x var' and propagating it to
the enclosing scope. */
static void
-propagate_temp_var (data)
- PTR_T data;
+propagate_temp_var (PTR_T data)
{
SHELL_VAR *var;
function can call stupidly_hack_special_variables on all the
variables in the list when the temporary hash table is destroyed. */
static void
-dispose_temporary_env (pushf)
- sh_free_func_t *pushf;
+dispose_temporary_env (sh_free_func_t *pushf)
{
int i;
HASH_TABLE *disposer;
}
void
-dispose_used_env_vars ()
+dispose_used_env_vars (void)
{
if (temporary_env)
{
accident of creating global variables from assignment statements preceding
special builtins, but we check in case this acquires another caller later. */
void
-merge_temporary_env ()
+merge_temporary_env (void)
{
if (temporary_env)
dispose_temporary_env (posixly_correct ? push_posix_temp_var : push_temp_var);
/* Temporary function to use if we want to separate function and special
builtin behavior. */
void
-merge_function_temporary_env ()
+merge_function_temporary_env (void)
{
if (temporary_env)
dispose_temporary_env (push_temp_var);
}
void
-flush_temporary_env ()
+flush_temporary_env (void)
{
if (temporary_env)
{
/* **************************************************************** */
static inline char *
-mk_env_string (name, value, attributes)
- const char *name, *value;
- int attributes;
+mk_env_string (const char *name, const char *value, int attributes)
{
size_t name_len, value_len;
char *p, *q, *t;
#ifdef DEBUG
/* Debugging */
static int
-valid_exportstr (v)
- SHELL_VAR *v;
+valid_exportstr (SHELL_VAR *v)
{
char *s;
#endif
static char **
-make_env_array_from_var_list (vars)
- SHELL_VAR **vars;
+make_env_array_from_var_list (SHELL_VAR **vars)
{
register int i, list_index;
register SHELL_VAR *var;
HASHED_VARS which contains SHELL_VARs. Only visible, exported
variables are eligible. */
static char **
-make_var_export_array (vcxt)
- VAR_CONTEXT *vcxt;
+make_var_export_array (VAR_CONTEXT *vcxt)
{
char **list;
SHELL_VAR **vars;
}
static char **
-make_func_export_array ()
+make_func_export_array (void)
{
char **list;
SHELL_VAR **vars;
/* Add ASSIGN to EXPORT_ENV, or supersede a previous assignment in the
array with the same left-hand side. Return the new EXPORT_ENV. */
char **
-add_or_supercede_exported_var (assign, do_alloc)
- char *assign;
- int do_alloc;
+add_or_supercede_exported_var (char *assign, int do_alloc)
{
register int i;
int equal_offset;
}
static void
-add_temp_array_to_env (temp_array, do_alloc, do_supercede)
- char **temp_array;
- int do_alloc, do_supercede;
+add_temp_array_to_env (char **temp_array, int do_alloc, int do_supercede)
{
register int i;
*/
static int
-n_shell_variables ()
+n_shell_variables (void)
{
VAR_CONTEXT *vc;
int n;
}
int
-chkexport (name)
- char *name;
+chkexport (char *name)
{
SHELL_VAR *v;
}
void
-maybe_make_export_env ()
+maybe_make_export_env (void)
{
register char **temp_array;
int new_size;
just update the variables in place and mark the exported environment
as no longer needing a remake. */
void
-update_export_env_inplace (env_prefix, preflen, value)
- char *env_prefix;
- int preflen;
- char *value;
+update_export_env_inplace (char *env_prefix, int preflen, char *value)
{
char *evar;
/* We always put _ in the environment as the name of this command. */
void
-put_command_name_into_env (command_name)
- char *command_name;
+put_command_name_into_env (char *command_name)
{
update_export_env_inplace ("_=", 2, command_name);
}
NAME can be NULL. */
VAR_CONTEXT *
-new_var_context (name, flags)
- char *name;
- int flags;
+new_var_context (char *name, int flags)
{
VAR_CONTEXT *vc;
/* Free a variable context and its data, including the hash table. Dispose
all of the variables. */
void
-dispose_var_context (vc)
- VAR_CONTEXT *vc;
+dispose_var_context (VAR_CONTEXT *vc)
{
FREE (vc->name);
/* Set VAR's scope level to the current variable context. */
static int
-set_context (var)
- SHELL_VAR *var;
+set_context (SHELL_VAR *var)
{
return (var->context = variable_context);
}
temporary variables, and push it onto shell_variables. This is
for shell functions. */
VAR_CONTEXT *
-push_var_context (name, flags, tempvars)
- char *name;
- int flags;
- HASH_TABLE *tempvars;
+push_var_context (char *name, int flags, HASH_TABLE *tempvars)
{
VAR_CONTEXT *vc;
int posix_func_behavior;
*/
static inline void
-push_posix_tempvar_internal (var, isbltin)
- SHELL_VAR *var;
- int isbltin;
+push_posix_tempvar_internal (SHELL_VAR *var, int isbltin)
{
SHELL_VAR *v;
int posix_var_behavior;
}
static void
-push_func_var (data)
- PTR_T data;
+push_func_var (PTR_T data)
{
SHELL_VAR *var;
}
static void
-push_builtin_var (data)
- PTR_T data;
+push_builtin_var (PTR_T data)
{
SHELL_VAR *var;
/* Pop the top context off of VCXT and dispose of it, returning the rest of
the stack. */
void
-pop_var_context ()
+pop_var_context (void)
{
VAR_CONTEXT *ret, *vcxt;
}
static void
-delete_local_contexts (vcxt)
- VAR_CONTEXT *vcxt;
+delete_local_contexts (VAR_CONTEXT *vcxt)
{
VAR_CONTEXT *v, *t;
/* Delete the HASH_TABLEs for all variable contexts beginning at VCXT, and
all of the VAR_CONTEXTs except GLOBAL_VARIABLES. */
void
-delete_all_contexts (vcxt)
- VAR_CONTEXT *vcxt;
+delete_all_contexts (VAR_CONTEXT *vcxt)
{
delete_local_contexts (vcxt);
delete_all_variables (global_variables->table);
/* Reset the context so we are not executing in a shell function. Only call
this if you are getting ready to exit the shell. */
void
-reset_local_contexts ()
+reset_local_contexts (void)
{
delete_local_contexts (shell_variables);
shell_variables = global_variables;
/* **************************************************************** */
VAR_CONTEXT *
-push_scope (flags, tmpvars)
- int flags;
- HASH_TABLE *tmpvars;
+push_scope (int flags, HASH_TABLE *tmpvars)
{
return (push_var_context ((char *)NULL, flags, tmpvars));
}
static void
-push_exported_var (data)
- PTR_T data;
+push_exported_var (PTR_T data)
{
SHELL_VAR *var, *v;
variables in its temporary environment. In the first case, we call
push_builtin_var, which does the right thing. */
void
-pop_scope (is_special)
- int is_special;
+pop_scope (int is_special)
{
VAR_CONTEXT *vcxt, *ret;
int is_bltinenv;
/* Functions to manipulate dollar_vars array. Need to keep these in sync with
whatever remember_args() does. */
static char **
-save_dollar_vars ()
+save_dollar_vars (void)
{
char **ret;
int i;
}
static void
-restore_dollar_vars (args)
- char **args;
+restore_dollar_vars (char **args)
{
int i;
}
static void
-free_dollar_vars ()
+free_dollar_vars (void)
{
int i;
}
static void
-free_saved_dollar_vars (args)
- char **args;
+free_saved_dollar_vars (char **args)
{
int i;
/* Do what remember_args (xxx, 1) would have done. */
void
-clear_dollar_vars ()
+clear_dollar_vars (void)
{
free_dollar_vars ();
dispose_words (rest_of_args);
}
/* XXX - should always be followed by remember_args () */
+/* NAME is the function name */
void
-push_context (name, is_subshell, tempvars)
- char *name; /* function name */
- int is_subshell;
- HASH_TABLE *tempvars;
+push_context (char *name, int is_subshell, HASH_TABLE *tempvars)
{
if (is_subshell == 0)
push_dollar_vars ();
/* Only called when subshell == 0, so we don't need to check, and can
unconditionally pop the dollar vars off the stack. */
void
-pop_context ()
+pop_context (void)
{
pop_dollar_vars ();
variable_context--;
/* Save the existing positional parameters on a stack. */
void
-push_dollar_vars ()
+push_dollar_vars (void)
{
if (dollar_arg_stack_index + 2 > dollar_arg_stack_slots)
{
/* Restore the positional parameters from our stack. */
void
-pop_dollar_vars ()
+pop_dollar_vars (void)
{
if (dollar_arg_stack == 0 || dollar_arg_stack_index == 0)
return;
}
void
-dispose_saved_dollar_vars ()
+dispose_saved_dollar_vars (void)
{
if (dollar_arg_stack == 0 || dollar_arg_stack_index == 0)
return;
/* Initialize BASH_ARGV and BASH_ARGC after turning on extdebug after the
shell is initialized */
void
-init_bash_argv ()
+init_bash_argv (void)
{
if (bash_argv_initialized == 0)
{
}
void
-save_bash_argv ()
+save_bash_argv (void)
{
WORD_LIST *list;
/* Manipulate the special BASH_ARGV and BASH_ARGC variables. */
void
-push_args (list)
- WORD_LIST *list;
+push_args (WORD_LIST *list)
{
#if defined (ARRAY_VARS) && defined (DEBUGGER)
SHELL_VAR *bash_argv_v, *bash_argc_v;
array and use that value as the count of elements to remove from
BASH_ARGV. */
void
-pop_args ()
+pop_args (void)
{
#if defined (ARRAY_VARS) && defined (DEBUGGER)
SHELL_VAR *bash_argv_v, *bash_argc_v;
#define N_SPECIAL_VARS (sizeof (special_vars) / sizeof (special_vars[0]) - 1)
static int
-sv_compare (sv1, sv2)
- struct name_and_function *sv1, *sv2;
+sv_compare (struct name_and_function *sv1, struct name_and_function *sv2)
{
int r;
}
static inline int
-find_special_var (name)
- const char *name;
+find_special_var (const char *name)
{
register int i, r;
/* The variable in NAME has just had its state changed. Check to see if it
is one of the special ones where something special happens. */
void
-stupidly_hack_special_variables (name)
- char *name;
+stupidly_hack_special_variables (char *name)
{
static int sv_sorted = 0;
int i;
/* Special variables that need hooks to be run when they are unset as part
of shell reinitialization should have their sv_ functions run here. */
void
-reinit_special_variables ()
+reinit_special_variables (void)
{
#if defined (READLINE)
sv_comp_wordbreaks ("COMP_WORDBREAKS");
}
void
-sv_ifs (name)
- char *name;
+sv_ifs (char *name)
{
SHELL_VAR *v;
/* What to do just after the PATH variable has changed. */
void
-sv_path (name)
- char *name;
+sv_path (char *name)
{
/* hash -r */
phash_flush ();
is the name of the variable. This is called with NAME set to one of
MAIL, MAILCHECK, or MAILPATH. */
void
-sv_mail (name)
- char *name;
+sv_mail (char *name)
{
/* If the time interval for checking the files has changed, then
reset the mail timer. Otherwise, one of the pathname vars
}
void
-sv_funcnest (name)
- char *name;
+sv_funcnest (char *name)
{
SHELL_VAR *v;
intmax_t num;
/* What to do when EXECIGNORE changes. */
void
-sv_execignore (name)
- char *name;
+sv_execignore (char *name)
{
setup_exec_ignore (name);
}
/* What to do when GLOBIGNORE changes. */
void
-sv_globignore (name)
- char *name;
+sv_globignore (char *name)
{
if (privileged_mode == 0)
setup_glob_ignore (name);
#if defined (READLINE)
void
-sv_comp_wordbreaks (name)
- char *name;
+sv_comp_wordbreaks (char *name)
{
SHELL_VAR *sv;
If we are an interactive shell, then try to reset the terminal
information in readline. */
void
-sv_terminal (name)
- char *name;
+sv_terminal (char *name)
{
if (interactive_shell && no_line_editing == 0)
rl_reset_terminal (get_string_value ("TERM"));
}
void
-sv_hostfile (name)
- char *name;
+sv_hostfile (char *name)
{
SHELL_VAR *v;
found in the initial environment) to override the terminal size reported by
the kernel. */
void
-sv_winsize (name)
- char *name;
+sv_winsize (char *name)
{
SHELL_VAR *v;
intmax_t xd;
/* Update the value of HOME in the export environment so tilde expansion will
work on cygwin. */
#if defined (__CYGWIN__)
-sv_home (name)
- char *name;
+sv_home (char *name)
{
array_needs_making = 1;
maybe_make_export_env ();
numeric, truncate the history file to hold no more than that many
lines. */
void
-sv_histsize (name)
- char *name;
+sv_histsize (char *name)
{
char *temp;
intmax_t num;
/* What to do after the HISTIGNORE variable changes. */
void
-sv_histignore (name)
- char *name;
+sv_histignore (char *name)
{
setup_history_ignore (name);
}
/* What to do after the HISTCONTROL variable changes. */
void
-sv_history_control (name)
- char *name;
+sv_history_control (char *name)
{
char *temp;
char *val;
#if defined (BANG_HISTORY)
/* Setting/unsetting of the history expansion character. */
void
-sv_histchars (name)
- char *name;
+sv_histchars (char *name)
{
char *temp;
#endif /* BANG_HISTORY */
void
-sv_histtimefmt (name)
- char *name;
+sv_histtimefmt (char *name)
{
SHELL_VAR *v;
#if defined (HAVE_TZSET)
void
-sv_tz (name)
- char *name;
+sv_tz (char *name)
{
SHELL_VAR *v;
of times we actually ignore the EOF. The default is small,
(smaller than csh, anyway). */
void
-sv_ignoreeof (name)
- char *name;
+sv_ignoreeof (char *name)
{
SHELL_VAR *tmp_var;
char *temp;
}
void
-sv_optind (name)
- char *name;
+sv_optind (char *name)
{
SHELL_VAR *var;
char *tt;
}
void
-sv_opterr (name)
- char *name;
+sv_opterr (char *name)
{
char *tt;
}
void
-sv_strict_posix (name)
- char *name;
+sv_strict_posix (char *name)
{
SHELL_VAR *var;
}
void
-sv_locale (name)
- char *name;
+sv_locale (char *name)
{
char *v;
int r;
#if defined (ARRAY_VARS)
void
-set_pipestatus_array (ps, nproc)
- int *ps;
- int nproc;
+set_pipestatus_array (int *ps, int nproc)
{
SHELL_VAR *v;
ARRAY *a;
}
ARRAY *
-save_pipestatus_array ()
+save_pipestatus_array (void)
{
SHELL_VAR *v;
ARRAY *a;
}
void
-restore_pipestatus_array (a)
- ARRAY *a;
+restore_pipestatus_array (ARRAY *a)
{
SHELL_VAR *v;
ARRAY *a2;
#endif
void
-set_pipestatus_from_exit (s)
- int s;
+set_pipestatus_from_exit (int s)
{
#if defined (ARRAY_VARS)
static int v[2] = { 0, -1 };
}
void
-sv_xtracefd (name)
- char *name;
+sv_xtracefd (char *name)
{
SHELL_VAR *v;
char *t, *e;
#define MIN_COMPAT_LEVEL 31
void
-sv_shcompat (name)
- char *name;
+sv_shcompat (char *name)
{
SHELL_VAR *v;
char *val;
#if defined (JOB_CONTROL)
void
-sv_childmax (name)
- char *name;
+sv_childmax (char *name)
{
char *tt;
int s;