backquote work, still some segfaults, end of day commit
This commit is contained in:
parent
ef400aa225
commit
dfdf245b1a
19 changed files with 142 additions and 68 deletions
|
|
@ -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: 2017/01/11 17:59:52 by jhalford ### ########.fr */
|
/* Updated: 2017/01/12 13:18:27 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/01 12:15:50 by jhalford #+# #+# */
|
/* Created: 2016/12/01 12:15:50 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/01/11 17:08:20 by jhalford ### ########.fr */
|
/* Updated: 2017/01/12 14:57:41 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -82,7 +82,8 @@ void token_print(t_list *lst);
|
||||||
void token_expand_var(t_token *token);
|
void token_expand_var(t_token *token);
|
||||||
|
|
||||||
int reduce_parens(t_list **alst, char *str);
|
int reduce_parens(t_list **alst, char *str);
|
||||||
int reduce_bquotes(t_list **alst, char *str);
|
int reduce_bquotes(t_list **alst, char **str);
|
||||||
|
char *command_getoutput(char *command);
|
||||||
|
|
||||||
int ft_is_delim(char c);
|
int ft_is_delim(char c);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 5cfe17901496443664e5b7be7fd87310f854030c
|
Subproject commit ab92f0e5d817c9d726a8ccf2f11c084ba446bbdf
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/14 17:28:14 by jhalford #+# #+# */
|
/* Created: 2016/11/14 17:28:14 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/01/11 17:51:08 by jhalford ### ########.fr */
|
/* Updated: 2017/01/12 13:14:35 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/13 15:10:20 by jhalford #+# #+# */
|
/* Created: 2016/12/13 15:10:20 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/01/11 17:53:45 by jhalford ### ########.fr */
|
/* Updated: 2017/01/12 15:15:21 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/15 12:51:08 by jhalford #+# #+# */
|
/* Created: 2016/12/15 12:51:08 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/01/10 12:31:00 by jhalford ### ########.fr */
|
/* Updated: 2017/01/12 15:16:05 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -19,11 +19,11 @@ void job_remove(int id)
|
||||||
jobc = &data_singleton()->jobc;
|
jobc = &data_singleton()->jobc;
|
||||||
if (job_is_completed(id))
|
if (job_is_completed(id))
|
||||||
{
|
{
|
||||||
/* DG("job_remove"); */
|
DG("job_remove");
|
||||||
if (id < data_singleton()->jobc.current_id)
|
if (id < data_singleton()->jobc.current_id)
|
||||||
data_singleton()->jobc.current_id = id;
|
data_singleton()->jobc.current_id = id;
|
||||||
ft_lst_delif(&jobc->first_job, &id, job_cmp_id, job_free);
|
ft_lst_delif(&jobc->first_job, &id, job_cmp_id, job_free);
|
||||||
}
|
}
|
||||||
/* else */
|
else
|
||||||
/* DG("job_remove failed (not completed)"); */
|
DG("job_remove failed (not completed)");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/15 11:49:05 by jhalford #+# #+# */
|
/* Created: 2016/12/15 11:49:05 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/01/11 17:55:30 by jhalford ### ########.fr */
|
/* Updated: 2017/01/12 15:14:38 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/09 13:05:55 by jhalford #+# #+# */
|
/* Created: 2017/01/09 13:05:55 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/01/11 16:49:50 by jhalford ### ########.fr */
|
/* Updated: 2017/01/12 13:16:45 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -43,7 +43,14 @@ void process_format(t_list **plist, int firstp, int opts)
|
||||||
ft_putchar('\t');
|
ft_putchar('\t');
|
||||||
if (opts & JOBS_OPTS_L)
|
if (opts & JOBS_OPTS_L)
|
||||||
{
|
{
|
||||||
ft_sstrprint(p->av, ' ');
|
if (p->attributes & PROCESS_SUBSHELL)
|
||||||
|
{
|
||||||
|
ft_putstr("( ");
|
||||||
|
ft_putstr(p->av[2]);
|
||||||
|
ft_putstr(" )");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ft_sstrprint(p->av, ' ');
|
||||||
if ((*plist)->next)
|
if ((*plist)->next)
|
||||||
ft_putstr(" |");
|
ft_putstr(" |");
|
||||||
(*plist) = (*plist)->next;
|
(*plist) = (*plist)->next;
|
||||||
|
|
@ -61,7 +68,14 @@ void process_format(t_list **plist, int firstp, int opts)
|
||||||
p->attributes &= ~PROCESS_STATE_MASK;
|
p->attributes &= ~PROCESS_STATE_MASK;
|
||||||
p->attributes &= ~PROCESS_RUNNING;
|
p->attributes &= ~PROCESS_RUNNING;
|
||||||
}
|
}
|
||||||
ft_sstrprint(p->av, ' ');
|
if (p->attributes & PROCESS_SUBSHELL)
|
||||||
|
{
|
||||||
|
ft_putstr("( ");
|
||||||
|
ft_putstr(p->av[2]);
|
||||||
|
ft_putstr(" )");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ft_sstrprint(p->av, ' ');
|
||||||
if ((*plist)->next)
|
if ((*plist)->next)
|
||||||
ft_putstr(" | ");
|
ft_putstr(" | ");
|
||||||
(*plist) = (*plist)->next;
|
(*plist) = (*plist)->next;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/12 12:41:11 by jhalford #+# #+# */
|
/* Created: 2016/12/12 12:41:11 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/01/11 17:54:22 by jhalford ### ########.fr */
|
/* Updated: 2017/01/12 15:14:28 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -23,13 +23,13 @@ int process_mark_status(pid_t pid, int status)
|
||||||
p->status = status;
|
p->status = status;
|
||||||
if (WIFSTOPPED(status))
|
if (WIFSTOPPED(status))
|
||||||
{
|
{
|
||||||
/* DG("marking: pid=%i, status=%i (stopped sig %i)", pid, status, WTERMSIG(status)); */
|
DG("marking: pid=%i, status=%i (stopped sig %i)", pid, status, WTERMSIG(status));
|
||||||
p->attributes &= ~PROCESS_STATE_MASK;
|
p->attributes &= ~PROCESS_STATE_MASK;
|
||||||
p->attributes |= PROCESS_SUSPENDED;
|
p->attributes |= PROCESS_SUSPENDED;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* DG("marking: pid=%i, status=%i (completed sig %i)", pid, status, WTERMSIG(status)); */
|
DG("marking: pid=%i, status=%i (completed sig %i)", pid, status, WTERMSIG(status));
|
||||||
p->attributes &= ~PROCESS_STATE_MASK;
|
p->attributes &= ~PROCESS_STATE_MASK;
|
||||||
p->attributes |= PROCESS_COMPLETED;
|
p->attributes |= PROCESS_COMPLETED;
|
||||||
if (WIFSIGNALED(status))
|
if (WIFSIGNALED(status))
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/13 14:58:36 by jhalford #+# #+# */
|
/* Created: 2016/12/13 14:58:36 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/01/11 17:54:29 by jhalford ### ########.fr */
|
/* Updated: 2017/01/12 13:16:48 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
56
42sh/src/lexer/command_getoutput.c
Normal file
56
42sh/src/lexer/command_getoutput.c
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* command_getoutput.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2017/01/12 14:01:59 by jhalford #+# #+# */
|
||||||
|
/* Updated: 2017/01/12 15:31:34 by jhalford ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "minishell.h"
|
||||||
|
#define BUF_SIZE 10
|
||||||
|
|
||||||
|
char *command_getoutput(char *command)
|
||||||
|
{
|
||||||
|
int fds[2];
|
||||||
|
t_btree *ast;
|
||||||
|
t_astnode item;
|
||||||
|
char *output;
|
||||||
|
char *buf;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
output = NULL;
|
||||||
|
buf = NULL;
|
||||||
|
item.type = TK_SUBSHELL;
|
||||||
|
item.data.sstr = malloc(4 * sizeof(char *));
|
||||||
|
item.data.sstr[0] = ft_strdup(data_singleton()->argv[0]);
|
||||||
|
item.data.sstr[1] = ft_strdup("-c");
|
||||||
|
item.data.sstr[2] = ft_strdup(command);
|
||||||
|
item.data.sstr[3] = NULL;
|
||||||
|
ast = btree_create_node(&item, sizeof(item));
|
||||||
|
pipe(fds);
|
||||||
|
dup2(fds[PIPE_WRITE], 1);
|
||||||
|
close(fds[PIPE_WRITE]);
|
||||||
|
ft_exec(&ast);
|
||||||
|
/* DG("gonna parse"); */
|
||||||
|
/* token_print(token); */
|
||||||
|
/* if (ft_parse(&ast, &token)) */
|
||||||
|
/* return (NULL); */
|
||||||
|
/* DG("gonna exec"); */
|
||||||
|
/* if (ft_exec(&ast)) */
|
||||||
|
/* return (NULL); */
|
||||||
|
|
||||||
|
DG("gonna read from pipe");
|
||||||
|
while ((ret = read(fds[PIPE_READ], buf, BUF_SIZE)))
|
||||||
|
{
|
||||||
|
buf[ret] = 0;
|
||||||
|
DG("read '%s' from pipe", buf);
|
||||||
|
ft_strappend(&output, buf);
|
||||||
|
}
|
||||||
|
DG("finished reading from pipe");
|
||||||
|
close(fds[PIPE_READ]);
|
||||||
|
return (output);
|
||||||
|
}
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/11 16:11:11 by jhalford #+# #+# */
|
/* Created: 2017/01/11 16:11:11 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/01/11 17:07:39 by jhalford ### ########.fr */
|
/* Updated: 2017/01/12 13:58:20 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -14,9 +14,14 @@
|
||||||
|
|
||||||
int ft_post_tokenize(t_list **alst, char *str)
|
int ft_post_tokenize(t_list **alst, char *str)
|
||||||
{
|
{
|
||||||
if (reduce_parens(alst, str))
|
int ret;
|
||||||
return (1);
|
|
||||||
if (reduce_bquotes(alst, str))
|
while ((ret = reduce_parens(alst, str)))
|
||||||
return (1);
|
if (ret == -1)
|
||||||
|
return (-1);
|
||||||
|
while ((ret = reduce_bquotes(alst, &str)))
|
||||||
|
if (ret == -1)
|
||||||
|
return (-1);
|
||||||
|
DG("new command from bquotes: '%s'", str);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,43 +6,44 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/11 16:46:27 by jhalford #+# #+# */
|
/* Created: 2017/01/11 16:46:27 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/01/11 17:56:40 by jhalford ### ########.fr */
|
/* Updated: 2017/01/12 15:10:16 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "lexer.h"
|
#include "lexer.h"
|
||||||
|
|
||||||
int reduce_bquotes(t_list **alst, char *str)
|
int reduce_bquotes(t_list **alst, char **str)
|
||||||
{
|
{
|
||||||
t_list *start;
|
t_list *start;
|
||||||
t_list *end;
|
t_list **end;
|
||||||
t_token *token;
|
t_token *token;
|
||||||
int tk;
|
int tk;
|
||||||
|
char *new;
|
||||||
|
char *fit;
|
||||||
|
char *bq_start;
|
||||||
|
char *bq_end;
|
||||||
|
|
||||||
(void)str;
|
|
||||||
tk = TK_BQUOTE;
|
tk = TK_BQUOTE;
|
||||||
if ((start = ft_lst_find(*alst, &tk, token_cmp_type)))
|
if ((start = ft_lst_find(*alst, &tk, token_cmp_type)))
|
||||||
{
|
{
|
||||||
end = start->next;
|
end = &start->next;
|
||||||
while (end)
|
while (end)
|
||||||
{
|
{
|
||||||
token = end->content;
|
token = (*end)->content;
|
||||||
if (token->type == TK_BQUOTE)
|
if (token->type == TK_BQUOTE)
|
||||||
break ;
|
break ;
|
||||||
end = end->next;
|
end = &(*end)->next;
|
||||||
if (token->type & TK_NON_FREEABLE)
|
|
||||||
ft_lst_delif(alst, token, ft_addrcmp, ft_lst_cfree);
|
|
||||||
else
|
|
||||||
ft_lst_delif(alst, token, ft_addrcmp, token_free);
|
|
||||||
}
|
|
||||||
if (end)
|
|
||||||
{
|
|
||||||
token = start->content;
|
|
||||||
token->type = TK_SUBSHELL;
|
|
||||||
token->data = ft_strbetween(token->data + 1, ((t_token*)end->content)->data);
|
|
||||||
ft_lst_delif(alst, end->content, ft_addrcmp, ft_lst_cfree);
|
|
||||||
return (0);
|
|
||||||
}
|
}
|
||||||
|
if (!*end)
|
||||||
|
return (-1);
|
||||||
|
bq_start = ((t_token*)start->content)->data;
|
||||||
|
bq_end = ((t_token*)(*end)->content)->data;
|
||||||
|
ft_lstdel(end, token_free);
|
||||||
|
fit = command_getoutput(ft_strbetween(bq_start + 1, bq_end));
|
||||||
|
new = ft_strreplace(str, bq_start, bq_end, fit);
|
||||||
|
ft_strdel(str);
|
||||||
|
*str = new;
|
||||||
|
ft_lstdel(alst, token_free);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/11 16:13:31 by jhalford #+# #+# */
|
/* Created: 2017/01/11 16:13:31 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/01/11 17:06:51 by jhalford ### ########.fr */
|
/* Updated: 2017/01/12 13:50:10 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -36,19 +36,14 @@ int reduce_parens(t_list **alst, char *str)
|
||||||
if (num_p == 0)
|
if (num_p == 0)
|
||||||
break ;
|
break ;
|
||||||
end = end->next;
|
end = end->next;
|
||||||
if (token->type & TK_NON_FREEABLE)
|
ft_lst_delif(alst, token, ft_addrcmp, token_free);
|
||||||
ft_lst_delif(alst, token, ft_addrcmp, ft_lst_cfree);
|
|
||||||
else
|
|
||||||
ft_lst_delif(alst, token, ft_addrcmp, token_free);
|
|
||||||
}
|
|
||||||
if (end)
|
|
||||||
{
|
|
||||||
token = start->content;
|
|
||||||
token->type = TK_SUBSHELL;
|
|
||||||
token->data = ft_strbetween(token->data + 1, ((t_token*)end->content)->data);
|
|
||||||
ft_lst_delif(alst, end->content, ft_addrcmp, ft_lst_cfree);
|
|
||||||
return (0);
|
|
||||||
}
|
}
|
||||||
|
if (!end)
|
||||||
|
return (-1);
|
||||||
|
token = start->content;
|
||||||
|
token->type = TK_SUBSHELL;
|
||||||
|
token->data = ft_strbetween(token->data + 1, ((t_token*)end->content)->data);
|
||||||
|
ft_lst_delif(alst, end->content, ft_addrcmp, token_free);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/03 12:07:30 by jhalford #+# #+# */
|
/* Created: 2016/12/03 12:07:30 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/12/05 13:17:56 by jhalford ### ########.fr */
|
/* Updated: 2017/01/12 13:18:46 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -18,6 +18,7 @@ void token_free(void *data, size_t size)
|
||||||
|
|
||||||
(void)size;
|
(void)size;
|
||||||
token = data;
|
token = data;
|
||||||
ft_strdel(&token->data);
|
if (!(token->type & TK_NON_FREEABLE))
|
||||||
|
ft_strdel(&token->data);
|
||||||
free(token);
|
free(token);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/28 14:39:01 by jhalford #+# #+# */
|
/* Created: 2016/11/28 14:39:01 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/01/11 16:28:42 by jhalford ### ########.fr */
|
/* Updated: 2017/01/12 14:48:33 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -21,6 +21,7 @@ void token_print(t_list *lst)
|
||||||
while (lst)
|
while (lst)
|
||||||
{
|
{
|
||||||
i = -1;
|
i = -1;
|
||||||
|
DG("lst at %p", lst);
|
||||||
token = lst->content;
|
token = lst->content;
|
||||||
type = token->type;
|
type = token->type;
|
||||||
while (type >> (i++ + 2))
|
while (type >> (i++ + 2))
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */
|
/* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/01/11 17:48:10 by jhalford ### ########.fr */
|
/* Updated: 2017/01/12 14:02:30 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -31,13 +31,13 @@ int shell_single_command(char *command)
|
||||||
return (1);
|
return (1);
|
||||||
DG("after post_tokenize");
|
DG("after post_tokenize");
|
||||||
token_print(token);
|
token_print(token);
|
||||||
if (ft_parse(&ast, &token))
|
/* if (ft_parse(&ast, &token)) */
|
||||||
return (1);
|
/* return (1); */
|
||||||
btree_print(STDBUG, ast, &ft_putast);
|
/* btree_print(STDBUG, ast, &ft_putast); */
|
||||||
/* ft_dprintf(STDBUG, "\n--- INFIX BREAKDOWN ---\n"); */
|
/* /1* ft_dprintf(STDBUG, "\n--- INFIX BREAKDOWN ---\n"); *1/ */
|
||||||
/* btree_apply_infix(ast, &ft_putast2); */
|
/* /1* btree_apply_infix(ast, &ft_putast2); *1/ */
|
||||||
if (ft_exec(&ast))
|
/* if (ft_exec(&ast)) */
|
||||||
return (1);
|
/* return (1); */
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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: 2017/01/11 16:52:25 by jhalford ### ########.fr */
|
/* Updated: 2017/01/12 15:07:31 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/11 16:52:44 by jhalford #+# #+# */
|
/* Created: 2017/01/11 16:52:44 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/01/11 17:50:54 by jhalford ### ########.fr */
|
/* Updated: 2017/01/12 15:10:24 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue