From 84dafe21429df5aa0e207c52d1a28ecbb1ac7a53 Mon Sep 17 00:00:00 2001 From: Michael Ea Date: Thu, 5 May 2022 15:44:52 +0200 Subject: [PATCH] replace_var fixed --- lexer.c | 6 +++--- minishell.c | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lexer.c b/lexer.c index 3ffc5fa..5985ccc 100755 --- a/lexer.c +++ b/lexer.c @@ -6,7 +6,7 @@ /* By: mea +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/05/02 13:44:57 by narnaud #+# #+# */ -/* Updated: 2022/05/05 13:12:49 by mea ### ########.fr */ +/* Updated: 2022/05/05 15:41:06 by mea ### ########.fr */ /* */ /* ************************************************************************** */ @@ -115,13 +115,13 @@ int replace_var(t_datas *datas, char **line, char *tmp, int tmp_i) value = strdup(""); else value = env[1]; - name_len = ft_strlen(var_name) + 1; + name_len = ft_strlen(var_name); } i = 0; while (value[i]) tmp[tmp_i++] = value[i++]; tmp[tmp_i] = 0; - *line += ft_max(name_len, i); + *line += name_len + 1; return (tmp_i); } diff --git a/minishell.c b/minishell.c index 2388857..4786702 100755 --- a/minishell.c +++ b/minishell.c @@ -6,7 +6,7 @@ /* By: mea +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/05/02 12:14:09 by narnaud #+# #+# */ -/* Updated: 2022/05/05 14:18:16 by mea ### ########.fr */ +/* Updated: 2022/05/05 15:31:45 by mea ### ########.fr */ /* */ /* ************************************************************************** */ @@ -108,7 +108,10 @@ t_token *lexer(t_datas *datas, char *line) if (check_state(lex, &line)) continue; if (lex->state != S_QUOTE_ST && *line == '$') + { tmp_i = replace_var(datas, &line, tmp, tmp_i); + printf("TEST tmpi %d\n", tmp_i); + } if (check_register(lex, &line, tmp)) { tmp_i = 0;