feature: switched env from ft_list to specific list

This commit is contained in:
Tanguy MAZE
2019-09-26 16:54:52 +02:00
parent 05d8424f75
commit aa8e971688
9 changed files with 128 additions and 89 deletions

View File

@@ -6,12 +6,35 @@
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/09/19 17:08:46 by tmaze #+# #+# */
/* Updated: 2019/09/20 14:49:03 by tmaze ### ########.fr */
/* Updated: 2019/09/26 16:48:49 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
t_env *env2lst(char **env)
{
t_env *ret;
t_env *new;
int i;
i = 0;
ret = NULL;
while (env[i])
{
if ((new = lstnew(env[i])) != NULL)
lstaddend(&ret, new);
else
{
lstdelelem(&new);
lstdel(&ret);
return (NULL);
}
i++;
}
return (ret);
}
int main(void)
{
extern char **environ;
@@ -19,7 +42,7 @@ int main(void)
, {"setenv", &cmd_setenv}, {"echo", &cmd_echo}
, {"unsetenv", &cmd_unsetenv}};
char **argv;
t_list *env;
t_env *env;
char *cmd;
int i;
@@ -37,7 +60,7 @@ int main(void)
if (ft_strequ(argv[0], "exit"))
{
ft_del_words_tables(&argv);
ft_lstdel(&env, &lstdelenvelem);
lstdel(&env);
return (0);
}
i = 0;
@@ -60,6 +83,6 @@ int main(void)
}
ft_del_words_tables(&argv);
ft_strdel(&cmd);
ft_lstdel(&env, &lstdelenvelem);
lstdel(&env);
return (0);
}