diff options
author | salad <fmoenne-@student.le-101.fr> | 2020-12-18 20:18:38 +0100 |
---|---|---|
committer | salad <fmoenne-@student.le-101.fr> | 2020-12-18 20:18:38 +0100 |
commit | bbc9757dccbc50fb051ca3cff585a9100023b1b1 (patch) | |
tree | cbf0c5280545d47cea0d7885e94c711edd4c5cc7 /src/u_vars_next.c | |
parent | Merge branch 'leaktarace' of jozanleclerc.xyz:42-minishell into leaktarace (diff) | |
download | 42-minishell-bbc9757dccbc50fb051ca3cff585a9100023b1b1.tar.gz 42-minishell-bbc9757dccbc50fb051ca3cff585a9100023b1b1.tar.bz2 42-minishell-bbc9757dccbc50fb051ca3cff585a9100023b1b1.tar.xz 42-minishell-bbc9757dccbc50fb051ca3cff585a9100023b1b1.tar.zst 42-minishell-bbc9757dccbc50fb051ca3cff585a9100023b1b1.zip |
qweqweqweqwe
Diffstat (limited to '')
-rw-r--r-- | src/u_vars_next.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/src/u_vars_next.c b/src/u_vars_next.c index 11027cb..0b48533 100644 --- a/src/u_vars_next.c +++ b/src/u_vars_next.c @@ -86,33 +86,28 @@ char u_subst_var_value(const char varname[], t_msh *msh) { size_t i; - long env_line; + long en_l; char new_line_fmt[ARG_MAX]; - if ((env_line = u_get_env_var_line(varname + 1, msh)) > -1) + if ((en_l = u_get_env_var_line(varname + 1, msh)) > -1) { - ft_memdel((void*)&msh->envp[env_line]); + ft_memdel((void*)&msh->envp[en_l]); ft_sprintf(new_line_fmt, "%s=%s", varname + 1, newval); - if ((msh->envp[env_line] = (char*)malloc((ft_strlen(new_line_fmt) + 1) * + if ((msh->envp[en_l] = (char*)malloc((ft_strlen(new_line_fmt) + 1) * sizeof(char))) == NULL) { - i = env_line; + i = en_l; while (msh->envp[++i] != NULL) ft_memdel((void*)&msh->envp[i]); ft_delwords(msh->envp); msh->envp = NULL; return (1); } - (void)ft_strlcpy(msh->envp[env_line], - new_line_fmt, ft_strlen(new_line_fmt) + 1); + ft_strlcpy(msh->envp[en_l], new_line_fmt, ft_strlen(new_line_fmt) + 1); } - else if ((env_line = u_get_custom_var_existance(varname + 1, msh)) == TRUE) - { + else if ((en_l = u_get_custom_var_existance(varname + 1, msh)) == TRUE) lvars_rebind(&msh->vars, varname + 1, newval); - } else - { lvars_add_front(&msh->vars, lvars_new(varname + 1, newval)); - } return (0); } |