multiline heredoc in history
This commit is contained in:
parent
7dd8b1861b
commit
9361d965bc
4 changed files with 21 additions and 10 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue