petit commit avant de merge job_control: unification de data_singleton (Samuel n'utilisais pas le meme) et quelques petites retouches. beau boulet sur le readline @sbenning
This commit is contained in:
parent
4d9b5c02ca
commit
21276905b7
14 changed files with 40 additions and 66 deletions
|
|
@ -47,7 +47,7 @@ $(D_OBJ)/%.o: $(D_SRC)/minishell-exec/%.c includes/minishell.h
|
|||
@$(CC) $(O_INC) $(W_FLAGS) -c $< -o $@ $(D_FLAGS)
|
||||
@echo "Compiling "$<"..."
|
||||
|
||||
$(D_OBJ)/%.o: $(D_SRC)/line-editing/%.c includes/line_editing.h
|
||||
$(D_OBJ)/%.o: $(D_SRC)/line-editing/%.c includes/ft_readline.h
|
||||
@$(MKDIR) $(D_OBJ)
|
||||
@$(CC) $(O_INC) $(W_FLAGS) -c $< -o $@ $(D_FLAGS)
|
||||
@echo "Compiling "$<"..."
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: sbenning <sbenning@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/09 02:05:22 by sbenning #+# #+# */
|
||||
/* Updated: 2016/12/14 13:50:33 by sbenning ### ########.fr */
|
||||
/* Updated: 2017/01/10 11:45:38 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: sbenning <sbenning@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/08 18:02:25 by sbenning #+# #+# */
|
||||
/* Updated: 2016/12/14 13:51:14 by sbenning ### ########.fr */
|
||||
/* Updated: 2017/01/10 11:46:49 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -65,13 +65,13 @@
|
|||
* QUOTING : Regroup ESC, QUOTE and DQUOTE
|
||||
*/
|
||||
|
||||
# define RL_FINISH 0x1
|
||||
# define RL_STACK 0x2
|
||||
# define RL_INSERT 0x4
|
||||
# define RL_SELECT 0x8
|
||||
# define RL_ESC 0x10
|
||||
# define RL_QUOTE 0x20
|
||||
# define RL_DQUOTE 0x40
|
||||
# define RL_FINISH (1 << 0)
|
||||
# define RL_STACK (1 << 1)
|
||||
# define RL_INSERT (1 << 2)
|
||||
# define RL_SELECT (1 << 3)
|
||||
# define RL_ESC (1 << 4)
|
||||
# define RL_QUOTE (1 << 5)
|
||||
# define RL_DQUOTE (1 << 6)
|
||||
# define RL_QUOTING (RL_ESC | RL_QUOTE | RL_DQUOTE)
|
||||
|
||||
typedef struct s_data t_data;
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* line_editing.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: sbenning <sbenning@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/10 09:41:50 by sbenning #+# #+# */
|
||||
/* Updated: 2016/12/10 10:24:12 by sbenning ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef LINE_EDITING_H
|
||||
# define LINE_EDITING_H
|
||||
|
||||
# include "ft_readline.h"
|
||||
# include "minishell.h"
|
||||
|
||||
typedef struct s_data t_data;
|
||||
|
||||
t_data **data_singleton(void);
|
||||
int ft_interactive_sh(t_data *data);
|
||||
|
||||
#endif
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/10 13:07:44 by jhalford #+# #+# */
|
||||
/* Updated: 2016/12/10 10:28:20 by sbenning ### ########.fr */
|
||||
/* Updated: 2017/01/10 11:50:31 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -16,9 +16,9 @@
|
|||
|
||||
# include "libft.h"
|
||||
|
||||
# include "line_editing.h"
|
||||
# include "lexer.h"
|
||||
# include "parser.h"
|
||||
# include "ft_readline.h"
|
||||
# include "exec.h"
|
||||
|
||||
# include <dirent.h>
|
||||
|
|
@ -68,6 +68,7 @@ extern t_stof g_builtins[];
|
|||
extern pid_t g_pid;
|
||||
|
||||
void sig_handler(int signo);
|
||||
t_data *data_singleton();
|
||||
int data_init(t_data *data);
|
||||
void data_exit(t_data *data);
|
||||
void ft_cleanup(void);
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 97bc4fed552dce523e2de8fb744ba46ec877f8eb
|
||||
Subproject commit d799465c2e0d51f24fe4d5cf1e51c5109a1617a0
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: sbenning <sbenning@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/08 16:50:26 by sbenning #+# #+# */
|
||||
/* Updated: 2016/12/09 16:50:10 by sbenning ### ########.fr */
|
||||
/* Updated: 2017/01/10 11:54:47 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: sbenning <sbenning@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/08 18:03:48 by sbenning #+# #+# */
|
||||
/* Updated: 2016/12/12 10:48:50 by sbenning ### ########.fr */
|
||||
/* Updated: 2017/01/10 11:51:34 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: sbenning <sbenning@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/12 10:49:03 by sbenning #+# #+# */
|
||||
/* Updated: 2016/12/14 13:49:39 by sbenning ### ########.fr */
|
||||
/* Updated: 2017/01/10 11:51:19 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ int rl_comp_function(t_line *line, long int input)
|
|||
{
|
||||
t_data *data;
|
||||
|
||||
data = *data_singleton();
|
||||
data = data_singleton();
|
||||
if (ft_autocomp(data) < 0)
|
||||
return (-1);
|
||||
line->size = ft_strlen(line->input);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: sbenning <sbenning@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/09 01:45:09 by sbenning #+# #+# */
|
||||
/* Updated: 2016/12/12 12:20:55 by sbenning ### ########.fr */
|
||||
/* Updated: 2017/01/10 11:43:12 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: sbenning <sbenning@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/08 18:07:47 by sbenning #+# #+# */
|
||||
/* Updated: 2016/12/12 13:24:28 by sbenning ### ########.fr */
|
||||
/* Updated: 2017/01/10 11:54:49 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */
|
||||
/* Updated: 2016/12/09 19:15:12 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/01/10 11:55:36 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,26 +1,22 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* interactive_sh.c :+: :+: :+: */
|
||||
/* data_singleton.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: sbenning <sbenning@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/10 09:44:43 by sbenning #+# #+# */
|
||||
/* Updated: 2016/12/10 10:24:12 by sbenning ### ########.fr */
|
||||
/* Created: 2017/01/10 11:36:39 by jhalford #+# #+# */
|
||||
/* Updated: 2017/01/10 11:47:11 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "line_editing.h"
|
||||
#include "minishell.h"
|
||||
|
||||
t_data **data_singleton(void)
|
||||
t_data *data_singleton()
|
||||
{
|
||||
static t_data *data;
|
||||
static t_data *data = NULL;
|
||||
|
||||
return (&data);
|
||||
}
|
||||
|
||||
int ft_interactive_sh(t_data *data)
|
||||
{
|
||||
*data_singleton() = data;
|
||||
return (ft_readline(&data->line));
|
||||
if (data == NULL)
|
||||
data = malloc(sizeof(t_data));
|
||||
return (data);
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */
|
||||
/* Updated: 2016/12/09 22:15:07 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/01/10 11:56:39 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -14,24 +14,25 @@
|
|||
|
||||
int main(void)
|
||||
{
|
||||
t_data data;
|
||||
t_data *data;
|
||||
t_list *token;
|
||||
t_btree *ast;
|
||||
|
||||
token = NULL;
|
||||
ast = NULL;
|
||||
if (data_init(&data))
|
||||
data = data_singleton();
|
||||
if (data_init(data))
|
||||
return (1);
|
||||
if (signal(SIGINT, sig_handler) == SIG_ERR)
|
||||
ft_dprintf(STDERR, "\ncan't catch SIGINT\n");
|
||||
DG("{inv}{bol}{gre}start of shell");
|
||||
while (1)
|
||||
{
|
||||
if (ft_interactive_sh(&data))
|
||||
if (ft_readline(&data->line))
|
||||
return (1);
|
||||
DG("{inv}{mag}got command '%s'", data.line.input);
|
||||
DG("{inv}{mag}got command '%s'", data->line.input);
|
||||
token = NULL;
|
||||
if (ft_tokenize(&token, data.line.input, DEFAULT))
|
||||
if (ft_tokenize(&token, data->line.input, DEFAULT))
|
||||
return (1);
|
||||
if (!token)
|
||||
continue ;
|
||||
|
|
@ -41,7 +42,7 @@ int main(void)
|
|||
btree_print(STDERR, ast, &ft_putast);
|
||||
/* ft_dprintf(STDERR, "\n--- INFIX BREAKDOWN ---\n"); */
|
||||
/* btree_apply_infix(ast, &ft_putast2); */
|
||||
if (ft_exec(&ast, &data))
|
||||
if (ft_exec(&ast, data))
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
|
|
|
|||
Loading…
Reference in a new issue