issue #81, probleme de protection free historique, p-e resolu #77 aussi

This commit is contained in:
Jack Halford 2017-03-13 14:48:40 +01:00
parent bfb7c13e94
commit 163c93c0c2
9 changed files with 16 additions and 23 deletions

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/10 16:55:09 by jhalford #+# #+# */
/* Updated: 2017/03/13 13:52:40 by jhalford ### ########.fr */
/* Updated: 2017/03/13 14:29:46 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 14:28:41 by jhalford #+# #+# */
/* Updated: 2017/03/09 15:14:37 by jhalford ### ########.fr */
/* Updated: 2017/03/13 14:47:29 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 15:47:30 by wescande #+# #+# */
/* Updated: 2017/03/13 14:21:27 by jhalford ### ########.fr */
/* Updated: 2017/03/13 14:37:01 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/13 14:20:45 by jhalford #+# #+# */
/* Updated: 2017/03/13 14:12:52 by jhalford ### ########.fr */
/* Updated: 2017/03/13 14:43:26 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/14 11:27:03 by gwojda #+# #+# */
/* Updated: 2017/03/13 14:23:03 by jhalford ### ########.fr */
/* Updated: 2017/03/13 14:30:48 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -21,7 +21,6 @@ void ft_add_in_history_file(char *str)
char **hist;
i = 0;
/* DG("gonna add [%s] in history"); */
hist = ft_strsplit(str, '\n');
if (!(home = ft_getenv(data_singleton()->env, "HOME")))
return ;

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/17 11:37:47 by gwojda #+# #+# */
/* Updated: 2017/03/09 11:21:06 by gwojda ### ########.fr */
/* Updated: 2017/03/13 14:47:06 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -16,13 +16,13 @@ void free_history_list(t_list_history *head)
{
t_list_history *prev;
free(head->prev);
if (!head)
return ;
while (head)
{
ft_strdel(&head->str);
prev = head;
head = head->next;
free(prev);
}
}

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/15 14:19:48 by gwojda #+# #+# */
/* Updated: 2017/03/10 15:48:30 by gwojda ### ########.fr */
/* Updated: 2017/03/13 14:43:28 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -15,15 +15,11 @@
int readline(int fd, int prompt, char **input)
{
if (!SH_IS_INTERACTIVE(data_singleton()->opts))
{
if (get_next_line(fd, input) == 0)
return (1);
return (0);
}
return (get_next_line(fd, input) == 0);
readline_init(prompt);
*input = ft_read_stdin();
if (STR)
ft_current_str(STR, POS);
ft_current_str(STR, POS);
ft_putchar('\n');
if (!prompt)
*input = ft_history_parsing();

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */
/* Updated: 2017/03/13 14:23:21 by jhalford ### ########.fr */
/* Updated: 2017/03/13 14:47:13 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -31,11 +31,13 @@ int handle_instruction(int fd)
if ((ret = readline(fd, get_lexer_stack(lexer) ||
parser.state == UNDEFINED || lexer.state == HEREDOC, &str)))
{
DG("readline trap");
if (ret == -1)
return (-1);
return (parser.state == UNDEFINED ? error_eof(&token,
&parser, &ast) : 1);
}
DG("INPUT STRING IS [%s]", str);
if (lexer.state == HEREDOC)
{
ft_strappend(&lexer.str, (char[]){'\n', 0});
@ -71,7 +73,6 @@ int handle_instruction(int fd)
}
}
btree_print(STDBUG, ast, &ft_putast);
/* ft_show_heredoc_data(ast->left->item); */
if (ft_exec(&ast))
return (1);
instruction_free(&token, &parser, &ast);
@ -124,11 +125,8 @@ int main(int ac, char **av)
}
DG("JOBC is %s, fd=[%i]", SH_HAS_JOBC(data_singleton()->opts)?"ON":"OFF", fd);
while (handle_instruction(fd) == 0)
{
// lexer_clean;
// parser_clean;
;
}
DG("gonna exit");
builtin_exit(NULL, NULL, NULL);
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/09 20:15:35 by ariard #+# #+# */
/* Updated: 2017/03/11 16:10:56 by ariard ### ########.fr */
/* Updated: 2017/03/13 14:41:45 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */