Commit b23cfe55 authored by pêle-mêle's avatar pêle-mêle
Browse files

parsing of vars: one more fix

parent 595eaa04
......@@ -137,6 +137,7 @@ char *letter(t_state_machine *machine, char *line)
if (add_arg(machine) == FAILURE)
return (NULL);
machine->cur_token_stack = &machine->args;
machine->var_state = FALSE;
machine->state = SPACE;
}
else
......@@ -174,6 +175,7 @@ int parse_input(char **line, char **env, int stat_loc, t_command *command)
if (*line == NULL)
break ;
}
free(machine.cur_arg);
command->pipe_flag = machine.pipe_flag;
command->redir_paths = machine.redir_paths;
command->redir_types = machine.redir_types;
......
......@@ -139,14 +139,16 @@ int add_arg(t_state_machine *machine)
if (reset_buf(machine) == FAILURE)
return (FAILURE);
if (machine->var_state == FALSE || machine->cur_arg[0] != '\0')
*machine->cur_token_stack = push_str_to_array(*machine->cur_token_stack, machine->cur_arg);
machine->var_state = FALSE;
if (*machine->cur_token_stack == NULL)
{
free(machine->cur_arg);
return (FAILURE);
*machine->cur_token_stack = push_str_to_array(*machine->cur_token_stack,
machine->cur_arg);
if (*machine->cur_token_stack == NULL)
{
free(machine->cur_arg);
return (FAILURE);
}
machine->cur_arg = NULL;
}
machine->cur_arg = NULL;
return (SUCCESS);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment