diff options
Diffstat (limited to '')
-rw-r--r-- | src/ft_p_lcom_next.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/ft_p_lcom_next.c b/src/ft_p_lcom_next.c index e025f96..34c0d2c 100644 --- a/src/ft_p_lcom_next.c +++ b/src/ft_p_lcom_next.c @@ -24,6 +24,7 @@ char /* TODO: norme */ char **p_words; char *s_varname; + char *varval; int64_t i; size_t varlen; @@ -31,20 +32,17 @@ char varlen = 0; while (*p_words) { - while (varlen < ft_strlen(*p_words) && - (i = ft_strlchr((*p_words) + varlen, '$'))) + while ((i = ft_strlchr(*p_words, '$')) != -1) { - ft_printf("%ld|||\n", i); - if (i == -1) - break ; varlen = i + 1; while ((*p_words)[varlen] != '\0' && (*p_words)[varlen] != '$') varlen += 1; - varlen -= 1; if (!(s_varname = ft_substr(*p_words, (uint32_t)i, varlen))) return (NULL); - ft_printf("{%s} | {%s}\n", s_varname, ft_subst_var_value(s_varname, msh)); + 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; |