]> git.ipfire.org Git - thirdparty/bash.git/blobdiff - copy_cmd.c
Imported from ../bash-2.04.tar.gz.
[thirdparty/bash.git] / copy_cmd.c
index e28e6f079decf3e7db257655ceceb0bc55aad9b9..964a3e772a22b9553768f2f87a48bc36e112ef1d 100644 (file)
@@ -8,7 +8,7 @@
 
    Bash 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 1, or (at your option)
+   the Free Software Foundation; either version 2, or (at your option)
    any later version.
 
    Bash is distributed in the hope that it will be useful, but WITHOUT
@@ -18,7 +18,7 @@
 
    You should have received a copy of the GNU General Public License
    along with Bash; see the file COPYING.  If not, write to the Free
-   Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+   Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 
 #include "config.h"
 
@@ -152,6 +152,24 @@ copy_for_command (com)
   return (new_for);
 }
 
+#if defined (ARITH_FOR_COMMAND)
+static ARITH_FOR_COM *
+copy_arith_for_command (com)
+     ARITH_FOR_COM *com;
+{
+  ARITH_FOR_COM *new_arith_for;
+
+  new_arith_for = (ARITH_FOR_COM *)xmalloc (sizeof (ARITH_FOR_COM));
+  new_arith_for->flags = com->flags;
+  new_arith_for->line = com->line;
+  new_arith_for->init = copy_word_list (com->init);
+  new_arith_for->test = copy_word_list (com->test);
+  new_arith_for->step = copy_word_list (com->step);
+  new_arith_for->action = copy_command (com->action);
+  return (new_arith_for);
+}
+#endif /* ARITH_FOR_COMMAND */
+
 static GROUP_COM *
 copy_group_command (com)
      GROUP_COM *com;
@@ -163,6 +181,18 @@ copy_group_command (com)
   return (new_group);
 }
 
+static SUBSHELL_COM *
+copy_subshell_command (com)
+     SUBSHELL_COM *com;
+{
+  SUBSHELL_COM *new_subshell;
+
+  new_subshell = (SUBSHELL_COM *)xmalloc (sizeof (SUBSHELL_COM));
+  new_subshell->command = copy_command (com->command);
+  new_subshell->flags = com->flags;
+  return (new_subshell);
+}
+
 static CASE_COM *
 copy_case_command (com)
      CASE_COM *com;
@@ -229,7 +259,8 @@ copy_cond_command (com)
   new_cond = (COND_COM *)xmalloc (sizeof (COND_COM));
   new_cond->flags = com->flags;
   new_cond->line = com->line;
-  new_cond->op = copy_word (com->op);
+  new_cond->type = com->type;
+  new_cond->op = com->op ? copy_word (com->op) : com->op;
   new_cond->left = com->left ? copy_cond_command (com->left) : (COND_COM *)NULL;
   new_cond->right = com->right ? copy_cond_command (com->right) : (COND_COM *)NULL;
 
@@ -289,6 +320,12 @@ copy_command (command)
        new_command->value.For = copy_for_command (command->value.For);
        break;
 
+#if defined (ARITH_FOR_COMMAND)
+      case cm_arith_for:
+       new_command->value.ArithFor = copy_arith_for_command (command->value.ArithFor);
+       break;
+#endif
+
 #if defined (SELECT_COMMAND)
       case cm_select:
        new_command->value.Select =
@@ -300,6 +337,10 @@ copy_command (command)
        new_command->value.Group = copy_group_command (command->value.Group);
        break;
 
+      case cm_subshell:
+        new_command->value.Subshell = copy_subshell_command (command->value.Subshell);
+        break;
+
       case cm_case:
        new_command->value.Case = copy_case_command (command->value.Case);
        break;