]> git.ipfire.org Git - thirdparty/bash.git/blobdiff - copy_cmd.c
Bash-5.2 patch 26: fix typo when specifying readline's custom color prefix
[thirdparty/bash.git] / copy_cmd.c
index 911d34f3daf1718cc6595fe98294024b729396e0..758ff238a111a8db9ab3ffe902c0eabd11c72766 100644 (file)
@@ -2,7 +2,7 @@
    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)
@@ -69,12 +69,20 @@ WORD_LIST *
 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 *
@@ -126,7 +134,7 @@ copy_redirect (redirect)
     {
     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:
@@ -221,6 +229,7 @@ copy_subshell_command (com)
   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);
 }