From f6517910eb0d6032a0678698d364987fb62158a5 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Sun, 26 Apr 2020 21:24:08 +0200 Subject: gdb time, strsubst might be broken --- src/ft_p_lcom_next.c | 4 +++- src/ft_u_vars.c | 12 +++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ft_p_lcom_next.c b/src/ft_p_lcom_next.c index 34c0d2c..272931d 100644 --- a/src/ft_p_lcom_next.c +++ b/src/ft_p_lcom_next.c @@ -30,6 +30,8 @@ char p_words = words; varlen = 0; + varval = NULL; + s_varname = NULL; while (*p_words) { while ((i = ft_strlchr(*p_words, '$')) != -1) @@ -39,11 +41,11 @@ char varlen += 1; if (!(s_varname = ft_substr(*p_words, (uint32_t)i, varlen))) return (NULL); + ft_printf("a\n"); varval = ft_subst_var_value(s_varname, msh); *p_words = ft_strsubst(*p_words, s_varname, varval); ft_memdel((void*)&s_varname); ft_memdel((void*)&varval); - varlen += 1; } p_words += 1; } diff --git a/src/ft_u_vars.c b/src/ft_u_vars.c index 619e83d..99f35bb 100644 --- a/src/ft_u_vars.c +++ b/src/ft_u_vars.c @@ -63,6 +63,7 @@ static char t_msh *msh) { char **p_env; + char *pp_env; char *varval; p_env = msh->envp; @@ -70,11 +71,12 @@ static char { if (!ft_strncmp(rvarname, *p_env, ft_strlen(rvarname))) { - while (**p_env != '\0' && **p_env != '=') - *p_env += 1; - if (**p_env == '=') - *p_env += 1; - varval = ft_dup_env(*p_env, rvarname, msh); + pp_env = *p_env; + while (*pp_env != '\0' && *pp_env != '=') + pp_env += 1; + if (*pp_env == '=') + pp_env += 1; + varval = ft_dup_env(pp_env, rvarname, msh); return (varval); } p_env += 1; -- cgit v1.2.3