Compare commits

...

2 Commits

Author SHA1 Message Date
Camille Chauvet
6ce54ea6fe fix 2023-03-13 15:34:57 +01:00
Camille Chauvet
74bbbd899a fix 2023-03-13 15:34:43 +01:00
5 changed files with 12 additions and 18 deletions

View File

@ -95,7 +95,7 @@ static void ft_space_simplifier(char *str)
} }
} }
char *ft_formater(char *str) char *ft_formater(t_data *data, const char *str)
{ {
char *out; char *out;
char *temp; char *temp;
@ -112,5 +112,7 @@ char *ft_formater(char *str)
ft_space_simplifier(out); ft_space_simplifier(out);
if (out[ft_strlen(out) - 1] == ' ') if (out[ft_strlen(out) - 1] == ' ')
out[ft_strlen(out) - 1] = '\0'; out[ft_strlen(out) - 1] = '\0';
return (out); temp = ft_env_filler(data, out);
free(out);
return (temp);
} }

View File

@ -1,6 +1,7 @@
#ifndef FORMAT_H #ifndef FORMAT_H
# define FORMAT_H # define FORMAT_H
# include "../data/data.h"
char *ft_formater(char *str); char *ft_formater(t_data *data, const char *str);
#endif #endif

2
main.c
View File

@ -43,7 +43,7 @@ static int ft_minishell(t_data *data, char *line)
if (ft_syntax_verif(data, line)) if (ft_syntax_verif(data, line))
return (0); return (0);
line_clean = ft_formater(line); line_clean = ft_formater(data, line);
if (line_clean == NULL) if (line_clean == NULL)
return (0); return (0);
if (ft_cmds_parser(data, line_clean)) if (ft_cmds_parser(data, line_clean))

View File

@ -1,9 +1,8 @@
#include "./parse_private.h" #include "./parse_private.h"
int ft_args_parse(t_data *data, char *cmd_str, t_cmd *cmd) static int ft_args_parse(char *cmd_str, t_cmd *cmd)
{ {
char **tab; char **tab;
char *str;
size_t i; size_t i;
tab = ft_split_quoted(cmd_str, ' '); tab = ft_split_quoted(cmd_str, ' ');
@ -12,22 +11,14 @@ int ft_args_parse(t_data *data, char *cmd_str, t_cmd *cmd)
i = 0; i = 0;
while (tab[i] != NULL) while (tab[i] != NULL)
{ {
str = ft_env_filler(data, tab[i]); ft_quote_remover(tab[i]);
if (str == NULL)
{
ft_freer_tab_ultimate(1, tab);
return (1);
}
ft_quote_remover(str);
free(tab[i]);
tab[i] = str;
i++; i++;
} }
cmd->args = tab; cmd->args = tab;
return (0); return (0);
} }
int ft_executable_parse(t_data *data, t_cmd *cmd) static int ft_executable_parse(t_data *data, t_cmd *cmd)
{ {
bool own; bool own;
char *path; char *path;
@ -76,7 +67,7 @@ int ft_cmd_parser(t_data *data, char *cmd_str)
ft_cmddel(cmd); ft_cmddel(cmd);
return (1); return (1);
} }
if (ft_args_parse(data, cmd_str, cmd)) if (ft_args_parse(cmd_str, cmd))
{ {
ft_cmddel(cmd); ft_cmddel(cmd);
return (1); return (1);

View File

@ -36,7 +36,7 @@ char *ft_quote_remover(char *str)
ft_strshift(str + stop - 1, -1); ft_strshift(str + stop - 1, -1);
start = -1; start = -1;
stop = -1; stop = -1;
i = i - 2; i = i - 1;
} }
else else
i++; i++;