From 7db099a010756d77d23ae04bddc0248f06dd5e7a Mon Sep 17 00:00:00 2001 From: Tanguy MAZE Date: Fri, 7 Feb 2020 15:57:21 +0100 Subject: [PATCH] Corrected extension in setenv --- libft/includes/libft.h | 2 +- libft/srcs/ft_envupdate.c | 2 +- srcs/cmd_setenv.c | 9 +++------ srcs/ms_ext.c | 4 ++-- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/libft/includes/libft.h b/libft/includes/libft.h index 120dc20..9204891 100644 --- a/libft/includes/libft.h +++ b/libft/includes/libft.h @@ -6,7 +6,7 @@ /* By: tmaze +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2018/04/08 00:12:36 by tmaze #+# #+# */ -/* Updated: 2019/12/06 09:57:17 by tmaze ### ########.fr */ +/* Updated: 2020/02/07 15:25:43 by tmaze ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libft/srcs/ft_envupdate.c b/libft/srcs/ft_envupdate.c index 54d6871..fa771f5 100644 --- a/libft/srcs/ft_envupdate.c +++ b/libft/srcs/ft_envupdate.c @@ -6,7 +6,7 @@ /* By: tmaze +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/12/05 19:10:38 by tmaze #+# #+# */ -/* Updated: 2019/12/05 19:10:52 by tmaze ### ########.fr */ +/* Updated: 2020/02/07 15:26:10 by tmaze ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/srcs/cmd_setenv.c b/srcs/cmd_setenv.c index 65295d0..7031c6b 100644 --- a/srcs/cmd_setenv.c +++ b/srcs/cmd_setenv.c @@ -6,7 +6,7 @@ /* By: tmaze +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/09/20 14:41:08 by tmaze #+# #+# */ -/* Updated: 2019/11/10 21:38:30 by tmaze ### ########.fr */ +/* Updated: 2020/02/07 15:56:06 by tmaze ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,14 +21,11 @@ int cmd_setenv(char **argv, t_env **env) { if (argv[1] && (tmp = ft_envgetelem(new->key, *env)) != NULL) { - ft_strdel(&(tmp->val)); - tmp->val = new->val; - ft_strdel(&(new->key)); - ft_memdel((void**)&new); + ft_envupdate(new->key, *env, new->val); + ft_envdelelem(&new); } else ft_envaddend(env, new); - ft_envclean(env); return (0); } else if (argv[1] && argv[1][0] != '=' && !ft_strchr(argv[1], '=')) diff --git a/srcs/ms_ext.c b/srcs/ms_ext.c index 10d76c9..4b72233 100644 --- a/srcs/ms_ext.c +++ b/srcs/ms_ext.c @@ -6,7 +6,7 @@ /* By: tmaze +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/10/25 18:21:47 by tmaze #+# #+# */ -/* Updated: 2020/02/01 15:56:43 by tmaze ### ########.fr */ +/* Updated: 2020/02/07 15:55:59 by tmaze ### ########.fr */ /* */ /* ************************************************************************** */ @@ -55,7 +55,7 @@ char *replace_env(char *src, t_env *elem, int key_size, int i) { ft_strncpy(ret, src, i); ft_strlcat(ret, elem->val, res_len + 1); - ft_strlcat(ret, src + key_size, res_len + 1); + ft_strlcat(ret, &src[i] + key_size, res_len + 1); } else ft_printf("minishell: memory error\n");