clean
This commit is contained in:
parent
4b5a50d7fe
commit
c75c6838d6
BIN
.outfile.c.swp
BIN
.outfile.c.swp
Binary file not shown.
23
main.c
23
main.c
@ -6,7 +6,7 @@
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/16 15:16:14 by cchauvet #+# #+# */
|
||||
/* Updated: 2023/02/17 18:22:52 by cchauvet ### ########.fr */
|
||||
/* Updated: 2023/02/17 18:59:50 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -33,6 +33,7 @@ static char *ft_get_user_input(t_list **env)
|
||||
static int ft_minishell(t_list **env, char *line)
|
||||
{
|
||||
t_list **cmds;
|
||||
int code;
|
||||
char *line_clean;
|
||||
int infile;
|
||||
int outfile;
|
||||
@ -68,16 +69,11 @@ static int ft_minishell(t_list **env, char *line)
|
||||
free(line_clean);
|
||||
return (1);
|
||||
}
|
||||
if (ft_cmds_executor(cmds, env) == 1)
|
||||
{
|
||||
close(outfile);
|
||||
close(infile);
|
||||
ft_lstclear(cmds, ft_cmddel);
|
||||
free(cmds);
|
||||
free(line_clean);
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
code = ft_cmds_executor(cmds, env);
|
||||
ft_lstclear(cmds, ft_cmddel);
|
||||
free(cmds);
|
||||
free(line_clean);
|
||||
return (code);
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
@ -104,8 +100,6 @@ int main(int ac, char **av, char **env)
|
||||
|
||||
#else
|
||||
|
||||
|
||||
|
||||
int main(int ac, char **av, char **env)
|
||||
{
|
||||
t_data data;
|
||||
@ -123,7 +117,8 @@ int main(int ac, char **av, char **env)
|
||||
}
|
||||
while (line != NULL)
|
||||
{
|
||||
ft_minishell(data.env, line);
|
||||
if (ft_minishell(data.env, line) == 2)
|
||||
break ;
|
||||
free(line);
|
||||
line = ft_get_user_input(data.env);
|
||||
if (line == NULL)
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/14 13:45:30 by cchauvet #+# #+# */
|
||||
/* Updated: 2023/02/17 18:24:08 by cchauvet ### ########.fr */
|
||||
/* Updated: 2023/02/17 18:51:58 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
# include <stdio.h>
|
||||
# include <readline/readline.h>
|
||||
# include <readline/history.h>
|
||||
# define DEBUG 1
|
||||
# define DEBUG 0
|
||||
|
||||
int ft_syntatic_verif(const char *str);
|
||||
int ft_file_is_readable(const char *path);
|
||||
|
11
outfile.c
11
outfile.c
@ -6,7 +6,7 @@
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/15 18:01:07 by cchauvet #+# #+# */
|
||||
/* Updated: 2023/02/17 18:50:02 by cchauvet ### ########.fr */
|
||||
/* Updated: 2023/02/17 19:03:00 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -86,14 +86,11 @@ static int ft_remove_outfile(char *line)
|
||||
{
|
||||
if (tab[i][0] == '>')
|
||||
{
|
||||
ft_strshift(line + y, -1 * (ft_strlen(tab[i]) + ft_strlen(tab[i + 1]) + 2));
|
||||
ft_strshift(line + y,
|
||||
-1 * (ft_strlen(tab[i]) + ft_strlen(tab[i + 1]) + 2));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (y != 0)
|
||||
y++;
|
||||
y = y + ft_strlen(tab[i]);
|
||||
}
|
||||
y = y + ft_strlen(tab[i]) + (y != 0);
|
||||
i++;
|
||||
}
|
||||
ft_freer_tab_ultimate(1, tab);
|
||||
|
Loading…
Reference in New Issue
Block a user