From 0249416b1d5aba3bc436f9892d7890df2613183e Mon Sep 17 00:00:00 2001 From: gwojda Date: Fri, 17 Mar 2017 16:04:21 +0100 Subject: [PATCH] fix msg erreur historique --- 42sh/src/line-editing/init_history.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/42sh/src/line-editing/init_history.c b/42sh/src/line-editing/init_history.c index b6859052..4c8f5c57 100644 --- a/42sh/src/line-editing/init_history.c +++ b/42sh/src/line-editing/init_history.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/07 17:34:23 by gwojda #+# #+# */ -/* Updated: 2017/03/17 14:35:12 by gwojda ### ########.fr */ +/* Updated: 2017/03/17 16:01:44 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -26,6 +26,12 @@ static int ft_str_is_print(char *str) return (1); } +static void corrupt_history(int corrupt, char *home) +{ + if (corrupt) + ft_dprintf(2, "42sh: corrupt history file %s/.zsh_history\n", home); +} + void ft_init_history(void) { int fd; @@ -45,10 +51,11 @@ void ft_init_history(void) if (ft_str_is_print(str) && *str) ft_push_back_history(&data_singleton()->line.list_beg, ft_create_history_list(str)); - else if (!corrupt) - ft_dprintf(2, "42sh: corrupt history file %s/.zsh_history", home); + else + corrupt = CORRUPT; free(str); } + corrupt_history(corrupt, home); free(path); free(str); close(fd);