quoting FSM repaired
This commit is contained in:
parent
3c0bd77766
commit
1ac56a21e8
7 changed files with 25 additions and 22 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/10 13:07:44 by jhalford #+# #+# */
|
||||
/* Updated: 2016/11/28 18:53:42 by jhalford ### ########.fr */
|
||||
/* Updated: 2016/11/29 15:32:43 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -41,14 +41,11 @@ enum e_qstate
|
|||
|
||||
struct s_data
|
||||
{
|
||||
char **env;
|
||||
t_dlist *history;
|
||||
|
||||
char **env;
|
||||
t_dlist *history;
|
||||
char *input;
|
||||
int input_pos;
|
||||
t_list *qstack;
|
||||
t_qstate state_now;
|
||||
t_qstate state_last;
|
||||
int fdin;
|
||||
int fdout;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/28 16:56:11 by jhalford #+# #+# */
|
||||
/* Updated: 2016/11/28 19:27:44 by jhalford ### ########.fr */
|
||||
/* Updated: 2016/11/29 15:38:51 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -15,40 +15,44 @@
|
|||
void qstate_update(t_data *data, char c)
|
||||
{
|
||||
t_qstate *state;
|
||||
t_qstate *new;
|
||||
t_list **list;
|
||||
t_list *tmp;
|
||||
|
||||
list = &data->qstack;
|
||||
state = (*list)->content;
|
||||
ft_lstadd(list, ft_lstnew(NULL, sizeof(t_qstate)));
|
||||
/* ft_printf("befor state: %i\n", *state); */
|
||||
if (c == -1)
|
||||
{
|
||||
tmp = ft_lstpop(list);
|
||||
ft_lstdelone(&tmp, &ft_lst_cfree);
|
||||
return ;
|
||||
}
|
||||
else if (*state == Q_NONE)
|
||||
ft_lstadd(list, ft_lstnew(NULL, sizeof(t_qstate)));
|
||||
new = (*list)->content;
|
||||
*new = *state;
|
||||
if (*state == Q_NONE)
|
||||
{
|
||||
if (c == '\\')
|
||||
*state = Q_BACKSLASH;
|
||||
*new = Q_BACKSLASH;
|
||||
else if (c == '\"')
|
||||
*state = Q_DQUOTE;
|
||||
*new = Q_DQUOTE;
|
||||
else if (c == '\'')
|
||||
*state = Q_QUOTE;
|
||||
*new = Q_QUOTE;
|
||||
}
|
||||
else if (*state == Q_QUOTE)
|
||||
{
|
||||
if (c == '\'')
|
||||
*state = Q_NONE;
|
||||
*new = Q_NONE;
|
||||
}
|
||||
else if (*state == Q_DQUOTE)
|
||||
{
|
||||
if (c == '\\')
|
||||
*state = Q_BACKSLASH;
|
||||
*new = Q_BACKSLASH;
|
||||
else if (c == '\"')
|
||||
*state = Q_NONE;
|
||||
*new = Q_NONE;
|
||||
}
|
||||
else if (*state == Q_BACKSLASH)
|
||||
state = (*list)->next->next->content;
|
||||
*((t_qstate *)(*list)->content) = *state;
|
||||
*new = *(t_qstate*)(*list)->next->next->content;
|
||||
/* ft_printf("new state: %i\n", *new); */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/10 13:44:21 by jhalford #+# #+# */
|
||||
/* Updated: 2016/11/28 19:28:23 by jhalford ### ########.fr */
|
||||
/* Updated: 2016/11/29 15:32:42 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/28 18:45:23 by jhalford #+# #+# */
|
||||
/* Updated: 2016/11/28 19:27:47 by jhalford ### ########.fr */
|
||||
/* Updated: 2016/11/29 13:49:51 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/10 13:44:26 by jhalford #+# #+# */
|
||||
/* Updated: 2016/11/28 18:54:02 by jhalford ### ########.fr */
|
||||
/* Updated: 2016/11/29 13:46:30 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/10 13:44:30 by jhalford #+# #+# */
|
||||
/* Updated: 2016/11/28 19:02:05 by jhalford ### ########.fr */
|
||||
/* Updated: 2016/11/29 13:50:20 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
int ft_key_enter(t_data *data, char *buf)
|
||||
{
|
||||
(void)buf;
|
||||
if (data->state_now == Q_NONE)
|
||||
if (*(t_qstate*)data->qstack->content == Q_NONE)
|
||||
{
|
||||
ft_putchar('\n');
|
||||
ft_history_add(data);
|
||||
|
|
|
|||
|
|
@ -20,8 +20,10 @@ int parse_separator(t_btree **ast, t_list **start, t_list **lst)
|
|||
token = (*lst)->content;
|
||||
node = (*ast)->item;
|
||||
ft_parse(&(*ast)->right, &(*lst)->next);
|
||||
|
||||
node->type = token->type;
|
||||
ft_lstdelone(lst, &token_free);
|
||||
|
||||
ft_parse(&(*ast)->left, start);
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue