along with Bash; see the file COPYING. If not, write to the Free
Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+#include "config.h"
+
+#if defined (HAVE_UNISTD_H)
+# include <unistd.h>
+#endif
+
+#include "bashansi.h"
#include "shell.h"
/* Dispose of the command structure passed. */
dispose_command (command)
COMMAND *command;
{
- if (!command) return;
+ if (command == 0)
+ return;
if (command->redirects)
dispose_redirects (command->redirects);
switch (command->type)
{
case cm_for:
- {
- register FOR_COM *c = command->value.For;
- dispose_word (c->name);
- dispose_words (c->map_list);
- dispose_command (c->action);
- free (c);
- break;
- }
-
#if defined (SELECT_COMMAND)
case cm_select:
+#endif
{
- register SELECT_COM *c = command->value.Select;
+ register FOR_COM *c;
+#if defined (SELECT_COMMAND)
+ if (command->type == cm_select)
+ c = (FOR_COM *)command->value.Select;
+ else
+#endif
+ c = command->value.For;
dispose_word (c->name);
dispose_words (c->map_list);
dispose_command (c->action);
free (c);
break;
}
-#endif
-
+
case cm_group:
{
dispose_command (command->value.Group->command);
case cm_case:
{
- register CASE_COM *c = command->value.Case;
- PATTERN_LIST *t, *p = c->clauses;
+ register CASE_COM *c;
+ PATTERN_LIST *t, *p;
+ c = command->value.Case;
dispose_word (c->word);
- while (p)
+ for (p = c->clauses; p; )
{
dispose_words (p->patterns);
dispose_command (p->action);
case cm_until:
case cm_while:
{
- register WHILE_COM *c = command->value.While;
+ register WHILE_COM *c;
+ c = command->value.While;
dispose_command (c->test);
dispose_command (c->action);
free (c);
case cm_if:
{
- register IF_COM *c = command->value.If;
+ register IF_COM *c;
+
+ c = command->value.If;
dispose_command (c->test);
dispose_command (c->true_case);
dispose_command (c->false_case);
case cm_simple:
{
- register SIMPLE_COM *c = command->value.Simple;
+ register SIMPLE_COM *c;
+
+ c = command->value.Simple;
dispose_words (c->words);
dispose_redirects (c->redirects);
free (c);
case cm_connection:
{
- register CONNECTION *c = command->value.Connection;
+ register CONNECTION *c;
+
+ c = command->value.Connection;
dispose_command (c->first);
dispose_command (c->second);
free (c);
case cm_function_def:
{
- register FUNCTION_DEF *c = command->value.Function_def;
+ register FUNCTION_DEF *c;
+
+ c = command->value.Function_def;
dispose_word (c->name);
dispose_command (c->command);
free (c);
}
default:
- report_error ("Attempt to free unknown command type `%d'.\n", command->type);
+ programming_error ("dispose_command: bad command type `%d'", command->type);
break;
}
free (command);
dispose_word (word)
WORD_DESC *word;
{
- if (word->word)
- free (word->word);
+ FREE (word->word);
free (word);
}
WORD_LIST *list;
{
WORD_LIST *t;
+
while (list)
{
t = list;
case r_reading_until:
case r_deblank_reading_until:
free (t->here_doc_eof);
- /* ... */
+ /*FALLTHROUGH*/
case r_output_direction:
case r_input_direction:
case r_inputa_direction:
case r_duplicating_input_word:
case r_duplicating_output_word:
dispose_word (t->redirectee.filename);
+ /* FALLTHROUGH */
+ default:
break;
}
free (t);