Browse Source

replace_var fixed

master
Michael Ea 3 years ago
parent
commit
84dafe2142
  1. 6
      lexer.c
  2. 5
      minishell.c

6
lexer.c

@ -6,7 +6,7 @@
/* By: mea <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

5
minishell.c

@ -6,7 +6,7 @@
/* By: mea <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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;

Loading…
Cancel
Save