diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-08-04 14:44:55 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-08-04 14:44:55 +0200 |
commit | 647a984ac6b6e2629ad16d3892ad3c231e8e277a (patch) | |
tree | ea96eb4f73efa946f100f77538ad1149a8f2de05 | |
parent | New libft function strclen, bug fix (diff) | |
download | 42-minishell-647a984ac6b6e2629ad16d3892ad3c231e8e277a.tar.gz 42-minishell-647a984ac6b6e2629ad16d3892ad3c231e8e277a.tar.bz2 42-minishell-647a984ac6b6e2629ad16d3892ad3c231e8e277a.tar.xz 42-minishell-647a984ac6b6e2629ad16d3892ad3c231e8e277a.tar.zst 42-minishell-647a984ac6b6e2629ad16d3892ad3c231e8e277a.zip |
Huge bug fix
-rw-r--r-- | src/b_export_next.c | 2 | ||||
-rw-r--r-- | src/s_lvars.c | 12 | ||||
-rw-r--r-- | src/u_vars.c | 6 | ||||
-rw-r--r-- | src/u_vars_next.c | 4 |
4 files changed, 15 insertions, 9 deletions
diff --git a/src/b_export_next.c b/src/b_export_next.c index 0c143b2..0a56968 100644 --- a/src/b_export_next.c +++ b/src/b_export_next.c @@ -51,7 +51,7 @@ static int64_t p_env = msh->envp; while (*p_env != NULL) { - if (ft_strncmp(varname, *p_env, ft_strlen(varname)) == 0) + if (ft_strncmp(varname, *p_env, ft_strclen(*p_env, '=')) == 0) { return (p_env - msh->envp); } diff --git a/src/s_lvars.c b/src/s_lvars.c index f2a1151..d9b7159 100644 --- a/src/s_lvars.c +++ b/src/s_lvars.c @@ -26,7 +26,7 @@ void t_lvars *tmp; tmp = *lvars; - while (tmp && ft_strncmp(tmp->name, name, ft_strlen(name))) + while (tmp && ft_strncmp(tmp->name, name, ft_strlen(name) + 1)) { tmp = tmp->next; } @@ -40,6 +40,12 @@ void ft_dprintf(STDERR_FILENO, "%s\n", strerror(errno)); exit(FT_RET_ALLOC); } + /* TODO: delete this */ + tmp = *lvars; + while (tmp) { + ft_printf("[%s]: [%s]\n", tmp->name, tmp->val); + tmp = tmp->next; + } } void @@ -50,7 +56,7 @@ void t_lvars *prev; tmp = *lvars; - if (tmp != NULL && !ft_strncmp(tmp->name, name, ft_strlen(name))) + if (tmp != NULL && !ft_strncmp(tmp->name, name, ft_strlen(name) + 1)) { *lvars = tmp->next; ft_memdel((void*)&tmp->name); @@ -58,7 +64,7 @@ void ft_memdel((void*)&tmp); return ; } - while (tmp && ft_strncmp(tmp->name, name, ft_strlen(name))) + while (tmp && ft_strncmp(tmp->name, name, ft_strlen(name) + 1)) { prev = tmp; tmp = tmp->next; diff --git a/src/u_vars.c b/src/u_vars.c index 913b07b..d6ed5f2 100644 --- a/src/u_vars.c +++ b/src/u_vars.c @@ -68,7 +68,7 @@ static char p_env = msh->envp; while (*p_env) { - if (!ft_strncmp(rvarname, *p_env, ft_strlen(rvarname))) + if (!ft_strncmp(rvarname, *p_env, ft_strclen(*p_env, '='))) { pp_env = *p_env; while (*pp_env != '\0' && *pp_env != '=') @@ -86,7 +86,7 @@ static char static char *u_get_special_var(const char varname[], - t_msh *msh) + t_msh *msh) { char *varval; @@ -122,7 +122,7 @@ char ptr = msh->vars; while (ptr != NULL && - ft_strncmp(varname + 1, ptr->name, ft_strlen(varname + 1)) != 0) + ft_strncmp(varname + 1, ptr->name, ft_strlen(varname + 1) + 1) != 0) { ptr = ptr->next; } diff --git a/src/u_vars_next.c b/src/u_vars_next.c index 5660449..820bbe1 100644 --- a/src/u_vars_next.c +++ b/src/u_vars_next.c @@ -28,7 +28,7 @@ static int64_t env_ptr = msh->envp; i = 0; while (*env_ptr && - ft_strncmp(*env_ptr, varname, ft_strlen(varname)) != 0) + ft_strncmp(varname, *env_ptr, ft_strclen(*env_ptr, '=')) != 0) { env_ptr++; i++; @@ -47,7 +47,7 @@ static t_bool ptr = msh->vars; while (ptr && - ft_strncmp(varname, ptr->name, ft_strlen(varname)) != 0) + ft_strncmp(varname, ptr->name, ft_strlen(varname) + 1) != 0) { ptr = ptr->next; } |