diff options
Diffstat (limited to 'src/u_vars_next.c')
-rw-r--r-- | src/u_vars_next.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/u_vars_next.c b/src/u_vars_next.c index 820bbe1..c6c351b 100644 --- a/src/u_vars_next.c +++ b/src/u_vars_next.c @@ -17,26 +17,28 @@ #include "d_enum.h" #include "s_lvars.h" #include "s_struct.h" +#include "u_utils.h" static int64_t u_get_env_var_line(const char varname[], t_msh *msh) { - char **env_ptr; + char **env_dup; int64_t i; - env_ptr = msh->envp; + env_dup = u_get_env_var_names(msh); i = 0; - while (*env_ptr && - ft_strncmp(varname, *env_ptr, ft_strclen(*env_ptr, '=')) != 0) + while (env_dup[i] != NULL && + ft_strncmp(varname, env_dup[i], ft_strlen(env_dup[i]) + 1) != 0) { - env_ptr++; i++; } - if (*env_ptr) - return (i); - else - return (-1); + if (env_dup[i] == NULL) + { + i = -1; + } + ft_delwords(env_dup); + return (i); } static t_bool |