commit de reference

This commit is contained in:
Jack Halford 2016-12-03 15:37:50 +01:00
parent 972e3e6cbc
commit 768d996b7a
42 changed files with 298 additions and 179 deletions

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */ /* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */
/* Updated: 2016/12/01 16:47:40 by jhalford ### ########.fr */ /* Updated: 2016/12/03 15:30:31 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -17,15 +17,15 @@
# define PIPE_READ 0 # define PIPE_READ 0
# define PIPE_WRITE 1 # define PIPE_WRITE 1
typedef struct s_exec t_exec; typedef struct s_execfunc t_execfunc;
struct s_exec struct s_execfunc
{ {
t_type type; t_type type;
int (*f)(t_btree *ast, t_data *data); int (*f)(t_btree *ast, t_data *data);
}; };
extern t_exec g_exec[]; extern t_execfunc g_execfunc[];
int ft_exec(t_btree *ast, t_data *data); int ft_exec(t_btree *ast, t_data *data);

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/10 13:38:21 by jhalford #+# #+# */ /* Created: 2016/11/10 13:38:21 by jhalford #+# #+# */
/* Updated: 2016/12/03 12:51:30 by jhalford ### ########.fr */ /* Updated: 2016/12/03 13:44:24 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -56,9 +56,11 @@ typedef enum e_qstate t_qstate;
extern t_stof g_keys[]; extern t_stof g_keys[];
int ft_set_termios(t_data *data, int input_mode);
int ft_interactive_sh(t_data *data); int ft_interactive_sh(t_data *data);
int input_init(t_data *data);
int ft_set_termios(t_data *data, int input_mode);
int ft_prompt(void); int ft_prompt(void);
int ft_history_add(t_data *data); int ft_history_add(t_data *data);
int ft_clear_line(t_data *data, char *buf); int ft_clear_line(t_data *data, char *buf);

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/10 13:07:44 by jhalford #+# #+# */ /* Created: 2016/11/10 13:07:44 by jhalford #+# #+# */
/* Updated: 2016/12/03 12:54:06 by jhalford ### ########.fr */ /* Updated: 2016/12/03 15:27:13 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -28,20 +28,39 @@
# include <fcntl.h> # include <fcntl.h>
typedef long long t_type; typedef long long t_type;
typedef struct s_line t_line;
typedef struct s_comp t_comp;
typedef struct s_exec t_exec;
struct s_data struct s_line
{ {
char **env;
t_dlist *history; t_dlist *history;
char *input;
int input_pos; int input_pos;
t_list *qstack; t_list *qstack;
char *input;
};
struct s_comp
{
int a;
};
struct s_exec
{
int fdin; int fdin;
int fdout; int fdout;
char *aol_status; char *aol_status;
int aol_search; int aol_search;
}; };
struct s_data
{
char **env;
t_exec exec;
t_line line;
t_comp comp;
};
typedef struct s_data t_data; typedef struct s_data t_data;
typedef enum e_qstate t_qstate; typedef enum e_qstate t_qstate;

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 14:21:34 by jhalford #+# #+# */ /* Created: 2016/11/28 14:21:34 by jhalford #+# #+# */
/* Updated: 2016/12/03 11:55:49 by jhalford ### ########.fr */ /* Updated: 2016/12/03 15:17:21 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -31,7 +31,7 @@ int ft_builtin(char **av, t_data *data)
while (g_builtin[++i].name) while (g_builtin[++i].name)
if (ft_strcmp(g_builtin[i].name, *av) == 0) if (ft_strcmp(g_builtin[i].name, *av) == 0)
{ {
if (data->fdout != STDOUT) if (data->exec.fdout != STDOUT)
{ {
if (fork() == 0) if (fork() == 0)
{ {

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/30 20:52:28 by jhalford #+# #+# */ /* Created: 2016/11/30 20:52:28 by jhalford #+# #+# */
/* Updated: 2016/12/01 17:46:48 by jhalford ### ########.fr */ /* Updated: 2016/12/03 15:22:12 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -14,18 +14,20 @@
int exec_and_if(t_btree *ast, t_data *data) int exec_and_if(t_btree *ast, t_data *data)
{ {
if (data->aol_status == NULL if (data->exec.aol_status == NULL
|| (data->aol_search == TK_AND_IF && *data->aol_status == '0') || (data->exec.aol_search == TK_AND_IF
|| (data->aol_search == TK_OR_IF && *data->aol_status != '0')) && *data->exec.aol_status == '0')
|| (data->exec.aol_search == TK_OR_IF
&& *data->exec.aol_status != '0'))
{ {
ft_exec(ast->left, data); ft_exec(ast->left, data);
data->aol_status = ft_getenv(data->env, "?"); data->exec.aol_status = ft_getenv(data->env, "?");
} }
data->aol_search = TK_AND_IF; data->exec.aol_search = TK_AND_IF;
if (*data->aol_status == '0' if (*data->exec.aol_status == '0'
|| ((t_astnode*)ast->right->item)->type != TK_COMMAND) || ((t_astnode*)ast->right->item)->type != TK_COMMAND)
ft_exec(ast->right, data); ft_exec(ast->right, data);
data->aol_status = NULL; data->exec.aol_status = NULL;
data->aol_search = 0; data->exec.aol_search = 0;
return (0); return (0);
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 18:15:13 by jhalford #+# #+# */ /* Created: 2016/11/28 18:15:13 by jhalford #+# #+# */
/* Updated: 2016/12/03 11:56:21 by jhalford ### ########.fr */ /* Updated: 2016/12/03 15:22:33 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -19,8 +19,8 @@ int exec_dgreat(t_btree *ast, t_data *data)
node = ast->item; node = ast->item;
fd = open(node->data.redir.word.word, O_WRONLY | O_APPEND | O_CREAT, 0644); fd = open(node->data.redir.word.word, O_WRONLY | O_APPEND | O_CREAT, 0644);
data->fdout = fd; data->exec.fdout = fd;
ft_exec(ast->left, data); ft_exec(ast->left, data);
data->fdout = STDOUT; data->exec.fdout = STDOUT;
return (0); return (0);
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/14 17:27:51 by jhalford #+# #+# */ /* Created: 2016/11/14 17:27:51 by jhalford #+# #+# */
/* Updated: 2016/12/03 11:56:28 by jhalford ### ########.fr */ /* Updated: 2016/12/03 15:22:43 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -19,8 +19,8 @@ int exec_great(t_btree *ast, t_data *data)
node = ast->item; node = ast->item;
fd = open(node->data.redir.word.word, O_WRONLY | O_TRUNC | O_CREAT, 0644); fd = open(node->data.redir.word.word, O_WRONLY | O_TRUNC | O_CREAT, 0644);
data->fdout = fd; data->exec.fdout = fd;
ft_exec(ast->left, data); ft_exec(ast->left, data);
data->fdout = STDOUT; data->exec.fdout = STDOUT;
return (0); return (0);
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/14 17:27:08 by jhalford #+# #+# */ /* Created: 2016/11/14 17:27:08 by jhalford #+# #+# */
/* Updated: 2016/12/03 11:57:29 by jhalford ### ########.fr */ /* Updated: 2016/12/03 15:22:51 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -19,8 +19,8 @@ int exec_less(t_btree *ast, t_data *data)
node = ast->item; node = ast->item;
fd = open(node->data.redir.word.word, O_RDONLY); fd = open(node->data.redir.word.word, O_RDONLY);
data->fdin = fd; data->exec.fdin = fd;
ft_exec(ast->left, data); ft_exec(ast->left, data);
data->fdin = STDIN; data->exec.fdin = STDIN;
return (0); return (0);
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/30 21:06:17 by jhalford #+# #+# */ /* Created: 2016/11/30 21:06:17 by jhalford #+# #+# */
/* Updated: 2016/12/01 17:51:53 by jhalford ### ########.fr */ /* Updated: 2016/12/03 15:23:28 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -14,18 +14,20 @@
int exec_or_if(t_btree *ast, t_data *data) int exec_or_if(t_btree *ast, t_data *data)
{ {
if (data->aol_status == NULL if (data->exec.aol_status == NULL
|| (data->aol_search == TK_AND_IF && *data->aol_status == '0') || (data->exec.aol_search == TK_AND_IF
|| (data->aol_search == TK_OR_IF && *data->aol_status != '0')) && *data->exec.aol_status == '0')
|| (data->exec.aol_search == TK_OR_IF
&& *data->exec.aol_status != '0'))
{ {
ft_exec(ast->left, data); ft_exec(ast->left, data);
data->aol_status = ft_getenv(data->env, "?"); data->exec.aol_status = ft_getenv(data->env, "?");
} }
data->aol_search = TK_OR_IF; data->exec.aol_search = TK_OR_IF;
if (*data->aol_status != '0' if (*data->exec.aol_status != '0'
|| ((t_astnode*)ast->right->item)->type != TK_COMMAND) || ((t_astnode*)ast->right->item)->type != TK_COMMAND)
ft_exec(ast->right, data); ft_exec(ast->right, data);
data->aol_status = NULL; data->exec.aol_status = NULL;
data->aol_search = 0; data->exec.aol_search = 0;
return (0); return (0);
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/27 21:13:23 by jhalford #+# #+# */ /* Created: 2016/11/27 21:13:23 by jhalford #+# #+# */
/* Updated: 2016/12/03 11:56:38 by jhalford ### ########.fr */ /* Updated: 2016/12/03 15:23:49 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -18,16 +18,16 @@ int exec_pipe(t_btree *ast, t_data *data)
pipe(fds); pipe(fds);
ft_dprintf(2, "pipe %i->%i\n", fds[PIPE_WRITE], fds[PIPE_READ]); ft_dprintf(2, "pipe %i->%i\n", fds[PIPE_WRITE], fds[PIPE_READ]);
data->fdout = fds[PIPE_WRITE]; data->exec.fdout = fds[PIPE_WRITE];
ft_exec(ast->left, data); ft_exec(ast->left, data);
if (data->fdout != STDOUT) if (data->exec.fdout != STDOUT)
close(data->fdout); close(data->exec.fdout);
data->fdout = STDOUT; data->exec.fdout = STDOUT;
data->fdin = fds[PIPE_READ]; data->exec.fdin = fds[PIPE_READ];
ft_exec(ast->right, data); ft_exec(ast->right, data);
close(fds[PIPE_WRITE]); close(fds[PIPE_WRITE]);
close(fds[PIPE_READ]); close(fds[PIPE_READ]);
data->fdin = STDIN; data->exec.fdin = STDIN;
data->fdout = STDOUT; data->exec.fdout = STDOUT;
return (0); return (0);
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/29 16:04:18 by jhalford #+# #+# */ /* Created: 2016/11/29 16:04:18 by jhalford #+# #+# */
/* Updated: 2016/12/03 11:58:27 by jhalford ### ########.fr */ /* Updated: 2016/12/03 15:24:08 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -14,14 +14,14 @@
void fd_redirect(t_data *data) void fd_redirect(t_data *data)
{ {
if (data->fdin != STDIN) if (data->exec.fdin != STDIN)
{ {
dup2(data->fdin, STDIN); dup2(data->exec.fdin, STDIN);
close(data->fdin); close(data->exec.fdin);
} }
if (data->fdout != STDOUT) if (data->exec.fdout != STDOUT)
{ {
dup2(data->fdout, STDOUT); dup2(data->exec.fdout, STDOUT);
close(data->fdout); close(data->exec.fdout);
} }
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/27 21:13:18 by jhalford #+# #+# */ /* Created: 2016/11/27 21:13:18 by jhalford #+# #+# */
/* Updated: 2016/12/03 12:06:32 by jhalford ### ########.fr */ /* Updated: 2016/12/03 15:24:31 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -55,7 +55,7 @@ int ft_cmd_exec(char *execpath, char **argv, t_data *data)
} }
else if ((g_pid = pid)) else if ((g_pid = pid))
{ {
if (data->fdout == STDOUT) if (data->exec.fdout == STDOUT)
{ {
waitpid(pid, &status, 0); waitpid(pid, &status, 0);
builtin_setenv((char*[3]){"?", ft_itoa(status)}, data); builtin_setenv((char*[3]){"?", ft_itoa(status)}, data);

View file

@ -6,13 +6,13 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/27 20:30:32 by jhalford #+# #+# */ /* Created: 2016/11/27 20:30:32 by jhalford #+# #+# */
/* Updated: 2016/12/03 11:58:36 by jhalford ### ########.fr */ /* Updated: 2016/12/03 15:25:00 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "exec.h" #include "exec.h"
t_exec g_exec[] = t_execfunc g_execfunc[] =
{ {
{TK_AND_IF, &exec_and_if}, {TK_AND_IF, &exec_and_if},
{TK_OR_IF, &exec_or_if}, {TK_OR_IF, &exec_or_if},
@ -34,10 +34,10 @@ int ft_exec(t_btree *ast, t_data *data)
item = ast->item; item = ast->item;
if (!ast) if (!ast)
return (0); return (0);
while (g_exec[i].type) while (g_execfunc[i].type)
{ {
if (item->type == g_exec[i].type) if (item->type == g_execfunc[i].type)
return ((*g_exec[i].f)(ast, data)); return ((*g_execfunc[i].f)(ast, data));
i++; i++;
} }
return (0); return (0);

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/10 13:37:11 by jhalford #+# #+# */ /* Created: 2016/11/10 13:37:11 by jhalford #+# #+# */
/* Updated: 2016/12/03 12:50:42 by jhalford ### ########.fr */ /* Updated: 2016/12/03 13:49:13 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/29 15:56:40 by jhalford #+# #+# */ /* Created: 2016/11/29 15:56:40 by jhalford #+# #+# */
/* Updated: 2016/12/03 12:36:20 by jhalford ### ########.fr */ /* Updated: 2016/12/03 15:36:24 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -19,7 +19,7 @@ void qstate_update(t_data *data, char c)
t_list **list; t_list **list;
t_list *tmp; t_list *tmp;
list = &data->qstack; list = &data->line.qstack;
state = (*list)->content; state = (*list)->content;
if (c == -1) if (c == -1)
{ {

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/10 13:43:10 by jhalford #+# #+# */ /* Created: 2016/11/10 13:43:10 by jhalford #+# #+# */
/* Updated: 2016/11/10 13:43:25 by jhalford ### ########.fr */ /* Updated: 2016/12/03 15:26:16 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -18,11 +18,11 @@ int ft_cursor_left(t_data *data, char *buf)
res = NULL; res = NULL;
(void)buf; (void)buf;
if (!data->input_pos) if (!data->line.input_pos)
return (0); return (0);
if (data->input[data->input_pos - 1] == '\n') if (data->line.input[data->line.input_pos - 1] == '\n')
return (0); return (0);
data->input_pos--; data->line.input_pos--;
if (!(res = tgetstr("le", NULL))) if (!(res = tgetstr("le", NULL)))
return (-1); return (-1);
tputs(tgoto(res, 0, 0), 0, &ft_putchar); tputs(tgoto(res, 0, 0), 0, &ft_putchar);

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/10 13:43:31 by jhalford #+# #+# */ /* Created: 2016/11/10 13:43:31 by jhalford #+# #+# */
/* Updated: 2016/11/10 13:43:31 by jhalford ### ########.fr */ /* Updated: 2016/12/03 15:26:46 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -18,11 +18,11 @@ int ft_cursor_right(t_data *data, char *buf)
res = NULL; res = NULL;
(void)buf; (void)buf;
if (!data->input[data->input_pos]) if (!data->line.input[data->line.input_pos])
return (0); return (0);
if (data->input[data->input_pos] == '\n') if (data->line.input[data->line.input_pos] == '\n')
return (0); return (0);
data->input_pos++; data->line.input_pos++;
if ((res = tgetstr("nd", NULL)) == NULL) if ((res = tgetstr("nd", NULL)) == NULL)
return (-1); return (-1);
tputs(tgoto(res, 0, 0), 0, &ft_putchar); tputs(tgoto(res, 0, 0), 0, &ft_putchar);

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/10 13:43:40 by jhalford #+# #+# */ /* Created: 2016/11/10 13:43:40 by jhalford #+# #+# */
/* Updated: 2016/12/03 12:51:27 by jhalford ### ########.fr */ /* Updated: 2016/12/03 15:27:54 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -17,17 +17,17 @@ int ft_history_add(t_data *data)
t_dlist *new; t_dlist *new;
char *str; char *str;
str = data->input; str = data->line.input;
if (data->history) if (data->line.history)
while (data->history->next) while (data->line.history->next)
data->history = data->history->next; data->line.history = data->line.history->next;
if (!data->history->prev if (!data->line.history->prev
|| ft_strcmp(str, (char *)data->history->prev->content)) || ft_strcmp(str, (char *)data->line.history->prev->content))
{ {
new = ft_dlstnew(str, sizeof(char) * (ft_strlen(str) + 1)); new = ft_dlstnew(str, sizeof(char) * (ft_strlen(str) + 1));
ft_dlstadd_before(&data->history, new); ft_dlstadd_before(&data->line.history, new);
data->history = data->history->next; data->line.history = data->line.history->next;
ft_strdel((char **)&data->history->content); ft_strdel((char **)&data->line.history->content);
} }
return (0); return (0);
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/10 13:44:06 by jhalford #+# #+# */ /* Created: 2016/11/10 13:44:06 by jhalford #+# #+# */
/* Updated: 2016/11/10 13:44:06 by jhalford ### ########.fr */ /* Updated: 2016/12/03 15:27:08 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -18,18 +18,14 @@ int ft_history_down(t_data *data, char *buf)
char *str; char *str;
(void)buf; (void)buf;
if (!data->history) if (!data->line.history)
return (0); return (0);
if (!data->history->next) if (!data->line.history->next)
return (0); return (0);
data->history = data->history->next; data->line.history = data->line.history->next;
str = data->history->content; str = data->line.history->content;
/* *input_chain = ft_dlstlast(*input_chain); */
/* ft_clear_input(input_chain); */
i = 0; i = 0;
/* while (str[i]) */ if (!data->line.history->next)
/* ft_key_basic(data, input_chain, str + i++); */
if (!data->history->next)
ft_strdel(&str); ft_strdel(&str);
return (0); return (0);
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/10 13:44:15 by jhalford #+# #+# */ /* Created: 2016/11/10 13:44:15 by jhalford #+# #+# */
/* Updated: 2016/11/10 13:44:15 by jhalford ### ########.fr */ /* Updated: 2016/12/03 15:28:24 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -18,20 +18,12 @@ int ft_history_up(t_data *data, char *buf)
char *str; char *str;
(void)buf; (void)buf;
if (!data->history) if (!data->line.history)
return (0); return (0);
if (!data->history->prev) if (!data->line.history->prev)
return (0); return (0);
/* if (!data->history->next) */ data->line.history = data->line.history->prev;
/* data->history->content = ft_dlsttostr(*input_chain); */ str = data->line.history->content;
data->history = data->history->prev;
str = data->history->content;
/* *input_chain = ft_dlst_last(*input_chain); */
/* ft_clear_line(data, input_chain, buf); */
i = 0; i = 0;
/* while (str[i]) */
/* ft_key_basic(data, input_chain, str + i++); */
/* if (!data->history->next) */
/* ft_strdel(&str); */
return (0); return (0);
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/01 12:14:12 by jhalford #+# #+# */ /* Created: 2016/12/01 12:14:12 by jhalford #+# #+# */
/* Updated: 2016/12/03 12:54:48 by jhalford ### ########.fr */ /* Updated: 2016/12/03 15:37:29 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -42,20 +42,11 @@ t_stof g_keys[] = {
int ft_interactive_sh(t_data *data) int ft_interactive_sh(t_data *data)
{ {
char buf[4]; char buf[4];
char null;
int ret; int ret;
int i; int i;
null = '\0'; if ((input_init(data)))
ft_strdel(&data->input);
data->input = ft_memalloc(10);
data->input_pos = 0;
data->qstack = ft_lstnew(NULL, sizeof(t_qstate));
*((t_qstate*)data->qstack->content) = Q_NONE;
if (ft_set_termios(data, 1))
return (-1); return (-1);
ft_prompt();
while (1) while (1)
{ {
ft_bzero(buf, 4); ft_bzero(buf, 4);
@ -69,7 +60,7 @@ int ft_interactive_sh(t_data *data)
return (-1); return (-1);
else if (ret == 2) else if (ret == 2)
{ {
ft_lstdel(&data->qstack, &ft_lst_cfree); ft_lstdel(&data->line.qstack, &ft_lst_cfree);
ft_set_termios(data, 0); ft_set_termios(data, 0);
return (0); return (0);
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/10 13:44:24 by jhalford #+# #+# */ /* Created: 2016/11/10 13:44:24 by jhalford #+# #+# */
/* Updated: 2016/11/10 13:44:24 by jhalford ### ########.fr */ /* Updated: 2016/12/03 15:29:09 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -15,9 +15,8 @@
int ft_key_ctrl_c(t_data *data, char *buf) int ft_key_ctrl_c(t_data *data, char *buf)
{ {
(void)buf; (void)buf;
ft_strdel(&data->line.input);
ft_strdel(&data->input); data->line.input = ft_memalloc(10);
data->input = ft_memalloc(10);
ft_putendl(""); ft_putendl("");
ft_prompt(); ft_prompt();
return (0); return (0);

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 18:45:23 by jhalford #+# #+# */ /* Created: 2016/11/28 18:45:23 by jhalford #+# #+# */
/* Updated: 2016/11/29 13:49:51 by jhalford ### ########.fr */ /* Updated: 2016/12/03 15:37:25 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -17,9 +17,9 @@ int ft_key_default(t_data *data, char *buf)
char *res; char *res;
char *tmp; char *tmp;
tmp = data->input; tmp = data->line.input;
data->input = ft_strinsert(data->input, *buf, data->input_pos); data->line.input = ft_strinsert(data->line.input, *buf, data->line.input_pos);
data->input_pos++; data->line.input_pos++;
ft_strdel(&tmp); ft_strdel(&tmp);
qstate_update(data, *buf); qstate_update(data, *buf);
if ((res = tgetstr("IC", NULL))) if ((res = tgetstr("IC", NULL)))

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/29 15:57:43 by jhalford #+# #+# */ /* Created: 2016/11/29 15:57:43 by jhalford #+# #+# */
/* Updated: 2016/11/29 15:57:44 by jhalford ### ########.fr */ /* Updated: 2016/12/03 15:30:02 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -18,14 +18,14 @@ int ft_key_del(t_data *data, char *buf)
(void)data; (void)data;
(void)buf; (void)buf;
if (!data->input_pos) if (!data->line.input_pos)
return (0); return (0);
if (data->input[data->input_pos - 1] == '\n') if (data->line.input[data->line.input_pos - 1] == '\n')
return (0); return (0);
qstate_update(data, -1); qstate_update(data, -1);
ft_strcpy(data->input + data->input_pos - 1, ft_strcpy(data->line.input + data->line.input_pos - 1,
data->input + data->input_pos); data->line.input + data->line.input_pos);
data->input_pos--; data->line.input_pos--;
if ((res = tgetstr("le", NULL)) == NULL) if ((res = tgetstr("le", NULL)) == NULL)
{ {
ft_printf("le error\n"); ft_printf("le error\n");

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/29 15:56:36 by jhalford #+# #+# */ /* Created: 2016/11/29 15:56:36 by jhalford #+# #+# */
/* Updated: 2016/11/29 15:56:36 by jhalford ### ########.fr */ /* Updated: 2016/12/03 15:30:46 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -15,7 +15,7 @@
int ft_key_enter(t_data *data, char *buf) int ft_key_enter(t_data *data, char *buf)
{ {
(void)buf; (void)buf;
if (*(t_qstate*)data->qstack->content == Q_NONE) if (*(t_qstate*)data->line.qstack->content == Q_NONE)
{ {
ft_putchar('\n'); ft_putchar('\n');
ft_history_add(data); ft_history_add(data);

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/10 13:44:36 by jhalford #+# #+# */ /* Created: 2016/11/10 13:44:36 by jhalford #+# #+# */
/* Updated: 2016/11/10 13:44:36 by jhalford ### ########.fr */ /* Updated: 2016/12/03 15:31:10 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -15,15 +15,11 @@
int ft_word_left(t_data *data, char *buf) int ft_word_left(t_data *data, char *buf)
{ {
ft_cursor_left(data, buf); ft_cursor_left(data, buf);
while (FT_WS(data->input[data->input_pos - 1])) while (FT_WS(data->line.input[data->line.input_pos - 1]))
{ if (!ft_cursor_left(data, buf))
if (!ft_cursor_left(data, buf)) return (0);
return (0) ; while (!FT_WS(data->line.input[data->line.input_pos - 1]))
}
while (!FT_WS(data->input[data->input_pos - 1]))
{
if (!ft_cursor_left(data, buf)) if (!ft_cursor_left(data, buf))
return (0); return (0);
}
return (0); return (0);
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/10 13:44:37 by jhalford #+# #+# */ /* Created: 2016/11/10 13:44:37 by jhalford #+# #+# */
/* Updated: 2016/11/10 13:44:37 by jhalford ### ########.fr */ /* Updated: 2016/12/03 15:31:25 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -14,15 +14,11 @@
int ft_word_right(t_data *data, char *buf) int ft_word_right(t_data *data, char *buf)
{ {
while (!FT_WS(data->input[data->input_pos])) while (!FT_WS(data->line.input[data->line.input_pos]))
{
if (!ft_cursor_right(data, buf)) if (!ft_cursor_right(data, buf))
return (0); return (0);
} while (FT_WS(data->line.input[data->line.input_pos]))
while (FT_WS(data->input[data->input_pos]))
{
if (!ft_cursor_right(data, buf)) if (!ft_cursor_right(data, buf))
return (0) ; return (0);
}
return (0); return (0);
} }

View file

@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* input_init.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/03 13:35:03 by jhalford #+# #+# */
/* Updated: 2016/12/03 15:34:29 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int input_init(t_data *data)
{
char null;
null = '\0';
ft_strdel(&data->line.input);
data->line.input = ft_memalloc(10);
data->line.input_pos = 0;
data->line.qstack = ft_lstnew(NULL, sizeof(t_qstate));
*((t_qstate*)data->line.qstack->content) = Q_NONE;
if (ft_set_termios(data, 1))
return (-1);
ft_prompt();
return (0);
}

View file

@ -0,0 +1,21 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* qstate_dquote.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/03 12:10:09 by jhalford #+# #+# */
/* Updated: 2016/12/03 12:26:09 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "line_editing.h"
void qstate_dquote(t_qstate *new, char c)
{
if (c == '\\')
*new = Q_BACKSLASH;
else if (c == '\"')
*new = Q_NONE;
}

View file

@ -0,0 +1,23 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* qstate_none.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/03 12:08:48 by jhalford #+# #+# */
/* Updated: 2016/12/03 12:51:29 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "line_editing.h"
void qstate_none(t_qstate *new, char c)
{
if (c == '\\')
*new = Q_BACKSLASH;
else if (c == '\"')
*new = Q_DQUOTE;
else if (c == '\'')
*new = Q_QUOTE;
}

View file

@ -0,0 +1,19 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* qstate_quote.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/03 12:10:09 by jhalford #+# #+# */
/* Updated: 2016/12/03 12:26:06 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "line_editing.h"
void qstate_quote(t_qstate *new, char c)
{
if (c == '\'')
*new = Q_NONE;
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */ /* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */
/* Updated: 2016/12/01 17:31:00 by jhalford ### ########.fr */ /* Updated: 2016/12/03 15:32:25 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -18,12 +18,12 @@ int data_init(t_data *data)
{ {
atexit(&ft_cleanup); atexit(&ft_cleanup);
data->env = ft_sstrdup(environ); data->env = ft_sstrdup(environ);
data->history = NULL; data->line.history = NULL;
data->fdin = STDIN; data->exec.fdin = STDIN;
data->fdout = STDOUT; data->exec.fdout = STDOUT;
data->aol_status = NULL; data->exec.aol_status = NULL;
data->aol_search = 0; data->exec.aol_search = 0;
if (!(data->history = ft_dlstnew(NULL, 0))) if (!(data->line.history = ft_dlstnew(NULL, 0)))
return (-1); return (-1);
return (0); return (0);
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/01 14:42:42 by jhalford #+# #+# */ /* Created: 2016/12/01 14:42:42 by jhalford #+# #+# */
/* Updated: 2016/12/01 14:46:07 by jhalford ### ########.fr */ /* Updated: 2016/12/03 15:19:41 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/14 18:18:04 by jhalford #+# #+# */ /* Created: 2016/11/14 18:18:04 by jhalford #+# #+# */
/* Updated: 2016/12/01 16:54:25 by jhalford ### ########.fr */ /* Updated: 2016/12/03 13:44:22 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -15,6 +15,23 @@
char *ft_putast(void *nodein) char *ft_putast(void *nodein)
{ {
t_astnode *node; t_astnode *node;
struct s_tmp{
char str[5];
t_type type;
};
/* struct s_tmp[] = */
/* { */
/* {TK_AMP, " & "}, */
/* {TK_SEMI, " & "}, */
/* {TK_AND_IF, " & "}, */
/* {TK_OR_IF, " & "}, */
/* {TK_PIPE, " & "}, */
/* {TK_COMMAND, " & "}, */
/* {TK_GREAT, " & "}, */
/* {TK_AMP, " & "}, */
/* {TK_AMP, " & "}, */
/* } */
node = nodein; node = nodein;
if (node->type == TK_AMP) if (node->type == TK_AMP)
@ -28,13 +45,7 @@ char *ft_putast(void *nodein)
else if (node->type == TK_PIPE) else if (node->type == TK_PIPE)
return (" | "); return (" | ");
else if (node->type == TK_COMMAND) else if (node->type == TK_COMMAND)
{
/*char **sstr = node->u_data.sstr; */
/* while (*sstr) */
/* ft_printf("%s,", *sstr++); */
/* return (ft_itoa_base(node->type, "0123456789abcdef", "")); */
return (" COM "); return (" COM ");
}
else if (node->type == TK_GREAT) else if (node->type == TK_GREAT)
return (" > "); return (" > ");
else if (node->type == TK_LESS) else if (node->type == TK_LESS)

View file

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* lib_expansion.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/03 13:37:41 by jhalford #+# #+# */
/* Updated: 2016/12/03 13:37:41 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h" #include "minishell.h"
void ft_expand_dollar(char **av, char **env) void ft_expand_dollar(char **av, char **env)

View file

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* lib_path.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/03 13:37:49 by jhalford #+# #+# */
/* Updated: 2016/12/03 13:37:49 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h" #include "minishell.h"
char *ft_findexec(char **path, char *file) char *ft_findexec(char **path, char *file)

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/27 21:13:34 by jhalford #+# #+# */ /* Created: 2016/11/27 21:13:34 by jhalford #+# #+# */
/* Updated: 2016/12/03 13:15:35 by jhalford ### ########.fr */ /* Updated: 2016/12/03 15:33:21 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -29,7 +29,7 @@ int main(void)
return (1); return (1);
/* ft_dprintf(STDERR, "command='%s'\n", data.input); */ /* ft_dprintf(STDERR, "command='%s'\n", data.input); */
token = NULL; token = NULL;
if (ft_tokenize(&token, data.input, DEFAULT)) if (ft_tokenize(&token, data.line.input, DEFAULT))
return (1); return (1);
if (!token) if (!token)
continue ; continue ;

View file

@ -6,11 +6,12 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/01 12:43:22 by jhalford #+# #+# */ /* Created: 2016/12/01 12:43:22 by jhalford #+# #+# */
/* Updated: 2016/12/01 14:46:41 by jhalford ### ########.fr */ /* Updated: 2016/12/03 13:31:33 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "minishell.h" #include "minishell.h"
pid_t g_pid; pid_t g_pid;
void sig_handler(int signo) void sig_handler(int signo)

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/30 17:14:58 by jhalford #+# #+# */ /* Created: 2016/11/30 17:14:58 by jhalford #+# #+# */
/* Updated: 2016/12/01 16:53:41 by jhalford ### ########.fr */ /* Updated: 2016/12/03 13:50:36 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -34,7 +34,7 @@ int ft_parse(t_btree **ast, t_list **start)
int i; int i;
i = 0; i = 0;
if(!*start) if (!*start)
return (0); return (0);
if (!*ast) if (!*ast)
{ {

View file

@ -3,10 +3,10 @@
/* ::: :::::::: */ /* ::: :::::::: */
/* parse_dless.c :+: :+: :+: */ /* parse_dless.c :+: :+: :+: */
/* +:+ +:+ +:+ */ /* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/14 12:49:45 by jhalford #+# #+# */ /* Created: 2016/12/03 13:31:40 by jhalford #+# #+# */
/* Updated: 2016/12/01 16:37:20 by jhalford ### ########.fr */ /* Updated: 2016/12/03 13:31:41 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -32,4 +32,3 @@ int parse_dless(t_btree **ast, t_list **start, t_list **lst)
ft_parse(&(*ast)->left, start); ft_parse(&(*ast)->left, start);
return (0); return (0);
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/14 12:49:45 by jhalford #+# #+# */ /* Created: 2016/11/14 12:49:45 by jhalford #+# #+# */
/* Updated: 2016/12/01 16:37:29 by jhalford ### ########.fr */ /* Updated: 2016/12/03 13:32:06 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 16:21:51 by jhalford #+# #+# */ /* Created: 2016/11/28 16:21:51 by jhalford #+# #+# */
/* Updated: 2016/11/30 21:45:49 by jhalford ### ########.fr */ /* Updated: 2016/12/03 13:32:14 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -20,11 +20,8 @@ int parse_separator(t_btree **ast, t_list **start, t_list **lst)
token = (*lst)->content; token = (*lst)->content;
node = (*ast)->item; node = (*ast)->item;
node->type = token->type; node->type = token->type;
ft_parse(&(*ast)->right, &(*lst)->next); ft_parse(&(*ast)->right, &(*lst)->next);
ft_lst_delif(start, (*lst)->content, &ft_addrcmp, &token_free); ft_lst_delif(start, (*lst)->content, &ft_addrcmp, &token_free);
ft_parse(&(*ast)->left, start); ft_parse(&(*ast)->left, start);
return (0); return (0);
} }