From 9df40e8152242f313587572fec0d59273827a14f Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Wed, 22 Mar 2017 23:58:58 +0100 Subject: [PATCH 1/2] double quote lexing with inner bquotes --- 42sh/src/exec/exec_var.c | 2 +- 42sh/src/lexer/lexer_bquote.c | 8 ++++++-- 42sh/src/lexer/lexer_dquote.c | 2 +- 42sh/src/main/main.c | 5 ++++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/42sh/src/exec/exec_var.c b/42sh/src/exec/exec_var.c index 394908be..9ec112d1 100644 --- a/42sh/src/exec/exec_var.c +++ b/42sh/src/exec/exec_var.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/07 11:12:05 by ariard #+# #+# */ -/* Updated: 2017/03/22 23:23:44 by jhalford ### ########.fr */ +/* Updated: 2017/03/22 23:36:11 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/lexer_bquote.c b/42sh/src/lexer/lexer_bquote.c index 084db882..2da9bce0 100644 --- a/42sh/src/lexer/lexer_bquote.c +++ b/42sh/src/lexer/lexer_bquote.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/09 22:03:48 by jhalford #+# #+# */ -/* Updated: 2017/03/17 21:01:50 by jhalford ### ########.fr */ +/* Updated: 2017/03/22 23:58:33 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -25,7 +25,11 @@ int lexer_bquote(t_list **alst, t_lexer *lexer) if (get_lexer_stack(*lexer) != BQUOTE) push(&lexer->stack, lexer->state); else - lexer->state = pop(&lexer->stack) == DQUOTE ? DQUOTE : DEFAULT; + { + lexer->state = pop(&lexer->stack) && + get_lexer_stack(*lexer) == DQUOTE ? DQUOTE : DEFAULT; + DG("going back into state: %i", lexer->state); + } } else if (lexer->str[lexer->pos] == '\\' && (back = 1)) { diff --git a/42sh/src/lexer/lexer_dquote.c b/42sh/src/lexer/lexer_dquote.c index f4df5b90..1786990d 100644 --- a/42sh/src/lexer/lexer_dquote.c +++ b/42sh/src/lexer/lexer_dquote.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/28 18:36:58 by jhalford #+# #+# */ -/* Updated: 2017/03/17 20:08:02 by jhalford ### ########.fr */ +/* Updated: 2017/03/22 23:56:49 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/main/main.c b/42sh/src/main/main.c index 7996a840..848f0f82 100644 --- a/42sh/src/main/main.c +++ b/42sh/src/main/main.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/20 14:45:40 by gwojda #+# #+# */ -/* Updated: 2017/03/22 22:02:30 by ariard ### ########.fr */ +/* Updated: 2017/03/22 23:50:17 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -43,6 +43,8 @@ static int handle_instruction(t_list **token, t_btree **ast) return (ret); if (do_lexer_routine(token, stream) > 0) continue ; + token_print(*token); + exit(1); if ((ret = do_parser_routine(token, ast)) == 1 && SH_NO_INTERACTIVE(data->opts)) return (ret); @@ -66,6 +68,7 @@ int main(int ac, char **av) t_btree *ast; g_argv = av; + DG("----------------"); setlocale(LC_ALL, ""); if (shell_init(ac, av) != 0) return (1); From 8bd468ffed421491aeda8d5753d86fcc90b0a125 Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Thu, 23 Mar 2017 00:04:00 +0100 Subject: [PATCH 2/2] norme --- 42sh/includes/ft_curs.h | 4 ++-- 42sh/src/lexer/lexer_bquote.c | 3 +-- 42sh/src/main/main.c | 4 +--- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/42sh/includes/ft_curs.h b/42sh/includes/ft_curs.h index d411b2c5..8d0bf2eb 100644 --- a/42sh/includes/ft_curs.h +++ b/42sh/includes/ft_curs.h @@ -6,7 +6,7 @@ /* By: sbenning +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/08 16:34:51 by sbenning #+# #+# */ -/* Updated: 2017/03/20 12:33:06 by gwojda ### ########.fr */ +/* Updated: 2017/03/23 00:03:16 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -27,7 +27,7 @@ typedef struct s_curs t_curs; ** Cursor data : cursor's coordonate and windows size */ -struct s_curs +struct s_curs { int co; int li; diff --git a/42sh/src/lexer/lexer_bquote.c b/42sh/src/lexer/lexer_bquote.c index 2da9bce0..e16cba63 100644 --- a/42sh/src/lexer/lexer_bquote.c +++ b/42sh/src/lexer/lexer_bquote.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/09 22:03:48 by jhalford #+# #+# */ -/* Updated: 2017/03/22 23:58:33 by jhalford ### ########.fr */ +/* Updated: 2017/03/22 23:59:05 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -28,7 +28,6 @@ int lexer_bquote(t_list **alst, t_lexer *lexer) { lexer->state = pop(&lexer->stack) && get_lexer_stack(*lexer) == DQUOTE ? DQUOTE : DEFAULT; - DG("going back into state: %i", lexer->state); } } else if (lexer->str[lexer->pos] == '\\' && (back = 1)) diff --git a/42sh/src/main/main.c b/42sh/src/main/main.c index 848f0f82..42581f14 100644 --- a/42sh/src/main/main.c +++ b/42sh/src/main/main.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/20 14:45:40 by gwojda #+# #+# */ -/* Updated: 2017/03/22 23:50:17 by jhalford ### ########.fr */ +/* Updated: 2017/03/22 23:59:09 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -43,8 +43,6 @@ static int handle_instruction(t_list **token, t_btree **ast) return (ret); if (do_lexer_routine(token, stream) > 0) continue ; - token_print(*token); - exit(1); if ((ret = do_parser_routine(token, ast)) == 1 && SH_NO_INTERACTIVE(data->opts)) return (ret);