From 487a66394061f2d14a2fa421302966b5442d643f Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Mon, 27 Jul 2020 18:55:07 +0200 Subject: I couldn't see shit --- src/b_exit.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/b_exit.c (limited to 'src/b_exit.c') diff --git a/src/b_exit.c b/src/b_exit.c new file mode 100644 index 0000000..75f16bf --- /dev/null +++ b/src/b_exit.c @@ -0,0 +1,43 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* b_exit.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/14 17:19:27 by rbousset #+# #+# */ +/* Updated: 2020/02/14 17:19:29 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include +#include +#include + +#include "f_fail.h" +#include "s_lcom.h" +#include "s_destroy.h" +#include "s_struct.h" +#include "u_utils.h" + +uint8_t + b_exit(char *args[], + t_msh *msh) +{ + uint8_t ret; + const uint64_t argc = get_argc((const char**)args); + + if (argc > 1) + { + fail_too_many_args("exit", msh); + return (1); + } + if (argc == 1) + { + ret = ft_atoi(args[0]); + /* TODO: non numeric args[0] */ + } + ft_dprintf(STDERR_FILENO, "exit\n"); + return (0); +} -- cgit v1.2.3 From 6dc6bf6f46b736299826bfdd63192bdee16ba875 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Thu, 30 Jul 2020 18:08:50 +0200 Subject: Less retarded stuff --- src/b_exit.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/b_exit.c') diff --git a/src/b_exit.c b/src/b_exit.c index 75f16bf..777bbb9 100644 --- a/src/b_exit.c +++ b/src/b_exit.c @@ -28,6 +28,7 @@ uint8_t uint8_t ret; const uint64_t argc = get_argc((const char**)args); + ret = 0; if (argc > 1) { fail_too_many_args("exit", msh); @@ -39,5 +40,6 @@ uint8_t /* TODO: non numeric args[0] */ } ft_dprintf(STDERR_FILENO, "exit\n"); + exit(ret); return (0); } -- cgit v1.2.3 From c19bd35afdb45e49cebdfd96e7adb1e6fe477f0c Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Thu, 30 Jul 2020 20:30:58 +0200 Subject: Double exit no more --- src/b_exit.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/b_exit.c') diff --git a/src/b_exit.c b/src/b_exit.c index 777bbb9..5f1c446 100644 --- a/src/b_exit.c +++ b/src/b_exit.c @@ -28,10 +28,9 @@ uint8_t uint8_t ret; const uint64_t argc = get_argc((const char**)args); - ret = 0; if (argc > 1) { - fail_too_many_args("exit", msh); + f_fail_too_many_args("exit", msh); return (1); } if (argc == 1) @@ -39,7 +38,11 @@ uint8_t ret = ft_atoi(args[0]); /* TODO: non numeric args[0] */ } + else + ret = msh->ret; ft_dprintf(STDERR_FILENO, "exit\n"); + lcom_clear(&msh->curr); + s_destroy(msh); exit(ret); return (0); } -- cgit v1.2.3 From 3b32afb082ba823885ac355413294b5e7ff3c360 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Mon, 3 Aug 2020 17:04:30 +0200 Subject: Changed function name --- src/b_exit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/b_exit.c') diff --git a/src/b_exit.c b/src/b_exit.c index 5f1c446..5384d25 100644 --- a/src/b_exit.c +++ b/src/b_exit.c @@ -26,7 +26,7 @@ uint8_t t_msh *msh) { uint8_t ret; - const uint64_t argc = get_argc((const char**)args); + const uint64_t argc = u_builtins_get_argc((const char**)args); if (argc > 1) { -- cgit v1.2.3