clean: norm
This commit is contained in:
@ -6,11 +6,12 @@
|
||||
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/29 17:32:06 by cchauvet #+# #+# */
|
||||
/* Updated: 2023/04/05 14:53:18 by alouis-j ### ########.fr */
|
||||
/* Updated: 2023/04/07 15:06:39 by alouis-j ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "./redirection_private.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
static bool ft_check_heredoc(t_data *data, t_cmd *cmd,
|
||||
char *redirection_identifier, char *redirection)
|
||||
@ -120,8 +121,10 @@ bool ft_check_redirection(t_data *data, t_cmd *cmd,
|
||||
char *redirection_identifier, char *redirection)
|
||||
{
|
||||
char *str;
|
||||
bool out;
|
||||
|
||||
if (ft_is_in("<>", redirection_identifier[0]) && ft_is_in("<>", redirection[0]))
|
||||
if (ft_is_in("<>", redirection_identifier[0])
|
||||
&& ft_is_in("<>", redirection[0]))
|
||||
{
|
||||
ft_eprintf("minishell: %s: invalid redirection file\n", redirection);
|
||||
return (1);
|
||||
@ -133,16 +136,12 @@ bool ft_check_redirection(t_data *data, t_cmd *cmd,
|
||||
return (1);
|
||||
}
|
||||
ft_quote_remover(str);
|
||||
out = 0;
|
||||
if (ft_check_heredoc(data, cmd, redirection_identifier, str)
|
||||
|| ft_check_infile(data, cmd, redirection_identifier, str)
|
||||
|| ft_check_outfile(data, cmd, redirection_identifier, str)
|
||||
|| ft_check_outfile_append(data, cmd, redirection_identifier,
|
||||
str))
|
||||
{
|
||||
free(str);
|
||||
return (1);
|
||||
}
|
||||
;
|
||||
|| ft_check_infile(data, cmd, redirection_identifier, str)
|
||||
|| ft_check_outfile(data, cmd, redirection_identifier, str)
|
||||
|| ft_check_outfile_append(data, cmd, redirection_identifier, str))
|
||||
out = 1;
|
||||
free(str);
|
||||
return (0);
|
||||
return (out);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/17 15:36:26 by cchauvet #+# #+# */
|
||||
/* Updated: 2023/04/05 14:58:01 by alouis-j ### ########.fr */
|
||||
/* Updated: 2023/04/07 15:11:17 by alouis-j ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -31,25 +31,35 @@ static int ft_format_and_write(t_data *data, const char *str, int fd)
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int ft_heredoc3(char *stop, int fds[2])
|
||||
{
|
||||
if (*ft_get_heredoc() == -1)
|
||||
{
|
||||
ft_putchar_fd('\n', 1);
|
||||
ft_closer(fds);
|
||||
return (1);
|
||||
}
|
||||
else
|
||||
{
|
||||
ft_eprintf("minishell: warning: here-document at line");
|
||||
ft_eprintf("1 delimited by end-of-file (wanted `%s')\n", stop);
|
||||
return (2);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int ft_heredoc2(t_data *data, char *stop, int fds[2])
|
||||
{
|
||||
char *line;
|
||||
int out;
|
||||
|
||||
ft_printf("> ");
|
||||
line = get_next_line(*ft_get_heredoc());
|
||||
if (line == NULL)
|
||||
{
|
||||
if (*ft_get_heredoc() == -1)
|
||||
{
|
||||
ft_putchar_fd('\n', 1);
|
||||
ft_closer(fds);
|
||||
return (1);
|
||||
}
|
||||
else
|
||||
{
|
||||
ft_eprintf("minishell: warning: here-document at line 1 delimited by end-of-file (wanted `%s')\n", stop);
|
||||
return (2);
|
||||
}
|
||||
out = ft_heredoc3(stop, fds);
|
||||
if (out)
|
||||
return (out);
|
||||
}
|
||||
line[ft_strlen(line) - 1] = '\0';
|
||||
if (ft_strcmp(line, stop) == 0)
|
||||
|
Reference in New Issue
Block a user