diff options
Diffstat (limited to 'src/u_vars_next.c')
-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); } |