42-archive/42sh/src/exec/exec_case_branch.c
2017-03-23 00:27:53 +01:00

33 lines
1.3 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* exec_case_branch.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 20:33:45 by wescande #+# #+# */
/* Updated: 2017/03/22 22:10:26 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int exec_case_branch(t_btree **ast)
{
t_astnode *node;
char **av;
t_exec *exec;
exec = &data_singleton()->exec;
if (EXEC_IS_CASE_BRANCH(exec->attrs))
return (0);
node = (*ast)->item;
av = token_to_argv(node->data.cmd.token, 1);
if (av && (ft_strcmp(av[0], ((char **)exec->case_pattern)[0]) == 0))
{
exec->attrs |= EXEC_CASE_BRANCH;
ft_exec(&(*ast)->right);
}
ft_tabdel(&av);
return (0);
}