From 3a09e7ae69c3eb1fc3d1f8dfa25f7376ca066e86 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Thu, 27 Aug 2020 15:33:35 +0200 Subject: Freed leaks --- src/u_utils.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/u_utils.c') diff --git a/src/u_utils.c b/src/u_utils.c index f50d861..ad44e82 100644 --- a/src/u_utils.c +++ b/src/u_utils.c @@ -19,12 +19,12 @@ #include "s_struct.h" void -u_eof_stdin(void) + u_eof_fd(int32_t fd) { char *line; - close(STDIN_FILENO); - get_next_line(STDIN_FILENO, &line); + close(fd); + get_next_line(fd, &line); ft_memdel((void*)&line); } -- cgit v1.2.3 From 247023e3fac41c99b5580d69262837429fb2bfed Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Sat, 5 Sep 2020 17:03:49 +0200 Subject: Fuck shell --- src/u_utils.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/u_utils.c') diff --git a/src/u_utils.c b/src/u_utils.c index ad44e82..d554a98 100644 --- a/src/u_utils.c +++ b/src/u_utils.c @@ -15,9 +15,20 @@ #include #include +#include "d_define.h" #include "f_fail.h" #include "s_struct.h" +t_bool + u_is_true_quote(char *head, char *ptr) +{ + if (((ptr - head) == 0) || + ((ptr - head) >= 1 && *(ptr - 1) != C_BS) || + ((ptr - head) > 1 && *(ptr - 1) == C_BS && *(ptr - 2) == C_BS)) + return (TRUE); + return (FALSE); +} + void u_eof_fd(int32_t fd) { -- cgit v1.2.3 From c75434256658e3009a5c61d02524cb49492bd120 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Sat, 5 Sep 2020 18:40:28 +0200 Subject: Clean af --- src/u_utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/u_utils.c') diff --git a/src/u_utils.c b/src/u_utils.c index d554a98..fb1dcf6 100644 --- a/src/u_utils.c +++ b/src/u_utils.c @@ -20,7 +20,7 @@ #include "s_struct.h" t_bool - u_is_true_quote(char *head, char *ptr) + u_is_not_escaped(char *head, char *ptr) { if (((ptr - head) == 0) || ((ptr - head) >= 1 && *(ptr - 1) != C_BS) || -- cgit v1.2.3 From ab69117ff18f8b4a2b13adeada00cabd7d997855 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Sun, 6 Sep 2020 17:56:59 +0200 Subject: Better defines --- src/u_utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/u_utils.c') diff --git a/src/u_utils.c b/src/u_utils.c index fb1dcf6..7f75c4d 100644 --- a/src/u_utils.c +++ b/src/u_utils.c @@ -23,8 +23,8 @@ t_bool u_is_not_escaped(char *head, char *ptr) { if (((ptr - head) == 0) || - ((ptr - head) >= 1 && *(ptr - 1) != C_BS) || - ((ptr - head) > 1 && *(ptr - 1) == C_BS && *(ptr - 2) == C_BS)) + ((ptr - head) >= 1 && *(ptr - 1) != C_BACKS) || + ((ptr - head) > 1 && *(ptr - 1) == C_BACKS && *(ptr - 2) == C_BACKS)) return (TRUE); return (FALSE); } -- cgit v1.2.3 From 74766656e5b605785e0e9622eb7f10d20a5467e3 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Tue, 8 Sep 2020 20:26:51 +0200 Subject: I hate myself and I want to die --- src/u_utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/u_utils.c') diff --git a/src/u_utils.c b/src/u_utils.c index 7f75c4d..dd1634b 100644 --- a/src/u_utils.c +++ b/src/u_utils.c @@ -20,7 +20,7 @@ #include "s_struct.h" t_bool - u_is_not_escaped(char *head, char *ptr) + u_is_not_escaped(const char *head, const char *ptr) { if (((ptr - head) == 0) || ((ptr - head) >= 1 && *(ptr - 1) != C_BACKS) || -- cgit v1.2.3 From ca2e36781039eb7e9901ccde395600e7af87ff4f Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Tue, 15 Sep 2020 19:59:41 +0200 Subject: Huge fixes and stack stuff --- src/u_utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/u_utils.c') diff --git a/src/u_utils.c b/src/u_utils.c index dd1634b..4e332b3 100644 --- a/src/u_utils.c +++ b/src/u_utils.c @@ -70,7 +70,7 @@ uint64_t uint64_t argc; argc = 0; - while (args[argc]) + while (args[argc] != NULL) { argc++; } -- cgit v1.2.3 From 33a5806163fb91e4a72e188a9933ada20395f4e9 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Tue, 15 Sep 2020 20:44:45 +0200 Subject: Builtins ref toked --- src/u_utils.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'src/u_utils.c') diff --git a/src/u_utils.c b/src/u_utils.c index 4e332b3..d56d7c0 100644 --- a/src/u_utils.c +++ b/src/u_utils.c @@ -19,8 +19,7 @@ #include "f_fail.h" #include "s_struct.h" -t_bool - u_is_not_escaped(const char *head, const char *ptr) +t_bool u_is_not_escaped(const char *head, const char *ptr) { if (((ptr - head) == 0) || ((ptr - head) >= 1 && *(ptr - 1) != C_BACKS) || @@ -29,8 +28,7 @@ t_bool return (FALSE); } -void - u_eof_fd(int32_t fd) +void u_eof_fd(int32_t fd) { char *line; @@ -39,11 +37,10 @@ void ft_memdel((void*)&line); } -char - **u_get_env_var_names(t_msh *msh) +char **u_get_env_var_names(t_msh *msh) { - size_t i; char **vars; + size_t i; i = 0; while (msh->envp[i] != NULL) @@ -64,8 +61,7 @@ char return (vars); } -uint64_t - u_builtins_get_argc(const char *args[]) +uint64_t u_builtins_get_argc(const char *args[]) { uint64_t argc; @@ -76,3 +72,20 @@ uint64_t } return (argc); } + +uint8_t u_get_builtin_id(const char bin[]) +{ + char tmp[M_BUILTINS_REF_LEN]; + char *tok; + uint8_t i; + + i = 0; + ft_strlcpy(tmp, M_BUILTINS_REF, M_BUILTINS_REF_LEN); + tok = ft_strtok(tmp, ":"); + while (tok != NULL && ft_strncmp(bin, tok, ft_strlen(tok) + 1) != 0) + { + tok = ft_strtok(NULL, ":"); + i++; + } + return (i); +} -- cgit v1.2.3