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
+4 -8
View File
@@ -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;
+4 -8
View File
@@ -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;
+3 -5
View File
@@ -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)
+2 -3
View File
@@ -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;
+2 -3
View File
@@ -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");
+9 -17
View File
@@ -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;
+3 -5
View File
@@ -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);
}
+1 -2
View File
@@ -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;
+16 -38
View File
@@ -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;
+6 -18
View File
@@ -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;
+2 -3
View File
@@ -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;
+8 -18
View File
@@ -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;
+2 -3
View File
@@ -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);
+16 -43
View File
@@ -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;
+3 -5
View File
@@ -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;
+4 -7
View File
@@ -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)
+9 -22
View File
@@ -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;
+3 -7
View File
@@ -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;
+3 -9
View File
@@ -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;
+6 -14
View File
@@ -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;
+9 -24
View File
@@ -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;
+5 -11
View File
@@ -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;
+3 -6
View File
@@ -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;
+2 -5
View File
@@ -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;
+2 -4
View File
@@ -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;
+6 -17
View File
@@ -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);
+76 -151
View File
@@ -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)
+20 -38
View File
@@ -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)
+13 -30
View File
@@ -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;
+16 -33
View File
@@ -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;
+1 -2
View File
@@ -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);
+20 -41
View File
@@ -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;
+13 -31
View File
@@ -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;
+2 -3
View File
@@ -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;
+28 -71
View File
@@ -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)
+2 -3
View File
@@ -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;
+2 -4
View File
@@ -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;
+2 -3
View File
@@ -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;
+2 -3
View File
@@ -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;
+3 -7
View File
@@ -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;
+2 -5
View File
@@ -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;
+13 -35
View File
@@ -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;
+6 -18
View File
@@ -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;
+3 -5
View File
@@ -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;