fix: main.c compile with clang

This commit is contained in:
Camille Chauvet 2023-02-24 11:16:35 +01:00
parent 8e22eb210a
commit 1626424ed7

28
main.c
View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/16 15:16:14 by cchauvet #+# #+# */ /* Created: 2023/02/16 15:16:14 by cchauvet #+# #+# */
/* Updated: 2023/02/21 23:54:44 by cchauvet ### ########.fr */ /* Updated: 2023/02/24 11:04:40 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -14,7 +14,7 @@
#include "minishell.h" #include "minishell.h"
#include <readline/readline.h> #include <readline/readline.h>
static char *ft_get_user_input(t_list **env) static char *ft_get_user_input()
{ {
char *line; char *line;
char *prompt; char *prompt;
@ -106,25 +106,39 @@ int main(int ac, char **av, char **env)
void ft_ctrlc(int num) void ft_ctrlc(int num)
{ {
(void) num;
if (*ft_get_heredoc()) if (*ft_get_heredoc())
{ {
kill(*ft_get_heredoc(), SIGQUIT); kill(*ft_get_heredoc(), SIGQUIT);
ft_putchar_fd('\n', 1);
} }
else else
{ {
rl_redisplay();
rl_on_new_line(); rl_on_new_line();
rl_replace_line("", 0); ft_putchar_fd('\n', 1);
rl_redisplay();
} }
} }
void ft_quit(int num)
{
(void) num;
if (*ft_get_heredoc())
{
ft_printf("pb");
}
else
ft_printf("bozoman");
}
int main(int ac, char **av, char **env) int main(int ac, char **av, char **env)
{ {
t_data data; t_data data;
char *line; char *line;
(void) ac;
(void) av;
signal(SIGINT, ft_ctrlc); signal(SIGINT, ft_ctrlc);
signal(SIGQUIT, ft_quit);
data.env = init_env(env); data.env = init_env(env);
if (data.env == NULL) if (data.env == NULL)
return (1); return (1);
@ -135,7 +149,7 @@ int main(int ac, char **av, char **env)
free(data.env); free(data.env);
return (1); return (1);
} }
line = ft_get_user_input(data.env); line = ft_get_user_input();
if (line == NULL) if (line == NULL)
{ {
ft_lstclear(data.env, env_del); ft_lstclear(data.env, env_del);
@ -147,7 +161,7 @@ int main(int ac, char **av, char **env)
if (ft_minishell(&data, line) == -1) if (ft_minishell(&data, line) == -1)
break ; break ;
free(line); free(line);
line = ft_get_user_input(data.env); line = ft_get_user_input();
if (line == NULL) if (line == NULL)
{ {
ft_lstclear(data.env, env_del); ft_lstclear(data.env, env_del);