fix: main.c compile with clang
This commit is contained in:
parent
8e22eb210a
commit
1626424ed7
28
main.c
28
main.c
@ -6,7 +6,7 @@
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 <readline/readline.h>
|
||||
|
||||
static char *ft_get_user_input(t_list **env)
|
||||
static char *ft_get_user_input()
|
||||
{
|
||||
char *line;
|
||||
char *prompt;
|
||||
@ -106,25 +106,39 @@ int main(int ac, char **av, char **env)
|
||||
|
||||
void ft_ctrlc(int num)
|
||||
{
|
||||
(void) num;
|
||||
if (*ft_get_heredoc())
|
||||
{
|
||||
kill(*ft_get_heredoc(), SIGQUIT);
|
||||
ft_putchar_fd('\n', 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
rl_redisplay();
|
||||
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)
|
||||
{
|
||||
t_data data;
|
||||
char *line;
|
||||
|
||||
(void) ac;
|
||||
(void) av;
|
||||
signal(SIGINT, ft_ctrlc);
|
||||
signal(SIGQUIT, ft_quit);
|
||||
data.env = init_env(env);
|
||||
if (data.env == NULL)
|
||||
return (1);
|
||||
@ -135,7 +149,7 @@ int main(int ac, char **av, char **env)
|
||||
free(data.env);
|
||||
return (1);
|
||||
}
|
||||
line = ft_get_user_input(data.env);
|
||||
line = ft_get_user_input();
|
||||
if (line == NULL)
|
||||
{
|
||||
ft_lstclear(data.env, env_del);
|
||||
@ -147,7 +161,7 @@ int main(int ac, char **av, char **env)
|
||||
if (ft_minishell(&data, line) == -1)
|
||||
break ;
|
||||
free(line);
|
||||
line = ft_get_user_input(data.env);
|
||||
line = ft_get_user_input();
|
||||
if (line == NULL)
|
||||
{
|
||||
ft_lstclear(data.env, env_del);
|
||||
|
Loading…
Reference in New Issue
Block a user