This commit is contained in:
gwojda 2017-03-14 13:44:32 +01:00
parent b1c3c2d66c
commit 23da659513

View file

@ -6,12 +6,26 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 17:34:23 by gwojda #+# #+# */ /* Created: 2017/03/07 17:34:23 by gwojda #+# #+# */
/* Updated: 2017/03/09 00:09:22 by ariard ### ########.fr */ /* Updated: 2017/03/14 13:42:15 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "minishell.h" #include "minishell.h"
static int ft_str_is_print(char *str)
{
int i;
i = 0;
while (str[i])
{
if (!ft_isprint(str[i]))
return (0);
++i;
}
return (1);
}
void ft_init_history(void) void ft_init_history(void)
{ {
int fd; int fd;
@ -27,6 +41,7 @@ void ft_init_history(void)
return ; return ;
while (get_next_line(fd, &str) > 0) while (get_next_line(fd, &str) > 0)
{ {
if (ft_str_is_print(str) && *str)
ft_push_back_history(&data_singleton()->line.list_beg, ft_push_back_history(&data_singleton()->line.list_beg,
ft_create_history_list(str)); ft_create_history_list(str));
free(str); free(str);