From 045b3c02269d0ebc89a231cd7dfa944333a6e9b6 Mon Sep 17 00:00:00 2001 From: gwojda Date: Fri, 3 Feb 2017 15:41:06 +0100 Subject: [PATCH] =?UTF-8?q?completion=20en=20cas=20d'unique=20possibilit?= =?UTF-8?q?=C3=A9=20:=20OK=20!=20:D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 42sh/Makefile | 4 ++-- 42sh/src/completion/c_output.c | 4 ++-- 42sh/src/completion/completion.c | 5 ++--- 42sh/src/line-editing/check_backslash.c | 4 +++- 42sh/src/line-editing/completion.c | 9 +++++---- 42sh/src/line-editing/get_touch.c | 6 +++--- 42sh/src/main/data_init.c | 3 ++- 42sh/src/main/data_singleton.c | 4 ++-- 8 files changed, 21 insertions(+), 18 deletions(-) diff --git a/42sh/Makefile b/42sh/Makefile index 31c4a6c1..b0d1c775 100644 --- a/42sh/Makefile +++ b/42sh/Makefile @@ -6,14 +6,14 @@ # By: wescande +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2016/08/29 21:32:58 by wescande #+# #+# # -# Updated: 2017/02/03 15:18:41 by alao ### ########.fr # +# Updated: 2017/02/03 15:23:50 by gwojda ### ########.fr # # # # **************************************************************************** # NAME = 42sh CC = gcc -FLAGS = -Wall -Wextra -Werror +FLAGS = -Wall -Wextra -Werror -g D_FLAGS = -g DELTA = $$(echo "$$(tput cols)-47"|bc) diff --git a/42sh/src/completion/c_output.c b/42sh/src/completion/c_output.c index f94317f7..cc703143 100644 --- a/42sh/src/completion/c_output.c +++ b/42sh/src/completion/c_output.c @@ -6,7 +6,7 @@ /* By: alao +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/03 13:10:38 by alao #+# #+# */ -/* Updated: 2017/02/03 13:52:01 by alao ### ########.fr */ +/* Updated: 2017/02/03 15:33:53 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -42,7 +42,7 @@ int c_updater(t_comp *c) DG("Resulting RCMD [%s] with pos [%d] from [%d]", rt, new_pos, c->ircmd); rt ? ft_memdel((void *)&rt) : (0); c_clear(data_singleton()); - return (0); + return (1); } /* diff --git a/42sh/src/completion/completion.c b/42sh/src/completion/completion.c index a6e72360..f63bc0ea 100644 --- a/42sh/src/completion/completion.c +++ b/42sh/src/completion/completion.c @@ -6,7 +6,7 @@ /* By: alao +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/09/20 14:50:33 by alao #+# #+# */ -/* Updated: 2017/02/03 14:53:57 by alao ### ########.fr */ +/* Updated: 2017/02/03 15:39:26 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -135,6 +135,5 @@ int completion(long int keypress) return (c_gtfo(s->comp, keypress)); } test(s->comp); - c_dispatcher(s); - return (0); + return (c_dispatcher(s)); } diff --git a/42sh/src/line-editing/check_backslash.c b/42sh/src/line-editing/check_backslash.c index 247d6828..12eb1976 100644 --- a/42sh/src/line-editing/check_backslash.c +++ b/42sh/src/line-editing/check_backslash.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/26 13:32:52 by gwojda #+# #+# */ -/* Updated: 2017/02/03 14:09:20 by gwojda ### ########.fr */ +/* Updated: 2017/02/03 15:27:37 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -77,6 +77,8 @@ void ft_check_line(void) i = 0; status = 0; str = data_singleton()->line.input; + if (!str) + return ; while (str[i]) { if (IS_BSLASH & status) diff --git a/42sh/src/line-editing/completion.c b/42sh/src/line-editing/completion.c index 872a1bd0..019cf514 100644 --- a/42sh/src/line-editing/completion.c +++ b/42sh/src/line-editing/completion.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/03 14:15:55 by gwojda #+# #+# */ -/* Updated: 2017/02/03 15:17:05 by alao ### ########.fr */ +/* Updated: 2017/02/03 15:39:40 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,8 +15,9 @@ int ft_completion(int ret) { size_t tmp; + char boolean; - + boolean = 0; if ((ret != TOUCHE_TAB && ret != 10) || (ret == 10 && !(data_singleton()->comp))) return (0); @@ -24,8 +25,8 @@ int ft_completion(int ret) if (ret == 10) ft_puttermcaps("cd"); if (data_singleton()->comp || ret == TOUCHE_TAB) - completion(ret); - if (ret == 10) + boolean = completion(ret); + if (boolean || ret == 10) { ft_current_str(data_singleton()->line.input, tmp); ft_get_next_str(data_singleton()->line.input, &tmp); diff --git a/42sh/src/line-editing/get_touch.c b/42sh/src/line-editing/get_touch.c index dd774bfe..b4ff5b06 100644 --- a/42sh/src/line-editing/get_touch.c +++ b/42sh/src/line-editing/get_touch.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/19 16:28:49 by gwojda #+# #+# */ -/* Updated: 2017/02/03 15:17:19 by alao ### ########.fr */ +/* Updated: 2017/02/03 15:24:37 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -49,8 +49,8 @@ char *ft_read_stdin(void) if (data_singleton()->line.input[data_singleton()->line.pos]) ++(data_singleton()->line.pos); } -if (data_singleton()->comp) - c_clear(data_singleton()); + if (data_singleton()->comp) + c_clear(data_singleton()); while (42) { ret = 0; diff --git a/42sh/src/main/data_init.c b/42sh/src/main/data_init.c index 5b9a0fd9..76bf0d90 100644 --- a/42sh/src/main/data_init.c +++ b/42sh/src/main/data_init.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */ -/* Updated: 2017/02/03 13:44:30 by jhalford ### ########.fr */ +/* Updated: 2017/02/03 15:25:55 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,6 +21,7 @@ int data_init(void) data = data_singleton(); data->env = ft_sstrdup(environ); + data->comp = NULL; data->opts = SHELL_OPTS_JOBC; data->exec.process.path = NULL; diff --git a/42sh/src/main/data_singleton.c b/42sh/src/main/data_singleton.c index 33d75a04..22c7306f 100644 --- a/42sh/src/main/data_singleton.c +++ b/42sh/src/main/data_singleton.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* data_singleton.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ +/* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/10 11:36:39 by jhalford #+# #+# */ -/* Updated: 2017/01/10 11:47:11 by jhalford ### ########.fr */ +/* Updated: 2017/02/03 15:25:13 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */