- introduce new unwind-protect function pointer type to replace
Function
From Paul Eggert <eggert@cs.ucla.edu>
+
+ 3/30
+ ----
+builtins/command.def,builtins/fc.def,builtins/read.def,builtins/source.def
+builtins/evalfile.c,builtins/evalstring.c
+dispose_cmd.c,execute_cmd.c,pcomplete.c,print_cmd.c,subst.c,jobs.c,variables.c
+dispose_cmd.h,general.h,trap.h
+unwind_prot.c,unwind_prot.h
+ - rest of work to convert unwind-protect framework to ANSI/ISO C.
+ Convert unwind-protects to use new shim functions that obey the new
+ unwind-protect function type
+ From Paul Eggert <eggert@cs.ucla.edu>
+
+general.h
+ - STREQ, STREQN: now static inline functions to take advantage of arg
+ type conversion
+
+pcomplete.c,subst.c
+lib/readline/histexpand.c,lib/readline/mbutil.c
+ - fix size_t subtractions in comparisons to avoid unsigned underflow
+
+externs.h
+execute_cmd.c
+builtins/times.h
+ - add prototypes for functions taking clock_t and timeval, make their
+ declaration in externs.h conditional on NEED_CLOCK_FUNCS_DECL and
+ NEED_TIMEVAL_FUNCS_DECL, respectively
$BUILTIN cd
$FUNCTION cd_builtin
-$SHORT_DOC cd [-L|[-P [-e]] [-@]] [dir]
+$SHORT_DOC cd [-L|[-P [-e]]] [-@] [dir]
Change the shell working directory.
Change the current directory to DIR. The default DIR is the value of the
This file is command.def, from which is created command.c.
It implements the builtin "command" in Bash.
-Copyright (C) 1987-2022 Free Software Foundation, Inc.
+Copyright (C) 1987-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
command->flags |= COMMAND_BUILTIN_FLAGS;
command->value.Simple->flags |= COMMAND_BUILTIN_FLAGS;
- add_unwind_protect ((char *)dispose_command, command);
+ add_unwind_protect (uw_dispose_command, command);
result = execute_command (command);
run_unwind_frame ("command_builtin");
fa->funcname_a = funcname_a;
fa->funcname_v = funcname_v;
if (flags & FEVAL_UNWINDPROT)
- add_unwind_protect (restore_funcarray_state, fa);
+ add_unwind_protect (uw_restore_funcarray_state, fa);
# if defined (DEBUGGER)
/* Have to figure out a better way to do this when `source' is supplied
tt[0] = '1'; tt[1] = '\0';
array_push (bash_argc_a, tt);
if (flags & FEVAL_UNWINDPROT)
- add_unwind_protect (pop_args, 0);
+ add_unwind_protect (uw_pop_args, 0);
}
# endif
#endif
#if defined (HISTORY)
static void
-set_history_remembering (void)
+uw_set_history_remembering (void *ignore)
{
remember_on_history = enable_history_list;
}
+
#endif
static void
-restore_lastcom (char *x)
+uw_restore_lastcom (void *x)
{
FREE (the_printed_command_except_trap);
the_printed_command_except_trap = x;
}
+static void
+uw_set_current_prompt_level (void *x)
+{
+ set_current_prompt_level ((intptr_t) x);
+}
+
+static void
+uw_pop_stream (void *x)
+{
+ pop_stream ();
+}
+
+static void
+uw_parser_restore_alias (void *x)
+{
+ parser_restore_alias ();
+}
+
int
should_optimize_fork (COMMAND *command, int subshell)
{
#if defined (HISTORY)
if (parse_and_execute_level == 0)
- add_unwind_protect (set_history_remembering, (char *)NULL);
+ add_unwind_protect (uw_set_history_remembering, (char *)NULL);
else
unwind_protect_int (remember_on_history); /* can be used in scripts */
# if defined (BANG_HISTORY)
if (interactive_shell)
{
x = get_current_prompt_level ();
- add_unwind_protect (set_current_prompt_level, x);
+ add_unwind_protect (uw_set_current_prompt_level, (void *) (intptr_t) x);
}
if (the_printed_command_except_trap)
{
lastcom = savestring (the_printed_command_except_trap);
- add_unwind_protect (restore_lastcom, lastcom);
+ add_unwind_protect (uw_restore_lastcom, lastcom);
}
- add_unwind_protect (pop_stream, (char *)NULL);
+ add_unwind_protect (uw_pop_stream, (char *)NULL);
if (parser_expanding_alias ())
- add_unwind_protect (parser_restore_alias, (char *)NULL);
+ add_unwind_protect (uw_parser_restore_alias, (char *)NULL);
if (orig_string && ((flags & SEVAL_NOFREE) == 0))
add_unwind_protect (xfree, orig_string);
bitmap = new_fd_bitmap (FD_BITMAP_SIZE);
begin_unwind_frame ("pe_dispose");
- add_unwind_protect (dispose_fd_bitmap, bitmap);
- add_unwind_protect (dispose_command, command); /* XXX */
+ add_unwind_protect (uw_dispose_fd_bitmap, bitmap);
+ add_unwind_protect (uw_dispose_command, command); /* XXX */
global_command = (COMMAND *)NULL;
#endif
static void
-set_verbose_flag (void)
+uw_set_verbose_flag (void *ignore)
{
echo_input_at_read = verbose_flag;
}
+static void
+uw_unlink (void *fn)
+{
+ unlink ((const char *)fn);
+}
+
/* String to execute on a file that we want to edit. */
#define FC_EDIT_COMMAND "${FCEDIT:-${EDITOR:-vi}}"
#if defined (STRICT_POSIX)
will be echoed as they are read by the parser. */
begin_unwind_frame ("fc builtin");
add_unwind_protect (xfree, fn);
- add_unwind_protect (unlink, fn);
- add_unwind_protect (set_verbose_flag, (char *)NULL);
+ add_unwind_protect (uw_unlink, fn);
+ add_unwind_protect (uw_set_verbose_flag, (char *)NULL);
unwind_protect_int (suppress_debug_trap_verbose);
echo_input_at_read = 1;
suppress_debug_trap_verbose = 1;
This file is jobs.def, from which is created jobs.c.
It implements the builtins "jobs" and "disown" in Bash.
-Copyright (C) 1987-2022 Free Software Foundation, Inc.
+Copyright (C) 1987-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
command->flags |= CMD_INHIBIT_EXPANSION;
command->value.Simple->flags |= CMD_INHIBIT_EXPANSION;
- add_unwind_protect (dispose_command, command);
+ add_unwind_protect (uw_dispose_command, command);
result = execute_command (command);
dispose_command (command);
This file is read.def, from which is created read.c.
It implements the builtin "read" in Bash.
-Copyright (C) 1987-2022 Free Software Foundation, Inc.
+Copyright (C) 1987-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
};
#if defined (READLINE)
-static void reset_attempted_completion_function (char *);
+static void uw_reset_attempted_completion_function (void *);
static int set_itext (void);
static char *edit_line (char *, char *);
static void set_eol_delim (int);
-static void reset_eol_delim (char *);
+static void reset_eol_delim (void *);
static void set_readline_timeout (sh_timer *t, time_t, long);
+static void uw_bashline_reset_event_hook (void *);
#endif
static SHELL_VAR *bind_read_variable (char *, char *, int);
#if defined (HANDLE_MULTIBYTE)
static int read_mbchar (int, char *, int, int, int);
#endif
static void ttyrestore (struct ttsave *);
+static void uw_ttyrestore (void *);
static sighandler sigalrm (int);
static void reset_timeout (void);
+static void uw_reset_timeout (void *);
/* Try this to see what the rest of the shell can do with the information. */
sh_timer *read_timeout;
read_timeout = 0;
}
+static void
+uw_reset_timeout (void *ignore)
+{
+ reset_timeout ();
+}
+
void
check_read_timeout (void)
{
}
if (interactive_shell == 0)
initialize_terminating_signals ();
- add_unwind_protect (reset_timeout, (char *)NULL);
+ add_unwind_protect (uw_reset_timeout, NULL);
#if defined (READLINE)
if (edit)
{
- add_unwind_protect (reset_attempted_completion_function, (char *)NULL);
- add_unwind_protect (bashline_reset_event_hook, (char *)NULL);
+ add_unwind_protect (uw_reset_attempted_completion_function, NULL);
+ add_unwind_protect (uw_bashline_reset_event_hook, NULL);
set_readline_timeout (read_timeout, tmsec, tmusec);
}
else
if (delim != '\n')
{
set_eol_delim (delim);
- add_unwind_protect (reset_eol_delim, (char *)NULL);
+ add_unwind_protect (reset_eol_delim, NULL);
}
}
else
if (i < 0)
sh_ttyerror (1);
tty_modified = 1;
- add_unwind_protect ((Function *)ttyrestore, (char *)&termsave);
+ add_unwind_protect (uw_ttyrestore, &termsave);
if (interactive_shell == 0)
initialize_terminating_signals ();
}
sh_ttyerror (1);
tty_modified = 1;
- add_unwind_protect ((Function *)ttyrestore, (char *)&termsave);
+ add_unwind_protect (uw_ttyrestore, &termsave);
if (interactive_shell == 0)
initialize_terminating_signals ();
}
if (nchars > 0)
rl_num_chars_to_read = 0;
if (delim != '\n')
- reset_eol_delim ((char *)NULL);
+ reset_eol_delim (NULL);
}
else
#endif
tty_modified = 0;
}
+static void
+uw_ttyrestore (void *ttp)
+{
+ ttyrestore (ttp);
+}
+
void
read_tty_cleanup (void)
{
static char *deftext;
static void
-reset_attempted_completion_function (char *cp)
+uw_reset_attempted_completion_function (void *cp)
{
if (rl_attempted_completion_function == 0 && old_attempted_completion_function)
rl_attempted_completion_function = old_attempted_completion_function;
}
+static void
+uw_bashline_reset_event_hook (void *ignore)
+{
+ bashline_reset_event_hook ();
+}
+
static int
set_itext (void)
{
}
static void
-reset_eol_delim (char *cp)
+reset_eol_delim (void *ignore)
{
Keymap cmap;
This file is source.def, from which is created source.c.
It implements the builtins "." and "source" in Bash.
-Copyright (C) 1987-2022 Free Software Foundation, Inc.
+Copyright (C) 1987-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
extern int errno;
#endif /* !errno */
-static void maybe_pop_dollar_vars (void);
+static void uw_maybe_pop_dollar_vars (void *);
/* If non-zero, `.' uses $PATH to look up the script to be sourced. */
int source_uses_path = 1;
not executing a shell function, we leave the new values alone and free
the saved values. */
static void
-maybe_pop_dollar_vars (void)
+uw_maybe_pop_dollar_vars (void *ignore)
{
if (variable_context == 0 && (dollar_vars_changed () & ARGS_SETBLTIN))
dispose_saved_dollar_vars ();
if (list->next)
{
push_dollar_vars ();
- add_unwind_protect ((Function *)maybe_pop_dollar_vars, (char *)NULL);
+ add_unwind_protect (uw_maybe_pop_dollar_vars, NULL);
if (debugging_mode || shell_compatibility_level <= 44)
init_bash_argv (); /* Initialize BASH_ARGV and BASH_ARGC */
remember_args (list->next, 1);
{
debug_trap = savestring (debug_trap);
add_unwind_protect (xfree, debug_trap);
- add_unwind_protect (maybe_set_debug_trap, debug_trap);
+ add_unwind_protect (uw_maybe_set_debug_trap, debug_trap);
restore_default_signal (DEBUG_TRAP);
}
#include <stdio.h>
#include "../bashtypes.h"
-#include "../shell.h"
#include <posixtime.h>
# include <sys/resource.h>
#endif
+#define NEED_CLOCK_FUNCS_DECL
+#define NEED_TIMEVAL_FUNCS_DECL
+
+#include "../shell.h"
#include "common.h"
/* Print the totals for system and user time used. */
/* dispose_command.c -- dispose of a COMMAND structure. */
-/* Copyright (C) 1987-2009,2022 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2009,2022,2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
free (command);
}
+void
+uw_dispose_command (void *command)
+{
+ dispose_command (command);
+}
+
#if defined (COND_COMMAND)
/* How to free a node in a conditional command. */
void
}
}
+void
+uw_dispose_words (void *list)
+{
+ dispose_words (list);
+}
+
#ifdef INCLUDE_UNUSED
/* How to dispose of an array of pointers to char. This is identical to
free_array in stringlib.c. */
/* dispose_cmd.h -- Functions appearing in dispose_cmd.c. */
-/* Copyright (C) 1993-2022 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
extern void dispose_function_def_contents (FUNCTION_DEF *);
extern void dispose_function_def (FUNCTION_DEF *);
+extern void uw_dispose_command (void *);
+extern void uw_dispose_words (void *);
+
#endif /* !_DISPOSE_CMD_H_ */
call or \fIexpr\fP does not correspond to a valid position in the
call stack.
.TP
-\fBcd\fP [\fB\-L\fP|[\fB\-P\fP [\fB\-e\fP]] [\-@]] [\fIdir\fP]
+\fBcd\fP [\fB\-L\fP|[\fB\-P\fP [\fB\-e\fP]]] [\-@] [\fIdir\fP]
Change the current directory to \fIdir\fP.
if \fIdir\fP is not supplied, the value of the
.SM
@item cd
@btindex cd
@example
-cd [-L|[-P [-e]] [-@@] [@var{directory}]
+cd [-L|[-P [-e]]] [-@@] [@var{directory}]
@end example
Change the current working directory to @var{directory}.
#define NEED_FPURGE_DECL
#define NEED_SH_SETLINEBUF_DECL
+#define NEED_CLOCK_FUNCS_DECL
+#define NEED_TIMEVAL_FUNCS_DECL
#include "bashansi.h"
#include "bashintl.h"
static void cleanup_redirects (REDIRECT *);
#if defined (JOB_CONTROL)
-static void restore_signal_mask (void *);
+static void uw_restore_signal_mask (void *);
#endif
static int builtin_status (int);
free (fdbp);
}
+void
+uw_dispose_fd_bitmap (void *fdbp)
+{
+ dispose_fd_bitmap (fdbp);
+}
+
void
close_fd_bitmap (struct fd_bitmap *fdbp)
{
}
}
+static void
+uw_close_fd_bitmap (void *fdbp)
+{
+ close_fd_bitmap (fdbp);
+}
+
+void
+uw_close (void *fd)
+{
+ close ((intptr_t) fd); /* XXX */
+}
+
/* Return the line number of the currently executing command. */
int
executing_line_number (void)
current_fds_to_close = (struct fd_bitmap *)NULL;
bitmap = new_fd_bitmap (FD_BITMAP_DEFAULT_SIZE);
begin_unwind_frame ("execute-command");
- add_unwind_protect (dispose_fd_bitmap, (char *)bitmap);
+ add_unwind_protect (uw_dispose_fd_bitmap, (char *)bitmap);
/* Just do the command, but not asynchronously. */
result = execute_command_internal (command, 0, NO_PIPE, NO_PIPE, bitmap);
dispose_redirects (list);
}
+static void
+uw_cleanup_redirects (void *list)
+{
+ cleanup_redirects (list);
+}
+
+static void
+uw_dispose_redirects (void *list)
+{
+ dispose_redirects (list);
+}
+
void
undo_partial_redirects (void)
{
/* A function to restore the signal mask to its proper value when the shell
is interrupted or errors occur while creating a pipeline. */
static void
-restore_signal_mask (void *set)
+uw_restore_signal_mask (void *set)
{
sigprocmask (SIG_SETMASK, set, NULL);
}
begin_unwind_frame ("loop_redirections");
if (my_undo_list)
- add_unwind_protect ((Function *)cleanup_redirects, my_undo_list);
+ add_unwind_protect (uw_cleanup_redirects, my_undo_list);
if (exec_undo_list)
- add_unwind_protect ((Function *)dispose_redirects, exec_undo_list);
+ add_unwind_protect (uw_dispose_redirects, exec_undo_list);
QUIT;
}
}
+static void
+uw_restore_stdin (void *s)
+{
+ restore_stdin ((intptr_t)s);
+}
+
+static void
+uw_merge_temporary_env (void *ignore)
+{
+ merge_temporary_env ();
+}
+
/* Catch-all cleanup function for lastpipe code for unwind-protects */
static void
-lastpipe_cleanup (int s)
+uw_lastpipe_cleanup (void *s)
{
- set_jobs_list_frozen (s);
+ set_jobs_list_frozen ((intptr_t) s);
}
static int
unwind-protects are run, and the storage used for the
bitmaps freed up. */
begin_unwind_frame ("pipe-file-descriptors");
- add_unwind_protect (dispose_fd_bitmap, fd_bitmap);
- add_unwind_protect (close_fd_bitmap, fd_bitmap);
+ add_unwind_protect (uw_dispose_fd_bitmap, fd_bitmap);
+ add_unwind_protect (uw_close_fd_bitmap, fd_bitmap);
if (prev >= 0)
- add_unwind_protect (close, prev);
+ add_unwind_protect (uw_close, (void *) (intptr_t) prev);
dummyfd = fildes[1];
- add_unwind_protect (close, dummyfd);
+ add_unwind_protect (uw_close, (void *) (intptr_t) dummyfd);
#if defined (JOB_CONTROL)
- add_unwind_protect (restore_signal_mask, &oset);
+ add_unwind_protect (uw_restore_signal_mask, &oset);
#endif /* JOB_CONTROL */
if (ignore_return && cmd->value.Connection->first)
{
do_piping (prev, pipe_out);
prev = NO_PIPE;
- add_unwind_protect (restore_stdin, lstdin);
+ add_unwind_protect (uw_restore_stdin, (void *) (intptr_t) lstdin);
lastpipe_flag = 1;
old_frozen = freeze_jobs_list ();
lastpipe_jid = stop_pipeline (0, (COMMAND *)NULL); /* XXX */
- add_unwind_protect (lastpipe_cleanup, old_frozen);
+ add_unwind_protect (uw_lastpipe_cleanup, (void *) (intptr_t) old_frozen);
#if defined (JOB_CONTROL)
UNBLOCK_CHILD (oset); /* XXX */
#endif
cmd->flags |= CMD_LASTPIPE;
}
if (prev >= 0)
- add_unwind_protect (close, prev);
+ add_unwind_protect (uw_close, (void *) (intptr_t) prev);
exec_result = execute_command_internal (cmd, asynchronous, prev, pipe_out, fds_to_close);
list = releaser = expand_words_no_vars (for_command->map_list);
begin_unwind_frame ("for");
- add_unwind_protect (dispose_words, releaser);
+ add_unwind_protect (uw_dispose_words, releaser);
#if 0
if (lexical_scoping)
{
old_value = copy_variable (find_variable (identifier));
if (old_value)
- add_unwind_protect (dispose_variable, old_value);
+ add_unwind_protect (uw_dispose_variable, old_value);
}
#endif
}
begin_unwind_frame ("select");
- add_unwind_protect (dispose_words, releaser);
+ add_unwind_protect (uw_dispose_words, releaser);
if (select_command->flags & CMD_IGNORE_RETURN)
select_command->action->flags |= CMD_IGNORE_RETURN;
builtin = 0;
}
- add_unwind_protect (dispose_words, words);
+ add_unwind_protect (uw_dispose_words, words);
QUIT;
/* Bind the last word in this command to "$_" after execution. */
{
error_trap = savestring (error_trap);
add_unwind_protect (xfree, error_trap);
- add_unwind_protect (set_error_trap, error_trap);
+ add_unwind_protect (uw_set_error_trap, error_trap);
restore_default_signal (ERROR_TRAP);
}
exit_immediately_on_error = 0;
if (flags & CMD_COMMAND_BUILTIN)
should_keep = 0;
if (subshell == 0)
- add_unwind_protect (pop_scope, should_keep ? "1" : 0);
+ add_unwind_protect (pop_scope, (void *) (intptr_t) should_keep);
temporary_env = (HASH_TABLE *)NULL;
}
}
if (posixly_correct && subshell == 0 && builtin == return_builtin && (flags & CMD_COMMAND_BUILTIN) == 0 && temporary_env)
{
begin_unwind_frame ("return_temp_env");
- add_unwind_protect (merge_temporary_env, (char *)NULL);
+ add_unwind_protect (uw_merge_temporary_env, NULL);
}
executing_builtin++;
}
static void
-maybe_restore_getopt_state (void *arg)
+uw_maybe_restore_getopt_state (void *arg)
{
sh_getopt_state_t *gs;
free (fa);
}
+
+void
+uw_restore_funcarray_state (void *fa)
+{
+ restore_funcarray_state (fa);
+}
#endif
static int
/* This has to be before the pop_context(), because the unwinding of
local variables may cause the restore of a local declaration of
OPTIND to force a getopts state reset. */
- add_unwind_protect (maybe_restore_getopt_state, gs);
- add_unwind_protect (pop_context, (char *)NULL);
+ add_unwind_protect (uw_maybe_restore_getopt_state, gs);
+ add_unwind_protect (pop_context, NULL);
unwind_protect_int (line_number);
unwind_protect_int (line_number_for_err_trap);
unwind_protect_int (function_line_number);
unwind_protect_int (return_catch_flag);
unwind_protect_jmp_buf (return_catch);
- add_unwind_protect (dispose_command, (char *)tc);
+ add_unwind_protect (uw_dispose_command, (char *)tc);
unwind_protect_pointer (this_shell_function);
unwind_protect_int (funcnest);
unwind_protect_int (loop_level);
{
debug_trap = savestring (debug_trap);
add_unwind_protect (xfree, debug_trap);
- add_unwind_protect (maybe_set_debug_trap, debug_trap);
+ add_unwind_protect (uw_maybe_set_debug_trap, debug_trap);
}
restore_default_signal (DEBUG_TRAP);
}
{
error_trap = savestring (error_trap);
add_unwind_protect (xfree, error_trap);
- add_unwind_protect (maybe_set_error_trap, error_trap);
+ add_unwind_protect (uw_maybe_set_error_trap, error_trap);
}
restore_default_signal (ERROR_TRAP);
}
{
return_trap = savestring (return_trap);
add_unwind_protect (xfree, return_trap);
- add_unwind_protect (maybe_set_return_trap, return_trap);
+ add_unwind_protect (uw_maybe_set_return_trap, return_trap);
}
restore_default_signal (RETURN_TRAP);
}
fa->funcname_a = (ARRAY *)funcname_a;
fa->funcname_v = funcname_v;
if (subshell == 0)
- add_unwind_protect (restore_funcarray_state, fa);
+ add_unwind_protect (uw_restore_funcarray_state, fa);
#endif
/* The temporary environment for a function is supposed to apply to
{
push_args (words->next);
if (subshell == 0)
- add_unwind_protect (pop_args, 0);
+ add_unwind_protect (uw_pop_args, 0);
}
/* Number of the line on which the function body starts. */
bitmap = new_fd_bitmap (FD_BITMAP_DEFAULT_SIZE);
begin_unwind_frame ("execute-shell-function");
- add_unwind_protect (dispose_fd_bitmap, (char *)bitmap);
+ add_unwind_protect (uw_dispose_fd_bitmap, (char *)bitmap);
ret = execute_function (var, words, 0, bitmap, 0, 0);
if (saved_undo_list)
{
begin_unwind_frame ("saved-redirects");
- add_unwind_protect (cleanup_redirects, (char *)saved_undo_list);
+ add_unwind_protect (uw_cleanup_redirects, (char *)saved_undo_list);
}
redirection_undo_list = (REDIRECT *)NULL;
#if defined (ARRAY_VARS)
extern void restore_funcarray_state (struct func_array_state *);
+extern void uw_restore_funcarray_state (void *);
#endif
extern void bind_lastarg (char *);
+
+extern void uw_dispose_fd_bitmap (void *);
+extern void uw_close (void *);
+
#endif /* _EXECUTE_CMD_H_ */
/* declarations for functions defined in lib/sh/clock.c */
/* No prototypes so we don't have to have clock_t defined when this file
is included. */
-extern void clock_t_to_secs ();
-extern void print_clock_t ();
+#ifdef NEED_CLOCK_FUNCS_DECL
+extern void clock_t_to_secs (clock_t, time_t *, int *);
+extern void print_clock_t (FILE *, clock_t);
+#endif
/* Declarations for functions defined in lib/sh/dprintf.c */
#if !defined (HAVE_DPRINTF)
/* declarations for functions defined in lib/sh/timeval.c. No prototypes
so we don't have to count on having a definition of struct timeval in
scope when this file is included. */
-extern void timeval_to_secs ();
-extern void print_timeval ();
+#ifdef NEED_TIMEVAL_FUNCS_DECL
+extern void timeval_to_secs (struct timeval *, time_t *, int *);
+extern void print_timeval (FILE *, struct timeval *);
+#endif
/* declarations for functions defined in lib/sh/tmpfile.c */
#define MT_USETMPDIR 0x0001
--- /dev/null
+./configure~: Do not test the value of __STDC__, because some compilers set it to 0
+./configure~:#if !defined __STDC__
+./configure~:#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus)
+./configure~:ibmrt-*bsd4*) LOCAL_CFLAGS="-ma -U__STDC__" ;;
+./configure.ac~:ibmrt-*bsd4*) LOCAL_CFLAGS="-ma -U__STDC__" ;;
+./configure.ac:ibmrt-*bsd4*) LOCAL_CFLAGS="-ma -U__STDC__" ;;
+./config-bot.h~:/* Try this without testing __STDC__ for the time being. */
+./configure: Do not test the value of __STDC__, because some compilers set it to 0
+./configure:#if !defined __STDC__
+./configure:ibmrt-*bsd4*) LOCAL_CFLAGS="-ma -U__STDC__" ;;
+./autom4te.cache/traces.0: && !(defined __SUNPRO_C && __STDC__))) \\
+./autom4te.cache/traces.1: && !(defined __SUNPRO_C && __STDC__))) \\
+./autom4te.cache/output.0: Do not test the value of __STDC__, because some compilers set it to 0
+./autom4te.cache/output.0:#if !defined __STDC__
+./autom4te.cache/output.0:ibmrt-*bsd4*) LOCAL_CFLAGS="-ma -U__STDC__" ;;
+./autom4te.cache/output.1: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.1:#ifdef __STDC__
+./autom4te.cache/output.1: # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.1:@%:@ifdef __STDC__
+./autom4te.cache/output.1: # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.1:@%:@ifdef __STDC__
+./autom4te.cache/output.1:#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus)
+./autom4te.cache/output.1:#ifndef __STDC__
+./autom4te.cache/output.1:#ifndef __STDC__
+./autom4te.cache/output.1:#ifndef __STDC__
+./autom4te.cache/output.1:ibmrt-*bsd4*) LOCAL_CFLAGS="-ma -U__STDC__" ;;
+./autom4te.cache/output.3: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.3:#ifdef __STDC__
+./autom4te.cache/output.3: # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.3:@%:@ifdef __STDC__
+./autom4te.cache/output.3: # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.3:@%:@ifdef __STDC__
+./autom4te.cache/output.3:#if defined(__STDC__) || defined(__cplusplus)
+./autom4te.cache/output.3:#ifndef __STDC__
+./autom4te.cache/output.3:#ifndef __STDC__
+./autom4te.cache/output.3:#ifndef __STDC__
+./autom4te.cache/output.3:ibmrt-*bsd4*) LOCAL_CFLAGS="-ma -U__STDC__" ;;
+./autom4te.cache/output.2: # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:@%:@ifdef __STDC__
+./autom4te.cache/output.2: # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:@%:@ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2:#if defined(__STDC__) || defined(__cplusplus)
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2:#ifndef __STDC__
+./autom4te.cache/output.2:#ifndef __STDC__
+./autom4te.cache/output.2:#ifndef __STDC__
+./autom4te.cache/output.2: Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+./autom4te.cache/output.2:#ifdef __STDC__
+./autom4te.cache/output.2:ibmrt-*bsd4*) LOCAL_CFLAGS="-ma -U__STDC__" ;;
+./include/memalloc.h~:# if defined (__STDC__)
+./include/memalloc.h~:# endif /* !__STDC__ */
+./include/stdc.h:# if defined (__STDC__) || defined (__GNUC__) || defined (__cplusplus) || defined (PROTOTYPES)
+./include/stdc.h:#if !defined (__STDC__)
+./include/stdc.h:#endif /* !__STDC__ */
+./include/stdc.h~:# if defined (__STDC__) || defined (__GNUC__) || defined (__cplusplus) || defined (PROTOTYPES)
+./include/stdc.h~:#if !defined (__STDC__)
+./include/stdc.h~:#endif /* !__STDC__ */
+./CWRU/old-conf/machines.h: /* SGI cc uses ansi c features *without* defining __STDC__ */
+./CWRU/old-conf/machines.h:# if defined (__EXTENSIONS__) && !defined (__STDC__)
+./CWRU/old-conf/machines.h:# define ANSIC -D__STDC__
+./CWRU/old-conf/machines.h:# endif /* !__EXTENSIONS__ || __STDC__ */
+./CWRU/old-conf/machines.h:# define SYSDEP_CFLAGS -ma -U__STDC__
+./CWRU/old-conf/machines.h:# if defined (__STDC__)
+./CWRU/old-conf/machines.h:# endif /* __STDC__ */
+./CWRU/old-changelogs/CWRU.chlog.v11: - hpux_9 needs alloca declared as `extern void *' if __STDC__
+./CWRU/old-changelogs/CWRU.chlog.v11: if __STDC__ is defined and we're using stdarg
+./CWRU/old-changelogs/CWRU.chlog.v10: - add a __STDC__ definition for getpwnam() for isc386 machines
+./CWRU/old-changelogs/CWRU.chlog.v10: - correctly declare the second argument as a size_t if __STDC__
+./CWRU/old-changelogs/CWRU.chlog.v10: on whether __STDC__ is defined and > 0. The `stdc' version uses
+./CWRU/old-changelogs/CWRU.chlog.v10: - sgi needs __STDC__ defined if __EXTENSIONS__ is defined
+./CWRU/old-changelogs/CWRU.chlog.v10: - moved the #if defined (__P) inside the check for __STDC__, so
+./CWRU/old-changelogs/CWRU.chlog.v10: - if __STDC__ is defined but we're not using gcc (__GNUC__ not
+./CWRU/old-changelogs/CWRU.chlog.v10: - only test for and possibly define __STDC__ if __GNUC__ is not
+./CWRU/old-changelogs/CWRU.chlog.v10: - removed support for outputting -D__STDC__; it's rarely right
+./CWRU/old-changelogs/CHANGES.090393:__STDC__ is defined
+./CWRU/old-changelogs/CWRU.chlog.v12: - add prototypes for extern function declarations if __STDC__
+./CWRU/old-changelogs/CWRU.chlog.v12: - break the definition of __P out from a strict __STDC__ block,
+./CWRU/old-changelogs/CWRU.chlog.v12: as either `__const' (gcc -traditional) or nothing if __STDC__ and
+./CWRU/old-changelogs/CWRU.chlog.v13: use `void *' and prototype if __STDC__ is defined
+./CWRU/old-changelogs/CWRU.chlog.v13: - don't test __STDC__ when deciding whether or not to use stdarg.h;
+./CWRU/old-changelogs/CWRU.chlog.v13: - don't try to use \a and \v unless __STDC__ is defined; use the
+./CWRU/old-changelogs/CWRU.chlog.v9: __STDC__ is defined
+./CWRU/old-changelogs/CWRU.chlog.v9: - add extern declaration of strcpy if __STDC__ and strcpy not defined
+./CWRU/old-changelogs/CWRU.chlog.v9: ANSI C environment (__STDC__)
+./CWRU/old-changelogs/CWRU.chlog.v9: - recognize __GNUC__ and __STDC__ and pass them along as output
+./CWRU/old-changelogs/CWRU.chlog.v9: where __STDC__ is not defined and _POSIX_SOURCE is
+./CWRU/old/RELEASE.113:__STDC__ is defined
+./CWRU/CWRU.chlog~: - restrict: make sure we have a definition if __STDC__ is not defined
+./CWRU/CWRU.chlog~: - don't bother with __STDC__ if we are just using C89 features like
+./CWRU/CWRU.chlog: - restrict: make sure we have a definition if __STDC__ is not defined
+./CWRU/CWRU.chlog: - don't bother with __STDC__ if we are just using C89 features like
+./lib/intl/explodename.c:# if defined __STDC__ && __STDC__
+./lib/intl/gmo.h:#if __STDC__
+./lib/intl/gettextP.h:# if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus || __PROTOTYPES
+./lib/intl/loadinfo.h:# if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus || __PROTOTYPES
+./lib/intl/plural.c:# if defined (__STDC__) || defined (__cplusplus)
+./lib/intl/plural.c:#if defined (__STDC__) || defined (__cplusplus)
+./lib/intl/plural.c:# if defined (__STDC__) || defined (__cplusplus)
+./lib/intl/plural.c:#if defined (__STDC__) || defined (__cplusplus)
+./lib/intl/plural.c:#if defined (__STDC__) || defined (__cplusplus)
+./lib/intl/plural.c:# if defined (__STDC__) || defined (__cplusplus)
+./lib/intl/plural.c:# if defined (__STDC__) || defined (__cplusplus)
+./lib/intl/plural.c:#if defined (__STDC__) || defined (__cplusplus)
+./lib/intl/plural.c:#if defined (__STDC__) || defined (__cplusplus)
+./lib/intl/plural.c:# if defined (__STDC__) || defined (__cplusplus)
+./lib/intl/plural.c:#if defined (__STDC__) || defined (__cplusplus)
+./lib/intl/plural.c:# if defined (__STDC__) || defined (__cplusplus)
+./lib/intl/plural.c:#if defined (__STDC__) || defined (__cplusplus)
+./lib/intl/localcharset.c:#if __STDC__ != 1
+./lib/intl/l10nflist.c:# if defined __STDC__ && __STDC__
+./lib/intl/libgnuintl.h.in:# if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus || __PROTOTYPES
+./lib/intl/libgnuintl.h.in:# if __GNUC__ >= 2 && !defined __APPLE_CC__ && (defined __STDC__ || defined __cplusplus)
+./lib/readline/histlib.h~:# if !defined (strchr) && !defined (__STDC__)
+./lib/readline/histlib.h~:# endif /* !strchr && !__STDC__ */
+./lib/readline/rldefs.h~:#if !defined (strchr) && !defined (__STDC__)
+./lib/readline/rldefs.h~:#endif /* !strchr && !__STDC__ */
+./lib/readline/bind.c~:#if !defined (strchr) && !defined (__STDC__)
+./lib/readline/bind.c~:#endif /* !strchr && !__STDC__ */
+./lib/readline/parens.c:#if !defined (strchr) && !defined (__STDC__)
+./lib/readline/parens.c:#endif /* !strchr && !__STDC__ */
+./lib/readline/complete.c~:#ifdef __STDC__
+./lib/readline/rlstdc.h:# if defined (__STDC__) || defined (__GNUC__) || defined (__cplusplus)
+./lib/readline/display.c~:#if !defined (strchr) && !defined (__STDC__)
+./lib/readline/display.c~:#endif /* !strchr && !__STDC__ */
+./lib/readline/rlstdc.h~:# if defined (__STDC__) || defined (__GNUC__) || defined (__cplusplus)
+./lib/readline/rlstdc.h~:#if defined (__STDC__) && defined (HAVE_STDARG_H)
+./lib/readline/funmap.c~:#ifdef __STDC__
+./lib/sh/vprint.c:# if defined (__STDC__)
+./lib/sh/vprint.c:# endif /* __STDC__ */
+./lib/termcap/grot/ChangeLog: * termcap.h [__STDC__]: Add consts. From Franc,ois Pinard.
+./lib/malloc/OLD/ogmalloc.c:#if defined (__GNU_LIBRARY__) || (defined (__STDC__) && __STDC__)
+./lib/malloc/OLD/ogmalloc.c:#if defined (__cplusplus) || (defined (__STDC__) && __STDC__)
+./lib/malloc/OLD/ogmalloc.c:#if defined (__STDC__) && __STDC__
+./lib/malloc/OLD/omalloc.c:# if defined (__STDC__)
+./lib/malloc/OLD/omalloc.c:#if defined (__STDC__)
+./lib/malloc/OLD/gmalloc.c:#if __STDC__
+./lib/malloc/OLD/gmalloc.c:#endif /* !__STDC__ */
+./lib/malloc/OLD/old-nmalloc.c:# if defined (__STDC__)
+./lib/malloc/OLD/old-nmalloc.c:#if defined (__STDC__)
+./lib/malloc/shmalloc.h~:#if defined (__STDC__)
+./lib/malloc/alloca.c~:#if __STDC__
+./lib/malloc/imalloc.h~:# if defined (__STDC__)
+./lib/malloc/imalloc.h~:# if defined (__STDC__) || defined (__GNUC__) || defined (__cplusplus) || defined (PROTOTYPES)
+./lib/malloc/xmalloc.c~:#if defined (__STDC__)
+./m4/iconv.m4~:#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus)
+./m4/extern-inline.m4: && !(defined __SUNPRO_C && __STDC__))) \
+./aclocal.m4~:#ifdef __STDC__
+./general.h~:#ifdef __STDC__
+./aclocal.m4:#ifdef __STDC__
#endif /* !__GNUC__ */
/* String comparisons that possibly save a function call each. */
-#define STREQ(a, b) ((a)[0] == (b)[0] && strcmp(a, b) == 0)
-#define STREQN(a, b, n) ((n == 0) ? (1) \
- : ((a)[0] == (b)[0] && strncmp(a, b, n) == 0))
+static inline int
+STREQ(const char *a, const char *b)
+{
+ return ((a)[0] == (b)[0] && strcmp(a, b) == 0);
+}
+
+static inline int
+STREQN(const char *a, const char *b, size_t n)
+{
+ return ((n == 0) || ((a)[0] == (b)[0] && strncmp(a, b, n) == 0));
+}
/* More convenience definitions that possibly save system or libc calls. */
#define STRLEN(s) (((s) && (s)[0]) ? ((s)[1] ? ((s)[2] ? strlen(s) : 2) : 1) : 0)
} \
} while (0)
-/* Function pointers can be declared as (Function *)foo. */
-#if !defined (_FUNCTION_DEF)
-# define _FUNCTION_DEF
-typedef int Function ();
-typedef void VFunction ();
-typedef char *CPFunction (); /* no longer used */
-typedef char **CPPFunction (); /* no longer used */
-#endif /* _FUNCTION_DEF */
-
#ifndef SH_FUNCTION_TYPEDEF
# define SH_FUNCTION_TYPEDEF
in reverse order of adding. We don't want maybe_set_sigchld_trap ()
to reference freed memory. */
add_unwind_protect (xfree, trap_command);
- add_unwind_protect (maybe_set_sigchld_trap, trap_command);
+ add_unwind_protect (uw_maybe_set_sigchld_trap, trap_command);
subst_assign_varlist = (WORD_LIST *)NULL;
the_pipeline = (PROCESS *)NULL;
#define ADD_CHAR(c) \
do \
{ \
- if (j >= result_len - 1) \
+ if ((j + 1) >= result_len) \
result = (char *)xrealloc (result, result_len += 64); \
result[j++] = c; \
result[j] = '\0'; \
if (_rl_utf8locale && UTF8_SINGLEBYTE(buf[ind]))
return ((WCHAR_T) buf[ind]);
l = strlen (buf);
- if (ind >= l - 1)
+ if (ind + 1 >= l)
return ((WCHAR_T) buf[ind]);
if (l < ind) /* Sanity check */
l = strlen (buf+ind);
#if !defined (_FUNCTION_DEF)
# define _FUNCTION_DEF
-#if defined(__GNUC__) || defined(__clang__)
typedef int Function () __attribute__((deprecated));
typedef void VFunction () __attribute__((deprecated));
typedef char *CPFunction () __attribute__((deprecated));
typedef char **CPPFunction () __attribute__((deprecated));
-#else
-typedef int Function ();
-typedef void VFunction ();
-typedef char *CPFunction ();
-typedef char **CPPFunction ();
-#endif
#endif /* _FUNCTION_DEF */
static SHELL_VAR *bind_comp_words (WORD_LIST *);
#endif
static void bind_compfunc_variables (char *, int, WORD_LIST *, int, int);
-static void unbind_compfunc_variables (int);
+static void unbind_compfunc_variables (void *); /* XXX uw_ */
static WORD_LIST *build_arg_list (const char *, const char *, const char *, WORD_LIST *, int);
static WORD_LIST *command_line_to_word_list (char *, int, int, int *, int *);
}
static void
-unbind_compfunc_variables (int exported)
+unbind_compfunc_variables (void *exported)
{
unbind_variable_noref ("COMP_LINE");
unbind_variable_noref ("COMP_POINT");
return ret;
}
+static void
+uw_restore_parser_state (void *ps)
+{
+ restore_parser_state (ps);
+}
+
+static void
+uw_rl_set_signals (void *ignore)
+{
+ rl_set_signals ();
+}
+
/* Build a command string with
$0 == cs->funcname (function to execute for completion list)
$1 == command name (command being completed)
pps = &ps;
save_parser_state (pps);
begin_unwind_frame ("gen-shell-function-matches");
- add_unwind_protect (restore_parser_state, (char *)pps);
- add_unwind_protect (dispose_words, (char *)cmdlist);
- add_unwind_protect (unbind_compfunc_variables, (char *)0);
+ add_unwind_protect (uw_restore_parser_state, pps);
+ add_unwind_protect (uw_dispose_words, cmdlist);
+ add_unwind_protect (unbind_compfunc_variables, NULL);
if (local_compgen == 0)
{
- add_unwind_protect (rl_set_signals, (char *)NULL);
+ add_unwind_protect (uw_rl_set_signals, (char *)NULL);
rl_clear_signals ();
}
/* Now clean up and destroy everything. */
dispose_words (cmdlist);
free (cscmd);
- unbind_compfunc_variables (1);
+ unbind_compfunc_variables ("");
if (csbuf == 0 || *csbuf == '\0')
{
we++;
}
t = substring (csbuf, ws, we);
- if (sl->list_len >= sl->list_size - 1)
+ if (sl->list_len + 1 >= sl->list_size)
strlist_resize (sl, sl->list_size + 16);
sl->list[sl->list_len++] = t;
while (csbuf[we] == '\n') we++;
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 uw_reset_locals (void *);
+
static void newline (char *);
static void indent (int);
static void semicolon (void);
#endif
static void print_function_def (FUNCTION_DEF *);
+#ifdef DEBUG
+void debug_print_word_list (char *, WORD_LIST *, char *);
+void debug_print_cond_command (COND_COM *);
+#endif
+
#define PRINTED_COMMAND_INITIAL_SIZE 64
#define PRINTED_COMMAND_GROW_SIZE 128
}
static void
-reset_locals (void)
+uw_reset_locals (void *ignore)
{
inside_function_def = 0;
indentation = 0;
cprintf ("%s () \n", func->name->word);
begin_unwind_frame ("function-def");
- add_unwind_protect (reset_locals, 0);
+ add_unwind_protect (uw_reset_locals, 0);
indent (indentation);
cprintf ("{ \n"); /* } */
size_t n, srclen;
srclen = STRLEN (source);
- if (srclen >= (*size - *indx))
+ if ((srclen + *indx) >= *size)
{
n = srclen + *indx;
n = (n + DEFAULT_ARRAY_SIZE) - (n % DEFAULT_ARRAY_SIZE);
static int nfds;
static int totfds; /* The highest possible number of open files. */
-void
+static void
clear_fifo (int i)
{
if (dev_fd_list[i])
begin_unwind_frame ("read-comsub");
dummyfd = fildes[0];
- add_unwind_protect (close, dummyfd);
+ add_unwind_protect (uw_close, (void *) (intptr_t) dummyfd);
/* Block SIGINT while we're reading from the pipe. If the child
process gets a SIGINT, it will either handle it or die, and the
at
star
declare -A a=(["@"]="at" )
-./assoc13.sub: line 22: ia[@]: bad array subscript
+./assoc13.sub: line 35: ia[@]: bad array subscript
declare -a ia
declare -A a=(["@"]="at2" )
declare -A a=(["@"]=" string" )
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# assignment to @ and *
declare -A assoc
declare -p a
unset a
-
reset the disposition to the default and not have the original signal
accidentally restored, undoing the user's command. */
void
-maybe_set_sigchld_trap (const char *command_string)
+uw_maybe_set_sigchld_trap (void *command_string)
{
if ((sigmodes[SIGCHLD] & SIG_TRAPPED) == 0 && trap_list[SIGCHLD] == (char *)IMPOSSIBLE_TRAP_HANDLER)
- set_signal (SIGCHLD, command_string);
+ set_signal (SIGCHLD, (const char *)command_string);
}
/* Temporarily set the SIGCHLD trap string to IMPOSSIBLE_TRAP_HANDLER. Used
{
restore_default_signal (SIGCHLD);
change_signal (SIGCHLD, (char *)IMPOSSIBLE_TRAP_HANDLER);
- sigmodes[SIGCHLD] &= ~SIG_TRAPPED; /* maybe_set_sigchld_trap checks this */
+ sigmodes[SIGCHLD] &= ~SIG_TRAPPED; /* uw_maybe_set_sigchld_trap checks this */
}
/* Act as if we received SIGCHLD NCHILD times and increment
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 (const char *command)
+uw_maybe_set_debug_trap (void *command)
{
trap_if_untrapped (DEBUG_TRAP, command);
}
}
void
-maybe_set_error_trap (const char *command)
+uw_set_error_trap (void *command)
+{
+ set_error_trap (command);
+}
+
+void
+uw_maybe_set_error_trap (void *command)
{
trap_if_untrapped (ERROR_TRAP, command);
}
}
void
-maybe_set_return_trap (const char *command)
+uw_maybe_set_return_trap (void *command)
{
trap_if_untrapped (RETURN_TRAP, command);
}
extern void run_pending_traps (void);
extern void queue_sigchld_trap (int);
-extern void maybe_set_sigchld_trap (const char *);
extern void set_impossible_sigchld_trap (void);
extern void set_sigchld_trap (const char *);
extern void set_error_trap (const char *);
extern void set_return_trap (const char *);
-extern void maybe_set_debug_trap (const char *);
-extern void maybe_set_error_trap (const char *);
-extern void maybe_set_return_trap (const char *);
+extern void uw_set_error_trap (void *);
+extern void uw_maybe_set_sigchld_trap (void *);
+extern void uw_maybe_set_debug_trap (void *);
+extern void uw_maybe_set_error_trap (void *);
+extern void uw_maybe_set_return_trap (void *);
extern void set_sigint_trap (const char *);
extern void set_signal (int, const char *);
typedef union uwp {
struct uwp_head {
union uwp *next;
- Function *cleanup;
+ sh_uwfunc_t *cleanup;
} head;
struct {
struct uwp_head uwp_head;
- char *v;
+ void *v;
} arg;
struct {
struct uwp_head uwp_head;
static void unwind_frame_discard_internal (char *);
static void unwind_frame_run_internal (char *);
-static void add_unwind_protect_internal (Function *, char *);
+static void add_unwind_protect_internal (sh_uwfunc_t *, void *);
static void remove_unwind_protect_internal (void);
static void run_unwind_protects_internal (void);
static void clear_unwind_protects_internal (int);
-static inline void restore_variable (SAVED_VAR *);
-static void unwind_protect_mem_internal (char *, char *);
+static inline void restore_variable (void *);
+static void unwind_protect_mem_internal (void *, int);
static UNWIND_ELT *unwind_protect_list = (UNWIND_ELT *)NULL;
/* Add the function CLEANUP with ARG to the list of unwindable things. */
void
-add_unwind_protect (Function *cleanup, char *arg)
+add_unwind_protect (sh_uwfunc_t *cleanup, void *arg)
{
add_unwind_protect_internal (cleanup, arg);
}
/* **************************************************************** */
static void
-add_unwind_protect_internal (Function *cleanup, char *arg)
+add_unwind_protect_internal (sh_uwfunc_t *cleanup, void *arg)
{
UNWIND_ELT *elt;
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 (SAVED_VAR *sv)
+restore_variable (void *arg)
{
+ SAVED_VAR *sv;
+ sv = arg;
FASTCOPY (sv->desired_setting, sv->variable, sv->size);
}
}
else
{
- if (elt->head.cleanup == (Function *) restore_variable)
+ if (elt->head.cleanup == restore_variable)
restore_variable (&elt->sv.v);
else
(*(elt->head.cleanup)) (elt->arg.v);
}
static void
-unwind_protect_mem_internal (char *var, char *psize)
+unwind_protect_mem_internal (void *var, int size)
{
- int size;
size_t allocated;
UNWIND_ELT *elt;
- size = *(int *) psize;
allocated = size + offsetof (UNWIND_ELT, sv.v.desired_setting[0]);
if (allocated < sizeof (UNWIND_ELT))
allocated = sizeof (UNWIND_ELT);
elt = (UNWIND_ELT *)xmalloc (allocated);
elt->head.next = unwind_protect_list;
- elt->head.cleanup = (Function *) restore_variable;
+ elt->head.cleanup = restore_variable;
elt->sv.v.variable = var;
elt->sv.v.size = size;
FASTCOPY (var, elt->sv.v.desired_setting, size);
void
unwind_protect_mem (char *var, int size)
{
- unwind_protect_mem_internal (var, (char *) &size);
+ unwind_protect_mem_internal (var, size);
}
#if defined (DEBUG)
while (elt)
{
if (elt->head.cleanup == 0)
- fprintf(stderr, "tag: %s\n", elt->arg.v);
+ fprintf(stderr, "tag: %s\n", (char *)elt->arg.v);
elt = elt->head.next;
}
}
extern void begin_unwind_frame (char *);
extern void discard_unwind_frame (char *);
extern void run_unwind_frame (char *);
-extern void add_unwind_protect (); /* Not portable to arbitrary C99 hosts. */
+extern void add_unwind_protect (sh_uwfunc_t *, void *);
extern void remove_unwind_protect (void);
extern void run_unwind_protects (void);
extern void clear_unwind_protect_list (int);
variables in its temporary environment. In the first case, we call
push_builtin_var, which does the right thing. */
void
-pop_scope (int is_special)
+pop_scope (void *is_special)
{
VAR_CONTEXT *vcxt, *ret;
int is_bltinenv;
FREE (vcxt->name);
if (vcxt->table)
{
- if (is_special)
+ if ((intptr_t) is_special)
hash_flush (vcxt->table, push_builtin_var);
else
hash_flush (vcxt->table, push_exported_var);
/* 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 (void)
+pop_context (void *ignore)
{
pop_dollar_vars ();
variable_context--;
#endif /* ARRAY_VARS && DEBUGGER */
}
+void
+uw_pop_args (void *ignore)
+{
+ pop_args ();
+}
+
/*************************************************
* *
* Functions to manage special variables *
extern VAR_CONTEXT *push_var_context (char *, int, HASH_TABLE *);
extern void pop_var_context (void);
extern VAR_CONTEXT *push_scope (int, HASH_TABLE *);
-extern void pop_scope (int);
+extern void pop_scope (void *); /* XXX uw_ */
extern void clear_dollar_vars (void);
extern void push_context (char *, int, HASH_TABLE *);
-extern void pop_context (void);
+extern void pop_context (void *); /* XXX uw_ */
extern void push_dollar_vars (void);
extern void pop_dollar_vars (void);
extern void dispose_saved_dollar_vars (void);
extern void save_bash_argv (void);
extern void push_args (WORD_LIST *);
extern void pop_args (void);
+extern void uw_pop_args (void *);
extern void adjust_shell_level (int);
extern void non_unsettable (char *);
extern void dispose_function_env (void);
extern void dispose_builtin_env (void);
extern void merge_temporary_env (void);
+extern void merge_function_temporary_env (void);
extern void flush_temporary_env (void);
extern void merge_builtin_env (void);
extern void kill_all_local_variables (void);