From: Chet Ramey Date: Tue, 3 Jan 2023 15:23:11 +0000 (-0500) Subject: second set of ANSI C changes: C89-style function declarations, more inline functions... X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a61ffa78ede6df4d1127fddd2e8a1a77a7186ea1;p=thirdparty%2Fbash.git second set of ANSI C changes: C89-style function declarations, more inline functions, remove register keyword --- diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 58357c85b..16a320841 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -4864,3 +4864,30 @@ examples/loadables/{uname,unlink,whoami}.c 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 + diff --git a/alias.c b/alias.c index 23f967fa8..a01496a1f 100644 --- a/alias.c +++ b/alias.c @@ -1,7 +1,7 @@ /* 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. @@ -48,17 +48,17 @@ #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 @@ -69,7 +69,7 @@ int alias_expand_all = 0; HASH_TABLE *aliases = (HASH_TABLE *)NULL; void -initialize_aliases () +initialize_aliases (void) { if (aliases == 0) aliases = hash_create (ALIAS_HASH_BUCKETS); @@ -78,8 +78,7 @@ initialize_aliases () /* 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; @@ -92,8 +91,7 @@ find_alias (name) /* 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; @@ -107,8 +105,7 @@ get_alias_value (name) /* 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; @@ -158,8 +155,7 @@ add_alias (name, value) /* Delete a single alias structure. */ static void -free_alias_data (data) - PTR_T data; +free_alias_data (PTR_T data) { register alias_t *a; @@ -177,8 +173,7 @@ free_alias_data (data) 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; @@ -201,7 +196,7 @@ remove_alias (name) /* Delete all aliases. */ void -delete_all_aliases () +delete_all_aliases (void) { if (aliases == 0) return; @@ -217,8 +212,7 @@ delete_all_aliases () /* 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; @@ -246,16 +240,8 @@ map_over_aliases (function) 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; @@ -265,9 +251,15 @@ qsort_alias_compare (as1, as2) 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; @@ -281,8 +273,7 @@ all_aliases () } char * -alias_expand_word (s) - char *s; +alias_expand_word (const char *s) { alias_t *r; @@ -319,9 +310,7 @@ static int command_word; backslash-escaped characters. */ static int -skipquotes (string, start) - char *string; - int start; +skipquotes (char *string, int start) { register int i; int delimiter = string[start]; @@ -348,9 +337,7 @@ skipquotes (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; @@ -435,9 +422,7 @@ skipws (string, start) 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; @@ -476,9 +461,10 @@ rd_token (string, start) /* 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; diff --git a/alias.h b/alias.h index 1f5ec708a..af4a54486 100644 --- a/alias.h +++ b/alias.h @@ -42,18 +42,18 @@ extern void initialize_aliases (void); /* 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); @@ -62,7 +62,7 @@ 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 *); diff --git a/array.c b/array.c index 910bbaad8..85e296554 100644 --- a/array.c +++ b/array.c @@ -9,7 +9,7 @@ * 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. @@ -61,7 +61,7 @@ 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 = " "; @@ -78,7 +78,7 @@ static char *spacesep = " "; #define UNSET_LASTREF(a) a->lastref = 0; ARRAY * -array_create() +array_create(void) { ARRAY *r; ARRAY_ELEMENT *head; @@ -94,8 +94,7 @@ array_create() } void -array_flush (a) -ARRAY *a; +array_flush (ARRAY *a) { register ARRAY_ELEMENT *r, *r1; @@ -113,8 +112,7 @@ ARRAY *a; } void -array_dispose(a) -ARRAY *a; +array_dispose(ARRAY *a) { if (a == 0) return; @@ -124,8 +122,7 @@ ARRAY *a; } ARRAY * -array_copy(a) -ARRAY *a; +array_copy(ARRAY *a) { ARRAY *a1; ARRAY_ELEMENT *ae, *new; @@ -149,9 +146,7 @@ ARRAY *a; * 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; @@ -175,10 +170,7 @@ ARRAY_ELEMENT *s, *e; * element as the argument. */ void -array_walk(a, func, udata) -ARRAY *a; -sh_ae_map_func_t *func; -void *udata; +array_walk(ARRAY *a, sh_ae_map_func_t *func, void *udata) { register ARRAY_ELEMENT *ae; @@ -198,9 +190,7 @@ void *udata; * 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; @@ -258,10 +248,7 @@ int n, flags; * 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; @@ -294,23 +281,19 @@ char *s; } 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; @@ -326,8 +309,7 @@ ARRAY *array; } ARRAY * -array_quote_escapes(array) -ARRAY *array; +array_quote_escapes(ARRAY *array) { ARRAY_ELEMENT *a; char *t; @@ -343,8 +325,7 @@ ARRAY *array; } ARRAY * -array_dequote(array) -ARRAY *array; +array_dequote(ARRAY *array) { ARRAY_ELEMENT *a; char *t; @@ -360,8 +341,7 @@ ARRAY *array; } ARRAY * -array_dequote_escapes(array) -ARRAY *array; +array_dequote_escapes(ARRAY *array) { ARRAY_ELEMENT *a; char *t; @@ -377,8 +357,7 @@ ARRAY *array; } ARRAY * -array_remove_quoted_nulls(array) -ARRAY *array; +array_remove_quoted_nulls(ARRAY *array) { ARRAY_ELEMENT *a; @@ -395,10 +374,7 @@ ARRAY *array; * Since arrays are sparse, unset array elements are not counted. */ char * -array_subrange (a, start, nelem, starsub, quoted, pflags) -ARRAY *a; -arrayind_t start, nelem; -int starsub, quoted, pflags; +array_subrange (ARRAY *a, arrayind_t start, arrayind_t nelem, int starsub, int quoted, int pflags) { ARRAY *a2; ARRAY_ELEMENT *h, *p; @@ -440,10 +416,7 @@ int starsub, quoted, pflags; } char * -array_patsub (a, pat, rep, mflags) -ARRAY *a; -char *pat, *rep; -int mflags; +array_patsub (ARRAY *a, char *pat, char *rep, int mflags) { char *t; int pchar, qflags, pflags; @@ -473,11 +446,7 @@ int mflags; } char * -array_modcase (a, pat, modop, mflags) -ARRAY *a; -char *pat; -int modop; -int mflags; +array_modcase (ARRAY *a, char *pat, int modop, int mflags) { char *t; int pchar, qflags, pflags; @@ -511,9 +480,7 @@ int mflags; * VALUE. */ ARRAY_ELEMENT * -array_create_element(indx, value) -arrayind_t indx; -char *value; +array_create_element(arrayind_t indx, char *value) { ARRAY_ELEMENT *r; @@ -526,8 +493,7 @@ char *value; #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); @@ -535,8 +501,7 @@ ARRAY_ELEMENT *ae; #endif void -array_dispose_element(ae) -ARRAY_ELEMENT *ae; +array_dispose_element(ARRAY_ELEMENT *ae) { if (ae) { FREE(ae->value); @@ -548,10 +513,7 @@ ARRAY_ELEMENT *ae; * Add a new element with index I and value V to array A (a[i] = v). */ int -array_insert(a, i, v) -ARRAY *a; -arrayind_t i; -char *v; +array_insert(ARRAY *a, arrayind_t i, char *v) { register ARRAY_ELEMENT *new, *ae, *start; arrayind_t startind; @@ -637,9 +599,7 @@ char *v; * caller can dispose of it. */ ARRAY_ELEMENT * -array_remove(a, i) -ARRAY *a; -arrayind_t i; +array_remove(ARRAY *a, arrayind_t i) { register ARRAY_ELEMENT *ae, *start; arrayind_t startind; @@ -694,9 +654,7 @@ arrayind_t i; * Return the value of a[i]. */ char * -array_reference(a, i) -ARRAY *a; -arrayind_t i; +array_reference(ARRAY *a, arrayind_t i) { register ARRAY_ELEMENT *ae, *start; arrayind_t startind; @@ -748,8 +706,7 @@ arrayind_t i; by the rest of the code. */ WORD_LIST * -array_to_word_list(a) -ARRAY *a; +array_to_word_list(ARRAY *a) { WORD_LIST *list; ARRAY_ELEMENT *ae; @@ -763,8 +720,7 @@ ARRAY *a; } ARRAY * -array_from_word_list (list) -WORD_LIST *list; +array_from_word_list (WORD_LIST *list) { ARRAY *a; @@ -775,8 +731,7 @@ WORD_LIST *list; } WORD_LIST * -array_keys_to_word_list(a) -ARRAY *a; +array_keys_to_word_list(ARRAY *a) { WORD_LIST *list; ARRAY_ELEMENT *ae; @@ -794,8 +749,7 @@ ARRAY *a; } WORD_LIST * -array_to_kvpair_list(a) -ARRAY *a; +array_to_kvpair_list(ARRAY *a) { WORD_LIST *list; ARRAY_ELEMENT *ae; @@ -815,9 +769,7 @@ ARRAY *a; } ARRAY * -array_assign_list (array, list) -ARRAY *array; -WORD_LIST *list; +array_assign_list (ARRAY *array, WORD_LIST *list) { register WORD_LIST *l; register arrayind_t i; @@ -828,9 +780,7 @@ WORD_LIST *list; } char ** -array_to_argv (a, countp) -ARRAY *a; -int *countp; +array_to_argv (ARRAY *a, int *countp) { char **ret, *t; int i; @@ -855,10 +805,7 @@ int *countp; } ARRAY * -array_from_argv(a, vec, count) -ARRAY *a; -char **vec; -int count; +array_from_argv(ARRAY *a, char **vec, int count) { arrayind_t i; ARRAY_ELEMENT *ae; @@ -908,10 +855,7 @@ int count; * 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; @@ -949,9 +893,7 @@ int quoted; } 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]; @@ -1003,9 +945,7 @@ int quoted; } 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]; @@ -1057,10 +997,7 @@ int quoted; } char * -array_to_string (a, sep, quoted) -ARRAY *a; -char *sep; -int quoted; +array_to_string (ARRAY *a, char *sep, int quoted) { if (a == 0) return((char *)NULL); @@ -1074,8 +1011,7 @@ int quoted; * Return an array consisting of elements in S, separated by SEP */ ARRAY * -array_from_string(s, sep) -char *s, *sep; +array_from_string(char *s, char *sep) { ARRAY *a; WORD_LIST *w; @@ -1098,8 +1034,7 @@ char *s, *sep; int interrupt_immediately = 0; int -signal_is_trapped(s) -int s; +signal_is_trapped(int s) { return 0; } @@ -1119,8 +1054,7 @@ programming_error(const char *s, ...) } WORD_DESC * -make_bare_word (s) -const char *s; +make_bare_word (const char *s) { WORD_DESC *w; @@ -1131,9 +1065,7 @@ const char *s; } WORD_LIST * -make_word_list(x, l) -WORD_DESC *x; -WORD_LIST *l; +make_word_list(WORD_DESC *x, WORD_LIST *l) { WORD_LIST *w; @@ -1144,9 +1076,7 @@ WORD_LIST *l; } WORD_LIST * -list_string(s, t, i) -char *s, *t; -int i; +list_string(char *s, char *t, int i) { char *r, *a; WORD_LIST *wl; @@ -1164,8 +1094,7 @@ int i; } GENERIC_LIST * -list_reverse (list) -GENERIC_LIST *list; +list_reverse (GENERIC_LIST *list) { register GENERIC_LIST *next, *prev; @@ -1179,22 +1108,18 @@ GENERIC_LIST *list; } char * -pat_subst(s, t, u, i) -char *s, *t, *u; -int i; +pat_subst(char *s, char *t, char *u, int i) { return ((char *)NULL); } char * -quote_string(s) -char *s; +quote_string(char *s) { return savestring(s); } -print_element(ae) -ARRAY_ELEMENT *ae; +print_element(ARRAY_ELEMENT *ae) { char lbuf[INT_STRLEN_BOUND (intmax_t) + 1]; @@ -1203,14 +1128,13 @@ ARRAY_ELEMENT *ae; 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; diff --git a/arrayfunc.c b/arrayfunc.c index 2c05d15b4..17be8ccf7 100644 --- a/arrayfunc.c +++ b/arrayfunc.c @@ -1,6 +1,6 @@ /* 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. @@ -52,15 +52,15 @@ int assoc_expand_once = 0; /* 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"); @@ -74,8 +74,7 @@ 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; @@ -112,8 +111,7 @@ convert_var_to_array (var) /* 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; @@ -148,12 +146,7 @@ convert_var_to_assoc (var) } 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; @@ -195,12 +188,7 @@ make_array_variable_value (entry, ind, key, value, flags) 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; @@ -223,12 +211,7 @@ bind_assoc_var_internal (entry, hash, key, value, flags) /* 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; @@ -256,11 +239,7 @@ bind_array_var_internal (entry, ind, key, value, flags) 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; @@ -291,22 +270,13 @@ bind_array_variable (name, ind, value, flags) } 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)) { @@ -341,10 +311,7 @@ flush_eltstate (array_eltstate_t *estatep) 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; @@ -392,15 +359,9 @@ assign_array_element (name, value, flags, estatep) } 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; @@ -462,9 +423,7 @@ assign_array_element_internal (entry, name, vname, sub, sublen, value, flags, es 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; @@ -515,9 +474,7 @@ find_or_make_array_variable (name, flags) /* 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; @@ -536,10 +493,7 @@ assign_array_from_string (name, value, flags) /* 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; @@ -557,10 +511,7 @@ assign_array_var_from_word_list (var, list, flags) } 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; @@ -625,11 +576,7 @@ expand_compound_array_assignment (var, value, flags) #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; @@ -665,15 +612,13 @@ assign_assoc_from_kvlist (var, nlist, h, flags) /* 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; @@ -696,10 +641,7 @@ expand_and_quote_kvpair_word (w) 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; @@ -876,10 +818,7 @@ assign_compound_array_list (var, nlist, flags) /* 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; @@ -902,8 +841,7 @@ assign_array_var_from_string (var, value, flags) 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; @@ -949,9 +887,7 @@ quote_assign (string) 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; @@ -997,9 +933,7 @@ quote_compound_array_word (w, type) 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; @@ -1050,9 +984,7 @@ expand_and_quote_assoc_word (w, type) 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; @@ -1078,8 +1010,7 @@ quote_compound_array_list (list, type) /* 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; @@ -1112,10 +1043,7 @@ quote_array_assignment_chars (list) 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; @@ -1209,9 +1137,7 @@ unbind_array_element (var, sub, flags) /* 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; @@ -1229,9 +1155,7 @@ print_array_assignment (var, quoted) /* 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; @@ -1254,8 +1178,6 @@ print_assoc_assignment (var, quoted) /* 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 @@ -1264,10 +1186,7 @@ print_assoc_assignment (var, quoted) 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; @@ -1327,20 +1246,14 @@ tokenize_array_reference (name, flags, subp) /* 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; @@ -1382,11 +1295,7 @@ array_expand_index (var, s, len, flags) 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; @@ -1436,11 +1345,7 @@ array_variable_name (s, flags, subp, lenp) 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; @@ -1475,10 +1380,7 @@ array_variable_part (s, flags, subp, lenp) 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; @@ -1636,10 +1538,7 @@ array_value_internal (s, quoted, flags, estatep) /* 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; @@ -1652,10 +1551,7 @@ array_value (s, quoted, flags, estatep) 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; @@ -1664,9 +1560,7 @@ get_array_value (s, flags, estatep) } 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; diff --git a/assoc.c b/assoc.c index cbb5c7e4f..d61545d09 100644 --- a/assoc.c +++ b/assoc.c @@ -7,7 +7,7 @@ * 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. @@ -44,13 +44,12 @@ #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) { @@ -60,17 +59,13 @@ assoc_dispose (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; @@ -89,10 +84,7 @@ assoc_insert (hash, key, value) /* 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; @@ -111,9 +103,7 @@ assoc_replace (hash, key, value) } void -assoc_remove (hash, string) - HASH_TABLE *hash; - char *string; +assoc_remove (HASH_TABLE *hash, char *string) { BUCKET_CONTENTS *b; @@ -127,9 +117,7 @@ assoc_remove (hash, string) } char * -assoc_reference (hash, string) - HASH_TABLE *hash; - char *string; +assoc_reference (HASH_TABLE *hash, char *string) { BUCKET_CONTENTS *b; @@ -143,8 +131,7 @@ assoc_reference (hash, string) /* 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; @@ -167,8 +154,7 @@ assoc_quote (h) /* 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; @@ -189,8 +175,7 @@ assoc_quote_escapes (h) } HASH_TABLE * -assoc_dequote (h) - HASH_TABLE *h; +assoc_dequote (HASH_TABLE *h) { int i; BUCKET_CONTENTS *tlist; @@ -211,8 +196,7 @@ assoc_dequote (h) } HASH_TABLE * -assoc_dequote_escapes (h) - HASH_TABLE *h; +assoc_dequote_escapes (HASH_TABLE *h) { int i; BUCKET_CONTENTS *tlist; @@ -233,8 +217,7 @@ assoc_dequote_escapes (h) } HASH_TABLE * -assoc_remove_quoted_nulls (h) - HASH_TABLE *h; +assoc_remove_quoted_nulls (HASH_TABLE *h) { int i; BUCKET_CONTENTS *tlist; @@ -258,10 +241,7 @@ assoc_remove_quoted_nulls (h) * 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; @@ -296,14 +276,12 @@ assoc_subrange (hash, start, nelem, starsub, quoted, pflags) 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; @@ -334,11 +312,7 @@ assoc_patsub (h, pat, rep, mflags) } 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; @@ -369,9 +343,7 @@ assoc_modcase (h, pat, modop, mflags) } char * -assoc_to_kvpair (hash, quoted) - HASH_TABLE *hash; - int quoted; +assoc_to_kvpair (HASH_TABLE *hash, int quoted) { char *ret; char *istr, *vstr; @@ -439,9 +411,7 @@ assoc_to_kvpair (hash, quoted) } char * -assoc_to_assign (hash, quoted) - HASH_TABLE *hash; - int quoted; +assoc_to_assign (HASH_TABLE *hash, int quoted) { char *ret; char *istr, *vstr; @@ -508,9 +478,7 @@ assoc_to_assign (hash, quoted) } 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; @@ -531,22 +499,19 @@ assoc_to_word_list_internal (h, t) } 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; @@ -569,10 +534,7 @@ assoc_to_kvpair_list (h) } 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; diff --git a/bashhist.c b/bashhist.c index 90cd8c34f..8295188e7 100644 --- a/bashhist.c +++ b/bashhist.c @@ -1,6 +1,6 @@ /* 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. @@ -68,10 +68,10 @@ extern int rl_done, rl_dispatching; /* should really include readline.h */ 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 = { @@ -193,25 +193,23 @@ int hist_verify; 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]; @@ -267,7 +265,7 @@ bash_history_inhibit_expansion (string, i) #endif void -bash_initialize_history () +bash_initialize_history (void) { history_quotes_inhibit_expansion = 1; history_search_delimiter_chars = ";&()|<>"; @@ -278,8 +276,7 @@ bash_initialize_history () } void -bash_history_reinit (interact) - int interact; +bash_history_reinit (int interact) { #if defined (BANG_HISTORY) history_expansion = (interact == 0) ? histexp_flag : HISTEXPAND_DEFAULT; @@ -290,7 +287,7 @@ bash_history_reinit (interact) } void -bash_history_disable () +bash_history_disable (void) { remember_on_history = 0; #if defined (BANG_HISTORY) @@ -299,7 +296,7 @@ bash_history_disable () } void -bash_history_enable () +bash_history_enable (void) { remember_on_history = enable_history_list = 1; #if defined (BANG_HISTORY) @@ -312,7 +309,7 @@ bash_history_enable () /* Load the history list from the history file. */ void -load_history () +load_history (void) { char *hf; @@ -343,7 +340,7 @@ load_history () } void -bash_clear_history () +bash_clear_history (void) { clear_history (); history_lines_this_session = 0; @@ -352,8 +349,7 @@ bash_clear_history () /* 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; @@ -367,8 +363,7 @@ bash_delete_histent (i) } 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; @@ -385,7 +380,7 @@ bash_delete_history_range (first, last) } int -bash_delete_last_history () +bash_delete_last_history (void) { register int i; HIST_ENTRY **hlist, *histent; @@ -415,7 +410,7 @@ bash_delete_last_history () #ifdef INCLUDE_UNUSED /* Write the existing history out to the history file. */ void -save_history () +save_history (void) { char *hf; int r; @@ -437,8 +432,7 @@ save_history () #endif int -maybe_append_history (filename) - char *filename; +maybe_append_history (char *filename) { int fd, result, histlen; struct stat buf; @@ -476,7 +470,7 @@ maybe_append_history (filename) /* 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; @@ -523,8 +517,7 @@ maybe_save_shell_history () #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); @@ -533,8 +526,7 @@ 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; @@ -552,9 +544,7 @@ history_expansion_p (line) 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; @@ -650,8 +640,7 @@ pre_process_line (line, print_changes, addit) 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; @@ -672,8 +661,7 @@ shell_comment (line) /* 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; @@ -688,8 +676,7 @@ filter_comments (line) /* 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; @@ -721,8 +708,7 @@ check_history_control (line) /* 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; @@ -756,8 +742,7 @@ hc_erasedups (line) 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; @@ -786,9 +771,7 @@ maybe_add_history (line) 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) { @@ -825,8 +808,7 @@ int syslog_history = 1; #endif void -bash_syslog_history (line) - const char *line; +bash_syslog_history (const char *line) { char trunc[SYSLOG_MAXLEN], *msg; char loghdr[SYSLOG_MAXHDR]; @@ -869,8 +851,7 @@ bash_syslog_history (line) 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; @@ -959,8 +940,7 @@ bash_add_history (line) } static void -really_add_history (line) - char *line; +really_add_history (char *line) { hist_last_line_added = 1; hist_last_line_pushed = 0; @@ -969,15 +949,14 @@ really_add_history (line) } 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; @@ -992,8 +971,7 @@ should_expand (s) } static int -histignore_item_func (ign) - struct ign *ign; +histignore_item_func (struct ign *ign) { if (should_expand (ign->val)) ign->flags |= HIGN_EXPAND; @@ -1001,14 +979,13 @@ histignore_item_func (ign) } 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; @@ -1019,7 +996,7 @@ last_history_entry () } char * -last_history_line () +last_history_line (void) { HIST_ENTRY *he; @@ -1030,8 +1007,7 @@ last_history_line () } static char * -expand_histignore_pattern (pat) - char *pat; +expand_histignore_pattern (char *pat) { HIST_ENTRY *phe; char *ret; @@ -1049,8 +1025,7 @@ expand_histignore_pattern (pat) /* 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; diff --git a/bashline.c b/bashline.c index 5660283c9..ab761ee07 100644 --- a/bashline.c +++ b/bashline.c @@ -104,127 +104,127 @@ #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 @@ -240,40 +240,40 @@ extern sh_timer *read_timeout; #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; @@ -346,8 +346,7 @@ static rl_command_func_t *vi_tab_binding = rl_complete; /* 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 */ @@ -368,7 +367,7 @@ posix_readline_initialize (on_or_off) } 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); } @@ -376,8 +375,7 @@ reset_completer_word_break_chars () /* 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; @@ -450,7 +448,7 @@ enable_hostname_completion (on_or_off) /* 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]; @@ -654,19 +652,19 @@ initialize_readline () } 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; } @@ -677,7 +675,7 @@ bashline_reset_event_hook () 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; @@ -702,7 +700,7 @@ static char *push_to_readline = (char *)NULL; /* Push the contents of push_to_readline into the readline buffer. */ static int -bash_push_line () +bash_push_line (void) { if (push_to_readline) { @@ -717,8 +715,7 @@ bash_push_line () /* 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); @@ -730,8 +727,7 @@ bash_re_edit (line) } static int -display_shell_version (count, c) - int count, c; +display_shell_version (int count, int c) { rl_crlf (); show_shell_version (0); @@ -767,7 +763,7 @@ int hostname_list_initialized = 0; /* Initialize the hostname completion table. */ static void -initialize_hostname_list () +initialize_hostname_list (void) { char *temp; @@ -785,8 +781,7 @@ initialize_hostname_list () /* 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) { @@ -801,8 +796,7 @@ add_host_name (name) #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]; @@ -868,7 +862,7 @@ snarf_hosts_from_file (filename) /* Return the hostname list. */ char ** -get_hostname_list () +get_hostname_list (void) { if (hostname_list_initialized == 0) initialize_hostname_list (); @@ -876,7 +870,7 @@ get_hostname_list () } void -clear_hostname_list () +clear_hostname_list (void) { register int i; @@ -891,8 +885,7 @@ clear_hostname_list () 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; @@ -945,9 +938,7 @@ hostnames_matching (text) #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; @@ -1021,27 +1012,24 @@ edit_and_execute_command (count, c, editing_mode, edit_command) #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; @@ -1069,8 +1057,7 @@ posix_edit_macros (count, key) #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; @@ -1178,8 +1165,7 @@ bash_forward_shellword (count, key) } 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; @@ -1240,8 +1226,7 @@ bash_backward_shellword (count, key) } static int -bash_kill_shellword (count, key) - int count, key; +bash_kill_shellword (int count, int key) { int p; @@ -1262,8 +1247,7 @@ bash_kill_shellword (count, key) } static int -bash_backward_kill_shellword (count, key) - int count, key; +bash_backward_kill_shellword (int count, int key) { int p; @@ -1283,8 +1267,7 @@ bash_backward_kill_shellword (count, key) } 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; @@ -1344,8 +1327,7 @@ bash_transpose_shellwords (count, key) /* 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; @@ -1403,9 +1385,8 @@ bash_spell_correct_shellword (count, key) /* 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; @@ -1441,8 +1422,7 @@ check_redir (ti) * 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; @@ -1490,8 +1470,7 @@ find_cmd_start (start) } static int -find_cmd_end (end) - int end; +find_cmd_end (int end) { register int e; @@ -1500,9 +1479,7 @@ find_cmd_end (end) } 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; @@ -1524,9 +1501,7 @@ find_cmd_name (start, sp, ep) } static char * -prog_complete_return (text, matchnum) - const char *text; - int matchnum; +prog_complete_return (const char *text, int matchnum) { static int ind; @@ -1543,9 +1518,7 @@ prog_complete_return (text, matchnum) /* 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; @@ -1571,9 +1544,7 @@ invalid_completion (text, ind) /* 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; @@ -1798,9 +1769,7 @@ attempt_shell_completion (text, start, end) } 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; @@ -1922,8 +1891,7 @@ bash_default_completion (text, start, end, qc, compflags) } static int -bash_command_name_stat_hook (name) - char **name; +bash_command_name_stat_hook (char **name) { char *cname, *result; @@ -1945,9 +1913,7 @@ bash_command_name_stat_hook (name) } 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; @@ -1972,9 +1938,7 @@ executable_completion (filename, searching_path) 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; @@ -2407,9 +2371,7 @@ globword: /* 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; @@ -2490,9 +2452,7 @@ command_subst_completion_function (text, state) /* 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; @@ -2550,9 +2510,7 @@ variable_completion_function (text, state) /* 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; @@ -2593,9 +2551,7 @@ hostname_completion_function (text, state) * 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); @@ -2651,9 +2607,7 @@ bash_servicename_completion_function (text, state) * 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); @@ -2696,8 +2650,7 @@ bash_groupname_completion_function (text, state) 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; @@ -2714,7 +2667,7 @@ history_expand_line_internal (line) /* 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) @@ -2739,8 +2692,7 @@ cleanup_expansion_error () 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) { @@ -2756,8 +2708,7 @@ maybe_make_readline_line (new_line) /* 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; @@ -2783,8 +2734,7 @@ set_up_new_line (new_line) #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; @@ -2806,8 +2756,7 @@ alias_expand_line (count, ignore) #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; @@ -2828,8 +2777,7 @@ history_expand_line (count, ignore) /* 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; @@ -2851,8 +2799,7 @@ tcsh_magic_space (count, ignore) /* 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; @@ -2889,8 +2836,7 @@ history_and_alias_expand_line (count, ignore) 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; @@ -2991,9 +2937,7 @@ static struct ignorevar fignore = }; 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; @@ -3082,8 +3026,7 @@ _ignore_completion_names (names, name_func) } static int -name_is_acceptable (name) - const char *name; +name_is_acceptable (const char *name) { struct ign *p; int nlen; @@ -3099,16 +3042,14 @@ name_is_acceptable (name) #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) @@ -3127,8 +3068,7 @@ filename_completion_ignore (names) /* 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; @@ -3141,8 +3081,7 @@ test_for_directory (name) } static int -test_for_canon_directory (name) - const char *name; +test_for_canon_directory (const char *name) { char *fn; int r; @@ -3157,31 +3096,27 @@ test_for_canon_directory (name) /* 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; @@ -3191,8 +3126,7 @@ bash_ignore_everything (names) 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; @@ -3248,8 +3182,7 @@ restore_tilde (val, directory_part) } 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; @@ -3265,8 +3198,7 @@ maybe_restore_tilde (val, directory_part) 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; @@ -3295,9 +3227,7 @@ bash_directory_expansion (dirname) /* 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; @@ -3310,7 +3240,7 @@ bash_filename_rewrite_hook (fname, fnlen) /* 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) { @@ -3325,7 +3255,7 @@ set_directory_hook () } static rl_icppfunc_t * -save_directory_hook () +save_directory_hook (void) { rl_icppfunc_t *ret; @@ -3344,8 +3274,7 @@ save_directory_hook () } 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; @@ -3356,9 +3285,7 @@ restore_directory_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; @@ -3380,8 +3307,7 @@ directory_exists (dirname, should_dequote) } static char * -bash_expand_filename (filename) - char *filename; +bash_expand_filename (char *filename) { char *newname; int global_nounset; @@ -3414,8 +3340,7 @@ bash_expand_filename (filename) /* 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; @@ -3494,8 +3419,7 @@ bash_filename_stat_hook (dirname) 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; @@ -3636,7 +3560,7 @@ static int harry_size; static int harry_len; static void -build_history_completion_array () +build_history_completion_array (void) { register int i, j; HIST_ENTRY **hlist; @@ -3682,9 +3606,7 @@ build_history_completion_array () } 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; @@ -3711,8 +3633,7 @@ history_completion_generator (hint_text, state) } 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; @@ -3741,8 +3662,7 @@ dynamic_complete_history (count, key) } 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; @@ -3781,43 +3701,37 @@ bash_dabbrev_expand (count, key) #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; @@ -3851,71 +3765,61 @@ bash_complete_filename_internal (what_to_do) } 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); } @@ -3924,9 +3828,7 @@ static char *globtext; 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; @@ -3970,8 +3872,7 @@ glob_complete_word (text, state) } 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); } @@ -3979,10 +3880,7 @@ bash_glob_completion_internal (what_to_do) /* 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)); @@ -3991,8 +3889,7 @@ bash_glob_quote_filename (s, rtype, qcp) } 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; @@ -4009,23 +3906,19 @@ bash_glob_complete_word (count, key) } 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; @@ -4056,8 +3949,7 @@ bash_specific_completion (what_to_do, generator) 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; @@ -4112,9 +4004,7 @@ bash_vi_complete (count, key) 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; @@ -4161,8 +4051,7 @@ bash_dequote_filename (text, quote_char) 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; @@ -4202,10 +4091,7 @@ quote_word_break_chars (text) 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; @@ -4261,8 +4147,7 @@ bash_check_expchar (dirname, need_closer, nextp, closerp) 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; @@ -4286,8 +4171,7 @@ set_filename_quote_chars (expchar, nextch, closer) 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; @@ -4303,10 +4187,7 @@ set_filename_bstab (string) 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; @@ -4444,8 +4325,7 @@ static void #else static int #endif -putx(c) - int c; +putx(int c) { int x; x = putc (c, rl_outstream); @@ -4455,8 +4335,7 @@ putx(c) } static int -readline_get_char_offset (ind) - int ind; +readline_get_char_offset (int ind) { int r, old_ch; @@ -4474,9 +4353,7 @@ readline_get_char_offset (ind) } static void -readline_set_char_offset (ind, varp) - int ind; - int *varp; +readline_set_char_offset (int ind, int *varp) { int i; @@ -4497,9 +4374,7 @@ readline_set_char_offset (ind, varp) } 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; @@ -4613,7 +4488,7 @@ bash_execute_unix_command (count, key) } int -print_unix_command_map () +print_unix_command_map (void) { Keymap save, cmd_xmap; @@ -4626,7 +4501,7 @@ print_unix_command_map () } static void -init_unix_command_map () +init_unix_command_map (void) { emacs_std_cmd_xmap = rl_make_bare_keymap (); @@ -4642,7 +4517,7 @@ init_unix_command_map () } 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 (); @@ -4661,8 +4536,7 @@ get_cmd_xmap_from_edit_mode () } 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 (); @@ -4684,9 +4558,7 @@ get_cmd_xmap_from_keymap (kmap) } 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; @@ -4733,8 +4605,7 @@ isolate_sequence (string, ind, need_dquote, startp) } int -bind_keyseq_to_unix_command (line) - char *line; +bind_keyseq_to_unix_command (char *line) { Keymap kmap, cmd_xmap; char *kseq, *value; @@ -4784,8 +4655,7 @@ bind_keyseq_to_unix_command (line) } int -unbind_unix_command (kseq) - char *kseq; +unbind_unix_command (char *kseq) { Keymap cmd_xmap; @@ -4802,8 +4672,7 @@ unbind_unix_command (kseq) 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; @@ -4831,8 +4700,7 @@ bash_directory_completion_matches (text) } char * -bash_dequote_text (text) - const char *text; +bash_dequote_text (const char *text) { char *dtxt; int qc; @@ -4847,7 +4715,7 @@ bash_dequote_text (text) and fatal signals without executing too much code in a signal handler context. */ static int -bash_event_hook () +bash_event_hook (void) { int sig; diff --git a/braces.c b/braces.c index 16eca18e8..761406d91 100644 --- a/braces.c +++ b/braces.c @@ -1,6 +1,6 @@ /* 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. @@ -59,7 +59,7 @@ extern int errno; #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: @@ -73,19 +73,11 @@ extern int asprintf PARAMS((char **, const char *, ...)) __attribute__((__format /* 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 @@ -101,8 +93,7 @@ dump_result (a) /* 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; @@ -282,10 +273,7 @@ add_tack: 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; @@ -357,9 +345,7 @@ expand_amble (text, tlen, flags) #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; @@ -469,9 +455,7 @@ mkseq (start, end, incr, type, width) } 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; @@ -591,11 +575,7 @@ expand_seqterm (text, tlen) 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) @@ -729,8 +709,7 @@ comsub: 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; @@ -795,29 +774,25 @@ array_concat (arr1, arr2) #include 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]; diff --git a/builtins/alias.def b/builtins/alias.def index b21005e60..fa186d7ea 100644 --- a/builtins/alias.def +++ b/builtins/alias.def @@ -67,8 +67,7 @@ static void print_alias (alias_t *, int); /* 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; @@ -167,10 +166,9 @@ $END #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; @@ -224,9 +222,7 @@ unalias_builtin (list) /* 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; diff --git a/builtins/bind.def b/builtins/bind.def index c6c360460..367ef86a7 100644 --- a/builtins/bind.def +++ b/builtins/bind.def @@ -108,8 +108,7 @@ static int unbind_keyseq (char *); #define XXFLAG 0x2000 int -bind_builtin (list) - WORD_LIST *list; +bind_builtin (WORD_LIST *list) { int return_code; Keymap kmap, saved_keymap; @@ -315,8 +314,7 @@ bind_builtin (list) } static int -query_bindings (name) - char *name; +query_bindings (char *name) { rl_command_func_t *function; char **keyseqs; @@ -347,8 +345,7 @@ query_bindings (name) } static int -unbind_command (name) - char *name; +unbind_command (char *name) { rl_command_func_t *function; @@ -364,8 +361,7 @@ unbind_command (name) } static int -unbind_keyseq (seq) - char *seq; +unbind_keyseq (char *seq) { char *kseq; int kslen, type; diff --git a/builtins/break.def b/builtins/break.def index ee593b502..820377e1b 100644 --- a/builtins/break.def +++ b/builtins/break.def @@ -60,8 +60,7 @@ int continuing = 0; /* 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; @@ -102,8 +101,7 @@ $END /* 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; @@ -132,7 +130,7 @@ continue_builtin (list) /* 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) diff --git a/builtins/builtin.def b/builtins/builtin.def index 74060ee09..3ceb50a6d 100644 --- a/builtins/builtin.def +++ b/builtins/builtin.def @@ -1,7 +1,7 @@ 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. @@ -50,8 +50,7 @@ $END /* 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; diff --git a/builtins/caller.def b/builtins/caller.def index 57746a299..b859ee558 100644 --- a/builtins/caller.def +++ b/builtins/caller.def @@ -2,7 +2,7 @@ This file is caller.def, from which is created caller.c. It implements the 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. @@ -69,8 +69,7 @@ extern int errno; #endif /* !errno */ int -caller_builtin (list) - WORD_LIST *list; +caller_builtin (WORD_LIST *list) { #if !defined (ARRAY_VARS) printf ("1 NULL\n"); diff --git a/builtins/cd.def b/builtins/cd.def index ba18f158e..7481000d4 100644 --- a/builtins/cd.def +++ b/builtins/cd.def @@ -115,8 +115,7 @@ $END /* 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; @@ -134,8 +133,7 @@ setpwd (dirname) } static int -bindpwd (no_symlinks) - int no_symlinks; +bindpwd (int no_symlinks) { char *dirname, *pwdvar; int old_anm, r, canon_failed; @@ -183,8 +181,7 @@ bindpwd (no_symlinks) /* Call get_working_directory to reset the value of the_current_working_directory () */ static char * -resetpwd (caller) - char *caller; +resetpwd (char *caller) { char *tdir; @@ -194,10 +191,9 @@ resetpwd (caller) 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; @@ -241,7 +237,7 @@ cdxattr (dir, ndirp) /* Clean up the O_XATTR baggage. Currently only closes xattrfd */ static void -resetxattr () +resetxattr (void) { #if defined (O_XATTR) if (xattrfd >= 0) @@ -264,8 +260,7 @@ resetxattr () 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; @@ -482,8 +477,7 @@ static int verbatim_pwd; /* 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; @@ -548,9 +542,7 @@ pwd_builtin (list) 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; diff --git a/builtins/colon.def b/builtins/colon.def index 6891b0799..7fe8cf00f 100644 --- a/builtins/colon.def +++ b/builtins/colon.def @@ -1,7 +1,7 @@ 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. @@ -61,16 +61,14 @@ $END /* 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); } diff --git a/builtins/command.def b/builtins/command.def index 818556e66..9689e9558 100644 --- a/builtins/command.def +++ b/builtins/command.def @@ -63,8 +63,7 @@ extern size_t confstr (int, char *, size_t); /* 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; diff --git a/builtins/complete.def b/builtins/complete.def index e060243bb..0d9b92938 100644 --- a/builtins/complete.def +++ b/builtins/complete.def @@ -153,8 +153,7 @@ static const struct _compopt { }; static int -find_compact (name) - char *name; +find_compact (char *name) { register int i; @@ -165,8 +164,7 @@ find_compact (name) } static int -find_compopt (name) - char *name; +find_compopt (char *name) { register int i; @@ -191,10 +189,7 @@ find_compopt (name) */ 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; @@ -367,8 +362,7 @@ build_actions (list, flagp, actp, optp) /* 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; @@ -473,8 +467,7 @@ complete_builtin (list) } static int -remove_cmd_completions (list) - WORD_LIST *list; +remove_cmd_completions (WORD_LIST *list) { WORD_LIST *l; int ret; @@ -491,9 +484,7 @@ remove_cmd_completions (list) } static void -print_compoptions (copts, full) - unsigned long copts; - int full; +print_compoptions (unsigned long copts, int full) { const struct _compopt *co; @@ -505,8 +496,7 @@ print_compoptions (copts, full) } static void -print_compactions (acts) - unsigned long acts; +print_compactions (unsigned long acts) { const struct _compacts *ca; @@ -522,9 +512,7 @@ print_compactions (acts) } 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; @@ -538,8 +526,7 @@ print_arg (arg, flag, quote) } static void -print_cmd_name (cmd) - const char *cmd; +print_cmd_name (const char *cmd) { char *x; @@ -562,9 +549,7 @@ print_cmd_name (cmd) } static int -print_one_completion (cmd, cs) - char *cmd; - COMPSPEC *cs; +print_one_completion (char *cmd, COMPSPEC *cs) { printf ("complete "); @@ -592,10 +577,7 @@ print_one_completion (cmd, cs) } 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 "); @@ -606,8 +588,7 @@ print_compopts (cmd, cs, full) } static int -print_compitem (item) - BUCKET_CONTENTS *item; +print_compitem (BUCKET_CONTENTS *item) { COMPSPEC *cs; char *cmd; @@ -619,14 +600,13 @@ print_compitem (item) } 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; @@ -662,8 +642,7 @@ Returns success unless an invalid option is supplied or an error occurs. $END int -compgen_builtin (list) - WORD_LIST *list; +compgen_builtin (WORD_LIST *list) { int rval; unsigned long acts, copts; @@ -787,8 +766,7 @@ have a completion specification defined. $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; diff --git a/builtins/declare.def b/builtins/declare.def index ac9a3b5dd..c8643760f 100644 --- a/builtins/declare.def +++ b/builtins/declare.def @@ -99,8 +99,7 @@ static int declare_internal (register WORD_LIST *, int); /* Declare or change variable attributes. */ int -declare_builtin (list) - register WORD_LIST *list; +declare_builtin (WORD_LIST *list) { return (declare_internal (list, 0)); } @@ -121,8 +120,7 @@ Returns success unless an invalid option is supplied, a variable 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")) @@ -147,9 +145,7 @@ local_builtin (list) #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; @@ -170,11 +166,7 @@ declare_find_variable (name, mkglobal, chklocal) 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; @@ -204,9 +196,7 @@ declare_build_newname (name, subscript_start, offset, value, aflags) } 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; @@ -230,9 +220,7 @@ declare_transform_name (name, flags_on, flags_off) /* 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; diff --git a/builtins/echo.def b/builtins/echo.def index 4e2243dbe..ae69b76a8 100644 --- a/builtins/echo.def +++ b/builtins/echo.def @@ -1,7 +1,7 @@ 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. @@ -107,8 +107,7 @@ int xpg_echo = 0; `-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; diff --git a/builtins/enable.def b/builtins/enable.def index f3b8ec03c..cabb4a7a9 100644 --- a/builtins/enable.def +++ b/builtins/enable.def @@ -106,8 +106,7 @@ static int enable_shell_command (char *, int); 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; @@ -254,10 +253,9 @@ enable_builtin (list) } /* 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; @@ -281,9 +279,7 @@ list_some_builtins (filter) /* 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; @@ -318,10 +314,7 @@ enable_shell_command (name, disable_p) #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; @@ -483,8 +476,7 @@ dyn_load_builtin (list, flags, filename) #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; @@ -519,8 +511,7 @@ delete_builtin (b) /* 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)); @@ -531,8 +522,7 @@ local_dlclose (handle) } static int -dyn_unload_builtin (name) - char *name; +dyn_unload_builtin (char *name) { struct builtin *b; void *handle; diff --git a/builtins/eval.def b/builtins/eval.def index f459bce34..0160b9618 100644 --- a/builtins/eval.def +++ b/builtins/eval.def @@ -1,7 +1,7 @@ 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. @@ -46,8 +46,7 @@ $END /* 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); diff --git a/builtins/evalstring.c b/builtins/evalstring.c index 29ee1dfe3..718ff393d 100644 --- a/builtins/evalstring.c +++ b/builtins/evalstring.c @@ -70,24 +70,21 @@ static int cat_file (REDIRECT *); #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 && @@ -103,8 +100,7 @@ should_optimize_fork (command, subshell) -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; @@ -116,8 +112,7 @@ should_suppress_fork (command) } int -can_optimize_connection (command) - COMMAND *command; +can_optimize_connection (COMMAND *command) { return (*bash_input.location.string == '\0' && parser_expanding_alias () == 0 && @@ -126,8 +121,7 @@ can_optimize_connection (command) } 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 == ';') && @@ -141,8 +135,7 @@ optimize_connection_fork (command) } void -optimize_subshell_command (command) - COMMAND *command; +optimize_subshell_command (COMMAND *command) { if (should_optimize_fork (command, 0)) { @@ -160,8 +153,7 @@ optimize_subshell_command (command) } void -optimize_shell_function (command) - COMMAND *command; +optimize_shell_function (COMMAND *command) { COMMAND *fc; @@ -180,8 +172,7 @@ optimize_shell_function (command) } 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 && @@ -194,8 +185,7 @@ can_optimize_cat_file (command) /* 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) { @@ -215,10 +205,7 @@ parse_and_execute_cleanup (old_running_trap) } 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; @@ -295,10 +282,7 @@ parse_prologue (string, flags, tag) */ 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; @@ -605,12 +589,7 @@ parse_and_execute (string, from_file, flags) 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; @@ -734,9 +713,7 @@ out: } int -open_redir_file (r, fnp) - REDIRECT *r; - char **fnp; +open_redir_file (REDIRECT *r, char **fnp) { char *fn; int fd, rval; @@ -776,8 +753,7 @@ open_redir_file (r, fnp) 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; @@ -795,10 +771,7 @@ cat_file (r) } 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; diff --git a/builtins/exec.def b/builtins/exec.def index add908229..b0638dac3 100644 --- a/builtins/exec.def +++ b/builtins/exec.def @@ -1,7 +1,7 @@ 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. @@ -85,8 +85,7 @@ int no_exit_on_failed_exec; /* 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; @@ -97,8 +96,7 @@ mkdashname (name) } int -exec_builtin (list) - WORD_LIST *list; +exec_builtin (WORD_LIST *list) { int exit_value = EXECUTION_FAILURE; int cleanenv, login, opt, orig_job_control; diff --git a/builtins/exit.def b/builtins/exit.def index eca5d82e8..a1469cdd1 100644 --- a/builtins/exit.def +++ b/builtins/exit.def @@ -54,8 +54,7 @@ static int exit_or_logout (WORD_LIST *); static int sourced_logout; int -exit_builtin (list) - WORD_LIST *list; +exit_builtin (WORD_LIST *list) { CHECK_HELPOPT (list); @@ -79,8 +78,7 @@ $END /* How to logout. */ int -logout_builtin (list) - WORD_LIST *list; +logout_builtin (WORD_LIST *list) { CHECK_HELPOPT (list); @@ -94,8 +92,7 @@ logout_builtin (list) } static int -exit_or_logout (list) - WORD_LIST *list; +exit_or_logout (WORD_LIST *list) { int exit_value; @@ -156,7 +153,7 @@ exit_or_logout (list) } 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) diff --git a/builtins/fc.def b/builtins/fc.def index 5070be86d..bd321b730 100644 --- a/builtins/fc.def +++ b/builtins/fc.def @@ -165,7 +165,7 @@ static void fc_addhist (char *); #endif static void -set_verbose_flag () +set_verbose_flag (void) { echo_input_at_read = verbose_flag; } @@ -179,8 +179,7 @@ set_verbose_flag () #endif int -fc_builtin (list) - WORD_LIST *list; +fc_builtin (WORD_LIST *list) { register int i; register char *sep; @@ -529,8 +528,7 @@ fc_builtin (list) /* 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; @@ -549,10 +547,7 @@ fc_number (list) 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; @@ -654,10 +649,7 @@ fc_gethnum (command, hlist, mode) 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; @@ -677,8 +669,7 @@ fc_gethist (command, hlist, mode) 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; @@ -721,9 +712,7 @@ fc_readline (stream) 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; @@ -742,8 +731,7 @@ fc_dosubs (command, subs) 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; @@ -764,8 +752,7 @@ fc_replhist (command) #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; diff --git a/builtins/fg_bg.def b/builtins/fg_bg.def index 2b62c3510..bfff5f9bc 100644 --- a/builtins/fg_bg.def +++ b/builtins/fg_bg.def @@ -56,8 +56,7 @@ static int fg_bg (WORD_LIST *, int); /* 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; @@ -101,8 +100,7 @@ $END #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; @@ -135,9 +133,7 @@ bg_builtin (list) /* 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; diff --git a/builtins/gen-helpfiles.c b/builtins/gen-helpfiles.c index f6a8039db..76f7c06b1 100644 --- a/builtins/gen-helpfiles.c +++ b/builtins/gen-helpfiles.c @@ -105,9 +105,7 @@ int write_helpfiles (struct builtin *); 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; @@ -138,10 +136,7 @@ main (argc, argv) 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; @@ -151,8 +146,7 @@ write_documentation (stream, documentation, indentation) } int -write_helpfiles (builtins) - struct builtin *builtins; +write_helpfiles (struct builtin *builtins) { char *helpfile, *bname, *fname; FILE *helpfp; diff --git a/builtins/hash.def b/builtins/hash.def index 323b8a657..cb5f8941b 100644 --- a/builtins/hash.def +++ b/builtins/hash.def @@ -80,8 +80,7 @@ static int list_hashed_filename_targets (WORD_LIST *, int); 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; @@ -206,9 +205,7 @@ hash_builtin (list) } static int -add_hashed_command (w, quiet) - char *w; - int quiet; +add_hashed_command (char *w, int quiet) { int rv; char *full_path; @@ -233,16 +230,14 @@ add_hashed_command (w, quiet) /* 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; @@ -257,8 +252,7 @@ print_portable_hash_info (item) } static int -print_hashed_commands (fmt) - int fmt; +print_hashed_commands (int fmt) { if (hashed_filenames == 0 || HASH_ENTRIES (hashed_filenames) == 0) return (0); @@ -270,9 +264,7 @@ print_hashed_commands (fmt) } 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; diff --git a/builtins/help.def b/builtins/help.def index cda8f0ada..d588979c0 100644 --- a/builtins/help.def +++ b/builtins/help.def @@ -89,8 +89,7 @@ static void show_longdoc (int); 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; @@ -190,7 +189,7 @@ help_builtin (list) } void -builtin_help () +builtin_help (void) { int ind; ptrdiff_t d; @@ -212,8 +211,7 @@ builtin_help () } static int -open_helpfile (name) - char *name; +open_helpfile (char *name) { int fd; @@ -230,8 +228,7 @@ open_helpfile (name) 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; @@ -253,9 +250,7 @@ show_longdoc (i) } static void -show_desc (name, i) - char *name; - int i; +show_desc (char *name, int i) { register int j, r; char **doc, *line; @@ -292,9 +287,7 @@ show_desc (name, i) /* 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; @@ -366,11 +359,7 @@ show_manpage (name, i) } 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; @@ -408,11 +397,7 @@ dispcolumn (i, buf, bufsize, width, height) #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; @@ -513,7 +498,7 @@ wdispcolumn (i, buf, bufsize, width, height) #endif /* HANDLE_MULTIBYTE */ static void -show_builtin_command_help () +show_builtin_command_help (void) { int i, j; int height, width; diff --git a/builtins/history.def b/builtins/history.def index b10d0f481..29a5cc482 100644 --- a/builtins/history.def +++ b/builtins/history.def @@ -105,8 +105,7 @@ static int expand_and_print_history (WORD_LIST *); #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; @@ -322,9 +321,7 @@ history_builtin (list) #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; @@ -343,8 +340,7 @@ histtime (hlist, histtimefmt) } static int -display_history (list) - WORD_LIST *list; +display_history (WORD_LIST *list) { register int i; intmax_t limit; @@ -395,8 +391,7 @@ display_history (list) /* 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; @@ -432,8 +427,7 @@ push_history (list) #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; diff --git a/builtins/jobs.def b/builtins/jobs.def index e0cee07d1..316f34bd8 100644 --- a/builtins/jobs.def +++ b/builtins/jobs.def @@ -79,8 +79,7 @@ static int execute_list_with_replacements (WORD_LIST *); 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; @@ -174,8 +173,7 @@ jobs_builtin (list) } static int -execute_list_with_replacements (list) - WORD_LIST *list; +execute_list_with_replacements (WORD_LIST *list) { register WORD_LIST *l; int job, result; @@ -238,8 +236,7 @@ $END #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; diff --git a/builtins/kill.def b/builtins/kill.def index c8938714c..4c2bc2edd 100644 --- a/builtins/kill.def +++ b/builtins/kill.def @@ -82,8 +82,7 @@ static void kill_error (pid_t, int); 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; @@ -263,9 +262,7 @@ use_sigspec: } static void -kill_error (pid, e) - pid_t pid; - int e; +kill_error (pid_t pid, int e) { char *x; diff --git a/builtins/let.def b/builtins/let.def index d090a45bc..df4e3c4f2 100644 --- a/builtins/let.def +++ b/builtins/let.def @@ -80,8 +80,7 @@ $END /* Arithmetic LET function. */ int -let_builtin (list) - WORD_LIST *list; +let_builtin (WORD_LIST *list) { intmax_t ret; int expok; @@ -110,8 +109,7 @@ let_builtin (list) #ifdef INCLUDE_UNUSED int -exp_builtin (list) - WORD_LIST *list; +exp_builtin (WORD_LIST *list) { char *exp; intmax_t ret; diff --git a/builtins/mapfile.def b/builtins/mapfile.def index 5f112b0a9..05c2e4b61 100644 --- a/builtins/mapfile.def +++ b/builtins/mapfile.def @@ -107,10 +107,7 @@ static int run_callback (const char *, unsigned int, const char *); 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; @@ -134,9 +131,7 @@ run_callback (callback, curindex, curline) } static void -do_chop(line, delim) - char *line; - unsigned char delim; +do_chop(char *line, unsigned char delim) { int length; @@ -146,12 +141,8 @@ do_chop(line, delim) } 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; @@ -231,8 +222,7 @@ mapfile (fd, line_count_goal, origin, nskip, callback_quantum, callback, array_n } int -mapfile_builtin (list) - WORD_LIST *list; +mapfile_builtin (WORD_LIST *list) { int opt, code, fd, flags; intmax_t intval; @@ -354,8 +344,7 @@ mapfile_builtin (list) #else int -mapfile_builtin (list) - WORD_LIST *list; +mapfile_builtin (WORD_LIST *list) { builtin_error (_("array variable support required")); return (EXECUTION_FAILURE); diff --git a/builtins/mkbuiltins.c b/builtins/mkbuiltins.c index 15e1ed4d7..2ba374719 100644 --- a/builtins/mkbuiltins.c +++ b/builtins/mkbuiltins.c @@ -191,47 +191,47 @@ char *arrayvar_builtins[] = }; /* 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) - /* 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; @@ -384,8 +384,7 @@ main (argc, argv) /* 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; @@ -404,8 +403,7 @@ array_create (width) /* Copy the array of strings in ARRAY. */ ARRAY * -copy_string_array (array) - ARRAY *array; +copy_string_array (ARRAY *array) { register int i; ARRAY *copy; @@ -431,9 +429,7 @@ copy_string_array (array) /* 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 @@ -445,8 +441,7 @@ array_add (element, array) /* Free an allocated array and data pointer. */ void -array_free (array) - ARRAY *array; +array_free (ARRAY *array) { if (array->array) free (array->array); @@ -494,8 +489,7 @@ HANDLER_ENTRY handlers[] = { /* Return the entry in the table of handlers for NAME. */ HANDLER_ENTRY * -find_directive (directive) - char *directive; +find_directive (char *directive) { register int i; @@ -524,9 +518,7 @@ int output_cpp_line_info = 0; 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; @@ -609,7 +601,7 @@ extract_info (filename, structfile, externfile) if (!handler) { - line_error (defs, "Unknown directive `%s'", directive); + line_error (defs, "Unknown directive `%s'", directive, ""); free (directive); continue; } @@ -666,8 +658,7 @@ extract_info (filename, structfile, externfile) #define free_safely(x) if (x) free (x) static void -free_builtin (builtin) - BUILTIN_DESC *builtin; +free_builtin (BUILTIN_DESC *builtin) { register int i; @@ -689,8 +680,7 @@ free_builtin (builtin) /* 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; @@ -722,8 +712,7 @@ free_defs (defs) /* 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++; @@ -734,8 +723,7 @@ strip_whitespace (string) /* Remove only the trailing whitespace from STRING. */ void -remove_trailing_whitespace (string) - char *string; +remove_trailing_whitespace (char *string) { register int i; @@ -752,35 +740,29 @@ remove_trailing_whitespace (string) 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) @@ -792,9 +774,7 @@ current_builtin (directive, defs) /* 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; @@ -813,10 +793,7 @@ add_documentation (defs, line) /* 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; @@ -824,7 +801,7 @@ builtin_handler (self, defs, arg) /* 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); } @@ -865,10 +842,7 @@ builtin_handler (self, defs, arg) /* 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; @@ -876,7 +850,7 @@ function_handler (self, defs, arg) 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) @@ -890,10 +864,7 @@ function_handler (self, defs, arg) /* 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; @@ -910,10 +881,7 @@ docname_handler (self, defs, arg) /* 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; @@ -930,20 +898,14 @@ short_doc_handler (self, defs, arg) /* 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; @@ -961,10 +923,7 @@ depends_on_handler (self, defs, arg) /* 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. */ @@ -995,10 +954,7 @@ produces_handler (self, defs, arg) /* 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; @@ -1013,9 +969,7 @@ end_handler (self, defs, arg) /* 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 : "./"); @@ -1027,8 +981,7 @@ line_error (defs, format, arg1, arg2) /* Print error message for FILENAME. */ void -file_error (filename) - char *filename; +file_error (char *filename) { perror (filename); exit (2); @@ -1040,11 +993,10 @@ file_error (filename) /* */ /* **************************************************************** */ -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); @@ -1054,9 +1006,7 @@ xmalloc (bytes) } static char * -xrealloc (pointer, bytes) - char *pointer; - int bytes; +xrealloc (void *pointer, size_t bytes) { char *temp; @@ -1072,7 +1022,7 @@ xrealloc (pointer, bytes) } static void -memory_error_and_abort () +memory_error_and_abort (void) { fprintf (stderr, "mkbuiltins: out of virtual memory\n"); abort (); @@ -1087,8 +1037,7 @@ memory_error_and_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; @@ -1109,8 +1058,7 @@ copy_builtin (builtin) /* How to save away a builtin. */ void -save_builtin (builtin) - BUILTIN_DESC *builtin; +save_builtin (BUILTIN_DESC *builtin) { BUILTIN_DESC *newbuiltin; @@ -1187,8 +1135,7 @@ char *structfile_footer[] = { /* 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; @@ -1214,8 +1161,7 @@ write_file_headers (structfile, externfile) /* 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; @@ -1230,9 +1176,7 @@ write_file_footers (structfile, externfile) /* 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; @@ -1336,9 +1280,7 @@ write_builtins (defs, structfile, externfile) /* 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; @@ -1375,9 +1317,7 @@ write_longdocs (stream, builtins) } void -write_dummy_declarations (stream, builtins) - FILE *stream; - ARRAY *builtins; +write_dummy_declarations (FILE *stream, ARRAY *builtins) { register int i; BUILTIN_DESC *builtin; @@ -1401,9 +1341,7 @@ write_dummy_declarations (stream, builtins) 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; @@ -1432,9 +1370,7 @@ write_ifdefs (stream, defines) 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; @@ -1459,10 +1395,7 @@ write_endifs (stream, defines) 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; @@ -1590,8 +1523,7 @@ write_documentation (stream, documentation, indentation, flags) } int -write_helpfiles (builtins) - ARRAY *builtins; +write_helpfiles (ARRAY *builtins) { char *helpfile, *bname; FILE *helpfp; @@ -1632,8 +1564,7 @@ write_helpfiles (builtins) } static int -_find_in_table (name, name_table) - char *name, *name_table[]; +_find_in_table (char *name, char **name_table) { register int i; @@ -1644,44 +1575,38 @@ _find_in_table (name, name_table) } 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) diff --git a/builtins/printf.def b/builtins/printf.def index f9b9f5b40..090e8179e 100644 --- a/builtins/printf.def +++ b/builtins/printf.def @@ -246,8 +246,7 @@ static char *conv_buf; 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; @@ -750,20 +749,19 @@ printf_builtin (list) } 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; @@ -884,10 +882,7 @@ printstr (fmt, string, len, fieldwidth, precision) 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; @@ -1001,9 +996,7 @@ tescape (estart, cp, lenp, sawc) } 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; @@ -1061,9 +1054,7 @@ bexpand (string, len, sawc, lenp) } static char * -vbadd (buf, blen) - char *buf; - int blen; +vbadd (char *buf, int blen) { size_t nlen; @@ -1092,13 +1083,7 @@ vbadd (buf, blen) } 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; @@ -1130,10 +1115,7 @@ vbprintf (format, va_alist) } 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; @@ -1155,7 +1137,7 @@ mklong (str, modifiers, mlen) } static int -getchr () +getchr (void) { int ret; @@ -1168,7 +1150,7 @@ getchr () } static char * -getstr () +getstr (void) { char *ret; @@ -1181,7 +1163,7 @@ getstr () } static int -getint () +getint (void) { intmax_t ret; @@ -1205,7 +1187,7 @@ getint () } static intmax_t -getintmax () +getintmax (void) { intmax_t ret; char *ep; @@ -1240,7 +1222,7 @@ getintmax () } static uintmax_t -getuintmax () +getuintmax (void) { uintmax_t ret; char *ep; @@ -1271,7 +1253,7 @@ getuintmax () } static double -getdouble () +getdouble (void) { double ret; char *ep; @@ -1298,7 +1280,7 @@ getdouble () } static floatmax_t -getfloatmax () +getfloatmax (void) { floatmax_t ret; char *ep; @@ -1330,7 +1312,7 @@ getfloatmax () /* NO check is needed for garglist here. */ static intmax_t -asciicode () +asciicode (void) { register intmax_t ch; #if defined (HANDLE_MULTIBYTE) diff --git a/builtins/pushd.def b/builtins/pushd.def index 96fcffd50..668e3da6a 100644 --- a/builtins/pushd.def +++ b/builtins/pushd.def @@ -170,8 +170,7 @@ static int get_dirstack_index (intmax_t, int, int *); #define CLEARSTAK 0x08 int -pushd_builtin (list) - WORD_LIST *list; +pushd_builtin (WORD_LIST *list) { WORD_LIST *orig_list; char *temp, *current_directory, *top; @@ -316,8 +315,7 @@ pushd_builtin (list) 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; @@ -406,8 +404,7 @@ popd_builtin (list) /* 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; @@ -516,9 +513,7 @@ dirs_builtin (list) } static void -pushd_error (offset, arg) - int offset; - char *arg; +pushd_error (int offset, char *arg) { if (offset == 0) builtin_error (_("directory stack empty")); @@ -527,7 +522,7 @@ pushd_error (offset, arg) } static void -clear_directory_stack () +clear_directory_stack (void) { register int i; @@ -540,8 +535,7 @@ clear_directory_stack () 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; @@ -555,8 +549,7 @@ cd_to_string (name) } static int -change_to_temp (temp) - char *temp; +change_to_temp (char *temp) { int tt; @@ -569,8 +562,7 @@ change_to_temp (temp) } 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); @@ -578,9 +570,7 @@ add_dirstack_element (dir) } 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; @@ -603,8 +593,7 @@ get_dirstack_index (ind, sign, indexp) /* 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; @@ -630,9 +619,7 @@ get_dirstack_from_string (string) #ifdef INCLUDE_UNUSED char * -get_dirstack_element (ind, sign) - intmax_t ind; - int sign; +get_dirstack_element (intmax_t ind, int sign) { int i; @@ -643,10 +630,7 @@ get_dirstack_element (ind, sign) #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; @@ -658,8 +642,7 @@ set_dirstack_element (ind, sign, value) } WORD_LIST * -get_directory_stack (flags) - int flags; +get_directory_stack (int flags) { register int i; WORD_LIST *ret; diff --git a/builtins/read.def b/builtins/read.def index 81542ec7e..51b21f6e7 100644 --- a/builtins/read.def +++ b/builtins/read.def @@ -153,8 +153,7 @@ static struct ttsave termsave; /* 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) @@ -162,7 +161,7 @@ sigalrm (s) } static void -reset_timeout () +reset_timeout (void) { /* Cancel alarm before restoring signal handler. */ if (read_timeout) @@ -174,15 +173,14 @@ reset_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) || @@ -204,8 +202,7 @@ read_builtin_timeout (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; @@ -1055,9 +1052,7 @@ assign_vars: } 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; @@ -1068,10 +1063,7 @@ bind_read_variable (name, value, flags) #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; @@ -1120,22 +1112,21 @@ mbchar_return: 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); } @@ -1146,15 +1137,14 @@ static rl_hook_func_t *old_startup_hook; 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; @@ -1172,9 +1162,7 @@ set_itext () } static char * -edit_line (p, itext) - char *p; - char *itext; +edit_line (char *p, char *itext) { char *ret; int len; @@ -1216,10 +1204,7 @@ edit_line (p, itext) } 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; @@ -1234,8 +1219,7 @@ static rl_command_func_t *old_newline_func; static unsigned char delim_char; static void -set_eol_delim (c) - int c; +set_eol_delim (int c) { Keymap cmap; @@ -1261,8 +1245,7 @@ set_eol_delim (c) } static void -reset_eol_delim (cp) - char *cp; +reset_eol_delim (char *cp) { Keymap cmap; diff --git a/builtins/return.def b/builtins/return.def index 03c98eb11..2cc37cde3 100644 --- a/builtins/return.def +++ b/builtins/return.def @@ -54,8 +54,7 @@ $END 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); diff --git a/builtins/set.def b/builtins/set.def index 236d73457..da92d1c68 100644 --- a/builtins/set.def +++ b/builtins/set.def @@ -245,8 +245,7 @@ const struct { : (*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; @@ -257,8 +256,7 @@ find_minus_o_option (name) } int -minus_o_option_value (name) - char *name; +minus_o_option_value (char *name) { register int i; int *on_or_off; @@ -279,9 +277,7 @@ minus_o_option_value (name) #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); @@ -290,8 +286,7 @@ print_minus_o_option (name, value, pflag) } 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; @@ -317,7 +312,7 @@ list_minus_o_opts (mode, reusable) } char ** -get_minus_o_opts () +get_minus_o_opts (void) { char **ret; int i; @@ -330,7 +325,7 @@ get_minus_o_opts () } char * -get_current_options () +get_current_options (void) { char *temp; int i, posixopts; @@ -355,8 +350,7 @@ get_current_options () } void -set_current_options (bitmap) - const char *bitmap; +set_current_options (const char *bitmap) { int i, v, cv, *on_or_off; @@ -388,9 +382,7 @@ set_current_options (bitmap) } 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"); @@ -403,9 +395,7 @@ set_ignoreeof (on_or_off, option_name) } 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) || @@ -424,9 +414,7 @@ set_posix_mode (on_or_off, option_name) #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; @@ -452,8 +440,7 @@ set_edit_mode (on_or_off, option_name) } 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); @@ -462,9 +449,7 @@ get_edit_mode (name) #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) { @@ -483,9 +468,7 @@ bash_set_history (on_or_off, option_name) #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; @@ -515,7 +498,7 @@ set_minus_o_option (on_or_off, option_name) } static void -print_all_shell_variables () +print_all_shell_variables (void) { SHELL_VAR **vars; @@ -540,7 +523,7 @@ print_all_shell_variables () } void -set_shellopts () +set_shellopts (void) { char *value; char tflag[N_O_OPTIONS]; @@ -607,8 +590,7 @@ set_shellopts () } void -parse_shellopts (value) - char *value; +parse_shellopts (char *value) { char *vname; int vptr; @@ -622,8 +604,7 @@ parse_shellopts (value) } void -initialize_shell_options (no_shellopts) - int no_shellopts; +initialize_shell_options (int no_shellopts) { char *temp; SHELL_VAR *var; @@ -651,7 +632,7 @@ initialize_shell_options (no_shellopts) 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; @@ -671,8 +652,7 @@ reset_shell_options () 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; @@ -831,8 +811,7 @@ $END #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; diff --git a/builtins/setattr.def b/builtins/setattr.def index 43d431382..0f0dbf2c7 100644 --- a/builtins/setattr.def +++ b/builtins/setattr.def @@ -1,7 +1,7 @@ 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. @@ -73,8 +73,7 @@ $END 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)); } @@ -104,8 +103,7 @@ $END /* 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)); } @@ -120,9 +118,7 @@ readonly_builtin (list) 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; @@ -350,8 +346,7 @@ set_or_show_attributes (list, attribute, nodefs) /* 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; @@ -378,8 +373,7 @@ show_all_var_attributes (v, nodefs) /* 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; @@ -403,11 +397,9 @@ show_local_var_attributes (v, nodefs) 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; @@ -476,9 +468,7 @@ var_attribute_string (var, pattr, flags) 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; @@ -533,9 +523,7 @@ show_var_attributes (var, pattr, nodefs) } int -show_name_attributes (name, nodefs) - char *name; - int nodefs; +show_name_attributes (char *name, int nodefs) { SHELL_VAR *var; @@ -551,9 +539,7 @@ show_name_attributes (name, nodefs) } int -show_localname_attributes (name, nodefs) - char *name; - int nodefs; +show_localname_attributes (char *name, int nodefs) { SHELL_VAR *var; @@ -573,9 +559,7 @@ show_localname_attributes (name, nodefs) } int -show_func_attributes (name, nodefs) - char *name; - int nodefs; +show_func_attributes (char *name, int nodefs) { SHELL_VAR *var; @@ -591,9 +575,7 @@ show_func_attributes (name, nodefs) } 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; diff --git a/builtins/shift.def b/builtins/shift.def index bb9af01b5..d6519c16b 100644 --- a/builtins/shift.def +++ b/builtins/shift.def @@ -1,7 +1,7 @@ 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. @@ -54,8 +54,7 @@ int print_shift_error; 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; diff --git a/builtins/shopt.def b/builtins/shopt.def index 7c08ad9f7..cf1187f37 100644 --- a/builtins/shopt.def +++ b/builtins/shopt.def @@ -292,8 +292,7 @@ static int set_shopt_o_options (int, WORD_LIST *, int); #define PFLAG 0x10 int -shopt_builtin (list) - WORD_LIST *list; +shopt_builtin (WORD_LIST *list) { int opt, flags, rval; @@ -351,7 +350,7 @@ shopt_builtin (list) /* 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; @@ -434,8 +433,7 @@ reset_shopt_options () } static int -find_shopt (name) - char *name; +find_shopt (char *name) { int i; @@ -446,17 +444,13 @@ find_shopt (name) } 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; @@ -485,9 +479,7 @@ toggle_shopts (mode, list, quiet) } 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); @@ -498,9 +490,7 @@ print_shopt (name, val, flags) /* 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; @@ -536,8 +526,7 @@ list_shopts (list, flags) } static int -list_some_shopts (mode, flags) - int mode, flags; +list_some_shopts (int mode, int flags) { int val, i; @@ -551,9 +540,7 @@ list_some_shopts (mode, flags) } 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; @@ -588,8 +575,7 @@ list_shopt_o_options (list, flags) } 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)); @@ -597,10 +583,7 @@ list_some_o_options (mode, flags) } 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; @@ -617,18 +600,14 @@ set_shopt_o_options (mode, list, quiet) /* 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; @@ -640,9 +619,7 @@ shopt_set_debug_mode (option_name, 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; @@ -650,9 +627,7 @@ shopt_set_expaliases (option_name, mode) #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; @@ -661,18 +636,14 @@ shopt_set_extglob (option_name, mode) #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; @@ -725,7 +696,7 @@ set_compatibility_level (option_name, mode) /* 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; @@ -755,9 +726,7 @@ set_compatibility_opts () #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; @@ -768,9 +737,7 @@ shopt_set_complete_direxpand (option_name, mode) /* 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; @@ -784,16 +751,14 @@ set_restricted_shell (option_name, mode) /* 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; @@ -812,9 +777,7 @@ get_shopt_options () * 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; @@ -826,9 +789,7 @@ shopt_setopt (name, mode) } int -shopt_listopt (name, reusable) - char *name; - int reusable; +shopt_listopt (char *name, int reusable) { int i; @@ -847,7 +808,7 @@ shopt_listopt (name, reusable) } void -set_bashopts () +set_bashopts (void) { char *value; char tflag[N_SHOPT_OPTIONS]; @@ -905,8 +866,7 @@ set_bashopts () } void -parse_bashopts (value) - char *value; +parse_bashopts (char *value) { char *vname; int vptr, ind; @@ -926,8 +886,7 @@ parse_bashopts (value) } void -initialize_bashopts (no_bashopts) - int no_bashopts; +initialize_bashopts (int no_bashopts) { char *temp; SHELL_VAR *var; @@ -953,9 +912,7 @@ initialize_bashopts (no_bashopts) #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) diff --git a/builtins/source.def b/builtins/source.def index 205abf531..c15dbc511 100644 --- a/builtins/source.def +++ b/builtins/source.def @@ -96,7 +96,7 @@ int source_searches_cwd = 1; 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 (); @@ -113,8 +113,7 @@ maybe_pop_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; diff --git a/builtins/suspend.def b/builtins/suspend.def index 1d60ef90b..b1db8031b 100644 --- a/builtins/suspend.def +++ b/builtins/suspend.def @@ -65,8 +65,7 @@ static SigHandler *old_stop; /* Continue handler. */ static sighandler -suspend_continue (sig) - int sig; +suspend_continue (int sig) { set_signal_handler (SIGCONT, old_cont); #if 0 @@ -78,8 +77,7 @@ suspend_continue (sig) /* 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; diff --git a/builtins/test.def b/builtins/test.def index bd9a203b6..da7870c77 100644 --- a/builtins/test.def +++ b/builtins/test.def @@ -1,7 +1,7 @@ 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. @@ -131,8 +131,7 @@ $END /* TEST/[ builtin. */ int -test_builtin (list) - WORD_LIST *list; +test_builtin (WORD_LIST *list) { char **argv; int argc, result; diff --git a/builtins/times.def b/builtins/times.def index f31f43331..c7e5874c4 100644 --- a/builtins/times.def +++ b/builtins/times.def @@ -1,7 +1,7 @@ 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. @@ -59,8 +59,7 @@ $END /* 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; diff --git a/builtins/trap.def b/builtins/trap.def index 80d05973c..4bb254cc2 100644 --- a/builtins/trap.def +++ b/builtins/trap.def @@ -102,8 +102,7 @@ static int display_traps (WORD_LIST *, int); #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; @@ -250,8 +249,7 @@ trap_builtin (list) } static void -showtrap (i, show_default) - int i, show_default; +showtrap (int i, int show_default) { char *t, *p, *sn; int free_t; @@ -291,9 +289,7 @@ showtrap (i, show_default) } static int -display_traps (list, show_all) - WORD_LIST *list; - int show_all; +display_traps (WORD_LIST *list, int show_all) { int result, i; diff --git a/builtins/type.def b/builtins/type.def index 004a18e20..1e0fb4579 100644 --- a/builtins/type.def +++ b/builtins/type.def @@ -107,8 +107,7 @@ extern int find_reserved_word (char *); */ int -type_builtin (list) - WORD_LIST *list; +type_builtin (WORD_LIST *list) { int dflags, any_failed, opt; WORD_LIST *this; @@ -210,9 +209,7 @@ type_builtin (list) * 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; diff --git a/builtins/ulimit.def b/builtins/ulimit.def index 0b0e17791..5f0e1379e 100644 --- a/builtins/ulimit.def +++ b/builtins/ulimit.def @@ -303,9 +303,7 @@ static int cmdlistsz; #if !defined (HAVE_RESOURCE) && !defined (HAVE_ULIMIT) long -ulimit (cmd, newlim) - int cmd; - long newlim; +ulimit (int cmd, long newlim) { errno = EINVAL; return -1; @@ -313,8 +311,7 @@ ulimit (cmd, newlim) #endif /* !HAVE_RESOURCE && !HAVE_ULIMIT */ static int -_findlim (opt) - int opt; +_findlim (int opt) { register int i; @@ -329,8 +326,7 @@ static char optstring[4 + 2 * NCMDS]; /* 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; @@ -445,10 +441,7 @@ ulimit_builtin (list) } 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; @@ -508,9 +501,7 @@ ulimit_internal (cmd, cmdarg, mode, multiple) } 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) @@ -569,10 +560,7 @@ get_limit (ind, softlim, hardlim) } 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; @@ -634,8 +622,7 @@ set_limit (ind, newlim, mode) } static int -getmaxvm (softlim, hardlim) - RLIMTYPE *softlim, *hardlim; +getmaxvm (RLIMTYPE *softlim, RLIMTYPE *hardlim) { #if defined (HAVE_RESOURCE) struct rlimit datalim, stacklim; @@ -657,8 +644,7 @@ getmaxvm (softlim, hardlim) } static int -filesize(valuep) - RLIMTYPE *valuep; +filesize (RLIMTYPE *valuep) { #if !defined (HAVE_RESOURCE) long result; @@ -674,8 +660,7 @@ filesize(valuep) } static int -pipesize (valuep) - RLIMTYPE *valuep; +pipesize (RLIMTYPE *valuep) { #if defined (PIPE_BUF) /* This is defined on Posix systems. */ @@ -699,8 +684,7 @@ pipesize (valuep) } static int -getmaxuprc (valuep) - RLIMTYPE *valuep; +getmaxuprc (RLIMTYPE *valuep) { long maxchild; @@ -718,8 +702,7 @@ getmaxuprc (valuep) } static void -print_all_limits (mode) - int mode; +print_all_limits (int mode) { register int i; RLIMTYPE softlim, hardlim; @@ -738,10 +721,7 @@ print_all_limits (mode) } static void -printone (limind, curlim, pdesc) - int limind; - RLIMTYPE curlim; - int pdesc; +printone (int limind, RLIMTYPE curlim, int pdesc) { char unitstr[64]; int factor; @@ -780,9 +760,7 @@ printone (limind, curlim, pdesc) */ static int -set_all_limits (mode, newlim) - int mode; - RLIMTYPE newlim; +set_all_limits (int mode, RLIMTYPE newlim) { register int i; int retval = 0; diff --git a/builtins/umask.def b/builtins/umask.def index f22bb7173..d3488bf90 100644 --- a/builtins/umask.def +++ b/builtins/umask.def @@ -73,8 +73,7 @@ static int symbolic_umask (WORD_LIST *); /* 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; @@ -146,12 +145,7 @@ umask_builtin (list) /* 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; @@ -187,8 +181,7 @@ print_symbolic_umask (um) } 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) | @@ -196,8 +189,7 @@ copyuser (mask) } 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) | @@ -205,8 +197,7 @@ copygroup (mask) } 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) | @@ -214,9 +205,7 @@ copyother (mask) } 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; @@ -361,8 +350,7 @@ spec_error: 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; diff --git a/builtins/wait.def b/builtins/wait.def index f29db2a71..782f0aa1c 100644 --- a/builtins/wait.def +++ b/builtins/wait.def @@ -108,8 +108,7 @@ static void unset_waitlist (void); while (0) int -wait_builtin (list) - WORD_LIST *list; +wait_builtin (WORD_LIST *list) { int status, code, opt, nflag, vflags, bindflags; volatile int wflags; @@ -331,8 +330,7 @@ wait_builtin (list) 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; @@ -367,7 +365,7 @@ set_waitlist (list) /* Clean up after a call to wait -n jobs */ static void -unset_waitlist () +unset_waitlist (void) { int i; sigset_t set, oset; diff --git a/error.c b/error.c index 3e7a2d617..76d20529f 100644 --- a/error.c +++ b/error.c @@ -1,6 +1,6 @@ /* 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. @@ -52,18 +52,18 @@ extern int errno; # 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. */ @@ -76,8 +76,7 @@ const char * const the_current_maintainer = MAINTAINER; int gnu_error_format = 0; static void -error_prolog (print_lineno) - int print_lineno; +error_prolog (int print_lineno) { char *ename; int line; @@ -93,7 +92,7 @@ error_prolog (print_lineno) /* 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) @@ -129,20 +128,13 @@ get_name_for_error () 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; @@ -180,13 +172,7 @@ programming_error (format, va_alist) 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; @@ -207,13 +193,7 @@ report_error (format, va_alist) } 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; @@ -229,13 +209,7 @@ fatal_error (format, va_alist) } 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; @@ -250,13 +224,7 @@ internal_error (format, va_alist) } 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; @@ -272,13 +240,7 @@ internal_warning (format, va_alist) } 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; @@ -295,13 +257,7 @@ internal_inform (format, va_alist) } 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; @@ -321,13 +277,7 @@ internal_debug (format, va_alist) } 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; @@ -352,14 +302,7 @@ sys_error (format, va_alist) 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; @@ -390,8 +333,7 @@ parser_error (lineno, format, va_alist) #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; @@ -419,13 +361,7 @@ strescape (str) } void -#if defined (PREFER_STDARG) itrace (const char *format, ...) -#else -itrace (format, va_alist) - const char *format; - va_dcl -#endif { va_list args; @@ -444,13 +380,7 @@ itrace (format, va_alist) /* 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; @@ -493,9 +423,7 @@ static const char * const cmd_error_table[] = { }; 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; @@ -504,8 +432,7 @@ command_error (func, code, e, flags) } char * -command_errstr (code) - int code; +command_errstr (int code) { if (code > CMDERR_LAST) code = CMDERR_DEFAULT; @@ -515,23 +442,20 @@ command_errstr (code) #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); } diff --git a/eval.c b/eval.c index 17fbf7366..7d6bdb360 100644 --- a/eval.c +++ b/eval.c @@ -48,13 +48,13 @@ # 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; @@ -195,7 +195,7 @@ reader_loop () /* Pretty print shell scripts */ int -pretty_print_loop () +pretty_print_loop (void) { COMMAND *current_command; char *command_to_print; @@ -235,8 +235,7 @@ pretty_print_loop () } static sighandler -alrm_catcher(i) - int i; +alrm_catcher(int i) { char *msg; @@ -251,7 +250,7 @@ alrm_catcher(i) /* 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; @@ -266,9 +265,7 @@ send_pwd_to_eterm () #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; @@ -288,7 +285,7 @@ execute_array_command (a, v) #endif static void -execute_prompt_command () +execute_prompt_command (void) { char *command_to_execute; SHELL_VAR *pcv; @@ -320,7 +317,7 @@ execute_prompt_command () 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; @@ -357,7 +354,7 @@ parse_command () 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; diff --git a/execute_cmd.c b/execute_cmd.c index f9c867369..7592d9003 100644 --- a/execute_cmd.c +++ b/execute_cmd.c @@ -116,84 +116,84 @@ extern struct timeval shellstart; 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. */ @@ -322,8 +322,7 @@ struct fd_bitmap *current_fds_to_close = (struct fd_bitmap *)NULL; 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; @@ -342,16 +341,14 @@ new_fd_bitmap (size) } 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; @@ -368,7 +365,7 @@ close_fd_bitmap (fdbp) /* 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) && @@ -401,8 +398,7 @@ executing_line_number () 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; @@ -431,8 +427,7 @@ execute_command (command) /* 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) { @@ -465,15 +460,14 @@ shell_control_structure (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) { @@ -485,15 +479,14 @@ undo_partial_redirects () #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) { @@ -503,7 +496,7 @@ dispose_exec_redirects () } void -dispose_partial_redirects () +dispose_partial_redirects (void) { if (redirection_undo_list) { @@ -516,8 +509,7 @@ dispose_partial_redirects () /* 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)); } @@ -544,7 +536,7 @@ open_files (void) #endif void -async_redirect_stdin () +async_redirect_stdin (void) { int fd; @@ -573,12 +565,7 @@ async_redirect_stdin () 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; @@ -1161,9 +1148,9 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out, #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" @@ -1173,11 +1160,7 @@ static const int precs[] = { 0, 100, 10, 1 }; /* 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]; @@ -1248,15 +1231,9 @@ mkfmt (buf, prec, lng, sec, sec_fraction) 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")]; @@ -1338,10 +1315,7 @@ print_formatted_time (fp, format, rs, rsf, us, usf, ss, ssf, cpu) } 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; @@ -1480,11 +1454,7 @@ time_command (command, asynchronous, pipe_in, pipe_out, fds_to_close) 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; @@ -1783,18 +1753,18 @@ typedef struct cplist } 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 }; @@ -1804,8 +1774,7 @@ cplist_t coproc_list = {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; @@ -1816,15 +1785,13 @@ cpe_alloc (cp) } 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; @@ -1846,8 +1813,7 @@ cpl_add (cp) } static struct cpelement * -cpl_delete (pid) - pid_t pid; +cpl_delete (pid_t pid) { struct cpelement *prev, *p; @@ -1879,7 +1845,7 @@ cpl_delete (pid) } static void -cpl_reap () +cpl_reap (void) { struct cpelement *p, *next, *nh, *nt; @@ -1920,7 +1886,7 @@ cpl_reap () /* Clear out the list of saved statuses */ static void -cpl_flush () +cpl_flush (void) { struct cpelement *cpe, *p; @@ -1938,7 +1904,7 @@ cpl_flush () } static void -cpl_closeall () +cpl_closeall (void) { struct cpelement *cpe; @@ -1947,8 +1913,7 @@ cpl_closeall () } static void -cpl_fdchk (fd) - int fd; +cpl_fdchk (int fd) { struct cpelement *cpe; @@ -1959,8 +1924,7 @@ cpl_fdchk (fd) /* 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; @@ -1973,8 +1937,7 @@ cpl_search (pid) /* 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; @@ -1985,7 +1948,7 @@ cpl_searchbyname (name) } static pid_t -cpl_firstactive () +cpl_firstactive (void) { struct cpelement *cpe; @@ -1997,7 +1960,7 @@ cpl_firstactive () #if 0 static void -cpl_prune () +cpl_prune (void) { struct cpelement *cp; @@ -2017,8 +1980,7 @@ cpl_prune () package above). */ struct coproc * -getcoprocbypid (pid) - pid_t pid; +getcoprocbypid (pid_t pid) { #if MULTIPLE_COPROCS struct cpelement *p; @@ -2031,8 +1993,7 @@ getcoprocbypid (pid) } struct coproc * -getcoprocbyname (name) - const char *name; +getcoprocbyname (const char *name) { #if MULTIPLE_COPROCS struct cpelement *p; @@ -2045,8 +2006,7 @@ getcoprocbyname (name) } void -coproc_init (cp) - struct coproc *cp; +coproc_init (struct coproc *cp) { cp->c_name = 0; cp->c_pid = NO_PID; @@ -2056,9 +2016,7 @@ coproc_init (cp) } struct coproc * -coproc_alloc (name, pid) - char *name; - pid_t pid; +coproc_alloc (char *name, pid_t pid) { struct coproc *cp; @@ -2080,15 +2038,13 @@ coproc_alloc (name, pid) } 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; @@ -2111,7 +2067,7 @@ coproc_dispose (cp) /* Placeholder for now. Will require changes for multiple coprocs */ void -coproc_flush () +coproc_flush (void) { #if MULTIPLE_COPROCS cpl_flush (); @@ -2121,8 +2077,7 @@ coproc_flush () } void -coproc_close (cp) - struct coproc *cp; +coproc_close (struct coproc *cp) { if (cp->c_rfd >= 0) { @@ -2138,7 +2093,7 @@ coproc_close (cp) } void -coproc_closeall () +coproc_closeall (void) { #if MULTIPLE_COPROCS cpl_closeall (); @@ -2148,7 +2103,7 @@ coproc_closeall () } void -coproc_reap () +coproc_reap (void) { #if MULTIPLE_COPROCS cpl_reap (); @@ -2162,9 +2117,7 @@ coproc_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) { @@ -2174,9 +2127,7 @@ coproc_rclose (cp, 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) { @@ -2186,9 +2137,7 @@ coproc_wclose (cp, fd) } void -coproc_checkfd (cp, fd) - struct coproc *cp; - int fd; +coproc_checkfd (struct coproc *cp, int fd) { int update; @@ -2202,8 +2151,7 @@ coproc_checkfd (cp, fd) } void -coproc_fdchk (fd) - int fd; +coproc_fdchk (int fd) { #if MULTIPLE_COPROCS cpl_fdchk (fd); @@ -2213,9 +2161,7 @@ coproc_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); @@ -2223,25 +2169,21 @@ coproc_fdclose (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; @@ -2254,9 +2196,7 @@ coproc_setstatus (cp, status) } void -coproc_pidchk (pid, status) - pid_t pid; - int status; +coproc_pidchk (pid_t pid, int status) { struct coproc *cp; @@ -2275,7 +2215,7 @@ coproc_pidchk (pid, status) } pid_t -coproc_active () +coproc_active (void) { #if MULTIPLE_COPROCS return (cpl_firstactive ()); @@ -2284,8 +2224,7 @@ coproc_active () #endif } void -coproc_setvars (cp) - struct coproc *cp; +coproc_setvars (struct coproc *cp) { SHELL_VAR *v; char *namevar, *t; @@ -2370,8 +2309,7 @@ coproc_setvars (cp) } void -coproc_unsetvars (cp) - struct coproc *cp; +coproc_unsetvars (struct coproc *cp) { int l; char *namevar; @@ -2398,10 +2336,7 @@ coproc_unsetvars (cp) } 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; @@ -2495,8 +2430,7 @@ execute_coproc (command, pipe_in, pipe_out, fds_to_close) /* 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); @@ -2509,17 +2443,13 @@ restore_stdin (s) /* 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; @@ -2709,10 +2639,7 @@ execute_pipeline (command, asynchronous, pipe_in, pipe_out, fds_to_close) } 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; @@ -2889,8 +2816,7 @@ execute_connection (command, asynchronous, pipe_in, pipe_out, fds_to_close) /* 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; @@ -3060,9 +2986,7 @@ execute_for_command (for_command) 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; @@ -3119,8 +3043,7 @@ eval_arith_for_expr (l, okp) } 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; @@ -3224,8 +3147,7 @@ static int LINES, COLS, tabsize; : 6))))) static int -displen (s) - const char *s; +displen (const char *s) { #if defined (HANDLE_MULTIBYTE) wchar_t *wcstr; @@ -3247,9 +3169,7 @@ displen (s) } 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; @@ -3265,8 +3185,7 @@ print_index_and_element (len, ind, list) } static void -indent (from, to) - int from, to; +indent (int from, int to) { while (from < to) { @@ -3284,9 +3203,7 @@ indent (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; @@ -3337,11 +3254,7 @@ print_select_list (list, list_len, max_elem_len, 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; @@ -3410,8 +3323,7 @@ select_query (list, list_len, prompt, print_menu) 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; @@ -3552,8 +3464,7 @@ execute_select_command (select_command) 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; @@ -3686,16 +3597,14 @@ exit_case_command: 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)); } @@ -3706,9 +3615,7 @@ execute_until_command (while_command) 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; @@ -3773,8 +3680,7 @@ execute_while_or_until (while_command, type) 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; @@ -3805,8 +3711,7 @@ execute_if_command (if_command) #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; @@ -3894,8 +3799,7 @@ static char * const nullstr = ""; /* 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; @@ -4045,8 +3949,7 @@ execute_cond_node (cond) } static int -execute_cond_command (cond_command) - COND_COM *cond_command; +execute_cond_command (COND_COM *cond_command) { int retval, save_line_number; @@ -4096,8 +3999,7 @@ execute_cond_command (cond_command) #endif /* COND_COMMAND */ static void -bind_lastarg (arg) - char *arg; +bind_lastarg (char *arg) { SHELL_VAR *var; @@ -4112,9 +4014,7 @@ bind_lastarg (arg) 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; @@ -4191,8 +4091,7 @@ execute_null_command (redirects, pipe_in, pipe_out, async) /* 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; @@ -4278,8 +4177,7 @@ fix_assignment_words (words) 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; @@ -4328,9 +4226,7 @@ fix_arrayref_words (words) 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; @@ -4364,8 +4260,7 @@ check_command_builtin (words, typep) /* 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; @@ -4380,10 +4275,7 @@ is_dirname (pathname) 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; @@ -4857,8 +4749,7 @@ execute_from_filesystem: /* 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; @@ -4883,10 +4774,7 @@ builtin_status (result) } 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; @@ -5023,8 +4911,7 @@ execute_builtin (builtin, words, flags, subshell) } 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 @@ -5038,8 +4925,7 @@ maybe_restore_getopt_state (gs) #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; @@ -5056,12 +4942,7 @@ restore_funcarray_state (fa) #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; @@ -5317,9 +5198,7 @@ execute_function (var, words, flags, fds_to_close, async, subshell) /* 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; @@ -5343,16 +5222,10 @@ execute_shell_function (var, words) 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) @@ -5455,14 +5328,10 @@ execute_subshell_builtin_or_function (words, redirects, builtin, var, 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; @@ -5566,7 +5435,7 @@ execute_builtin_or_function (words, builtin, var, redirects, } void -setup_async_signals () +setup_async_signals (void) { #if defined (__BEOS__) set_signal_handler (SIGHUP, SIG_IGN); /* they want csh-like behavior */ @@ -5613,14 +5482,9 @@ setup_async_signals () #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; @@ -5814,9 +5678,7 @@ parent_return: #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; @@ -5848,11 +5710,8 @@ getinterp (sample, sample_len, endp) 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; @@ -5901,7 +5760,7 @@ execute_shell_script (sample, sample_len, command, args, env) #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. */ @@ -5975,9 +5834,7 @@ initialize_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]; @@ -6140,9 +5997,7 @@ shell_execve (command, args, env) } 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; @@ -6191,7 +6046,7 @@ execute_intern_function (name, funcdef) #if defined (INCLUDE_UNUSED) #if defined (PROCESS_SUBSTITUTION) void -close_all_files () +close_all_files (void) { register int i, fd_table_size; @@ -6206,8 +6061,7 @@ close_all_files () #endif static void -close_pipes (in, out) - int in, out; +close_pipes (int in, int out) { if (in >= 0) close (in); @@ -6216,8 +6070,7 @@ close_pipes (in, out) } 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); } @@ -6225,8 +6078,7 @@ dup_error (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) { diff --git a/expr.c b/expr.c index d8f34a410..2fbf64f52 100644 --- a/expr.c +++ b/expr.c @@ -1,6 +1,6 @@ /* 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. @@ -155,7 +155,8 @@ struct lvalue }; /* A structure defining a single expression context. */ -typedef struct { +typedef struct +{ int curtok, lasttok; char *expression, *tp, *lasttp; intmax_t tokval; @@ -181,43 +182,43 @@ static int already_expanded; 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; @@ -255,7 +256,7 @@ extern const char * const bash_badsub_errmsg; /* Push and save away the contents of the globals describing the current expression context. */ static void -pushexp () +pushexp (void) { EXPR_CONTEXT *context; @@ -279,7 +280,7 @@ pushexp () /* 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; @@ -300,7 +301,7 @@ popexp () } static void -expr_unwind () +expr_unwind (void) { while (--expr_depth > 0) { @@ -319,8 +320,7 @@ expr_unwind () } static void -expr_bind_variable (lhs, rhs) - char *lhs, *rhs; +expr_bind_variable (char *lhs, char *rhs) { SHELL_VAR *v; int aflags; @@ -344,8 +344,7 @@ expr_bind_variable (lhs, rhs) /* 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; @@ -365,10 +364,7 @@ expr_skipsubscript (vp, cp) /* 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; @@ -403,10 +399,7 @@ expr_bind_array_element (tok, ind, rhs) 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; @@ -448,8 +441,7 @@ evalexp (expr, flags, validp) } static intmax_t -subexpr (expr) - char *expr; +subexpr (char *expr) { intmax_t val; char *p; @@ -487,7 +479,7 @@ subexpr (expr) } static intmax_t -expcomma () +expcomma (void) { register intmax_t value; @@ -502,7 +494,7 @@ expcomma () } static intmax_t -expassign () +expassign (void) { register intmax_t value; char *lhs, *rhs; @@ -621,7 +613,7 @@ expassign () /* Conditional expression (expr?expr:expr) */ static intmax_t -expcond () +expcond (void) { intmax_t cval, val1, val2, rval; int set_noeval; @@ -669,7 +661,7 @@ expcond () /* Logical OR. */ static intmax_t -explor () +explor (void) { register intmax_t val1, val2; int set_noeval; @@ -697,7 +689,7 @@ explor () /* Logical AND. */ static intmax_t -expland () +expland (void) { register intmax_t val1, val2; int set_noeval; @@ -725,7 +717,7 @@ expland () /* Bitwise OR. */ static intmax_t -expbor () +expbor (void) { register intmax_t val1, val2; @@ -744,7 +736,7 @@ expbor () /* Bitwise XOR. */ static intmax_t -expbxor () +expbxor (void) { register intmax_t val1, val2; @@ -763,16 +755,16 @@ expbxor () /* 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; } @@ -781,18 +773,18 @@ expband () } 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) @@ -803,7 +795,7 @@ exp5 () } static intmax_t -exp4 () +expcompare (void) { register intmax_t val1, val2; @@ -833,18 +825,18 @@ exp4 () /* 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; @@ -857,7 +849,7 @@ expshift () } static intmax_t -exp3 () +expaddsub (void) { register intmax_t val1, val2; @@ -880,7 +872,7 @@ exp3 () } static intmax_t -expmuldiv () +expmuldiv (void) { register intmax_t val1, val2; #if defined (HAVE_IMAXDIV) @@ -941,8 +933,7 @@ expmuldiv () } static intmax_t -ipow (base, exp) - intmax_t base, exp; +ipow (intmax_t base, intmax_t exp) { intmax_t result; @@ -958,11 +949,11 @@ ipow (base, exp) } static intmax_t -exppower () +exppower (void) { register intmax_t val1, val2, c; - val1 = exp1 (); + val1 = expunary (); while (curtok == POWER) { readtok (); @@ -978,32 +969,32 @@ exppower () } 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 @@ -1013,13 +1004,14 @@ exp1 () } 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) @@ -1112,8 +1104,7 @@ exp0 () } static void -init_lvalue (lv) - struct lvalue *lv; +init_lvalue (struct lvalue *lv) { lv->tokstr = 0; lv->tokvar = 0; @@ -1121,7 +1112,7 @@ init_lvalue (lv) } static struct lvalue * -alloc_lvalue () +alloc_lvalue (void) { struct lvalue *lv; @@ -1131,17 +1122,13 @@ alloc_lvalue () } 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; @@ -1246,8 +1233,7 @@ expr_streval (tok, e, lvalue) } static int -_is_multiop (c) - int c; +_is_multiop (int c) { switch (c) { @@ -1273,8 +1259,7 @@ _is_multiop (c) } static int -_is_arithop (c) - int c; +_is_arithop (int c) { switch (c) { @@ -1308,7 +1293,7 @@ _is_arithop (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; @@ -1515,8 +1500,7 @@ readtok () } static void -evalerror (msg) - const char *msg; +evalerror (const char *msg) { char *name, *t; @@ -1543,8 +1527,7 @@ evalerror (msg) #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; @@ -1632,16 +1615,13 @@ strlong (num) #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)); } @@ -1653,9 +1633,7 @@ char *get_string_value () { return 0; } procenv_t top_level; -main (argc, argv) - int argc; - char **argv; +main (int argc, char **argv) { register int i; intmax_t v; @@ -1686,8 +1664,7 @@ builtin_error (format, arg1, arg2, arg3, arg4, arg5) } char * -itos (n) - intmax_t n; +itos (intmax_t n) { return ("42"); } diff --git a/externs.h b/externs.h index bac470800..a75fedb31 100644 --- a/externs.h +++ b/externs.h @@ -169,7 +169,7 @@ extern char *strsub (char *, char *, char *, int); 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); diff --git a/findcmd.c b/findcmd.c index 95f231e5c..468cbd8b7 100644 --- a/findcmd.c +++ b/findcmd.c @@ -52,13 +52,13 @@ extern int errno; #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 @@ -89,15 +89,13 @@ static struct ignorevar execignore = }; 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; @@ -112,8 +110,7 @@ exec_name_should_ignore (name) 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; @@ -202,8 +199,7 @@ file_status (name) 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; @@ -216,15 +212,13 @@ executable_file (file) } 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; @@ -238,8 +232,7 @@ executable_or_directory (file) 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)); } @@ -250,16 +243,13 @@ find_user_command (name) 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; @@ -280,9 +270,7 @@ _find_user_command_internal (name, flags) } 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; @@ -305,9 +293,7 @@ find_user_command_internal (name, flags) 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; @@ -333,9 +319,7 @@ get_next_path_element (path_list, path_index_pointer) 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; @@ -415,9 +399,7 @@ search_for_command (pathname, flags) } 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; @@ -498,9 +480,7 @@ user_command_matches (name, flags, state) } static char * -find_absolute_program (name, flags) - const char *name; - int flags; +find_absolute_program (const char *name, int flags) { int st; @@ -520,12 +500,7 @@ find_absolute_program (name, flags) } 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; @@ -607,10 +582,7 @@ find_in_path_element (name, path, flags, name_len, dotinfop, rflagsp) 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; @@ -687,10 +659,7 @@ find_user_command_in_path (name, path_list, flags, rflagsp) /* 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)); } diff --git a/flags.c b/flags.c index 30f6c13d4..b7829db02 100644 --- a/flags.c +++ b/flags.c @@ -1,7 +1,7 @@ /* 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. @@ -33,7 +33,7 @@ #endif #if defined (JOB_CONTROL) -extern int set_job_control PARAMS((int)); +extern int set_job_control (int); #endif /* **************************************************************** */ @@ -208,8 +208,7 @@ const struct flags_alist shell_flags[] = { 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++) @@ -224,9 +223,7 @@ find_flag (name) 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; @@ -294,7 +291,7 @@ change_flag (flag, on_or_off) /* 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; @@ -314,7 +311,7 @@ which_set_flags () } char * -get_current_flags () +get_current_flags (void) { char *temp; int i; @@ -327,8 +324,7 @@ get_current_flags () } void -set_current_flags (bitmap) - const char *bitmap; +set_current_flags (const char *bitmap) { int i; @@ -339,7 +335,7 @@ set_current_flags (bitmap) } 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; @@ -373,7 +369,7 @@ reset_shell_flags () } void -initialize_flags () +initialize_flags (void) { register int i; diff --git a/general.c b/general.c index bda39f413..24d7426bc 100644 --- a/general.c +++ b/general.c @@ -1,6 +1,6 @@ /* 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. @@ -62,9 +62,9 @@ extern int errno; # include #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"); @@ -100,8 +100,7 @@ static struct { 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) @@ -130,14 +129,13 @@ posix_initialize (on) } 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; @@ -150,14 +148,13 @@ get_posix_options (bitmap) #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; @@ -173,8 +170,7 @@ set_posix_options (bitmap) #if defined (RLIMTYPE) RLIMTYPE -string_to_rlimtype (s) - char *s; +string_to_rlimtype (char *s) { RLIMTYPE ret; int neg; @@ -194,9 +190,7 @@ string_to_rlimtype (s) } void -print_rlimtype (n, addnl) - RLIMTYPE n; - int addnl; +print_rlimtype (RLIMTYPE n, int addnl) { char s[INT_STRLEN_BOUND (RLIMTYPE) + 1], *p; @@ -230,8 +224,7 @@ print_rlimtype (n, addnl) /* 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; @@ -246,9 +239,7 @@ all_digits (string) 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; @@ -287,8 +278,7 @@ legal_number (string, result) 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; @@ -310,9 +300,7 @@ legal_identifier (name) 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; @@ -329,10 +317,7 @@ valid_nameref_value (name, flags) } int -check_selfref (name, value, flags) - const char *name; - char *value; - int flags; +check_selfref (const char *name, char *value, int flags) { char *t; @@ -361,9 +346,7 @@ check_selfref (name, value, flags) 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? */ { @@ -385,9 +368,7 @@ check_identifier (word, check_word) 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; @@ -399,8 +380,7 @@ importable_function_name (string, len) } int -exportable_function_name (string) - const char *string; +exportable_function_name (const char *string) { if (absolute_program (string)) return 0; @@ -413,9 +393,7 @@ exportable_function_name (string) 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; @@ -430,9 +408,7 @@ legal_alias_name (string, flags) 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; @@ -492,8 +468,7 @@ assignment (string, flags) } int -line_isblank (line) - const char *line; +line_isblank (const char *line) { register int i; @@ -523,8 +498,7 @@ line_isblank (line) /* 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; @@ -554,23 +528,20 @@ sh_unset_nodelay_mode (fd) /* 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)); @@ -587,7 +558,7 @@ fd_ispipe (fd) #endif /* __BEOS__ */ void -check_dev_tty () +check_dev_tty (void) { int tty_fd; char *tty; @@ -609,9 +580,7 @@ check_dev_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; @@ -640,8 +609,7 @@ same_file (path1, path2, stp1, stp2) 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; @@ -678,9 +646,7 @@ move_to_high_fd (fd, check_new, maxfd) 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; @@ -712,8 +678,7 @@ check_binary_file (sample, sample_len) /* **************************************************************** */ int -sh_openpipe (pv) - int *pv; +sh_openpipe (int *pv) { int r; @@ -727,8 +692,7 @@ sh_openpipe (pv) } int -sh_closepipe (pv) - int *pv; +sh_closepipe (int *pv) { if (pv[0] >= 0) close (pv[0]); @@ -747,8 +711,7 @@ sh_closepipe (pv) /* **************************************************************** */ int -file_exists (fn) - const char *fn; +file_exists (const char *fn) { struct stat sb; @@ -756,8 +719,7 @@ file_exists (fn) } int -file_isdir (fn) - const char *fn; +file_isdir (const char *fn) { struct stat sb; @@ -765,8 +727,7 @@ file_isdir (fn) } int -file_iswdir (fn) - const char *fn; +file_iswdir (const char *fn) { return (file_isdir (fn) && sh_eaccess (fn, W_OK) == 0); } @@ -774,8 +735,7 @@ file_iswdir (fn) /* 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); @@ -790,8 +750,7 @@ path_dot_or_dotdot (string) /* 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); @@ -812,8 +771,7 @@ absolute_pathname (string) 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); } @@ -829,8 +787,7 @@ absolute_program (string) 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; @@ -855,8 +812,7 @@ make_absolute (string, dot_path) /* 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; @@ -877,8 +833,7 @@ base_pathname (string) 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; @@ -900,8 +855,7 @@ static char tdir[PATH_MAX]; /* 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; @@ -923,9 +877,7 @@ polite_directory_format (name) 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; @@ -990,9 +942,7 @@ trim_pathname (name, maxlen) 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; @@ -1010,9 +960,7 @@ printable_filename (fn, flags) 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; @@ -1060,7 +1008,7 @@ extract_colon_unit (string, p_index) /* **************************************************************** */ #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; @@ -1074,8 +1022,7 @@ static char **bash_tilde_suffixes2; 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; @@ -1097,7 +1044,7 @@ bash_special_tilde_expansions (text) 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; @@ -1143,8 +1090,7 @@ tilde_initialize () #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; @@ -1166,9 +1112,7 @@ unquoted_tilde_word (s) *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; @@ -1205,9 +1149,7 @@ bash_tilde_find_word (s, flags, lenp) 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; @@ -1241,7 +1183,7 @@ static GETGROUPS_T *group_array = (GETGROUPS_T *)NULL; #endif static void -initialize_group_array () +initialize_group_array (void) { register int i; @@ -1294,12 +1236,7 @@ initialize_group_array () /* 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; @@ -1327,8 +1264,7 @@ group_member (gid) } char ** -get_group_list (ngp) - int *ngp; +get_group_list (int *ngp) { static char **group_vector = (char **)NULL; register int i; @@ -1360,8 +1296,7 @@ get_group_list (ngp) } int * -get_group_array (ngp) - int *ngp; +get_group_array (int *ngp) { int i; static int *group_iarray = (int *)NULL; @@ -1402,7 +1337,7 @@ get_group_array (ngp) 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; @@ -1428,7 +1363,7 @@ conf_standard_path () } int -default_columns () +default_columns (void) { char *v; int c; diff --git a/hashcmd.c b/hashcmd.c index 891f967a5..ebb923469 100644 --- a/hashcmd.c +++ b/hashcmd.c @@ -1,7 +1,7 @@ /* 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. @@ -37,25 +37,24 @@ 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); @@ -63,8 +62,7 @@ phash_flush () /* Remove FILENAME from the table of hashed commands. */ int -phash_remove (filename) - const char *filename; +phash_remove (const char *filename) { register BUCKET_CONTENTS *item; @@ -89,9 +87,7 @@ phash_remove (filename) 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; @@ -124,8 +120,7 @@ phash_insert (filename, full_path, check_dot, found) 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; diff --git a/hashlib.c b/hashlib.c index 4a7e8132b..a9df3ed60 100644 --- a/hashlib.c +++ b/hashlib.c @@ -1,6 +1,6 @@ /* 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. @@ -50,17 +50,16 @@ 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; @@ -81,16 +80,15 @@ hash_create (buckets) } 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; @@ -122,9 +120,7 @@ copy_bucket_array (ba, cpdata) } 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; @@ -155,8 +151,7 @@ hash_rehash (table, nsize) } static void -hash_grow (table) - HASH_TABLE *table; +hash_grow (HASH_TABLE *table) { int nsize; @@ -166,8 +161,7 @@ hash_grow (table) } static void -hash_shrink (table) - HASH_TABLE *table; +hash_shrink (HASH_TABLE *table) { int nsize; @@ -175,10 +169,9 @@ hash_shrink (table) 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; @@ -212,8 +205,7 @@ FNV_PRIME 1099511628211 /* 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; @@ -233,9 +225,7 @@ hash_string (s) 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; @@ -245,10 +235,7 @@ hash_bucket (string, table) /* 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; @@ -297,10 +284,7 @@ hash_search (string, table, flags) 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; @@ -331,10 +315,7 @@ hash_remove (string, table, flags) /* 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; @@ -372,9 +353,7 @@ hash_insert (string, table, flags) 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; @@ -406,17 +385,16 @@ hash_flush (table, free_data) /* 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; @@ -434,9 +412,7 @@ hash_walk (table, func) #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; @@ -477,8 +453,7 @@ int interrupt_immediately = 0; int running_trap = 0; int -signal_is_trapped (s) - int s; +signal_is_trapped (int s) { return (0); } @@ -501,7 +476,7 @@ internal_warning (const char *format, ...) } int -main () +main (int c, char **v) { char string[256]; int count = 0; diff --git a/input.c b/input.c index 7b439f8c8..c48e1cfce 100644 --- a/input.c +++ b/input.c @@ -1,6 +1,6 @@ /* 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. @@ -57,7 +57,7 @@ extern int errno; # 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. */ @@ -69,8 +69,7 @@ static int local_index = 0, local_bufused = 0; 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; @@ -117,9 +116,7 @@ getc_with_restart (stream) } 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; @@ -165,8 +162,7 @@ static int nbuffers; /* Make sure `buffers' has at least N elements. */ static void -allocate_buffers (n) - int n; +allocate_buffers (int n) { register int i, orig_nbuffers; @@ -183,10 +179,7 @@ allocate_buffers (n) /* 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; @@ -206,8 +199,7 @@ make_buffered_stream (fd, buffer, bufsize) /* 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; @@ -220,8 +212,7 @@ copy_buffered_stream (bp) } 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; @@ -231,8 +222,7 @@ set_bash_input_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; @@ -246,8 +236,7 @@ fd_is_bash_input (fd) 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; @@ -312,8 +301,7 @@ save_bash_input (fd, new_fd) 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)) { @@ -330,8 +318,7 @@ check_bash_input (fd) BUFFERS[fd1] is copied to BUFFERS[fd2]. This is called by the redirect code for constructs like 4<&0 and 3b_inputp == 0) return (EOF); @@ -548,8 +525,7 @@ bufstream_ungetc(c, bp) /* 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; @@ -565,7 +541,7 @@ sync_buffered_stream (bfd) } int -buffered_getchar () +buffered_getchar (void) { CHECK_TERMSIG; @@ -584,17 +560,14 @@ buffered_getchar () } 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; @@ -608,16 +581,13 @@ with_input_from_buffered_stream (bfd, name) #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)); @@ -626,12 +596,11 @@ int size; } void -init_yy_io () +init_yy_io (void) { } -process(bp) -BUFFERED_STREAM *bp; +process(BUFFERED_STREAM *bp) { int c; @@ -644,9 +613,7 @@ BASH_INPUT bash_input; 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; diff --git a/jobs.c b/jobs.c index 1179d907c..294e286cb 100644 --- a/jobs.c +++ b/jobs.c @@ -87,7 +87,7 @@ extern int errno; #endif /* !errno */ #if !defined (HAVE_KILLPG) -extern int killpg PARAMS((pid_t, int)); +extern int killpg (pid_t, int); #endif #if !DEFAULT_CHILD_MAX @@ -162,14 +162,14 @@ extern int killpg PARAMS((pid_t, int)); /* 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 }; @@ -237,77 +237,77 @@ PROCESS *last_procsub_child = (PROCESS *)NULL; 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 */ @@ -357,8 +357,7 @@ static char retcode_name_buffer[64]; #define tcsetpgrp(fd, pgrp) ioctl ((fd), TIOCSPGRP, &(pgrp)) pid_t -tcgetpgrp (fd) - int fd; +tcgetpgrp (int fd) { pid_t pgrp; @@ -372,7 +371,7 @@ tcgetpgrp (fd) /* Initialize the global job stats structure and other bookkeeping variables */ void -init_job_stats () +init_job_stats (void) { js = zerojs; } @@ -382,7 +381,7 @@ init_job_stats () 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]; @@ -404,7 +403,7 @@ current_working_directory () /* Return the working directory for the current process. */ static char * -job_working_directory () +job_working_directory (void) { char *dir; @@ -420,7 +419,7 @@ job_working_directory () } void -making_children () +making_children (void) { if (already_making_children) return; @@ -430,13 +429,13 @@ making_children () } 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; @@ -452,7 +451,7 @@ cleanup_the_pipeline () /* Not used right now */ void -discard_last_procsub_child () +discard_last_procsub_child (void) { PROCESS *disposer; sigset_t set, oset; @@ -467,7 +466,7 @@ discard_last_procsub_child () } static struct pipeline_saver * -alloc_pipeline_saver () +alloc_pipeline_saver (void) { struct pipeline_saver *ret; @@ -478,8 +477,7 @@ alloc_pipeline_saver () } void -save_pipeline (clear) - int clear; +save_pipeline (int clear) { sigset_t set, oset; struct pipeline_saver *saver; @@ -496,8 +494,7 @@ save_pipeline (clear) } PROCESS * -restore_pipeline (discard) - int discard; +restore_pipeline (int discard) { PROCESS *old_pipeline; sigset_t set, oset; @@ -522,7 +519,7 @@ restore_pipeline (discard) /* Start building a pipeline. */ void -start_pipeline () +start_pipeline (void) { if (the_pipeline) { @@ -552,9 +549,7 @@ start_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; @@ -758,7 +753,7 @@ stop_pipeline (async, deferred) /* 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; @@ -801,7 +796,7 @@ bgp_resize () } static ps_index_t -bgp_getindex () +bgp_getindex (void) { if (bgpids.nalloc < (ps_index_t)js.c_childmax || bgpids.head >= bgpids.nalloc) bgp_resize (); @@ -811,8 +806,7 @@ bgp_getindex () } static ps_index_t * -pshash_getbucket (pid) - pid_t pid; +pshash_getbucket (pid_t pid) { unsigned long hash; /* XXX - u_bits32_t */ @@ -821,9 +815,7 @@ pshash_getbucket (pid) } 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; @@ -865,8 +857,7 @@ bgp_add (pid, status) } static void -pshash_delindex (psi) - ps_index_t psi; +pshash_delindex (ps_index_t psi) { struct pidstat *ps; ps_index_t *bucket; @@ -891,8 +882,7 @@ pshash_delindex (psi) } static int -bgp_delete (pid) - pid_t pid; +bgp_delete (pid_t pid) { ps_index_t psi, orig_psi; @@ -926,7 +916,7 @@ bgp_delete (pid) /* Clear out the list of saved statuses */ static void -bgp_clear () +bgp_clear (void) { if (bgpids.storage == 0 || bgpids.nalloc == 0) return; @@ -944,8 +934,7 @@ bgp_clear () 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; @@ -969,7 +958,7 @@ bgp_search (pid) #if 0 static void -bgp_prune () +bgp_prune (void) { return; } @@ -978,9 +967,7 @@ bgp_prune () /* 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; @@ -998,16 +985,14 @@ save_proc_status (pid, status) 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; @@ -1029,8 +1014,7 @@ procsub_add (p) } PROCESS * -procsub_search (pid) - pid_t pid; +procsub_search (pid_t pid) { PROCESS *p; sigset_t set, oset; @@ -1045,8 +1029,7 @@ procsub_search (pid) } PROCESS * -procsub_delete (pid) - pid_t pid; +procsub_delete (pid_t pid) { PROCESS *p, *prev; sigset_t set, oset; @@ -1083,8 +1066,7 @@ procsub_delete (pid) } int -procsub_waitpid (pid) - pid_t pid; +procsub_waitpid (pid_t pid) { PROCESS *p; int r; @@ -1099,7 +1081,7 @@ procsub_waitpid (pid) } void -procsub_waitall () +procsub_waitall (void) { PROCESS *p; int r; @@ -1113,7 +1095,7 @@ procsub_waitall () } void -procsub_clear () +procsub_clear (void) { PROCESS *p, *ps; sigset_t set, oset; @@ -1133,7 +1115,7 @@ procsub_clear () /* Must be called with SIGCHLD blocked. */ void -procsub_prune () +procsub_prune (void) { PROCESS *ohead, *oend, *ps, *p; int onproc; @@ -1169,7 +1151,7 @@ procsub_prune () 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; @@ -1209,7 +1191,7 @@ reset_job_indices () /* 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; @@ -1249,8 +1231,7 @@ cleanup_dead_jobs () } static int -processes_in_job (job) - int job; +processes_in_job (int job) { int nproc; register PROCESS *p; @@ -1268,8 +1249,7 @@ processes_in_job (job) } static void -delete_old_job (pid) - pid_t pid; +delete_old_job (pid_t pid) { PROCESS *p; int job; @@ -1293,7 +1273,7 @@ delete_old_job (pid) 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; @@ -1370,8 +1350,7 @@ realloc_jobs_list () 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; @@ -1389,8 +1368,7 @@ compact_jobs_list (flags) /* 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; @@ -1452,8 +1430,7 @@ delete_job (job_index, dflags) /* Must be called with SIGCHLD blocked. */ void -nohup_job (job_index) - int job_index; +nohup_job (int job_index) { register JOB *temp; @@ -1466,8 +1443,7 @@ nohup_job (job_index) /* 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; @@ -1491,9 +1467,7 @@ discard_pipeline (chain) 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; @@ -1532,11 +1506,7 @@ add_process (name, pid) /* 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; @@ -1560,7 +1530,7 @@ append_process (name, pid, status, jid) /* 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; @@ -1574,7 +1544,7 @@ rotate_the_pipeline () /* 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; @@ -1599,9 +1569,7 @@ reverse_the_pipeline () 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; @@ -1635,7 +1603,7 @@ map_over_jobs (func, arg1, arg2) /* 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) { @@ -1646,7 +1614,7 @@ terminate_current_pipeline () /* Cause all stopped jobs to exit. */ void -terminate_stopped_jobs () +terminate_stopped_jobs (void) { register int i; @@ -1664,7 +1632,7 @@ terminate_stopped_jobs () /* 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; @@ -1683,17 +1651,14 @@ hangup_all_jobs () } 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; @@ -1712,12 +1677,10 @@ find_pid_in_pipeline (pid, pipeline, alive_only) /* 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; @@ -1748,13 +1711,10 @@ find_pipeline (pid, alive_only, jobp) } /* 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; @@ -1767,10 +1727,7 @@ find_process (pid, alive_only, jobp) /* 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; @@ -1808,10 +1765,7 @@ find_job (pid, alive_only, procp) /* 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; @@ -1829,8 +1783,7 @@ get_job_by_pid (pid, block, procp) /* 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; @@ -1848,8 +1801,7 @@ describe_pid (pid) } static char * -j_strsignal (s) - int s; +j_strsignal (int s) { char *x; @@ -1863,10 +1815,7 @@ j_strsignal (s) } 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; @@ -1936,10 +1885,7 @@ printable_job_status (j, p, format) 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; @@ -2037,9 +1983,7 @@ print_pipeline (p, job_index, format, stream) /* 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; @@ -2075,9 +2019,7 @@ pretty_print_job (job_index, format, stream) } 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); @@ -2085,25 +2027,21 @@ print_job (job, format, state, job_index) } 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); @@ -2112,8 +2050,7 @@ list_running_jobs (format) /* 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); @@ -2124,9 +2061,7 @@ list_all_jobs (format) 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; @@ -2361,7 +2296,7 @@ make_child (command, flags) /* 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); @@ -2373,7 +2308,7 @@ ignore_tty_job_signals () 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); @@ -2393,7 +2328,7 @@ default_tty_job_signals () /* Called once in a parent process. */ void -get_original_tty_job_signals () +get_original_tty_job_signals (void) { static int fetched = 0; @@ -2443,8 +2378,7 @@ static int ttspeeds[] = }; static void -draino (fd, ospeed) - int fd, ospeed; +draino (int fd, int ospeed) { register int delay = ttspeeds[ospeed]; int n; @@ -2474,7 +2408,7 @@ draino (fd, ospeed) /* Fill the contents of shell_tty_info with the current tty info. */ int -get_tty_state () +get_tty_state (void) { int tty; @@ -2511,7 +2445,7 @@ get_tty_state () /* Make the current tty use the state in shell_tty_info. */ int -set_tty_state () +set_tty_state (void) { int tty; @@ -2549,9 +2483,7 @@ set_tty_state () 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; @@ -2570,9 +2502,7 @@ find_last_proc (job, block) } static pid_t -find_last_pid (job, block) - int job; - int block; +find_last_pid (int job, int block) { PROCESS *p; @@ -2589,9 +2519,7 @@ find_last_pid (job, block) 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; @@ -2651,8 +2579,7 @@ wait_for_single_pid (pid, flags) /* 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; @@ -2733,7 +2660,7 @@ int waiting_for_child; /* Clean up state after longjmp to wait_intr_buf */ void -wait_sigint_cleanup () +wait_sigint_cleanup (void) { queue_sigchld = 0; waiting_for_child = 0; @@ -2741,7 +2668,7 @@ wait_sigint_cleanup () } static void -restore_sigint_handler () +restore_sigint_handler (void) { if (old_sigint_handler != INVALID_SIGNAL_HANDLER) { @@ -2755,8 +2682,7 @@ restore_sigint_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; @@ -2799,15 +2725,13 @@ wait_sigint_handler (sig) } 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)); @@ -2818,8 +2742,7 @@ process_exit_status (status) } static WAIT -job_signal_status (job) - int job; +job_signal_status (int job) { register PROCESS *p; WAIT s; @@ -2840,8 +2763,7 @@ job_signal_status (job) /* 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; @@ -2871,22 +2793,19 @@ raw_job_exit_status (job) (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; @@ -2918,9 +2837,7 @@ job_killed_by_signal (job) 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; @@ -3234,9 +3151,7 @@ wait_for_return: 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; @@ -3288,9 +3203,7 @@ wait_for_job (job, flags, ps) 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; @@ -3372,7 +3285,7 @@ return_job: 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; @@ -3386,7 +3299,7 @@ notify_and_cleanup () /* 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 (); @@ -3396,9 +3309,7 @@ reap_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; @@ -3422,8 +3333,7 @@ most_recent_job_in_state (job, state) /* 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)); } @@ -3431,8 +3341,7 @@ job_last_stopped (job) /* 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)); } @@ -3440,8 +3349,7 @@ job_last_running (job) /* 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; @@ -3501,7 +3409,7 @@ set_current_job (job) next-newest running job is `-'. Must be called with SIGCHLD blocked. */ static void -reset_current () +reset_current (void) { int candidate; @@ -3535,8 +3443,7 @@ reset_current () /* 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; @@ -3560,8 +3467,7 @@ set_job_running (job) 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; @@ -3684,9 +3590,7 @@ start_job (job, foreground) 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; @@ -3760,8 +3664,7 @@ kill_pid (pid, sig, group) /* 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; @@ -3783,9 +3686,7 @@ sigchld_handler (sig) 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; @@ -3999,8 +3900,7 @@ itrace("waitchld: waitpid returns %d block = %d children_exited = %d", pid, bloc 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; @@ -4174,8 +4074,7 @@ set_job_status_and_cleanup (job) /* 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; @@ -4204,8 +4103,7 @@ setjstatus (j) } void -run_sigchld_trap (nchild) - int nchild; +run_sigchld_trap (int nchild) { char *trap_command; int i; @@ -4254,7 +4152,7 @@ run_sigchld_trap (nchild) 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; @@ -4389,8 +4287,7 @@ notify_of_job_status () /* 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; @@ -4540,7 +4437,7 @@ just_bail: #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); @@ -4553,8 +4450,7 @@ debug_print_pgrps () /* 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; @@ -4609,7 +4505,7 @@ set_new_line_discipline (tty) /* Setup this shell to handle C-C, etc. */ void -initialize_job_signals () +initialize_job_signals (void) { if (interactive) { @@ -4630,8 +4526,7 @@ initialize_job_signals () /* 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); @@ -4642,8 +4537,7 @@ sigcont_sighandler (sig) /* 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); @@ -4660,9 +4554,7 @@ sigstop_sighandler (sig) /* 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; @@ -4702,9 +4594,7 @@ give_terminal_to (pgrp, force) /* 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; @@ -4731,8 +4621,7 @@ maybe_give_terminal_to (opgrp, npgrp, flags) 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; @@ -4777,8 +4666,7 @@ delete_all_jobs (running_only) /* 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; @@ -4797,7 +4685,7 @@ nohup_all_jobs (running_only) } int -count_all_jobs () +count_all_jobs (void) { int i, n; sigset_t set, oset; @@ -4820,7 +4708,7 @@ count_all_jobs () } static void -mark_all_jobs_as_dead () +mark_all_jobs_as_dead (void) { register int i; sigset_t set, oset; @@ -4846,8 +4734,7 @@ mark_all_jobs_as_dead () 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; @@ -4952,7 +4839,7 @@ itrace("mark_dead_jobs_as_notified: child_max = %d ndead = %d ndeadproc = %d", j /* 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; @@ -4962,23 +4849,21 @@ freeze_jobs_list () } 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; @@ -5016,7 +4901,7 @@ set_job_control (arg) /* 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 (); @@ -5032,7 +4917,7 @@ without_job_control () 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 (); @@ -5047,7 +4932,7 @@ end_job_control () /* 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); @@ -5058,8 +4943,7 @@ restart_job_control () 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; @@ -5086,7 +4970,7 @@ set_maxchild (nchild) /* 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); } @@ -5095,8 +4979,7 @@ set_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; @@ -5115,15 +4998,13 @@ pipe_read (pp) /* 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]; @@ -5132,8 +5013,7 @@ save_pgrp_pipe (p, clear) } void -restore_pgrp_pipe (p) - int *p; +restore_pgrp_pipe (int *p) { pgrp_pipe[0] = p[0]; pgrp_pipe[1] = p[1]; diff --git a/locale.c b/locale.c index fabf7b125..bccbe6d99 100644 --- a/locale.c +++ b/locale.c @@ -1,6 +1,6 @@ /* 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. @@ -68,15 +68,15 @@ static char *lang; /* 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, ""); @@ -101,7 +101,7 @@ set_default_locale () 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; @@ -174,8 +174,7 @@ set_default_locale_vars () /* 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; @@ -303,8 +302,7 @@ set_locale_var (var, value) 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) @@ -321,7 +319,7 @@ set_lang (var, 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; @@ -336,8 +334,7 @@ set_default_lang () 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; @@ -360,7 +357,7 @@ get_locale_var (var) 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) @@ -406,9 +403,7 @@ reset_locale_vars () 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; @@ -464,9 +459,7 @@ localetrans (string, len, lenp) /* 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; @@ -515,9 +508,7 @@ mk_msgstr (string, foundnlp) 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; @@ -573,7 +564,7 @@ locale_expand (string, start, end, lineno, lenp) /* Set every character in the 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; @@ -595,8 +586,7 @@ locale_setblanks () 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; @@ -628,7 +618,7 @@ locale_isutf8 (lspec) #if defined (HAVE_LOCALECONV) int -locale_decpoint () +locale_decpoint (void) { struct lconv *lv; @@ -638,7 +628,7 @@ locale_decpoint () #else # undef locale_decpoint int -locale_decpoint () +locale_decpoint (void) { return '.'; } diff --git a/mailcheck.c b/mailcheck.c index fe335e7b2..a29f3e0d7 100644 --- a/mailcheck.c +++ b/mailcheck.c @@ -1,6 +1,6 @@ /* 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. @@ -47,7 +47,7 @@ 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; @@ -69,24 +69,23 @@ static time_t last_time_mail_checked = 0; /* 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; @@ -113,7 +112,7 @@ time_to_check_mail () /* 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; } @@ -121,8 +120,7 @@ reset_mail_timer () /* 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; @@ -153,8 +151,7 @@ find_mail_file (file) 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; @@ -162,8 +159,7 @@ init_mail_file (i) } static void -update_mail_file (i) - int i; +update_mail_file (int i) { char *file; struct stat finfo; @@ -178,8 +174,7 @@ update_mail_file (i) /* 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; @@ -208,7 +203,7 @@ add_mail_file (file, msg) /* Reset the existing mail files access and modification times to zero. */ void -reset_mail_files () +reset_mail_files (void) { register int i; @@ -217,8 +212,7 @@ reset_mail_files () } static FILEINFO * -alloc_mail_file (filename, msg) - char *filename, *msg; +alloc_mail_file (char *filename, char *msg) { FILEINFO *mf; @@ -231,8 +225,7 @@ alloc_mail_file (filename, msg) } static void -dispose_mail_file (mf) - FILEINFO *mf; +dispose_mail_file (FILEINFO *mf) { free (mf->name); FREE (mf->msg); @@ -241,7 +234,7 @@ dispose_mail_file (mf) /* Free the information that we have about the remembered mail files. */ void -free_mail_files () +free_mail_files (void) { register int i; @@ -256,7 +249,7 @@ free_mail_files () } void -init_mail_dates () +init_mail_dates (void) { if (mailfiles == 0) remember_mail_dates (); @@ -266,8 +259,7 @@ init_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; @@ -290,8 +282,7 @@ file_mod_date_changed (i) /* 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; @@ -311,8 +302,7 @@ file_access_date_changed (i) /* 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; @@ -328,8 +318,7 @@ file_has_grown (i) 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; @@ -353,7 +342,7 @@ parse_mailpath_spec (str) } char * -make_default_mailpath () +make_default_mailpath (void) { #if defined (DEFAULT_MAIL_DIRECTORY) char *mp; @@ -374,7 +363,7 @@ make_default_mailpath () default value, which we randomly concoct from using Unix. */ void -remember_mail_dates () +remember_mail_dates (void) { char *mailpaths; char *mailfile, *mp; @@ -423,7 +412,7 @@ remember_mail_dates () mail file has been accessed since the last time we remembered, then the message "The mail in has been read" is printed. */ void -check_mail () +check_mail (void) { char *current_mail_file, *message; int i, use_user_notification; diff --git a/make_cmd.c b/make_cmd.c index 98151a41a..90abdcf7e 100644 --- a/make_cmd.c +++ b/make_cmd.c @@ -55,21 +55,21 @@ sh_obj_cache_t wlcache = {0, 0, 0}; #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; @@ -80,8 +80,7 @@ alloc_word_desc () } WORD_DESC * -make_bare_word (string) - const char *string; +make_bare_word (const char *string) { WORD_DESC *temp; @@ -99,9 +98,7 @@ make_bare_word (string) } 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; @@ -132,8 +129,7 @@ make_word_flags (w, string) } WORD_DESC * -make_word (string) - const char *string; +make_word (const char *string) { WORD_DESC *temp; @@ -142,8 +138,7 @@ make_word (string) } WORD_DESC * -make_word_from_token (token) - int token; +make_word_from_token (int token) { char tokenizer[2]; @@ -154,9 +149,7 @@ make_word_from_token (token) } 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; @@ -168,9 +161,7 @@ make_word_list (word, wlink) } COMMAND * -make_command (type, pointer) - enum command_type type; - SIMPLE_COM *pointer; +make_command (enum command_type type, SIMPLE_COM *pointer) { COMMAND *temp; @@ -183,9 +174,7 @@ make_command (type, pointer) } COMMAND * -command_connect (com1, com2, connector) - COMMAND *com1, *com2; - int connector; +command_connect (COMMAND *com1, COMMAND *com2, int connector) { CONNECTION *temp; @@ -197,12 +186,7 @@ command_connect (com1, com2, connector) } 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; @@ -216,21 +200,13 @@ make_for_or_select (type, name, map_list, action, lineno) } 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)); @@ -242,8 +218,7 @@ make_select_command (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; @@ -262,10 +237,7 @@ make_arith_for_expr (s) 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; @@ -340,8 +312,7 @@ make_arith_for_command (exprs, action, lineno) } COMMAND * -make_group_command (command) - COMMAND *command; +make_group_command (COMMAND *command) { GROUP_COM *temp; @@ -351,10 +322,7 @@ make_group_command (command) } 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; @@ -367,9 +335,7 @@ make_case_command (word, clauses, lineno) } PATTERN_LIST * -make_pattern_list (patterns, action) - WORD_LIST *patterns; - COMMAND *action; +make_pattern_list (WORD_LIST *patterns, COMMAND *action) { PATTERN_LIST *temp; @@ -382,8 +348,7 @@ make_pattern_list (patterns, action) } 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; @@ -396,9 +361,7 @@ make_if_command (test, true_case, false_case) } 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; @@ -410,22 +373,19 @@ make_until_or_while (which, test, action) } 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; @@ -451,10 +411,7 @@ make_arith_command (exp) #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; @@ -471,8 +428,7 @@ make_cond_node (type, op, left, right) #endif COMMAND * -make_cond_command (cond_node) - COND_COM *cond_node; +make_cond_command (COND_COM *cond_node) { #if defined (COND_COMMAND) COMMAND *command; @@ -493,7 +449,7 @@ make_cond_command (cond_node) } COMMAND * -make_bare_simple_command () +make_bare_simple_command (void) { COMMAND *command; SIMPLE_COM *temp; @@ -516,9 +472,7 @@ make_bare_simple_command () /* 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 @@ -555,9 +509,7 @@ make_simple_command (element, command) 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; @@ -683,11 +635,7 @@ document_done: 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; @@ -772,10 +720,7 @@ make_redirection (source, instruction, dest_and_filename, flags) } 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) @@ -813,8 +758,7 @@ make_function_def (name, command, lineno, lstart) } COMMAND * -make_subshell_command (command) - COMMAND *command; +make_subshell_command (COMMAND *command) { SUBSHELL_COM *temp; @@ -826,9 +770,7 @@ make_subshell_command (command) } COMMAND * -make_coproc_command (name, command) - char *name; - COMMAND *command; +make_coproc_command (char *name, COMMAND *command) { COPROC_COM *temp; @@ -843,8 +785,7 @@ make_coproc_command (name, command) 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); @@ -870,9 +811,7 @@ clean_simple_command (command) 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; diff --git a/nojobs.c b/nojobs.c index b7504cd80..4374d2630 100644 --- a/nojobs.c +++ b/nojobs.c @@ -74,7 +74,7 @@ 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; @@ -121,36 +121,36 @@ static int wait_sigint_received; 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; @@ -169,8 +169,7 @@ alloc_pid_list () /* 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; @@ -187,8 +186,7 @@ find_proc_slot (pid) /* 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; @@ -202,8 +200,7 @@ find_index_by_pid (pid) /* 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; @@ -216,8 +213,7 @@ find_status_by_pid (pid) } static int -process_exit_status (status) - WAIT status; +process_exit_status (WAIT status) { if (WIFSIGNALED (status)) return (128 + WTERMSIG (status)); @@ -228,8 +224,7 @@ process_exit_status (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; @@ -245,8 +240,7 @@ find_termsig_by_pid (pid) 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)); @@ -256,9 +250,7 @@ get_termsig (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; @@ -288,9 +280,7 @@ set_pid_status (pid, status) /* 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; @@ -303,9 +293,7 @@ set_pid_flags (pid, flags) /* 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; @@ -318,8 +306,7 @@ unset_pid_flags (pid, flags) /* 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; @@ -331,9 +318,7 @@ get_pid_flags (pid) } static void -add_pid (pid, async) - pid_t pid; - int async; +add_pid (pid_t pid, int async) { int slot; @@ -347,8 +332,7 @@ add_pid (pid, async) } static void -mark_dead_jobs_as_notified (force) - int force; +mark_dead_jobs_as_notified (int force) { register int i, ndead; @@ -388,7 +372,7 @@ mark_dead_jobs_as_notified (force) /* Remove all dead, notified jobs from the pid_list. */ int -cleanup_dead_jobs () +cleanup_dead_jobs (void) { register int i; @@ -412,7 +396,7 @@ cleanup_dead_jobs () } void -reap_dead_jobs () +reap_dead_jobs (void) { mark_dead_jobs_as_notified (0); cleanup_dead_jobs (); @@ -420,8 +404,7 @@ reap_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); @@ -432,7 +415,7 @@ initialize_job_control (force) /* Setup this shell to handle C-C, etc. */ void -initialize_job_signals () +initialize_job_signals (void) { set_signal_handler (SIGINT, sigint_sighandler); @@ -446,7 +429,7 @@ initialize_job_signals () /* 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; @@ -469,8 +452,7 @@ reap_zombie_children () #endif static int -siginterrupt (sig, flag) - int sig, flag; +siginterrupt (int sig, int flag) { struct sigaction act; @@ -490,9 +472,7 @@ siginterrupt (sig, flag) 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; @@ -594,7 +574,7 @@ make_child (command, flags) } void -ignore_tty_job_signals () +ignore_tty_job_signals (void) { #if defined (SIGTSTP) set_signal_handler (SIGTSTP, SIG_IGN); @@ -604,7 +584,7 @@ ignore_tty_job_signals () } void -default_tty_job_signals () +default_tty_job_signals (void) { #if defined (SIGTSTP) if (signal_is_trapped (SIGTSTP) == 0 && signal_is_hard_ignored (SIGTSTP)) @@ -624,7 +604,7 @@ default_tty_job_signals () /* Called once in a parent process. */ void -get_original_tty_job_signals () +get_original_tty_job_signals (void) { static int fetched = 0; @@ -651,9 +631,7 @@ get_original_tty_job_signals () /* 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; @@ -708,8 +686,7 @@ wait_for_single_pid (pid, flags) /* 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; @@ -757,7 +734,7 @@ wait_for_background_pids (ps) } void -wait_sigint_cleanup () +wait_sigint_cleanup (void) { } @@ -766,7 +743,7 @@ wait_sigint_cleanup () static SigHandler *old_sigint_handler = INVALID_SIGNAL_HANDLER; static void -restore_sigint_handler () +restore_sigint_handler (void) { if (old_sigint_handler != INVALID_SIGNAL_HANDLER) { @@ -779,8 +756,7 @@ restore_sigint_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; @@ -803,8 +779,7 @@ wait_sigint_handler (sig) } static char * -j_strsignal (s) - int s; +j_strsignal (int s) { static char retcode_name_buffer[64] = { '\0' }; char *x; @@ -821,9 +796,7 @@ j_strsignal (s) /* 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; @@ -943,9 +916,7 @@ wait_for (pid, flags) /* 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; @@ -963,7 +934,7 @@ static int got_tty_state; /* Fill the contents of shell_tty_info with the current tty info. */ int -get_tty_state () +get_tty_state (void) { int tty; @@ -980,7 +951,7 @@ get_tty_state () /* Make the current tty use the state in shell_tty_info. */ int -set_tty_state () +set_tty_state (void) { int tty; @@ -996,48 +967,41 @@ set_tty_state () /* 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; @@ -1047,31 +1011,29 @@ get_job_by_pid (pid, block, ignore) /* 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; } diff --git a/parse.y b/parse.y index cad4d5964..ed39bf163 100644 --- a/parse.y +++ b/parse.y @@ -71,7 +71,7 @@ #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) @@ -144,87 +144,87 @@ extern int errno; /* **************************************************************** */ #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; @@ -1397,8 +1397,7 @@ int EOF_Reached = 0; #ifdef DEBUG static void -debug_parser (i) - int i; +debug_parser (int i) { #if YYDEBUG != 0 yydebug = i; @@ -1418,7 +1417,7 @@ debug_parser (i) /* Unconditionally returns end-of-file. */ int -return_EOF () +return_EOF (void) { return (EOF); } @@ -1430,7 +1429,7 @@ BASH_INPUT bash_input; /* 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); @@ -1444,12 +1443,7 @@ initialize_bash_input () /* 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); @@ -1466,14 +1460,14 @@ init_yy_io (get, unget, type, name, location) } 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)) (); } @@ -1481,8 +1475,7 @@ yy_getc () /* 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); } @@ -1490,7 +1483,7 @@ yy_ungetc (c) #if defined (BUFFERED_INPUT) #ifdef INCLUDE_UNUSED int -input_file_descriptor () +input_file_descriptor (void) { switch (bash_input.type) { @@ -1518,7 +1511,7 @@ char *current_readline_line = (char *)NULL; int current_readline_line_index = 0; static int -yy_readline_get () +yy_readline_get (void) { SigHandler *old_sigint; int line_len; @@ -1581,8 +1574,7 @@ yy_readline_get () } 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; @@ -1590,7 +1582,7 @@ yy_readline_unget (c) } void -with_input_from_stdin () +with_input_from_stdin (void) { INPUT_STREAM location; @@ -1607,7 +1599,7 @@ with_input_from_stdin () 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); } @@ -1615,7 +1607,7 @@ parser_will_prompt () #else /* !READLINE */ void -with_input_from_stdin () +with_input_from_stdin (void) { with_input_from_stream (stdin, "stdin"); } @@ -1628,7 +1620,7 @@ with_input_from_stdin () /* **************************************************************** */ static int -yy_string_get () +yy_string_get (void) { register char *string; register unsigned char c; @@ -1647,17 +1639,14 @@ yy_string_get () } 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; @@ -1671,7 +1660,7 @@ with_input_from_string (string, name) 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; @@ -1705,7 +1694,7 @@ rewind_input_string () We will need to restart it ourselves. */ static int -yy_stream_get () +yy_stream_get (void) { int result; @@ -1720,16 +1709,13 @@ yy_stream_get () } 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; @@ -1760,8 +1746,7 @@ static int cond_token; 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)); @@ -1785,7 +1770,7 @@ push_stream (reset_lineno) } void -pop_stream () +pop_stream (void) { if (!stream_list) EOF_Reached = 1; @@ -1833,8 +1818,7 @@ pop_stream () /* 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; @@ -1846,7 +1830,7 @@ stream_on_stack (type) /* Save the current token state and return it in a malloced array. */ int * -save_token_state () +save_token_state (void) { int *ret; @@ -1859,8 +1843,7 @@ save_token_state () } void -restore_token_state (ts) - int *ts; +restore_token_state (int *ts) { if (ts == 0) return; @@ -1918,10 +1901,7 @@ STRING_SAVER *pushed_string_list = (STRING_SAVER *)NULL; * 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)); @@ -1963,7 +1943,7 @@ push_string (s, expand, ap) * and needs to return to the original input line. */ static void -pop_string () +pop_string (void) { STRING_SAVER *t; @@ -1995,7 +1975,7 @@ pop_string () } static void -free_string_list () +free_string_list (void) { register STRING_SAVER *t, *t1; @@ -2014,7 +1994,7 @@ free_string_list () } void -free_pushed_string_input () +free_pushed_string_input (void) { #if defined (ALIAS) || defined (DPAREN_ARITHMETIC) free_string_list (); @@ -2022,13 +2002,13 @@ free_pushed_string_input () } 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); @@ -2039,7 +2019,7 @@ parser_save_alias () } void -parser_restore_alias () +parser_restore_alias (void) { #if defined (ALIAS) || defined (DPAREN_ARITHMETIC) if (pushed_string_list) @@ -2053,8 +2033,7 @@ parser_restore_alias () /* 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; @@ -2067,7 +2046,7 @@ clear_string_list_expander (ap) #endif void -clear_shell_input_line () +clear_shell_input_line (void) { if (shell_input_line) shell_input_line[shell_input_line_index = 0] = '\0'; @@ -2078,8 +2057,7 @@ clear_shell_input_line () is non-zero, we remove unquoted \ 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; @@ -2169,8 +2147,7 @@ read_a_line (remove_quoted_newline) 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; @@ -2325,8 +2302,7 @@ static int eol_ungetc_lookahead = 0; 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; @@ -2733,8 +2709,7 @@ pop_alias: 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; @@ -2744,8 +2719,7 @@ shell_ungetc (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; @@ -2797,7 +2771,7 @@ shell_ungets (s) } char * -parser_remaining_input () +parser_remaining_input (void) { if (shell_input_line == 0) return 0; @@ -2809,7 +2783,7 @@ parser_remaining_input () #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--; @@ -2819,8 +2793,7 @@ shell_ungetchar () /* 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; @@ -2832,8 +2805,7 @@ discard_until (character) } void -execute_variable_command (command, vname) - char *command, *vname; +execute_variable_command (char *command, char *vname) { char *last_lastarg; sh_parser_state_t ps; @@ -2854,8 +2826,7 @@ execute_variable_command (command, vname) } void -push_token (x) - int x; +push_token (int x) { two_tokens_ago = token_before_that; token_before_that = last_read_token; @@ -2880,7 +2851,7 @@ static size_t token_buffer_size; /* 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')) { @@ -2930,8 +2901,7 @@ static int esacs_needed_count; static int expecting_in_token; static void -push_heredoc (r) - REDIRECT *r; +push_heredoc (REDIRECT *r) { if (need_here_doc >= HEREDOC_MAX) { @@ -2945,7 +2915,7 @@ push_heredoc (r) } void -gather_here_documents () +gather_here_documents (void) { int r; @@ -3043,8 +3013,7 @@ static int open_brace_count; 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; @@ -3066,8 +3035,7 @@ mk_alexpansion (s) } static int -alias_expand_token (tokstr) - char *tokstr; +alias_expand_token (char *tokstr) { char *expanded; alias_t *ap; @@ -3104,7 +3072,7 @@ alias_expand_token (tokstr) #endif /* ALIAS */ static int -time_command_acceptable () +time_command_acceptable (void) { #if defined (COMMAND_TIMING) int i; @@ -3182,8 +3150,7 @@ time_command_acceptable () */ static int -special_case_tokens (tokstr) - char *tokstr; +special_case_tokens (char *tokstr) { /* Posix grammar rule 6 */ if ((last_read_token == WORD) && @@ -3307,7 +3274,7 @@ special_case_tokens (tokstr) /* 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; @@ -3352,7 +3319,7 @@ reset_parser () } void -reset_readahead_token () +reset_readahead_token (void) { if (token_to_read == '\n') token_to_read = 0; @@ -3361,8 +3328,7 @@ reset_readahead_token () /* 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. */ @@ -3667,11 +3633,9 @@ tokword: 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; @@ -3985,8 +3949,7 @@ parse_dollar_word: #if defined (DEBUG) static void -dump_tflags (flags) - int flags; +dump_tflags (int flags) { int f; @@ -4074,12 +4037,9 @@ dump_tflags (flags) #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; @@ -4242,11 +4202,7 @@ INTERNAL_DEBUG(("current_token (%d) != shell_eof_token (%c)", current_token, she 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; @@ -4380,9 +4336,7 @@ xparse_dolparen (base, string, indp, flags) 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; @@ -4451,8 +4405,7 @@ parse_string_to_command (string, flags) 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; @@ -4513,9 +4466,7 @@ parse_dparen (c) 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; @@ -4564,7 +4515,7 @@ parse_arith_cmd (ep, adddq) #if defined (COND_COMMAND) static void -cond_error () +cond_error (void) { char *etext; @@ -4583,13 +4534,13 @@ cond_error () } static COND_COM * -cond_expr () +cond_expr (void) { return (cond_or ()); } static COND_COM * -cond_or () +cond_or (void) { COND_COM *l, *r; @@ -4603,7 +4554,7 @@ cond_or () } static COND_COM * -cond_and () +cond_and (void) { COND_COM *l, *r; @@ -4617,7 +4568,7 @@ cond_and () } static int -cond_skip_newlines () +cond_skip_newlines (void) { while ((cond_token = read_token (READ)) == '\n') { @@ -4631,7 +4582,7 @@ cond_skip_newlines () 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; @@ -4801,7 +4752,7 @@ cond_term () /* 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; @@ -4817,9 +4768,7 @@ parse_cond_command () 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; @@ -4840,9 +4789,7 @@ token_is_assignment (t, i) /* 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; @@ -4856,8 +4803,7 @@ token_is_ident (t, i) #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; @@ -5368,9 +5314,8 @@ got_token: /* 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) { @@ -5422,8 +5367,7 @@ reserved_word_acceptable (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++) @@ -5435,7 +5379,7 @@ find_reserved_word (tokstr) /* 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)); } @@ -5446,7 +5390,7 @@ parser_in_command_position () 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; @@ -5486,8 +5430,7 @@ static const int no_semi_successors[] = { 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; @@ -5579,8 +5522,7 @@ history_delimiting_chars (line) /* 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; @@ -5623,21 +5565,20 @@ prompt_again (force) } 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); @@ -5648,8 +5589,7 @@ print_prompt () 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; @@ -5701,8 +5641,7 @@ prompt_history_number (pmt) */ #define PROMPT_GROWTH 48 char * -decode_prompt_string (string) - char *string; +decode_prompt_string (char *string) { WORD_LIST *list; char *result, *t, *orig_string; @@ -6124,8 +6063,7 @@ not_escape: /* 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); @@ -6134,8 +6072,7 @@ yyerror (msg) } static char * -error_token_from_token (tok) - int tok; +error_token_from_token (int tok) { char *t; @@ -6174,7 +6111,7 @@ error_token_from_token (tok) } static char * -error_token_from_text () +error_token_from_text (void) { char *msg, *t; int token_end, i; @@ -6216,7 +6153,7 @@ error_token_from_text () } static void -print_offending_line () +print_offending_line (void) { char *msg; int token_end; @@ -6235,8 +6172,7 @@ print_offending_line () 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; @@ -6317,8 +6253,7 @@ report_syntax_error (message) 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) { } @@ -6346,7 +6281,7 @@ int eof_encountered_limit = 10; 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) { @@ -6401,10 +6336,7 @@ static WORD_LIST parse_string_error; /* 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; @@ -6487,8 +6419,7 @@ parse_string_to_word_list (s, flags, whom) } static char * -parse_compound_assignment (retlenp) - int *retlenp; +parse_compound_assignment (int *retlenp) { WORD_LIST *wl, *rl; int tok, orig_line_number, assignok; @@ -6576,8 +6507,7 @@ parse_compound_assignment (retlenp) ************************************************/ 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)); @@ -6638,8 +6568,7 @@ save_parser_state (ps) } void -restore_parser_state (ps) - sh_parser_state_t *ps; +restore_parser_state (sh_parser_state_t *ps) { int i; @@ -6705,8 +6634,7 @@ restore_parser_state (ps) } 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)); @@ -6736,8 +6664,7 @@ save_input_line_state (ls) } 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; @@ -6768,7 +6695,7 @@ restore_input_line_state (ls) #define MAX_PROPSIZE 32768 static void -set_line_mbstate () +set_line_mbstate (void) { int c; size_t i, previ, len; diff --git a/pathexp.c b/pathexp.c index 379128e79..0ae7862a5 100644 --- a/pathexp.c +++ b/pathexp.c @@ -1,6 +1,6 @@ /* 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. @@ -38,9 +38,9 @@ #include -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 @@ -58,8 +58,7 @@ int glob_star = 0; 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; @@ -142,8 +141,7 @@ unquoted_glob_pattern_p (string) /* 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) { @@ -168,8 +166,7 @@ ere_char (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) { @@ -203,9 +200,7 @@ glob_char_p (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; @@ -377,8 +372,7 @@ endpat: } char * -quote_globbing_chars (string) - const char *string; +quote_globbing_chars (const char *string) { size_t slen; char *temp, *t; @@ -404,9 +398,7 @@ quote_globbing_chars (string) /* 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; @@ -449,8 +441,7 @@ static struct ignorevar globignore = 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; @@ -464,15 +455,14 @@ setup_glob_ignore (name) } 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; @@ -505,9 +495,7 @@ glob_name_is_acceptable (name) 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; @@ -542,8 +530,7 @@ ignore_globbed_names (names, name_func) } void -ignore_glob_matches (names) - char **names; +ignore_glob_matches (char **names) { if (globignore.num_ignores == 0) return; @@ -552,9 +539,7 @@ ignore_glob_matches (names) } static char * -split_ignorespec (s, ip) - char *s; - int *ip; +split_ignorespec (char *s, int *ip) { char *t; int n, i; @@ -576,8 +561,7 @@ split_ignorespec (s, ip) } void -setup_ignore_patterns (ivp) - struct ignorevar *ivp; +setup_ignore_patterns (struct ignorevar *ivp) { int numitems, maxitems, ptr; char *colon_bit, *this_ignoreval; @@ -614,11 +598,7 @@ setup_ignore_patterns (ivp) 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) { diff --git a/pcomplete.c b/pcomplete.c index b13e24911..d8398c3fb 100644 --- a/pcomplete.c +++ b/pcomplete.c @@ -1,6 +1,6 @@ /* 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. @@ -79,71 +79,69 @@ 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? */ @@ -193,13 +191,7 @@ int pcomp_ind; #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; @@ -221,15 +213,13 @@ debug_printf (format, va_alist) /* 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; @@ -237,8 +227,7 @@ initialize_itemlist (itp) } void -clean_itemlist (itp) - ITEMLIST *itp; +clean_itemlist (ITEMLIST *itp) { STRINGLIST *sl; @@ -255,10 +244,8 @@ clean_itemlist (itp) itp->flags &= ~(LIST_DONTFREE|LIST_DONTFREEMEMBERS|LIST_INITIALIZED|LIST_DIRTY); } - static int -shouldexp_filterpat (s) - char *s; +shouldexp_filterpat (char *s) { register char *p; @@ -276,9 +263,7 @@ shouldexp_filterpat (s) 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; @@ -292,10 +277,7 @@ preproc_filterpat (pat, text) 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; @@ -334,8 +316,7 @@ filter_stringlist (sl, filterpat, text) 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; @@ -365,8 +346,7 @@ completions_to_stringlist (matches) 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; @@ -395,9 +375,7 @@ it_init_aliases (itp) } 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; @@ -420,8 +398,7 @@ init_itemlist_from_varlist (itp, svfunc) } 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); @@ -432,8 +409,7 @@ it_init_arrayvars (itp) } static int -it_init_bindings (itp) - ITEMLIST *itp; +it_init_bindings (ITEMLIST *itp) { char **blist; STRINGLIST *sl; @@ -451,8 +427,7 @@ it_init_bindings (itp) } static int -it_init_builtins (itp) - ITEMLIST *itp; +it_init_builtins (ITEMLIST *itp) { STRINGLIST *sl; register int i, n; @@ -468,8 +443,7 @@ it_init_builtins (itp) } static int -it_init_enabled (itp) - ITEMLIST *itp; +it_init_enabled (ITEMLIST *itp) { STRINGLIST *sl; register int i, n; @@ -487,8 +461,7 @@ it_init_enabled (itp) } static int -it_init_disabled (itp) - ITEMLIST *itp; +it_init_disabled (ITEMLIST *itp) { STRINGLIST *sl; register int i, n; @@ -506,16 +479,14 @@ it_init_disabled (itp) } 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; @@ -524,8 +495,7 @@ it_init_functions (itp) /* 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; @@ -540,8 +510,7 @@ it_init_helptopics (itp) } static int -it_init_hostnames (itp) - ITEMLIST *itp; +it_init_hostnames (ITEMLIST *itp) { STRINGLIST *sl; @@ -555,9 +524,7 @@ it_init_hostnames (itp) } static int -it_init_joblist (itp, jstate) - ITEMLIST *itp; - int jstate; +it_init_joblist (ITEMLIST *itp, int jstate) { #if defined (JOB_CONTROL) STRINGLIST *sl; @@ -597,29 +564,25 @@ it_init_joblist (itp, jstate) } 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; @@ -636,8 +599,7 @@ it_init_keywords (itp) } static int -it_init_signals (itp) - ITEMLIST *itp; +it_init_signals (ITEMLIST *itp) { STRINGLIST *sl; @@ -650,16 +612,14 @@ it_init_signals (itp) } 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; @@ -672,8 +632,7 @@ it_init_setopts (itp) } static int -it_init_shopts (itp) - ITEMLIST *itp; +it_init_shopts (ITEMLIST *itp) { STRINGLIST *sl; @@ -691,9 +650,7 @@ it_init_shopts (itp) 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; @@ -729,9 +686,7 @@ gen_matches_from_itemlist (itp, text) /* 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; @@ -825,9 +780,7 @@ pcomp_filename_completion_function (text, state) /* 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 ... */ @@ -889,9 +842,7 @@ gen_action_completions (cs, text) 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; @@ -909,9 +860,7 @@ gen_globpat_matches (cs, text) /* 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; @@ -956,8 +905,7 @@ gen_wordlist_matches (cs, text) #ifdef ARRAY_VARS static SHELL_VAR * -bind_comp_words (lwords) - WORD_LIST *lwords; +bind_comp_words (WORD_LIST *lwords) { SHELL_VAR *v; @@ -980,11 +928,7 @@ bind_comp_words (lwords) #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; @@ -1033,8 +977,7 @@ bind_compfunc_variables (line, ind, lwords, cw, exported) } static void -unbind_compfunc_variables (exported) - int exported; +unbind_compfunc_variables (int exported) { unbind_variable_noref ("COMP_LINE"); unbind_variable_noref ("COMP_POINT"); @@ -1061,12 +1004,7 @@ unbind_compfunc_variables (exported) 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; @@ -1105,15 +1043,9 @@ build_arg_list (cmd, cname, text, lwords, ind) 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; @@ -1221,14 +1153,9 @@ gen_shell_function_matches (cs, cmd, text, line, ind, lwords, nw, cw, foundp) 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; @@ -1307,18 +1234,12 @@ gen_command_matches (cs, cmd, text, line, ind, lwords, nw, cw) } 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); } @@ -1326,12 +1247,8 @@ command_line_to_word_list (line, llen, sentinel, nwp, cwp) /* 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; @@ -1536,8 +1453,7 @@ gen_compspec_completions (cs, cmd, word, start, end, foundp) } 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. */ @@ -1557,9 +1473,7 @@ pcomp_set_readline_variables (flags, nval) /* 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; @@ -1570,13 +1484,9 @@ pcomp_set_compspec_options (cs, flags, set_or_unset) } 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; @@ -1635,10 +1545,8 @@ gen_progcomp_completions (ocmd, cmd, word, start, end, foundp, retryp, lastcs) 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; diff --git a/pcomplete.h b/pcomplete.h index 945e9381b..1b2b0a0c6 100644 --- a/pcomplete.h +++ b/pcomplete.h @@ -158,7 +158,7 @@ extern void progcomp_dispose (void); 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 *); diff --git a/pcomplib.c b/pcomplib.c index e8df62ece..671c3e387 100644 --- a/pcomplib.c +++ b/pcomplib.c @@ -1,6 +1,6 @@ /* 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. @@ -43,10 +43,10 @@ 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; @@ -69,8 +69,7 @@ compspec_create () } void -compspec_dispose (cs) - COMPSPEC *cs; +compspec_dispose (COMPSPEC *cs) { cs->refcount--; if (cs->refcount == 0) @@ -89,8 +88,7 @@ compspec_dispose (cs) } COMPSPEC * -compspec_copy (cs) - COMPSPEC *cs; +compspec_copy (COMPSPEC *cs) { COMPSPEC *new; @@ -113,21 +111,20 @@ compspec_copy (cs) } 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; @@ -136,14 +133,14 @@ free_progcomp (data) } 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); @@ -151,8 +148,7 @@ progcomp_dispose () } int -progcomp_remove (cmd) - char *cmd; +progcomp_remove (const char *cmd) { register BUCKET_CONTENTS *item; @@ -172,9 +168,7 @@ progcomp_remove (cmd) } int -progcomp_insert (cmd, cs) - char *cmd; - COMPSPEC *cs; +progcomp_insert (char *cmd, COMPSPEC *cs) { register BUCKET_CONTENTS *item; @@ -196,8 +190,7 @@ progcomp_insert (cmd, cs) } COMPSPEC * -progcomp_search (cmd) - const char *cmd; +progcomp_search (const char *cmd) { register BUCKET_CONTENTS *item; COMPSPEC *cs; @@ -216,8 +209,7 @@ progcomp_search (cmd) } void -progcomp_walk (pfunc) - hash_wfunc *pfunc; +progcomp_walk (hash_wfunc *pfunc) { if (prog_completes == 0 || pfunc == 0 || HASH_ENTRIES (prog_completes) == 0) return; diff --git a/print_cmd.c b/print_cmd.c index 2efd935e4..a32ebc116 100644 --- a/print_cmd.c +++ b/print_cmd.c @@ -50,58 +50,52 @@ #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 @@ -142,8 +136,7 @@ static int indirection_stringsiz = 0; /* 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)); @@ -154,8 +147,7 @@ print_command (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; @@ -167,8 +159,7 @@ make_command_string (command) 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; @@ -180,8 +171,7 @@ print_comsub (command) /* 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]; @@ -376,10 +366,7 @@ make_command_string_internal (command) } 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; @@ -388,17 +375,13 @@ _print_word_list (list, separator, pfunc) } 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) { @@ -418,13 +401,13 @@ xtrace_set (fd, fp) } void -xtrace_init () +xtrace_init (void) { xtrace_set (-1, stderr); } void -xtrace_reset () +xtrace_reset (void) { if (xtrace_fd >= 0 && xtrace_fp) { @@ -439,8 +422,7 @@ xtrace_reset () } void -xtrace_fdchk (fd) - int fd; +xtrace_fdchk (int fd) { if (fd == xtrace_fd) xtrace_reset (); @@ -449,7 +431,7 @@ xtrace_fdchk (fd) /* Return a string denoting what our indirection level is. */ char * -indirection_level_string () +indirection_level_string (void) { register int i, j; char *ps4; @@ -517,9 +499,7 @@ indirection_level_string () } 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; @@ -554,9 +534,7 @@ xtrace_print_assignment (name, value, assign_list, xflags) 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; @@ -593,24 +571,20 @@ xtrace_print_word_list (list, xtflags) } 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 ()); @@ -619,8 +593,7 @@ xtrace_print_for_command_head (for_command) } 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 (";"); @@ -637,8 +610,7 @@ print_for_command (for_command) #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, " "); @@ -659,16 +631,14 @@ print_arith_for_command (arith_for_command) #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 ()); @@ -677,8 +647,7 @@ xtrace_print_select_command_head (select_command) } static void -print_select_command (select_command) - SELECT_COM *select_command; +print_select_command (SELECT_COM *select_command) { print_select_command_head (select_command); @@ -694,8 +663,7 @@ print_select_command (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 ("{ "); @@ -732,15 +700,13 @@ print_group_command (group_command) } 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 ()); @@ -748,8 +714,7 @@ xtrace_print_case_command_head (case_command) } static void -print_case_command (case_command) - CASE_COM *case_command; +print_case_command (CASE_COM *case_command) { print_case_command_head (case_command); @@ -759,8 +724,7 @@ print_case_command (case_command) } static void -print_case_clauses (clauses) - PATTERN_LIST *clauses; +print_case_clauses (PATTERN_LIST *clauses) { indentation += indentation_amount; while (clauses) @@ -784,23 +748,19 @@ print_case_clauses (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++; @@ -817,8 +777,7 @@ print_until_or_while (while_command, which) } static void -print_if_command (if_command) - IF_COM *if_command; +print_if_command (IF_COM *if_command) { cprintf ("if "); skip_this_indent++; @@ -845,8 +804,7 @@ print_if_command (if_command) #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, " "); @@ -856,8 +814,7 @@ print_arith_command (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 ("! "); @@ -901,8 +858,7 @@ print_cond_node (cond) } void -print_cond_command (cond) - COND_COM *cond; +print_cond_command (COND_COM *cond) { cprintf ("[[ "); print_cond_node (cond); @@ -911,10 +867,7 @@ print_cond_command (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; @@ -926,8 +879,7 @@ debug_print_word_list (s, list, sep) } void -debug_print_cond_command (cond) - COND_COM *cond; +debug_print_cond_command (COND_COM *cond) { fprintf (stderr, "DEBUG: "); command_string_index = 0; @@ -937,10 +889,7 @@ debug_print_cond_command (cond) #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; @@ -970,8 +919,7 @@ xtrace_print_cond_term (type, invert, op, arg1, arg2) #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; @@ -987,8 +935,7 @@ xtrace_print_arith_cmd (list) #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, " "); @@ -1002,8 +949,7 @@ print_simple_command (simple_command) } static void -print_heredocs (heredocs) - REDIRECT *heredocs; +print_heredocs (REDIRECT *heredocs) { REDIRECT *hdtail; @@ -1017,8 +963,7 @@ print_heredocs (heredocs) } static void -print_heredoc_bodies (heredocs) - REDIRECT *heredocs; +print_heredoc_bodies (REDIRECT *heredocs) { REDIRECT *hdtail; @@ -1039,8 +984,7 @@ print_heredoc_bodies (heredocs) 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])) @@ -1057,8 +1001,7 @@ print_deferred_heredocs (cstring) } static void -print_redirection_list (redirects) - REDIRECT *redirects; +print_redirection_list (REDIRECT *redirects) { REDIRECT *heredocs, *hdtail, *newredir; char *rw; @@ -1120,8 +1063,7 @@ print_redirection_list (redirects) } static void -print_heredoc_header (redirect) - REDIRECT *redirect; +print_heredoc_header (REDIRECT *redirect) { int kill_leading; char *x; @@ -1146,16 +1088,14 @@ print_heredoc_header (redirect) } 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; @@ -1318,7 +1258,7 @@ print_redirection (redirect) } static void -reset_locals () +reset_locals (void) { inside_function_def = 0; indentation = 0; @@ -1328,8 +1268,7 @@ reset_locals () } static void -print_function_def (func) - FUNCTION_DEF *func; +print_function_def (FUNCTION_DEF *func) { COMMAND *cmdcopy; REDIRECT *func_redirects; @@ -1386,10 +1325,7 @@ print_function_def (func) 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; @@ -1404,7 +1340,7 @@ named_function_string (name, command, flags) if (name && *name) { - if (find_reserved_word (name) >= 0) + if (find_reserved_word (name) >= 0) /* check valid identifier too? */ cprintf ("function "); cprintf ("%s ", name); } @@ -1483,8 +1419,7 @@ named_function_string (name, command, flags) } static void -newline (string) - char *string; +newline (char *string) { cprintf ("\n"); indent (indentation); @@ -1496,8 +1431,7 @@ static char *indentation_string; static int indentation_size; static void -indent (amount) - int amount; +indent (int amount) { register int i; @@ -1510,7 +1444,7 @@ indent (amount) } static void -semicolon () +semicolon (void) { if (command_string_index > 0 && (the_printed_command[command_string_index - 1] == '&' || @@ -1521,13 +1455,7 @@ semicolon () /* 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]; @@ -1611,8 +1539,7 @@ cprintf (control, va_alist) /* 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) { @@ -1638,13 +1565,7 @@ the_printed_command_resize (length) 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; diff --git a/redir.c b/redir.c index 8369adccb..38a942813 100644 --- a/redir.c +++ b/redir.c @@ -1,6 +1,6 @@ /* 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. @@ -94,24 +94,24 @@ extern REDIRECT *redirection_undo_list; 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. */ @@ -133,10 +133,7 @@ do { \ } 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; @@ -238,9 +235,7 @@ redirection_error (temp, error, fn) 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; @@ -275,8 +270,7 @@ do_redirections (list, flags) /* 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) { @@ -302,8 +296,7 @@ expandable_redirection_filename (redirect) /* 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; @@ -353,10 +346,7 @@ redirection_expand (word) 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; @@ -410,10 +400,7 @@ heredoc_expand (redirectee, ri, lenp) /* 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; @@ -434,9 +421,7 @@ heredoc_write (fd, heredoc, herelen) 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]; @@ -603,11 +588,7 @@ static STRING_INT_ALIST _redir_special_filenames[] = { }; 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) @@ -665,10 +646,7 @@ redir_special_open (spec, filename, flags, mode, ri) 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; @@ -717,10 +695,7 @@ noclobber_open (filename, flags, mode, ri) } 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; @@ -764,8 +739,7 @@ redir_open (filename, flags, mode, ri) } static int -undoablefd (fd) - int fd; +undoablefd (int fd) { int clexec; @@ -784,10 +758,7 @@ undoablefd (fd) 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; @@ -1283,10 +1254,7 @@ do_redirection_internal (redirect, flags, fnp) 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; @@ -1373,8 +1341,7 @@ add_undo_redirect (fd, ri, fdbase) /* 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; @@ -1390,8 +1357,7 @@ add_undo_close_redirect (fd) } 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; @@ -1400,9 +1366,7 @@ add_exec_redirect (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) { @@ -1436,8 +1400,7 @@ stdin_redirection (ri, redirector) /* 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; @@ -1449,9 +1412,7 @@ stdin_redirects (redirs) } /* 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; @@ -1467,8 +1428,7 @@ redir_varassign (redir, fd) /* Handles {array[ind]} for redirection words */ static int -redir_varvalue (redir) - REDIRECT *redir; +redir_varvalue (REDIRECT *redir) { SHELL_VAR *v; char *val, *w; diff --git a/shell.c b/shell.c index ebd89651e..66194b26b 100644 --- a/shell.c +++ b/shell.c @@ -1,6 +1,6 @@ /* 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. @@ -62,8 +62,8 @@ #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" @@ -310,42 +310,42 @@ static FILE *default_input; 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; @@ -362,14 +362,10 @@ _cygwin32_check_tmp () #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; @@ -835,9 +831,7 @@ main (argc, argv, env) } 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; @@ -890,9 +884,7 @@ parse_long_options (argv, arg_start, arg_end) } 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; @@ -985,8 +977,7 @@ parse_shell_options (argv, arg_start, arg_end) /* Exit the shell with status S. */ void -exit_shell (s) - int s; +exit_shell (int s) { fflush (stdout); /* XXX */ fflush (stderr); @@ -1040,8 +1031,7 @@ exit_shell (s) /* 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) @@ -1056,8 +1046,7 @@ sh_exit (s) 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); @@ -1072,8 +1061,7 @@ subshell_exit (s) } void -set_exit_status (s) - int s; +set_exit_status (int s) { set_pipestatus_from_exit (last_command_exit_value = s); } @@ -1106,8 +1094,7 @@ set_exit_status (s) */ static void -execute_env_file (env_file) - char *env_file; +execute_env_file (char *env_file) { char *fn; @@ -1121,7 +1108,7 @@ execute_env_file (env_file) } static void -run_startup_files () +run_startup_files (void) { #if defined (JOB_CONTROL) int old_job_control; @@ -1264,8 +1251,7 @@ run_startup_files () 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; @@ -1285,8 +1271,7 @@ shell_is_restricted (name) 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; @@ -1313,7 +1298,7 @@ maybe_make_restricted (name) /* 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; @@ -1336,7 +1321,7 @@ uidget () } void -disable_priv_mode () +disable_priv_mode (void) { int e; @@ -1366,8 +1351,7 @@ disable_priv_mode () #if defined (WORDEXP_OPTION) static int -run_wordexp (words) - char *words; +run_wordexp (char *words) { int code, nw, nb; WORD_LIST *wl, *tl, *result; @@ -1443,8 +1427,7 @@ run_wordexp (words) /* 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; @@ -1475,9 +1458,7 @@ run_one_command (command) #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; @@ -1529,14 +1510,14 @@ bind_args (argv, arg_start, arg_end, start_index) } 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; @@ -1561,8 +1542,7 @@ start_debugger () } 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; @@ -1737,7 +1717,7 @@ open_shell_script (script_name) /* 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. */ @@ -1764,8 +1744,7 @@ set_bash_input () 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) || @@ -1790,8 +1769,7 @@ unset_bash_input (check_zero) #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. */ @@ -1826,7 +1804,7 @@ set_shell_name (argv0) 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; @@ -1834,7 +1812,7 @@ set_option_defaults () } static void -reset_option_defaults () +reset_option_defaults (void) { #if defined (HISTORY) enable_history_list = -1; @@ -1842,7 +1820,7 @@ reset_option_defaults () } static void -init_interactive () +init_interactive (void) { expand_aliases = expaliases_flag = 1; interactive_shell = startup_state = interactive = 1; @@ -1857,7 +1835,7 @@ init_interactive () } static void -init_noninteractive () +init_noninteractive (void) { #if defined (HISTORY) if (enable_history_list == -1) /* set default */ @@ -1875,7 +1853,7 @@ init_noninteractive () } static void -init_interactive_script () +init_interactive_script (void) { #if defined (HISTORY) if (enable_history_list == -1) @@ -1889,7 +1867,7 @@ init_interactive_script () } void -get_current_user_info () +get_current_user_info (void) { struct passwd *entry; @@ -1925,7 +1903,7 @@ get_current_user_info () /* 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; @@ -2005,7 +1983,7 @@ shell_initialize () 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; @@ -2057,9 +2035,7 @@ shell_reinitialize () } 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; @@ -2108,9 +2084,7 @@ show_shell_usage (fp, extra) } 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) { @@ -2123,7 +2097,7 @@ add_shopt_to_alist (opt, on_or_off) } static void -run_shopt_alist () +run_shopt_alist (void) { register int i; diff --git a/sig.c b/sig.c index 659545b2e..d2a126715 100644 --- a/sig.c +++ b/sig.c @@ -24,7 +24,7 @@ #if defined (HAVE_UNISTD_H) # ifdef _MINIX -# include +initialize_shell_signals (# include # endif # include #endif @@ -55,11 +55,11 @@ # 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. */ @@ -93,12 +93,11 @@ int terminate_immediately = 0; 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 (); @@ -227,7 +226,7 @@ static int termsigs_initialized = 0; 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) @@ -307,7 +306,7 @@ initialize_terminating_signals () } static void -initialize_shell_signals () +initialize_shell_signals (void) { if (interactive) initialize_terminating_signals (); @@ -339,7 +338,7 @@ initialize_shell_signals () } void -reset_terminating_signals () +reset_terminating_signals (void) { register int i; #if defined (HAVE_POSIX_SIGNALS) @@ -381,7 +380,7 @@ reset_terminating_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) @@ -399,7 +398,7 @@ top_level_cleanup () /* 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; @@ -480,14 +479,13 @@ throw_to_top_level () /* 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); @@ -497,8 +495,7 @@ restore_sigmask () 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. */ @@ -581,8 +578,7 @@ termsig_sighandler (sig) } 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 @@ -636,8 +632,7 @@ termsig_handler (sig) } static void -kill_shell (sig) - int sig; +kill_shell (int sig) { int i, core; sigset_t mask; @@ -683,8 +678,7 @@ kill_shell (sig) /* 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); @@ -733,8 +727,7 @@ sigint_sighandler (sig) #if defined (SIGWINCH) sighandler -sigwinch_sighandler (sig) - int sig; +sigwinch_sighandler (int sig) { #if defined (MUST_REINSTALL_SIGHANDLERS) set_signal_handler (SIGWINCH, sigwinch_sighandler); @@ -745,7 +738,7 @@ sigwinch_sighandler (sig) #endif /* SIGWINCH */ void -set_sigwinch_handler () +set_sigwinch_handler (void) { #if defined (SIGWINCH) old_winch = set_signal_handler (SIGWINCH, sigwinch_sighandler); @@ -753,7 +746,7 @@ set_sigwinch_handler () } void -unset_sigwinch_handler () +unset_sigwinch_handler (void) { #if defined (SIGWINCH) set_signal_handler (SIGWINCH, old_winch); @@ -761,8 +754,7 @@ unset_sigwinch_handler () } sighandler -sigterm_sighandler (sig) - int sig; +sigterm_sighandler (int sig) { sigterm_received = 1; /* XXX - counter? */ SIGRETURN (0); @@ -772,8 +764,7 @@ sigterm_sighandler (sig) #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; @@ -811,9 +802,7 @@ sigprocmask (operation, newset, oldset) #endif SigHandler * -set_signal_handler (sig, handler) - int sig; - SigHandler *handler; +set_signal_handler (int sig, SigHandler *handler) { struct sigaction act, oact; diff --git a/siglist.c b/siglist.c index ec706c90b..4c3bf6f44 100644 --- a/siglist.c +++ b/siglist.c @@ -1,6 +1,6 @@ /* 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. @@ -38,7 +38,7 @@ char *sys_siglist[NSIG]; void -initialize_siglist () +initialize_siglist (void) { register int i; diff --git a/stringlib.c b/stringlib.c index 73304966f..c91fc2c2e 100644 --- a/stringlib.c +++ b/stringlib.c @@ -1,6 +1,6 @@ /* 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. @@ -48,10 +48,7 @@ /* 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; @@ -75,10 +72,7 @@ find_string_in_alist (string, alist, flags) 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; @@ -91,10 +85,7 @@ find_token_in_alist (token, alist, flags) } 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; @@ -124,9 +115,7 @@ find_index_in_alist (string, alist, flags) /* 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; @@ -142,9 +131,7 @@ substring (string, start, end) 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; @@ -183,11 +170,7 @@ strsub (string, pat, rep, global) 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; @@ -248,8 +231,7 @@ strcreplace (string, c, text, flags) /* 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; @@ -269,10 +251,7 @@ strip_leading (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) { @@ -287,9 +266,7 @@ strip_trailing (string, len, newlines_only) /* 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); } diff --git a/subst.c b/subst.c index 59fc90407..c2146f96d 100644 --- a/subst.c +++ b/subst.c @@ -144,7 +144,7 @@ extern int errno; /* 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; @@ -202,7 +202,7 @@ extern PROCESS *last_procsub_child; #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 @@ -233,145 +233,145 @@ static int expand_no_split_dollar_star = 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); /* **************************************************************** */ /* */ @@ -381,8 +381,7 @@ static int do_assignment_statements PARAMS((WORD_LIST *, char *, int)); #if defined (DEBUG) void -dump_word_flags (flags) - int flags; +dump_word_flags (int flags) { int f; @@ -546,9 +545,7 @@ dump_word_flags (flags) #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; @@ -589,8 +586,7 @@ quoted_substring (string, start, end) #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; @@ -617,9 +613,7 @@ quoted_strlen (s) 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; @@ -642,9 +636,7 @@ quoted_strchr (s, c, flags) /* 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; @@ -683,8 +675,7 @@ unquoted_member (character, string) /* 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; @@ -738,10 +729,7 @@ unquoted_substring (substr, string) 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) { @@ -769,11 +757,7 @@ sub_append_string (source, target, indx, size) /* 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; @@ -792,11 +776,7 @@ sub_append_number (number, target, indx, size) 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; @@ -857,9 +837,7 @@ string_extract (string, sindex, charlist, flags) 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; @@ -1020,11 +998,7 @@ add_one_character: /* 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; @@ -1095,10 +1069,7 @@ skip_double_quoted (string, slen, sind, flags) 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; @@ -1138,11 +1109,7 @@ string_extract_single_quoted (string, sindex, allowesc) 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; @@ -1163,12 +1130,7 @@ skip_single_quoted (string, slen, sind, flags) /* 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) @@ -1280,10 +1242,7 @@ string_extract_verbatim (string, slen, sindex, charlist, flags) 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; @@ -1301,9 +1260,7 @@ extract_command_subst (string, sindex, xflags) 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)); /*]*/ } @@ -1313,11 +1270,7 @@ extract_arithmetic_subst (string, sindex) 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? */ @@ -1334,9 +1287,7 @@ extract_process_subst (string, starter, sindex, xflags) 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; @@ -1361,11 +1312,7 @@ extract_array_assignment_list (string, sindex) 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; @@ -1533,9 +1480,7 @@ extract_delimited_string (string, sindex, opener, alt_opener, closer, flags) 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; @@ -1815,9 +1760,7 @@ static int dbstate[PARAMEXPNEST_MAX]; 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; @@ -2001,9 +1944,7 @@ extract_dollar_brace_string (string, sindex, quoted, flags) /* 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; @@ -2036,8 +1977,7 @@ de_backslash (string, qflags) /*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; @@ -2068,9 +2008,7 @@ unquote_bang (string) 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; @@ -2171,9 +2109,7 @@ skip_matched_pair (string, start, open, close, flags) 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)); } @@ -2186,11 +2122,7 @@ skipsubscript (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; @@ -2368,11 +2300,7 @@ skip_to_delim (string, start, delims, flags) 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; @@ -2493,9 +2421,7 @@ skip_to_histexp (string, start, delims, flags) 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; @@ -2561,10 +2487,7 @@ char_is_quoted (string, eindex) } 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; @@ -2616,12 +2539,7 @@ unclosed_pair (string, eindex, openstr) 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; @@ -2784,8 +2702,7 @@ split_at_delims (string, slen, delims, sentinel, flags, nwp, cwp) /* 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; @@ -2807,9 +2724,7 @@ assignment_name (string) /* 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; @@ -2860,8 +2775,7 @@ string_list_internal (list, sep) /* 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, " ")); } @@ -2871,8 +2785,7 @@ string_list (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; @@ -2910,9 +2823,7 @@ ifs_firstchar (lenp) /* 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) @@ -2967,10 +2878,7 @@ string_list_dollar_star (list, quoted, flags) 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) @@ -3043,10 +2951,7 @@ string_list_dollar_at (list, quoted, flags) /* 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; @@ -3140,9 +3045,7 @@ string_list_pos_params (pchar, list, quoted, pflags) : 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; @@ -3169,14 +3072,10 @@ list_string (string, separators, quoted) 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++); @@ -3293,8 +3192,7 @@ list_string (string, separators, quoted) #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; @@ -3392,9 +3290,7 @@ get_word_from_string (stringp, separators, endptr) 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; @@ -3411,8 +3307,7 @@ strip_trailing_ifs_whitespace (string, separators, saw_escape) /* 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; @@ -3469,9 +3364,7 @@ list_string_with_quotes (string) #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; @@ -3555,9 +3448,7 @@ do_compound_assignment (name, value, flags) 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; @@ -3676,8 +3567,7 @@ do_assignment_internal (word, expand) /* 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; @@ -3688,9 +3578,7 @@ do_assignment (string) } 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); } @@ -3699,8 +3587,7 @@ do_word_assignment (word, flags) 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; @@ -3718,7 +3605,7 @@ do_assignment_no_expand (string) /* 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; @@ -3735,8 +3622,7 @@ list_rest_of_args () /* 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; @@ -3757,8 +3643,7 @@ get_dollar_var_value (ind) 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; @@ -3775,9 +3660,7 @@ string_rest_of_args (dollar_star) 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; @@ -3840,10 +3723,7 @@ pos_params (string, start, end, quoted, pflags) 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; @@ -3883,10 +3763,7 @@ expand_string_if_necessary (string, quoted, func) } 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; @@ -3907,25 +3784,19 @@ expand_string_to_string_internal (string, quoted, func) } 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)); } @@ -3935,9 +3806,7 @@ expand_assignment_string_to_string (string, quoted) 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; @@ -3996,9 +3865,7 @@ quote_string_for_repl (string, flags) 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; @@ -4029,9 +3896,7 @@ expand_string_for_patsub (string, quoted) } char * -expand_arith_string (string, quoted) - char *string; - int quoted; +expand_arith_string (char *string, int quoted) { WORD_DESC td; WORD_LIST *list, *tlist; @@ -4096,8 +3961,7 @@ expand_arith_string (string, quoted) #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; @@ -4127,9 +3991,7 @@ remove_backslashes (string) 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; @@ -4185,9 +4047,7 @@ cond_expand_word (w, special) 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; @@ -4329,9 +4189,7 @@ expand_string_dollar_quote (string, flags) 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; @@ -4357,9 +4215,7 @@ call_expand_word_internal (w, q, i, c, e) 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; @@ -4382,9 +4238,7 @@ expand_string_internal (string, quoted) 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; @@ -4409,9 +4263,7 @@ expand_string_unsplit (string, quoted) /* 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; @@ -4455,10 +4307,7 @@ expand_string_assignment (string, quoted) 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; @@ -4497,9 +4346,7 @@ expand_prompt_string (string, quoted, wflags) 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; @@ -4521,10 +4368,7 @@ expand_string_leave_quoted (string, quoted) /* 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; @@ -4569,9 +4413,7 @@ expand_string_for_rhs (string, quoted, op, pflags, dollar_at_p, expanded_p) /* 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; @@ -4597,9 +4439,7 @@ expand_string_for_pat (string, quoted, dollar_at_p, expanded_p) 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; @@ -4621,9 +4461,7 @@ expand_string (string, quoted) 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; @@ -4637,9 +4475,7 @@ expand_word (word, quoted) 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; @@ -4651,9 +4487,7 @@ expand_word_unsplit (word, quoted) 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; @@ -4692,9 +4526,7 @@ expand_word_leave_quoted (word, quoted) 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; @@ -4729,22 +4561,19 @@ quote_escapes_internal (string, flags) } 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; @@ -4770,8 +4599,7 @@ list_quote_escapes (list) 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; @@ -4810,8 +4638,7 @@ dequote_escapes (string) #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; @@ -4830,8 +4657,7 @@ list_dequote_escapes (list) 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; @@ -4854,8 +4680,7 @@ make_quoted_char (c) 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; @@ -4888,8 +4713,7 @@ quote_string (string) /* De-quote quoted characters in STRING. */ char * -dequote_string (string) - char *string; +dequote_string (char *string) { register char *s, *t; size_t slen; @@ -4941,8 +4765,7 @@ dequote_string (string) /* 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; @@ -4960,8 +4783,7 @@ quote_list (list) } WORD_DESC * -dequote_word (word) - WORD_DESC *word; +dequote_word (WORD_DESC *word) { register char *s; @@ -4976,8 +4798,7 @@ dequote_word (word) /* 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; @@ -4996,8 +4817,7 @@ dequote_list (list) /* 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; @@ -5016,8 +4836,7 @@ remove_quoted_escapes (string) 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; @@ -5049,8 +4868,7 @@ remove_quoted_ifs (string) } char * -remove_quoted_nulls (string) - char *string; +remove_quoted_nulls (char *string) { register size_t slen; register int i, j, prev_i; @@ -5098,8 +4916,7 @@ remove_quoted_nulls (string) /* 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; @@ -5119,9 +4936,7 @@ word_list_remove_quoted_nulls (list) #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; @@ -5158,9 +4973,7 @@ mb_getcharlens (string, len) /* 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; @@ -5231,11 +5044,7 @@ remove_upattern (param, pattern, op) #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; @@ -5300,9 +5109,7 @@ remove_wpattern (wparam, wstrlen, wpattern, op) #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; @@ -5372,10 +5179,7 @@ remove_pattern (param, pattern, op) 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; @@ -5530,13 +5334,8 @@ match_upattern (string, pat, mtype, sp, ep) 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; @@ -5675,10 +5474,7 @@ match_wpattern (wstring, indices, wstrlen, wpat, mtype, sp, ep) #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; @@ -5719,9 +5515,7 @@ match_pattern (string, pat, mtype, sp, ep) } static int -getpatspec (c, value) - int c; - char *value; +getpatspec (int c, char *value) { if (c == '#') return ((*value == '#') ? RP_LONG_LEFT : RP_SHORT_LEFT); @@ -5738,9 +5532,7 @@ getpatspec (c, value) 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; @@ -5785,9 +5577,7 @@ getpattern (value, quoted, expandpat) /* 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; @@ -5798,10 +5588,7 @@ variable_remove_pattern (value, pattern, patspec, quoted) #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; @@ -5823,10 +5610,7 @@ list_remove_pattern (list, pattern, patspec, itype, quoted) } 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; @@ -5840,13 +5624,9 @@ parameter_list_remove_pattern (itype, pattern, patspec, quoted) } #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; @@ -5873,11 +5653,9 @@ array_remove_pattern (var, pattern, patspec, starsub, quoted) #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; @@ -5959,14 +5737,14 @@ parameter_brace_remove_pattern (varname, value, estatep, patstr, rtype, quoted, #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 @@ -5989,7 +5767,7 @@ static int nfifo; static int fifo_list_size; void -clear_fifo_list () +clear_fifo_list (void) { int i; @@ -6004,8 +5782,7 @@ clear_fifo_list () } void * -copy_fifo_list (sizep) - int *sizep; +copy_fifo_list (int *sizep) { if (sizep) *sizep = 0; @@ -6013,8 +5790,7 @@ copy_fifo_list (sizep) } static void -add_fifo_list (pathname) - char *pathname; +add_fifo_list (char *pathname) { int osize, i; @@ -6036,8 +5812,7 @@ add_fifo_list (pathname) } 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))) { @@ -6049,7 +5824,7 @@ unlink_fifo (i) } void -unlink_fifo_list () +unlink_fifo_list (void) { int saved, i, j; @@ -6091,7 +5866,7 @@ unlink_fifo_list () } void -unlink_all_fifos () +unlink_all_fifos (void) { int i, fd; @@ -6120,9 +5895,7 @@ unlink_all_fifos () 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; @@ -6142,8 +5915,7 @@ close_new_fifos (list, lsize) } int -find_procsub_child (pid) - pid_t pid; +find_procsub_child (pid_t pid) { int i; @@ -6154,10 +5926,7 @@ find_procsub_child (pid) } 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 */ @@ -6166,8 +5935,7 @@ set_procsub_status (ind, pid, status) /* 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; @@ -6177,7 +5945,7 @@ reap_some_procsubs (max) } void -reap_procsubs () +reap_procsubs (void) { reap_some_procsubs (nfifo); } @@ -6185,7 +5953,7 @@ reap_procsubs () #if 0 /* UNUSED */ void -wait_procsubs () +wait_procsubs (void) { int i, r; @@ -6202,19 +5970,19 @@ wait_procsubs () #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; @@ -6243,8 +6011,7 @@ static int nfds; 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]) { @@ -6254,7 +6021,7 @@ clear_fifo (i) } void -clear_fifo_list () +clear_fifo_list (void) { register int i; @@ -6268,8 +6035,7 @@ clear_fifo_list () } void * -copy_fifo_list (sizep) - int *sizep; +copy_fifo_list (int *sizep) { void *ret; @@ -6287,8 +6053,7 @@ copy_fifo_list (sizep) } static void -add_fifo_list (fd) - int fd; +add_fifo_list (int fd) { if (dev_fd_list == 0 || fd >= totfds) { @@ -6311,20 +6076,19 @@ add_fifo_list (fd) } 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]) { @@ -6335,7 +6099,7 @@ unlink_fifo (fd) } void -unlink_fifo_list () +unlink_fifo_list (void) { register int i; @@ -6349,7 +6113,7 @@ unlink_fifo_list () } void -unlink_all_fifos () +unlink_all_fifos (void) { unlink_fifo_list (); } @@ -6360,9 +6124,7 @@ unlink_all_fifos () 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; @@ -6382,8 +6144,7 @@ close_new_fifos (list, lsize) } int -find_procsub_child (pid) - pid_t pid; +find_procsub_child (pid_t pid) { int i; @@ -6398,10 +6159,7 @@ find_procsub_child (pid) } 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 */ @@ -6410,8 +6168,7 @@ set_procsub_status (ind, pid, status) /* 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; @@ -6421,7 +6178,7 @@ reap_some_procsubs (max) } void -reap_procsubs () +reap_procsubs (void) { reap_some_procsubs (totfds); } @@ -6429,7 +6186,7 @@ reap_procsubs () #if 0 /* UNUSED */ void -wait_procsubs () +wait_procsubs (void) { int i, r; @@ -6446,7 +6203,7 @@ wait_procsubs () #endif #if defined (NOTDEF) -print_dev_fd_list () +print_dev_fd_list (void) { register int i; @@ -6463,8 +6220,7 @@ print_dev_fd_list () #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; @@ -6493,9 +6249,7 @@ make_dev_fd_filename (fd) 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; @@ -6775,9 +6529,7 @@ process_substitute (string, open_for_read_in_child) #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; @@ -6793,9 +6545,7 @@ optimize_cat_file (r, quoted, flags, flagp) } 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; @@ -6928,10 +6678,7 @@ read_comsub (fd, quoted, flags, rflag) /* 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; @@ -7239,8 +6986,7 @@ command_substitute (string, quoted, flags) #if defined (ARRAY_VARS) static arrayind_t -array_length_reference (s) - char *s; +array_length_reference (char *s) { int len; arrayind_t ind; @@ -7320,9 +7066,7 @@ array_length_reference (s) #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; @@ -7339,10 +7083,7 @@ valid_brace_expansion_word (name, var_is_special) } 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; @@ -7405,10 +7146,7 @@ chk_atstar (name, quoted, pflags, quoted_dollar_atp, contains_dollar_at) 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; @@ -7591,9 +7329,7 @@ expand_arrayref: } 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; @@ -7637,10 +7373,7 @@ parameter_brace_find_indir (name, var_is_special, quoted, find_nameref) /* 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; @@ -7721,9 +7454,9 @@ parameter_brace_expand_indir (name, var_is_special, quoted, pflags, quoted_dolla "-", "+", 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; @@ -7951,9 +7684,7 @@ parameter_brace_expand_rhs (name, value, op, quoted, pflags, qdollaratp, hasdoll 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; @@ -7981,8 +7712,7 @@ parameter_brace_expand_error (name, value, check_null) /* 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 */ @@ -7996,8 +7726,7 @@ valid_length_expression (name) /* 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; @@ -8116,9 +7845,7 @@ parameter_brace_expand_length (name) */ static char * -skiparith (substr, delim) - char *substr; - int delim; +skiparith (char *substr, int delim) { int i; char delims[2]; @@ -8137,11 +7864,8 @@ skiparith (substr, delim) 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; @@ -8274,12 +7998,8 @@ verify_substring_values (v, value, substr, vtype, e1p, e2p) 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; @@ -8394,9 +8114,7 @@ get_var_and_type (varname, value, estatep, quoted, flags, varp, valp) /***********************************************************/ 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; @@ -8419,9 +8137,7 @@ string_var_assignment (v, s) #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; @@ -8466,10 +8182,7 @@ array_var_assignment (v, itype, quoted, atype) #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; @@ -8483,10 +8196,7 @@ pos_params_assignment (list, itype, quoted) } 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; @@ -8539,11 +8249,7 @@ string_transform (xc, v, s) } 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; @@ -8572,10 +8278,7 @@ list_transform (xc, v, list, itype, quoted) } 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; @@ -8592,12 +8295,9 @@ parameter_list_transform (xc, itype, quoted) } #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; @@ -8655,9 +8355,8 @@ array_transform (xc, var, starsub, quoted) } #endif /* ARRAY_VARS */ -static int -valid_parameter_transform (xform) - char *xform; +static inline int +valid_parameter_transform (char *xform) { if (xform[1]) return 0; @@ -8682,11 +8381,8 @@ valid_parameter_transform (xform) } 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; @@ -8784,9 +8480,7 @@ parameter_brace_transform (varname, value, estatep, xform, rtype, quoted, pflags 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; @@ -8814,11 +8508,8 @@ mb_substring (string, s, e) 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; @@ -8919,8 +8610,7 @@ parameter_brace_substring (varname, value, estatep, substr, quoted, pflags, flag /****************************************************************/ static int -shouldexp_replacement (s) - char *s; +shouldexp_replacement (char *s) { size_t slen; int sindex, c; @@ -8952,9 +8642,7 @@ shouldexp_replacement (s) } 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; @@ -9092,9 +8780,7 @@ pat_subst (string, pat, rep, mflags) /* 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; @@ -9134,11 +8820,8 @@ pos_params_pat_subst (string, pat, rep, mflags) 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; @@ -9335,10 +9018,7 @@ parameter_brace_patsub (varname, value, estatep, patsub, quoted, pflags, flags) /* 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; @@ -9378,12 +9058,8 @@ pos_params_modcase (string, pat, modop, mflags) 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; @@ -9509,9 +9185,7 @@ parameter_brace_casemod (varname, value, estatep, modspec, patspec, quoted, pfla 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; @@ -9561,9 +9235,7 @@ chk_arithsub (s, len) /* ${[#][!]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; @@ -10249,12 +9921,9 @@ bad_substitution: 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; @@ -10817,9 +10486,7 @@ static char abstab[256] = { '\1' }; /* 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; @@ -10859,10 +10526,7 @@ expand_subscript_string (string, quoted) 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; @@ -10922,7 +10586,7 @@ expand_array_subscript (string, sindex, quoted, flags) #endif void -invalidate_cached_quoted_dollar_at () +invalidate_cached_quoted_dollar_at (void) { dispose_words (cached_quoted_dollar_at); cached_quoted_dollar_at = 0; @@ -10955,11 +10619,7 @@ invalidate_cached_quoted_dollar_at () #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; @@ -11915,9 +11575,7 @@ set_word_flags: /* 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; @@ -11983,9 +11641,7 @@ string_quote_removal (string, quoted) /* 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; @@ -12000,18 +11656,13 @@ word_quote_removal (word, quoted) 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 @@ -12020,7 +11671,6 @@ word_list_quote_removal (list, quoted) while (e->next) e = e->next; } -#endif } return (result); } @@ -12033,8 +11683,7 @@ word_list_quote_removal (list, quoted) *******************************************/ void -setifs (v) - SHELL_VAR *v; +setifs (SHELL_VAR *v) { char *t; unsigned char uc; @@ -12086,7 +11735,7 @@ setifs (v) } char * -getifs () +getifs (void) { return ifs_value; } @@ -12095,9 +11744,7 @@ getifs () 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; @@ -12117,8 +11764,7 @@ word_split (w, ifs_chars) /* 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; @@ -12165,8 +11811,7 @@ word_list_split (list) /* 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); @@ -12193,8 +11838,7 @@ exp_jump_to_top_level (v) 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; @@ -12305,8 +11949,7 @@ separate_out_assignments (tlist) variable assignments. */ WORD_LIST * -expand_words (list) - WORD_LIST *list; +expand_words (WORD_LIST *list) { return (expand_word_list_internal (list, WEXP_ALL)); } @@ -12314,23 +11957,19 @@ expand_words (list) /* 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; @@ -12437,9 +12076,7 @@ glob_expand_word_list (tlist, eflags) #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; @@ -12517,10 +12154,7 @@ brace_expand_word_list (tlist, eflags) 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; @@ -12562,9 +12196,7 @@ make_internal_declare (word, option, cmd) ['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; @@ -12617,9 +12249,7 @@ expand_oneword (value, flags) 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; @@ -12677,8 +12307,7 @@ expand_compound_assignment_word (tlist, flags) 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; @@ -12815,9 +12444,7 @@ expand_declaration_argument (tlist, wcmd) #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; @@ -12898,10 +12525,7 @@ shell_expand_word_list (tlist, eflags) 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; @@ -12989,9 +12613,7 @@ do_assignment_statements (varlist, command, is_nullcmd) 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; diff --git a/test.c b/test.c index fadc33d2a..5098e325c 100644 --- a/test.c +++ b/test.c @@ -2,7 +2,7 @@ /* 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. @@ -103,35 +103,34 @@ static int test_error_return; #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); @@ -142,7 +141,7 @@ test_syntax_error (format, arg) * error condition) */ static void -beyond () +beyond (void) { test_syntax_error (_("argument expected"), (char *)NULL); } @@ -150,8 +149,7 @@ beyond () /* 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); } @@ -167,7 +165,7 @@ integer_expected_error (pch) * or */ static int -expr () +expr (void) { if (pos >= argc) beyond (); @@ -181,7 +179,7 @@ expr () * and '-o' or */ static int -or () +or (void) { int value, v2; @@ -202,7 +200,7 @@ or () * term '-a' and */ static int -and () +and (void) { int value, v2; @@ -236,7 +234,7 @@ and () * positive and negative integers */ static int -term () +term (void) { int value; @@ -288,10 +286,7 @@ term () } 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; @@ -303,9 +298,7 @@ stat_mtime (fn, st, ts) } 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; @@ -332,9 +325,7 @@ filecomp (s, t, op) } 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; @@ -373,9 +364,7 @@ arithcomp (s, t, op, flags) } static int -patcomp (string, pat, op) - char *string, *pat; - int op; +patcomp (char *string, char *pat, int op) { int m; @@ -384,9 +373,7 @@ patcomp (string, pat, op) } 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; @@ -438,9 +425,8 @@ binary_test (op, arg1, arg2, flags) return (FALSE); /* should never get here */ } - static int -binary_operator () +binary_operator (void) { int value; char *w; @@ -481,7 +467,7 @@ binary_operator () } static int -unary_operator () +unary_operator (void) { char *op; intmax_t r; @@ -517,9 +503,7 @@ unary_operator () } 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; @@ -688,8 +672,7 @@ unary_test (op, arg, flags) /* 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); /* '=' */ @@ -742,8 +725,7 @@ test_binop (op) /* 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); @@ -763,7 +745,7 @@ test_unop (op) } static int -two_arguments () +two_arguments (void) { if (argv[pos][0] == '!' && argv[pos][1] == '\0') return (argv[pos + 1][0] == '\0'); @@ -787,7 +769,7 @@ two_arguments () #define ONE_ARG_TEST(s) ((s)[0] != '\0') static int -three_arguments () +three_arguments (void) { int value; @@ -823,7 +805,7 @@ three_arguments () /* This is an implementation of a Posix.2 proposal by David Korn. */ static int -posixtest () +posixtest (void) { int value; @@ -877,9 +859,7 @@ posixtest () * test expr */ int -test_command (margc, margv) - int margc; - char **margv; +test_command (int margc, char **margv) { int value; int code; diff --git a/trap.c b/trap.c index a642052f7..3dc476353 100644 --- a/trap.c +++ b/trap.c @@ -150,7 +150,7 @@ int suppress_debug_trap_verbose = 0; GETORIGSIG(sig) void -initialize_traps () +initialize_traps (void) { register int i; @@ -198,8 +198,7 @@ initialize_traps () #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"; @@ -216,8 +215,7 @@ trap_handler_string (sig) /* Return the print name of this signal. */ char * -signal_name (sig) - int sig; +signal_name (int sig) { char *ret; @@ -234,9 +232,7 @@ signal_name (sig) 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; @@ -300,7 +296,7 @@ decode_signal (string, flags) static int catch_flag; void -run_pending_traps () +run_pending_traps (void) { register int sig; int x; @@ -501,8 +497,7 @@ run_pending_traps () /* 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]++; @@ -510,8 +505,7 @@ set_trap_state (sig) } sighandler -trap_handler (sig) - int sig; +trap_handler (int sig) { int oerrno; @@ -585,8 +579,7 @@ trap_handler (sig) } int -next_pending_trap (start) - int start; +next_pending_trap (int start) { register int i; @@ -597,7 +590,7 @@ next_pending_trap (start) } int -first_pending_trap () +first_pending_trap (void) { return (next_pending_trap (1)); } @@ -605,7 +598,7 @@ first_pending_trap () /* 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; @@ -616,7 +609,7 @@ any_signals_trapped () } void -clear_pending_traps () +clear_pending_traps (void) { register int i; @@ -625,7 +618,7 @@ clear_pending_traps () } void -check_signals () +check_signals (void) { /* Add any other shell timeouts here */ check_read_timeout (); /* set by the read builtin */ @@ -634,7 +627,7 @@ check_signals () /* Convenience functions the rest of the shell can use */ void -check_signals_and_traps () +check_signals_and_traps (void) { check_signals (); @@ -646,8 +639,7 @@ check_signals_and_traps () #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); } @@ -659,8 +651,7 @@ set_sigchld_trap (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); @@ -670,7 +661,7 @@ maybe_set_sigchld_trap (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); @@ -681,8 +672,7 @@ set_impossible_sigchld_trap () 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) { @@ -695,17 +685,14 @@ queue_sigchld_trap (nchild) /* 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); } @@ -717,44 +704,38 @@ set_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); } @@ -764,7 +745,7 @@ set_sigint_trap (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); @@ -776,7 +757,8 @@ set_sigint_handler () 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 @@ -786,8 +768,7 @@ set_sigint_handler () /* 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); @@ -799,9 +780,7 @@ trap_to_sighandler (sig) /* 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; @@ -845,8 +824,7 @@ set_signal (sig, string) } 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) && @@ -858,9 +836,7 @@ free_trap_command (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); @@ -876,8 +852,7 @@ change_signal (sig, value) } 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) @@ -885,7 +860,7 @@ get_original_signal (sig) } void -get_all_original_signals () +get_all_original_signals (void) { register int i; @@ -894,9 +869,7 @@ get_all_original_signals () } 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); @@ -907,8 +880,7 @@ set_original_signal (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)) { @@ -950,8 +922,7 @@ restore_default_signal (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)) { @@ -982,7 +953,7 @@ ignore_signal (sig) 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; @@ -1045,8 +1016,7 @@ run_exit_trap () } 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); @@ -1057,9 +1027,7 @@ run_trap_cleanup (sig) /* 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; @@ -1198,7 +1166,7 @@ _run_trap_internal (sig, tag) } int -run_debug_trap () +run_debug_trap (void) { int trap_exit_value, old_verbose; pid_t save_pgrp; @@ -1254,14 +1222,14 @@ run_debug_trap () } 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; @@ -1280,9 +1248,9 @@ run_return_trap () /* 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); @@ -1299,7 +1267,7 @@ run_interrupt_trap (will_throw) 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; @@ -1322,8 +1290,7 @@ free_trap_strings () /* 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? */ @@ -1332,8 +1299,7 @@ free_trap_string (sig) /* 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? */ @@ -1342,8 +1308,7 @@ reset_signal (sig) /* 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); @@ -1351,8 +1316,7 @@ restore_signal (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; @@ -1399,7 +1363,7 @@ reset_or_restore_signal_handlers (reset) 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); } @@ -1408,7 +1372,7 @@ reset_signal_handlers () 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); } @@ -1416,8 +1380,7 @@ restore_original_signals () /* 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) @@ -1432,7 +1395,7 @@ reinit_trap (sig) leaves the trap strings in place. This understands how reset_signal_handlers works. */ void -restore_traps () +restore_traps (void) { char *trapstr; int i; @@ -1487,8 +1450,7 @@ restore_traps () /* 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)) @@ -1518,67 +1480,57 @@ maybe_call_trap_handler (sig) } 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; @@ -1590,8 +1542,7 @@ block_trapped_signals (maskp, omaskp) } int -unblock_trapped_signals (maskp) - sigset_t *maskp; +unblock_trapped_signals (sigset_t *maskp) { return (sigprocmask (SIG_SETMASK, maskp, 0)); } diff --git a/unwind_prot.c b/unwind_prot.c index ec82393d5..aa523d693 100644 --- a/unwind_prot.c +++ b/unwind_prot.c @@ -3,7 +3,7 @@ /* 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. @@ -77,15 +77,15 @@ typedef union uwp { } 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; @@ -103,7 +103,7 @@ sh_obj_cache_t uwcache = {0, 0, 0}; #endif void -uwp_init () +uwp_init (void) { ocache_create (uwcache, UNWIND_ELT, UWCACHESIZE); } @@ -111,25 +111,21 @@ uwp_init () /* 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); @@ -137,8 +133,7 @@ discard_unwind_frame (tag) /* 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); @@ -146,16 +141,14 @@ run_unwind_frame (tag) /* 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 @@ -164,7 +157,7 @@ remove_unwind_protect () /* Run the list of cleanup functions in unwind_protect_list. */ void -run_unwind_protects () +run_unwind_protects (void) { if (unwind_protect_list) without_interrupts @@ -173,8 +166,7 @@ run_unwind_protects () /* 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; @@ -187,14 +179,13 @@ clear_unwind_protect_list (flags) } 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; @@ -215,9 +206,7 @@ unwind_protect_tag_on_stack (tag) /* **************************************************************** */ static void -add_unwind_protect_internal (cleanup, arg) - Function *cleanup; - char *arg; +add_unwind_protect_internal (Function *cleanup, char *arg) { UNWIND_ELT *elt; @@ -229,8 +218,7 @@ add_unwind_protect_internal (cleanup, arg) } static void -remove_unwind_protect_internal (ignore1, ignore2) - char *ignore1, *ignore2; +remove_unwind_protect_internal (char *ignore1, char *ignore2) { UNWIND_ELT *elt; @@ -243,15 +231,13 @@ remove_unwind_protect_internal (ignore1, ignore2) } 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) { @@ -262,8 +248,7 @@ clear_unwind_protects_internal (flag, ignore) } static void -unwind_frame_discard_internal (tag, ignore) - char *tag, *ignore; +unwind_frame_discard_internal (char *tag, char *ignore) { UNWIND_ELT *elt; int found; @@ -290,15 +275,13 @@ unwind_frame_discard_internal (tag, ignore) 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; @@ -333,9 +316,7 @@ unwind_frame_run_internal (tag, ignore) } 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; @@ -357,9 +338,7 @@ unwind_protect_mem_internal (var, psize) 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); } @@ -368,7 +347,7 @@ unwind_protect_mem (var, size) #include void -print_unwind_protect_tags () +print_unwind_protect_tags (void) { UNWIND_ELT *elt; diff --git a/variables.c b/variables.c index 4db3d86c7..04dbaedb1 100644 --- a/variables.c +++ b/variables.c @@ -188,157 +188,157 @@ static HASH_TABLE *last_table_searched; /* hash_lookup sets this */ 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) { @@ -360,9 +360,7 @@ create_variable_tables () 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; @@ -718,7 +716,7 @@ initialize_shell_variables (env, privmode) /* **************************************************************** */ static void -set_machine_vars () +set_machine_vars (void) { SHELL_VAR *temp_var; @@ -735,7 +733,7 @@ set_machine_vars () /* 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 (); @@ -743,7 +741,7 @@ sh_get_home_dir () } static void -set_home_var () +set_home_var (void) { SHELL_VAR *temp_var; @@ -758,7 +756,7 @@ set_home_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; @@ -775,7 +773,7 @@ set_shell_var () } static char * -get_bash_name () +get_bash_name (void) { char *name; @@ -848,8 +846,7 @@ get_bash_name () } void -adjust_shell_level (change) - int change; +adjust_shell_level (int change) { char new_level[5], *old_SHLVL; intmax_t old_level; @@ -894,7 +891,7 @@ adjust_shell_level (change) } static void -initialize_shell_level () +initialize_shell_level (void) { adjust_shell_level (1); } @@ -907,7 +904,7 @@ initialize_shell_level () 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; @@ -970,7 +967,7 @@ set_pwd () /* 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; @@ -984,7 +981,7 @@ set_ppid () } static void -uidset () +uidset (void) { char buff[INT_STRLEN_BOUND(uid_t) + 1], *b; register SHELL_VAR *v; @@ -1010,7 +1007,7 @@ uidset () #if defined (ARRAY_VARS) static void -make_vers_array () +make_vers_array (void) { SHELL_VAR *vv; ARRAY *av; @@ -1040,8 +1037,7 @@ make_vers_array () /* 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; @@ -1067,8 +1063,7 @@ sh_set_lines_and_columns (lines, cols) /* 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; @@ -1081,8 +1076,7 @@ print_var_list (list) /* 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; @@ -1099,8 +1093,7 @@ print_func_list (list) 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; @@ -1130,9 +1123,7 @@ print_assignment (var) 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; @@ -1158,8 +1149,7 @@ print_var_value (var, quote) /* 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; @@ -1237,22 +1227,14 @@ print_var_function (var) 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); } @@ -1261,8 +1243,7 @@ null_array_assign (self, value, ind, key) /* 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); } @@ -1271,11 +1252,7 @@ get_self (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; @@ -1289,11 +1266,7 @@ init_dynamic_array_var (name, getfunc, setfunc, attrs) } 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; @@ -1346,11 +1319,7 @@ set_string_value (SHELL_VAR *var, const char *value, int flags) 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; @@ -1366,8 +1335,7 @@ assign_seconds (self, value, unused, key) } static SHELL_VAR * -get_seconds (var) - SHELL_VAR *var; +get_seconds (SHELL_VAR *var) { time_t time_since_start; struct timeval tv; @@ -1378,7 +1346,7 @@ get_seconds (var) } static SHELL_VAR * -init_seconds_var () +init_seconds_var (void) { SHELL_VAR *v; @@ -1398,11 +1366,7 @@ int last_random_value; 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; @@ -1420,7 +1384,7 @@ assign_random (self, value, unused, key) } int -get_random_number () +get_random_number (void) { int rv, pid; @@ -1440,8 +1404,7 @@ get_random_number () } static SHELL_VAR * -get_random (var) - SHELL_VAR *var; +get_random (SHELL_VAR *var) { int rv; @@ -1450,8 +1413,7 @@ get_random (var) } static SHELL_VAR * -get_urandom (var) - SHELL_VAR *var; +get_urandom (SHELL_VAR *var) { u_bits32_t rv; @@ -1460,11 +1422,7 @@ get_urandom (var) } 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; @@ -1476,8 +1434,7 @@ assign_lineno (var, value, unused, key) /* Function which returns the current line number. */ static SHELL_VAR * -get_lineno (var) - SHELL_VAR *var; +get_lineno (SHELL_VAR *var) { int ln; @@ -1486,11 +1443,7 @@ get_lineno (var) } 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; @@ -1501,15 +1454,13 @@ assign_subshell (var, value, unused, key) } 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; @@ -1518,8 +1469,7 @@ get_epochseconds (var) } static SHELL_VAR * -get_epochrealtime (var) - SHELL_VAR *var; +get_epochrealtime (SHELL_VAR *var) { char buf[32]; struct timeval tv; @@ -1533,8 +1483,7 @@ get_epochrealtime (var) } static SHELL_VAR * -get_bashpid (var) - SHELL_VAR *var; +get_bashpid (SHELL_VAR *var) { int pid; @@ -1543,8 +1492,7 @@ get_bashpid (var) } 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)); } @@ -1552,11 +1500,7 @@ get_bash_argv0 (var) 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; @@ -1576,7 +1520,7 @@ assign_bash_argv0 (var, value, unused, key) } static void -set_argv0 () +set_argv0 (void) { SHELL_VAR *v; @@ -1586,8 +1530,7 @@ set_argv0 () } static SHELL_VAR * -get_bash_command (var) - SHELL_VAR *var; +get_bash_command (SHELL_VAR *var) { char *p; @@ -1597,8 +1540,7 @@ get_bash_command (var) #if defined (HISTORY) static SHELL_VAR * -get_histcmd (var) - SHELL_VAR *var; +get_histcmd (SHELL_VAR *var) { int n; @@ -1617,8 +1559,7 @@ get_histcmd (var) #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) @@ -1630,11 +1571,7 @@ get_comp_wordbreaks (var) /* 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) @@ -1647,19 +1584,14 @@ assign_comp_wordbreaks (self, value, unused, key) #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; @@ -1677,8 +1609,7 @@ get_dirstack (self) /* 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; @@ -1697,8 +1628,7 @@ get_groupset (self) # if defined (DEBUGGER) static SHELL_VAR * -get_bashargcv (self) - SHELL_VAR *self; +get_bashargcv (SHELL_VAR *self) { static int self_semaphore = 0; @@ -1717,8 +1647,7 @@ get_bashargcv (self) # endif static SHELL_VAR * -build_hashcmd (self) - SHELL_VAR *self; +build_hashcmd (SHELL_VAR *self) { HASH_TABLE *h; int i; @@ -1751,19 +1680,14 @@ build_hashcmd (self) } 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; @@ -1793,8 +1717,7 @@ assign_hashcmd (self, value, ind, key) #if defined (ALIAS) static SHELL_VAR * -build_aliasvar (self) - SHELL_VAR *self; +build_aliasvar (SHELL_VAR *self) { HASH_TABLE *h; int i; @@ -1827,19 +1750,14 @@ build_aliasvar (self) } 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) { @@ -1856,8 +1774,7 @@ assign_aliasvar (self, value, ind, key) /* 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) @@ -1867,8 +1784,7 @@ get_funcname (self) } void -make_funcname_visible (on_or_off) - int on_or_off; +make_funcname_visible (int on_or_off) { SHELL_VAR *v; @@ -1883,7 +1799,7 @@ make_funcname_visible (on_or_off) } static SHELL_VAR * -init_funcname_var () +init_funcname_var (void) { SHELL_VAR *v; @@ -1900,7 +1816,7 @@ init_funcname_var () } static void -initialize_dynamic_variables () +initialize_dynamic_variables (void) { SHELL_VAR *v; @@ -1966,15 +1882,13 @@ initialize_dynamic_variables () #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); } @@ -1985,9 +1899,7 @@ var_isunset (var) 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; @@ -2000,9 +1912,7 @@ hash_lookup (name, hashed_vars) } 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; @@ -2023,9 +1933,7 @@ var_lookup (name, vcontext) */ 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; @@ -2073,8 +1981,7 @@ find_variable_internal (name, flags) /* 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; @@ -2114,9 +2021,7 @@ find_variable_nameref (v) /* 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; @@ -2144,9 +2049,7 @@ find_variable_last_nameref (name, vflags) /* 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; @@ -2170,9 +2073,7 @@ find_global_variable_last_nameref (name, vflags) } 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; @@ -2202,10 +2103,7 @@ find_nameref_at_context (v, vc) 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; @@ -2233,10 +2131,7 @@ find_variable_nameref_context (v, vc, nvcp) 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; @@ -2257,9 +2152,7 @@ find_variable_last_nameref_context (v, vc, nvcp) } 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; @@ -2288,9 +2181,7 @@ find_variable_nameref_for_create (name, flags) } 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; @@ -2324,9 +2215,7 @@ find_variable_nameref_for_assignment (name, flags) 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; @@ -2350,8 +2239,7 @@ nameref_transform_name (name, flags) /* 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; @@ -2370,8 +2258,7 @@ find_variable_tempenv (name) /* 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; @@ -2389,8 +2276,7 @@ find_variable_notempenv (name) } SHELL_VAR * -find_global_variable (name) - const char *name; +find_global_variable (const char *name) { SHELL_VAR *var; @@ -2412,8 +2298,7 @@ find_global_variable (name) } SHELL_VAR * -find_global_variable_noref (name) - const char *name; +find_global_variable_noref (const char *name) { SHELL_VAR *var; @@ -2426,8 +2311,7 @@ find_global_variable_noref (name) } SHELL_VAR * -find_shell_variable (name) - const char *name; +find_shell_variable (const char *name) { SHELL_VAR *var; @@ -2450,8 +2334,7 @@ find_shell_variable (name) /* 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; @@ -2478,8 +2361,7 @@ find_variable (name) 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; @@ -2505,8 +2387,7 @@ find_variable_no_invisible (name) /* 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; @@ -2530,8 +2411,7 @@ find_variable_for_assignment (name) } SHELL_VAR * -find_variable_noref (name) - const char *name; +find_variable_noref (const char *name) { SHELL_VAR *v; int flags; @@ -2546,8 +2426,7 @@ find_variable_noref (name) /* 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)); } @@ -2555,8 +2434,7 @@ find_function (name) /* 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)); @@ -2589,19 +2467,17 @@ get_variable_value (var) 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); } @@ -2612,10 +2488,8 @@ sh_get_env_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; @@ -2634,9 +2508,7 @@ var_sametype (v1, v2) } 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)) @@ -2650,8 +2522,7 @@ validate_inherited_value (var, type) /* 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; @@ -2666,9 +2537,7 @@ set_if_not (name, value) /* 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; @@ -2822,8 +2691,7 @@ set_local_var_flags: /* 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; @@ -2849,9 +2717,7 @@ new_shell_variable (name) /* 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; @@ -2870,8 +2736,7 @@ make_new_variable (name, table) #if defined (ARRAY_VARS) SHELL_VAR * -make_new_array_variable (name) - char *name; +make_new_array_variable (char *name) { SHELL_VAR *entry; ARRAY *array; @@ -2885,9 +2750,7 @@ make_new_array_variable (name) } 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; @@ -2926,8 +2789,7 @@ make_local_array_variable (name, flags) } SHELL_VAR * -make_new_assoc_variable (name) - char *name; +make_new_assoc_variable (char *name) { SHELL_VAR *entry; HASH_TABLE *hash; @@ -2941,9 +2803,7 @@ make_new_assoc_variable (name) } 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; @@ -2983,10 +2843,7 @@ make_local_assoc_variable (name, flags) #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; @@ -3092,10 +2949,7 @@ make_value: /* 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; @@ -3112,10 +2966,7 @@ can_optimize_assignment (entry, value, aflags) /* 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; @@ -3140,11 +2991,7 @@ optimized_assignment (entry, value, aflags) 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; @@ -3315,10 +3162,7 @@ assign_value: 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; @@ -3389,10 +3233,7 @@ bind_variable (name, value, flags) } 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 (); @@ -3402,14 +3243,11 @@ bind_global_variable (name, value, flags) } 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 @@ -3418,10 +3256,7 @@ bind_invalid_envvar (name, value, flags) 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; @@ -3487,9 +3322,7 @@ bind_variable_value (var, value, aflags) 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; @@ -3553,10 +3386,7 @@ bind_int_variable (lhs, rhs, flags) } 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; @@ -3567,9 +3397,7 @@ bind_var_to_int (var, val, flags) /* 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; @@ -3616,10 +3444,7 @@ bind_function (name, value) 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; @@ -3651,9 +3476,7 @@ bind_function_def (name, value, flags) 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; @@ -3779,8 +3602,7 @@ assign_in_env (word, flags) #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; @@ -3825,8 +3647,7 @@ copy_variable (var) /* 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)); @@ -3843,8 +3664,7 @@ dispose_variable_value (var) } void -dispose_variable (var) - SHELL_VAR *var; +dispose_variable (SHELL_VAR *var) { if (var == 0) return; @@ -3865,8 +3685,7 @@ dispose_variable (var) /* 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; @@ -3885,8 +3704,7 @@ unbind_variable (name) /* 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; @@ -3898,8 +3716,7 @@ unbind_nameref (name) /* 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; @@ -3910,8 +3727,7 @@ unbind_variable_noref (name) } int -unbind_global_variable (name) - const char *name; +unbind_global_variable (const char *name) { SHELL_VAR *v, *nv; int r; @@ -3931,8 +3747,7 @@ unbind_global_variable (name) } int -unbind_global_variable_noref (name) - const char *name; +unbind_global_variable_noref (const char *name) { SHELL_VAR *v; @@ -3943,8 +3758,7 @@ unbind_global_variable_noref (name) } int -check_unbind_variable (name) - const char *name; +check_unbind_variable (const char *name) { SHELL_VAR *v; @@ -3964,8 +3778,7 @@ check_unbind_variable (name) /* Unset the shell function named NAME. */ int -unbind_func (name) - const char *name; +unbind_func (const char *name) { BUCKET_CONTENTS *elt; SHELL_VAR *func; @@ -3995,8 +3808,7 @@ unbind_func (name) #if defined (DEBUGGER) int -unbind_function_def (name) - const char *name; +unbind_function_def (const char *name) { BUCKET_CONTENTS *elt; FUNCTION_DEF *funcdef; @@ -4018,9 +3830,7 @@ unbind_function_def (name) #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; @@ -4046,9 +3856,7 @@ delete_var (name, vc) 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; @@ -4123,7 +3931,7 @@ makunbound (name, vc) /* Get rid of all of the variables in the current context. */ void -kill_all_local_variables () +kill_all_local_variables (void) { VAR_CONTEXT *vc; @@ -4142,8 +3950,7 @@ kill_all_local_variables () } static void -free_variable_hash_data (data) - PTR_T data; +free_variable_hash_data (PTR_T data) { SHELL_VAR *var; @@ -4153,8 +3960,7 @@ free_variable_hash_data (data) /* 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); } @@ -4180,8 +3986,7 @@ delete_all_variables (hashed_vars) /* 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; @@ -4193,8 +3998,7 @@ set_var_read_only (name) /* 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; @@ -4206,8 +4010,7 @@ set_func_read_only (name) /* 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; @@ -4217,8 +4020,7 @@ set_var_auto_export (name) /* 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; @@ -4235,8 +4037,7 @@ set_func_auto_export (name) /* **************************************************************** */ static VARLIST * -vlist_alloc (nentries) - int nentries; +vlist_alloc (int nentries) { VARLIST *vlist; @@ -4250,9 +4051,7 @@ vlist_alloc (nentries) } static VARLIST * -vlist_realloc (vlist, n) - VARLIST *vlist; - int n; +vlist_realloc (VARLIST *vlist, int n) { if (vlist == 0) return (vlist = vlist_alloc (n)); @@ -4265,10 +4064,7 @@ vlist_realloc (vlist, 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; @@ -4289,9 +4085,7 @@ vlist_add (vlist, var, flags) 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; @@ -4315,8 +4109,7 @@ map_over (function, vc) } 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; @@ -4340,11 +4133,7 @@ map_over_funcs (function) 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; @@ -4368,15 +4157,13 @@ flatten (var_hash_table, func, vlist, flags) } 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; @@ -4389,8 +4176,7 @@ qsort_var_comp (var1, var2) /* 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; @@ -4403,8 +4189,7 @@ vapply (func) /* 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; @@ -4416,33 +4201,32 @@ fapply (func) /* 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)); } @@ -4450,8 +4234,7 @@ all_visible_variables () /* 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)); } @@ -4460,8 +4243,7 @@ visible_and_exported (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))); } @@ -4469,41 +4251,37 @@ export_environment_candidate (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; @@ -4539,22 +4317,20 @@ all_local_variables (visible_only) #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; @@ -4586,9 +4362,7 @@ all_variables_matching_prefix (prefix) /* 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; @@ -4607,8 +4381,7 @@ bind_tempenv_variable (name, value) /* 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); } @@ -4621,8 +4394,7 @@ int tvlist_ind; 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; @@ -4676,8 +4448,7 @@ push_posix_temp_var (data) 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; @@ -4723,8 +4494,7 @@ push_temp_var (data) 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; @@ -4747,8 +4517,7 @@ propagate_temp_var (data) 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; @@ -4775,7 +4544,7 @@ dispose_temporary_env (pushf) } void -dispose_used_env_vars () +dispose_used_env_vars (void) { if (temporary_env) { @@ -4790,7 +4559,7 @@ dispose_used_env_vars () 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); @@ -4799,14 +4568,14 @@ merge_temporary_env () /* 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) { @@ -4823,9 +4592,7 @@ flush_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; @@ -4914,8 +4681,7 @@ mk_env_string (name, value, attributes) #ifdef DEBUG /* Debugging */ static int -valid_exportstr (v) - SHELL_VAR *v; +valid_exportstr (SHELL_VAR *v) { char *s; @@ -4956,8 +4722,7 @@ valid_exportstr (v) #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; @@ -5028,8 +4793,7 @@ make_env_array_from_var_list (vars) 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; @@ -5050,7 +4814,7 @@ make_var_export_array (vcxt) } static char ** -make_func_export_array () +make_func_export_array (void) { char **list; SHELL_VAR **vars; @@ -5082,9 +4846,7 @@ do \ /* 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; @@ -5114,9 +4876,7 @@ add_or_supercede_exported_var (assign, do_alloc) } 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; @@ -5151,7 +4911,7 @@ add_temp_array_to_env (temp_array, do_alloc, do_supercede) */ static int -n_shell_variables () +n_shell_variables (void) { VAR_CONTEXT *vc; int n; @@ -5162,8 +4922,7 @@ n_shell_variables () } int -chkexport (name) - char *name; +chkexport (char *name) { SHELL_VAR *v; @@ -5178,7 +4937,7 @@ chkexport (name) } void -maybe_make_export_env () +maybe_make_export_env (void) { register char **temp_array; int new_size; @@ -5258,10 +5017,7 @@ maybe_make_export_env () 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; @@ -5274,8 +5030,7 @@ update_export_env_inplace (env_prefix, preflen, value) /* 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); } @@ -5290,9 +5045,7 @@ put_command_name_into_env (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; @@ -5310,8 +5063,7 @@ new_var_context (name, flags) /* 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); @@ -5326,8 +5078,7 @@ dispose_var_context (vc) /* 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); } @@ -5336,10 +5087,7 @@ set_context (var) 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; @@ -5383,9 +5131,7 @@ push_var_context (name, flags, tempvars) */ 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; @@ -5456,8 +5202,7 @@ push_posix_tempvar_internal (var, isbltin) } static void -push_func_var (data) - PTR_T data; +push_func_var (PTR_T data) { SHELL_VAR *var; @@ -5466,8 +5211,7 @@ push_func_var (data) } static void -push_builtin_var (data) - PTR_T data; +push_builtin_var (PTR_T data) { SHELL_VAR *var; @@ -5478,7 +5222,7 @@ push_builtin_var (data) /* 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; @@ -5504,8 +5248,7 @@ pop_var_context () } static void -delete_local_contexts (vcxt) - VAR_CONTEXT *vcxt; +delete_local_contexts (VAR_CONTEXT *vcxt) { VAR_CONTEXT *v, *t; @@ -5519,8 +5262,7 @@ delete_local_contexts (vcxt) /* 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); @@ -5530,7 +5272,7 @@ delete_all_contexts (vcxt) /* 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; @@ -5544,16 +5286,13 @@ reset_local_contexts () /* **************************************************************** */ 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; @@ -5587,8 +5326,7 @@ push_exported_var (data) 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; @@ -5642,7 +5380,7 @@ static int dollar_arg_stack_index; /* 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; @@ -5657,8 +5395,7 @@ save_dollar_vars () } static void -restore_dollar_vars (args) - char **args; +restore_dollar_vars (char **args) { int i; @@ -5667,7 +5404,7 @@ restore_dollar_vars (args) } static void -free_dollar_vars () +free_dollar_vars (void) { int i; @@ -5679,8 +5416,7 @@ free_dollar_vars () } static void -free_saved_dollar_vars (args) - char **args; +free_saved_dollar_vars (char **args) { int i; @@ -5690,7 +5426,7 @@ free_saved_dollar_vars (args) /* 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); @@ -5700,11 +5436,9 @@ clear_dollar_vars () } /* 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 (); @@ -5715,7 +5449,7 @@ push_context (name, is_subshell, tempvars) /* 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--; @@ -5726,7 +5460,7 @@ pop_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) { @@ -5747,7 +5481,7 @@ push_dollar_vars () /* 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; @@ -5769,7 +5503,7 @@ pop_dollar_vars () } void -dispose_saved_dollar_vars () +dispose_saved_dollar_vars (void) { if (dollar_arg_stack == 0 || dollar_arg_stack_index == 0) return; @@ -5786,7 +5520,7 @@ dispose_saved_dollar_vars () /* 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) { @@ -5796,7 +5530,7 @@ init_bash_argv () } void -save_bash_argv () +save_bash_argv (void) { WORD_LIST *list; @@ -5808,8 +5542,7 @@ save_bash_argv () /* 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; @@ -5834,7 +5567,7 @@ push_args (list) 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; @@ -5963,8 +5696,7 @@ static struct name_and_function special_vars[] = { #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; @@ -5974,8 +5706,7 @@ sv_compare (sv1, sv2) } static inline int -find_special_var (name) - const char *name; +find_special_var (const char *name) { register int i, r; @@ -5997,8 +5728,7 @@ find_special_var (name) /* 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; @@ -6018,7 +5748,7 @@ stupidly_hack_special_variables (name) /* 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"); @@ -6028,8 +5758,7 @@ reinit_special_variables () } void -sv_ifs (name) - char *name; +sv_ifs (char *name) { SHELL_VAR *v; @@ -6039,8 +5768,7 @@ sv_ifs (name) /* What to do just after the PATH variable has changed. */ void -sv_path (name) - char *name; +sv_path (char *name) { /* hash -r */ phash_flush (); @@ -6050,8 +5778,7 @@ sv_path (name) 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 @@ -6067,8 +5794,7 @@ sv_mail (name) } void -sv_funcnest (name) - char *name; +sv_funcnest (char *name) { SHELL_VAR *v; intmax_t num; @@ -6084,16 +5810,14 @@ sv_funcnest (name) /* 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); @@ -6101,8 +5825,7 @@ sv_globignore (name) #if defined (READLINE) void -sv_comp_wordbreaks (name) - char *name; +sv_comp_wordbreaks (char *name) { SHELL_VAR *sv; @@ -6115,16 +5838,14 @@ sv_comp_wordbreaks (name) 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; @@ -6140,8 +5861,7 @@ sv_hostfile (name) 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; @@ -6172,8 +5892,7 @@ sv_winsize (name) /* 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 (); @@ -6188,8 +5907,7 @@ sv_home (name) 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; @@ -6228,16 +5946,14 @@ sv_histsize (name) /* 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; @@ -6268,8 +5984,7 @@ sv_history_control (name) #if defined (BANG_HISTORY) /* Setting/unsetting of the history expansion character. */ void -sv_histchars (name) - char *name; +sv_histchars (char *name) { char *temp; @@ -6294,8 +6009,7 @@ sv_histchars (name) #endif /* BANG_HISTORY */ void -sv_histtimefmt (name) - char *name; +sv_histtimefmt (char *name) { SHELL_VAR *v; @@ -6310,8 +6024,7 @@ sv_histtimefmt (name) #if defined (HAVE_TZSET) void -sv_tz (name) - char *name; +sv_tz (char *name) { SHELL_VAR *v; @@ -6333,8 +6046,7 @@ sv_tz (name) 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; @@ -6350,8 +6062,7 @@ sv_ignoreeof (name) } void -sv_optind (name) - char *name; +sv_optind (char *name) { SHELL_VAR *var; char *tt; @@ -6378,8 +6089,7 @@ sv_optind (name) } void -sv_opterr (name) - char *name; +sv_opterr (char *name) { char *tt; @@ -6388,8 +6098,7 @@ sv_opterr (name) } void -sv_strict_posix (name) - char *name; +sv_strict_posix (char *name) { SHELL_VAR *var; @@ -6404,8 +6113,7 @@ sv_strict_posix (name) } void -sv_locale (name) - char *name; +sv_locale (char *name) { char *v; int r; @@ -6424,9 +6132,7 @@ sv_locale (name) #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; @@ -6515,7 +6221,7 @@ set_pipestatus_array (ps, nproc) } ARRAY * -save_pipestatus_array () +save_pipestatus_array (void) { SHELL_VAR *v; ARRAY *a; @@ -6530,8 +6236,7 @@ save_pipestatus_array () } void -restore_pipestatus_array (a) - ARRAY *a; +restore_pipestatus_array (ARRAY *a) { SHELL_VAR *v; ARRAY *a2; @@ -6549,8 +6254,7 @@ restore_pipestatus_array (a) #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 }; @@ -6561,8 +6265,7 @@ set_pipestatus_from_exit (s) } void -sv_xtracefd (name) - char *name; +sv_xtracefd (char *name) { SHELL_VAR *v; char *t, *e; @@ -6598,8 +6301,7 @@ sv_xtracefd (name) #define MIN_COMPAT_LEVEL 31 void -sv_shcompat (name) - char *name; +sv_shcompat (char *name) { SHELL_VAR *v; char *val; @@ -6651,8 +6353,7 @@ compat_error: #if defined (JOB_CONTROL) void -sv_childmax (name) - char *name; +sv_childmax (char *name) { char *tt; int s;