mise en commentaire du nestage par l'env + ajout du ft_tabdel pour ne plus leaks au niveau des func
This commit is contained in:
parent
af0f345afc
commit
704f5e6ad7
3 changed files with 16 additions and 14 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/08 03:23:59 by wescande #+# #+# */
|
/* Created: 2017/03/08 03:23:59 by wescande #+# #+# */
|
||||||
/* Updated: 2017/03/23 03:15:20 by ariard ### ########.fr */
|
/* Updated: 2017/03/23 06:19:00 by wescande ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -18,22 +18,23 @@
|
||||||
int plaunch_function(t_process *p)
|
int plaunch_function(t_process *p)
|
||||||
{
|
{
|
||||||
static int protection= 0;
|
static int protection= 0;
|
||||||
|
/* char *val; */
|
||||||
|
|
||||||
if (ft_atoi(ft_getenv(data_singleton()->env, "FUNC_LVL")) > 10)
|
/* if (ft_atoi(ft_getenv(data_singleton()->env, "FUNC_LVL")) > FUNC_LVL) */
|
||||||
return(SH_ERR(FUNCERR_0));
|
/* return(SH_ERR(FUNCERR_0)); */
|
||||||
|
|
||||||
if (protection >= FUNC_LVL)
|
if (protection >= FUNC_LVL)
|
||||||
return(SH_ERR(FUNCERR_0));
|
return(SH_ERR(FUNCERR_0));
|
||||||
protection++;
|
protection++;
|
||||||
|
|
||||||
// jack faut qu on parle
|
// jack faut qu on parle
|
||||||
builtin_setenv("setenv", (char *[]){"env", "FUNC_LVL",
|
/* val = ft_itoa(ft_atoi(ft_getenv(data_singleton()->env, "FUNC_LVL")) + 1); */
|
||||||
ft_itoa(ft_atoi(ft_getenv(data_singleton()->env, "FUNC_LVL")) + 1),
|
/* builtin_setenv("setenv", (char *[]){"env", "FUNC_LVL", val, NULL}, NULL); */
|
||||||
NULL}, NULL);
|
/* ft_strdel(&val); */
|
||||||
ft_exec(&p->data.function.content);
|
ft_exec(&p->data.function.content);
|
||||||
builtin_setenv("setenv", (char *[]){"env", "FUNC_LVL",
|
/* val = ft_itoa(ft_atoi(ft_getenv(data_singleton()->env, "FUNC_LVL")) - 1); */
|
||||||
ft_itoa(ft_atoi(ft_getenv(data_singleton()->env, "FUNC_LVL")) - 1),
|
/* builtin_setenv("setenv", (char *[]){"env", "FUNC_LVL", val, NULL}, NULL); */
|
||||||
NULL}, NULL);
|
/* ft_strdel(&val); */
|
||||||
protection--;
|
protection--;
|
||||||
return (ft_atoi(ft_getenv(data_singleton()->env, "?")));
|
return (ft_atoi(ft_getenv(data_singleton()->env, "?")));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/20 12:41:54 by jhalford #+# #+# */
|
/* Created: 2017/03/20 12:41:54 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/21 21:10:58 by ariard ### ########.fr */
|
/* Updated: 2017/03/23 06:29:11 by wescande ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -21,6 +21,7 @@ int pset_cmd(t_process *p, t_btree *ast)
|
||||||
return ((p->type = PROCESS_EMPTY) ? 0 : 0);
|
return ((p->type = PROCESS_EMPTY) ? 0 : 0);
|
||||||
if ((func = is_function(p)))
|
if ((func = is_function(p)))
|
||||||
{
|
{
|
||||||
|
ft_tabdel(&p->data.cmd.av);
|
||||||
p->data.function.content = func;
|
p->data.function.content = func;
|
||||||
p->type = PROCESS_FUNCTION;
|
p->type = PROCESS_FUNCTION;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */
|
/* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/23 03:16:08 by ariard ### ########.fr */
|
/* Updated: 2017/03/23 06:19:27 by wescande ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -66,9 +66,9 @@ int data_init(int ac, char **av)
|
||||||
data->lst_func = NULL;
|
data->lst_func = NULL;
|
||||||
lexer_init(&data->lexer);
|
lexer_init(&data->lexer);
|
||||||
parser_init(&data->parser);
|
parser_init(&data->parser);
|
||||||
if (!ft_getenv(data_singleton()->env, "FUNC_LVL"))
|
/* if (!ft_getenv(data_singleton()->env, "FUNC_LVL")) */
|
||||||
builtin_setenv("setenv", (char *[]){"env", "FUNC_LVL", "-1",
|
/* builtin_setenv("setenv", (char *[]){"env", "FUNC_LVL", "-1", */
|
||||||
NULL}, NULL);
|
/* NULL}, NULL); */
|
||||||
if ((term_name = ft_getenv(data->env, "TERM")) == NULL)
|
if ((term_name = ft_getenv(data->env, "TERM")) == NULL)
|
||||||
{
|
{
|
||||||
term_name = "dumb";
|
term_name = "dumb";
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue