diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-08-05 23:05:03 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-08-05 23:05:03 +0200 |
commit | f7b13a353092017e37045344528c985172eafc3a (patch) | |
tree | c0bf8c6e8611cb72055f6a65634d1d0d35d6c4d8 /src/u_vars_next.c | |
parent | New utils functions (diff) | |
download | 42-minishell-f7b13a353092017e37045344528c985172eafc3a.tar.gz 42-minishell-f7b13a353092017e37045344528c985172eafc3a.tar.bz2 42-minishell-f7b13a353092017e37045344528c985172eafc3a.tar.xz 42-minishell-f7b13a353092017e37045344528c985172eafc3a.tar.zst 42-minishell-f7b13a353092017e37045344528c985172eafc3a.zip |
Vars are fixed and finished
Diffstat (limited to '')
-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 |