protection free_history_list

This commit is contained in:
Jack Halford 2017-03-20 21:26:02 +01:00
parent 6460fa3f61
commit aebb4f7613
10 changed files with 18 additions and 13 deletions

View file

@ -6,7 +6,7 @@
# By: wescande <wescande@student.42.fr> +#+ +:+ +#+ # # By: wescande <wescande@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2016/08/29 21:32:58 by wescande #+# #+# # # Created: 2016/08/29 21:32:58 by wescande #+# #+# #
# Updated: 2017/03/20 19:08:06 by jhalford ### ########.fr # # Updated: 2017/03/20 21:07:34 by jhalford ### ########.fr #
# # # #
# **************************************************************************** # # **************************************************************************** #

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/14 18:06:24 by jhalford #+# #+# */ /* Created: 2016/11/14 18:06:24 by jhalford #+# #+# */
/* Updated: 2017/03/18 17:33:49 by ariard ### ########.fr */ /* Updated: 2017/03/20 21:06:28 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/15 13:12:06 by jhalford #+# #+# */ /* Created: 2016/11/15 13:12:06 by jhalford #+# #+# */
/* Updated: 2017/03/14 17:47:51 by jhalford ### ########.fr */ /* Updated: 2017/03/20 21:18:01 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -43,6 +43,7 @@ static int ft_loop_read(int fd, char **line, char *save)
while ((ret = read(fd, buf, BUFF_SIZE)) > 0) while ((ret = read(fd, buf, BUFF_SIZE)) > 0)
{ {
DG("boucle");
buf[ret] = 0; buf[ret] = 0;
tmp = *line; tmp = *line;
if ((pos = ft_strchr(buf, '\n'))) if ((pos = ft_strchr(buf, '\n')))
@ -58,6 +59,7 @@ static int ft_loop_read(int fd, char **line, char *save)
} }
if (ret < 0) if (ret < 0)
return (-1); return (-1);
DG("GNL ret %i, fd=%i", **line ? 1 : 0, fd);
return (**line ? 1 : 0); return (**line ? 1 : 0);
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 14:28:41 by jhalford #+# #+# */ /* Created: 2016/11/28 14:28:41 by jhalford #+# #+# */
/* Updated: 2017/03/20 14:17:40 by gwojda ### ########.fr */ /* Updated: 2017/03/20 21:23:03 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/03 13:46:40 by jhalford #+# #+# */ /* Created: 2017/02/03 13:46:40 by jhalford #+# #+# */
/* Updated: 2017/03/15 17:48:21 by jhalford ### ########.fr */ /* Updated: 2017/03/20 21:13:57 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/17 11:37:47 by gwojda #+# #+# */ /* Created: 2016/12/17 11:37:47 by gwojda #+# #+# */
/* Updated: 2017/03/20 18:16:45 by gwojda ### ########.fr */ /* Updated: 2017/03/20 21:25:22 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -16,9 +16,9 @@ void free_history_list(t_list_history *head)
{ {
t_list_history *prev; t_list_history *prev;
if (!head) if (!SH_IS_INTERACTIVE(data_singleton()->opts))
return ; return ;
if (head->next) if (head && head->next)
free(head->next); free(head->next);
while (head) while (head)
{ {

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/15 14:19:48 by gwojda #+# #+# */ /* Created: 2016/12/15 14:19:48 by gwojda #+# #+# */
/* Updated: 2017/03/20 14:49:03 by gwojda ### ########.fr */ /* Updated: 2017/03/20 21:19:20 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -21,7 +21,10 @@ int readline(int has_prompt, char **input)
if (!SH_IS_INTERACTIVE(data_singleton()->opts)) if (!SH_IS_INTERACTIVE(data_singleton()->opts))
{ {
if ((ret = get_next_line(data_singleton()->fd, input)) >= 0) if ((ret = get_next_line(data_singleton()->fd, input)) >= 0)
{
DG("returning %i", !ret);
return (!ret); return (!ret);
}
return (ret); return (ret);
} }
readline_init(has_prompt); readline_init(has_prompt);

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/07 18:07:50 by jhalford #+# #+# */ /* Created: 2016/12/07 18:07:50 by jhalford #+# #+# */
/* Updated: 2017/03/20 14:44:51 by gwojda ### ########.fr */ /* Updated: 2017/03/20 21:25:25 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/20 14:45:40 by gwojda #+# #+# */ /* Created: 2017/03/20 14:45:40 by gwojda #+# #+# */
/* Updated: 2017/03/20 18:12:18 by gwojda ### ########.fr */ /* Updated: 2017/03/20 21:20:51 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -46,13 +46,13 @@ static int handle_instruction(t_list **token, t_btree **ast)
if (do_parser_routine(token, ast) > 0) if (do_parser_routine(token, ast) > 0)
break ; break ;
} }
btree_print(STDBUG, *ast, &ft_putast);
if (data->parser.state == SUCCESS && ft_exec(ast) < 0) if (data->parser.state == SUCCESS && ft_exec(ast) < 0)
exit(1); exit(1);
else if (data->parser.state != SUCCESS) else if (data->parser.state != SUCCESS)
set_exitstatus(1, 1); set_exitstatus(1, 1);
if (SH_IS_INTERACTIVE(data->opts) && data->lexer.str) if (SH_IS_INTERACTIVE(data->opts) && data->lexer.str)
ft_add_str_in_history(data->lexer.str); ft_add_str_in_history(data->lexer.str);
/* exit(0); */
return (0); return (0);
} }

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */ /* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/19 14:24:14 by wescande #+# #+# */ /* Created: 2017/03/19 14:24:14 by wescande #+# #+# */
/* Updated: 2017/03/20 15:47:03 by ariard ### ########.fr */ /* Updated: 2017/03/20 21:11:21 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */