second set of ANSI C changes: C89-style function declarations, more inline functions, remove register keyword

This commit is contained in:
Chet Ramey
2023-01-03 10:23:11 -05:00
parent 81e3a4fb07
commit a61ffa78ed
85 changed files with 2867 additions and 5479 deletions
+36 -97
View File
@@ -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;