diff --git a/42sh/includes/exec.h b/42sh/includes/exec.h index 71991239..fab2584b 100644 --- a/42sh/includes/exec.h +++ b/42sh/includes/exec.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */ -/* Updated: 2017/03/10 13:19:04 by jhalford ### ########.fr */ +/* Updated: 2017/03/10 13:26:16 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/lexer_heredoc.c b/42sh/src/lexer/lexer_heredoc.c index 966d2821..67cfd884 100644 --- a/42sh/src/lexer/lexer_heredoc.c +++ b/42sh/src/lexer/lexer_heredoc.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/08 15:51:17 by jhalford #+# #+# */ -/* Updated: 2017/03/10 13:16:54 by jhalford ### ########.fr */ +/* Updated: 2017/03/10 13:27:32 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/main/main.c b/42sh/src/main/main.c index 0d9b5b15..a71a1ebc 100644 --- a/42sh/src/main/main.c +++ b/42sh/src/main/main.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */ -/* Updated: 2017/03/10 13:19:01 by jhalford ### ########.fr */ +/* Updated: 2017/03/10 13:28:24 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -36,6 +36,11 @@ int handle_instruction(int fd) return (parser.state == UNDEFINED ? error_EOF(&token, &parser, &ast) : 1); } + if (lexer.state == HEREDOC) + { + ft_strappend(&lexer.str, (char[]){'\n', 0}); + lexer.pos++; + } ft_strappend(&lexer.str, str); if (get_lexer_stack(lexer) == BACKSLASH) pop(&lexer.stack); diff --git a/42sh/src/parser/heredoc_parser.c b/42sh/src/parser/heredoc_parser.c index 6ed353a9..6da6ff5e 100644 --- a/42sh/src/parser/heredoc_parser.c +++ b/42sh/src/parser/heredoc_parser.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/08 16:21:05 by ariard #+# #+# */ -/* Updated: 2017/03/10 13:19:06 by jhalford ### ########.fr */ +/* Updated: 2017/03/10 13:26:15 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -26,15 +26,21 @@ int pop_heredoc(t_list **lst) head = data_singleton()->heredoc_queue->content; temp = data_singleton()->heredoc_queue; DG("compare %s with %s", (char *)token->data, head->word); - if (head && token && ft_strcmp((char *)token->data, head->word) == 0) + if (head && token) { DG(); - temp2 = temp->next; - free(temp); - data_singleton()->heredoc_queue = temp2; + if (ft_strcmp((char *)token->data, head->word) == 0) + { + temp2 = temp->next; + free(temp); + data_singleton()->heredoc_queue = temp2; + } + else + { + DG("joining [%s] to heredoc", (char*)token->data); + head->heredoc_data = ft_strjoin(head->heredoc_data, token->data); + } } - else if (token) - head->heredoc_data = ft_strjoin(head->heredoc_data, token->data); ft_lstdel(lst, &token_free); return (1); }