corrected make'

This commit is contained in:
Tanguy MAZE 2020-02-14 12:31:39 +01:00
parent b9c1a344b2
commit 5dbce99ee2
4 changed files with 35 additions and 5 deletions

View File

@ -48,7 +48,6 @@ SRC = main.c \
put_error_cd.c \
ms_exec_utils.c \
def_env.c \
envnew.c \
check_path_slash_cd.c
OBJ = $(SRC:.c=.o)

View File

@ -6,7 +6,7 @@
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/08 00:12:36 by tmaze #+# #+# */
/* Updated: 2020/02/07 15:25:43 by tmaze ### ########.fr */
/* Updated: 2020/02/14 12:28:38 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
@ -374,7 +374,7 @@ int ft_putendl_fd2(char const *s, int fd);
void ft_envdelelem(t_env **elem);
void ft_envdel(t_env **env);
t_env *ft_envnew(char *env);
t_env *ft_envnewinit(char *key, char *val, t_env *env);
t_env *ft_envnewinit(char *key, char *val);
t_env *ft_envaddend(t_env **alst, t_env *new);
t_env *ft_envgetelem(char *key, t_env *env);
char *ft_envtochar(t_env *env);

View File

@ -6,7 +6,7 @@
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/12/05 14:54:55 by tmaze #+# #+# */
/* Updated: 2019/12/05 17:12:59 by tmaze ### ########.fr */
/* Updated: 2020/02/14 12:28:20 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
@ -28,7 +28,7 @@ t_env *ft_envnew(char *env)
return (ret);
}
t_env *ft_envnewinit(char *key, char *val, t_env *env)
t_env *ft_envnewinit(char *key, char *val)
{
t_env *ret;
int i;

31
srcs/cmd_cd_utils.c Normal file
View File

@ -0,0 +1,31 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* cmd_cd_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/14 11:55:54 by tmaze #+# #+# */
/* Updated: 2020/02/14 11:56:53 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
t_env *cd_updateenv(char *key, char *val, t_env **env)
{
t_env *tmp;
if ((tmp = ft_envgetelem(key, *env)) != NULL)
ft_envupdate(key, *env, val);
else if ((tmp = (t_env*)ft_memalloc(sizeof(t_env))) != NULL)
{
if ((tmp->key = ft_strdup(key)) == NULL)
ft_envdelelem(&tmp);
if (tmp && (tmp->val = ft_strdup(val)) == NULL)
ft_envdelelem(&tmp);
if (tmp)
ft_envaddend(env, tmp);
}
return (tmp);
}