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

ambig redirs

parent a3a6cca2
......@@ -54,8 +54,7 @@ typedef struct s_state_machine
int stat_loc;
t_byte pipe_flag;
t_byte var_state;
t_byte ambig_redir;
uint8_t pad[5];
uint8_t pad[6];
} t_state_machine;
typedef char *(*t_parse)(t_state_machine *, char *);
......
......@@ -36,7 +36,10 @@ static int get_input(char **line)
else if (ret == 0) // EOF in files and heredocs (noeol files not yet supported)
{
if (ft_strcmp(*line, "") == 0)
{
free(*line);
return (CLEAN_EXIT);
}
else
return (handle_eof(line, ret));
}
......@@ -49,13 +52,16 @@ static int main_loop(t_xe *xe)
char *line;
ret = get_input(&line);
xe->line = line;
if (ret == SUCCESS)
{
if ((ret = check_syntax(line)) != SUCCESS)
xe->line = line;
ret = check_syntax(line);
if (ret != SUCCESS)
{
free(line);
return (ft_error(ret, xe));
}
ret = handle_execution(xe, STDIN_FILENO, 0);
//printf("ret = %d\n", ret);
free(line);
if (ret != SUCCESS)
return (ft_error(ret, xe));
......
......@@ -175,7 +175,7 @@ int parse_input(char **line, char **env, int stat_loc, t_command *command)
command->args = machine.args;
if (*line == NULL)
{
if (machine.ambig_redir == TRUE)
if (machine.redir_types[0] == TRUE)
return (AMBIG_REDIR);
return (FAILURE);
}
......@@ -208,7 +208,5 @@ t_command *parse_one_command(t_xe *xe)
free_command(cur_command); // et args, redir_paths et types
return (NULL);
}
else if (ret == AMBIG_REDIR)
cur_command->redir_types[0] = AMBIG;
return (cur_command);
}
......@@ -103,7 +103,7 @@ char *parse_variable(t_state_machine *machine, char *line)
{
if (machine->cur_token_stack == &machine->redir_paths)
{
machine->ambig_redir = TRUE;
machine->redir_types[0] = AMBIG;
free(var_value);
return (NULL);
}
......@@ -122,7 +122,7 @@ char *parse_variable(t_state_machine *machine, char *line)
{
if (machine->cur_token_stack == &machine->redir_paths)
{
machine->ambig_redir = TRUE;
machine->redir_types[0] = AMBIG;
free(var_value);
return (NULL);
}
......@@ -163,7 +163,7 @@ int add_arg(t_state_machine *machine)
}
else if (machine->cur_token_stack == &machine->redir_paths)
{
machine->ambig_redir = TRUE;
machine->redir_types[0] = AMBIG;
free(machine->cur_arg);
machine->cur_arg = NULL;
return (FAILURE);
......
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