primarily for making function definitions, but I'm not sure
that anyone else will need it. */
-/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
#include "shell.h"
-static PATTERN_LIST *copy_case_clause __P((PATTERN_LIST *));
-static PATTERN_LIST *copy_case_clauses __P((PATTERN_LIST *));
-static FOR_COM *copy_for_command __P((FOR_COM *));
+static PATTERN_LIST *copy_case_clause PARAMS((PATTERN_LIST *));
+static PATTERN_LIST *copy_case_clauses PARAMS((PATTERN_LIST *));
+static FOR_COM *copy_for_command PARAMS((FOR_COM *));
#if defined (ARITH_FOR_COMMAND)
-static ARITH_FOR_COM *copy_arith_for_command __P((ARITH_FOR_COM *));
+static ARITH_FOR_COM *copy_arith_for_command PARAMS((ARITH_FOR_COM *));
#endif
-static GROUP_COM *copy_group_command __P((GROUP_COM *));
-static SUBSHELL_COM *copy_subshell_command __P((SUBSHELL_COM *));
-static COPROC_COM *copy_coproc_command __P((COPROC_COM *));
-static CASE_COM *copy_case_command __P((CASE_COM *));
-static WHILE_COM *copy_while_command __P((WHILE_COM *));
-static IF_COM *copy_if_command __P((IF_COM *));
+static GROUP_COM *copy_group_command PARAMS((GROUP_COM *));
+static SUBSHELL_COM *copy_subshell_command PARAMS((SUBSHELL_COM *));
+static COPROC_COM *copy_coproc_command PARAMS((COPROC_COM *));
+static CASE_COM *copy_case_command PARAMS((CASE_COM *));
+static WHILE_COM *copy_while_command PARAMS((WHILE_COM *));
+static IF_COM *copy_if_command PARAMS((IF_COM *));
#if defined (DPAREN_ARITHMETIC)
-static ARITH_COM *copy_arith_command __P((ARITH_COM *));
+static ARITH_COM *copy_arith_command PARAMS((ARITH_COM *));
#endif
#if defined (COND_COMMAND)
-static COND_COM *copy_cond_command __P((COND_COM *));
+static COND_COM *copy_cond_command PARAMS((COND_COM *));
#endif
-static SIMPLE_COM *copy_simple_command __P((SIMPLE_COM *));
+static SIMPLE_COM *copy_simple_command PARAMS((SIMPLE_COM *));
WORD_DESC *
copy_word (w)
copy_word_list (list)
WORD_LIST *list;
{
- WORD_LIST *new_list;
+ WORD_LIST *new_list, *tl;
- for (new_list = (WORD_LIST *)NULL; list; list = list->next)
- new_list = make_word_list (copy_word (list->word), new_list);
+ for (new_list = tl = (WORD_LIST *)NULL; list; list = list->next)
+ {
+ if (new_list == 0)
+ new_list = tl = make_word_list (copy_word (list->word), new_list);
+ else
+ {
+ tl->next = make_word_list (copy_word (list->word), (WORD_LIST *)NULL);
+ tl = tl->next;
+ }
+ }
- return (REVERSE_LIST (new_list, WORD_LIST *));
+ return (new_list);
}
static PATTERN_LIST *
REDIRECT *new_redirect;
new_redirect = (REDIRECT *)xmalloc (sizeof (REDIRECT));
+#if 0
FASTCOPY ((char *)redirect, (char *)new_redirect, (sizeof (REDIRECT)));
+#else
+ *new_redirect = *redirect; /* let the compiler do the fast structure copy */
+#endif
+
+ if (redirect->rflags & REDIR_VARASSIGN)
+ new_redirect->redirector.filename = copy_word (redirect->redirector.filename);
+
switch (redirect->instruction)
{
case r_reading_until:
case r_deblank_reading_until:
- new_redirect->here_doc_eof = savestring (redirect->here_doc_eof);
+ new_redirect->here_doc_eof = redirect->here_doc_eof ? savestring (redirect->here_doc_eof) : 0;
/*FALLTHROUGH*/
case r_reading_string:
case r_appending_to:
new_subshell = (SUBSHELL_COM *)xmalloc (sizeof (SUBSHELL_COM));
new_subshell->command = copy_command (com->command);
new_subshell->flags = com->flags;
+ new_subshell->line = com->line;
return (new_subshell);
}