From 836639d1be47849cbe94489b42c5d4a7544e8aee Mon Sep 17 00:00:00 2001 From: joan cordelier Date: Tue, 9 Apr 2024 15:57:51 +0200 Subject: [PATCH] ADD: last parsing test --- Makefile | 1 + include/my.h | 4 +++- input | 10 ++++++++++ robots | 2 ++ room | 9 +++++++++ src/main.c | 2 +- src/str/is_in_str.c | 17 +++++++++++++++++ tunel | 10 ++++++++++ 8 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 input create mode 100644 robots create mode 100644 room create mode 100644 src/str/is_in_str.c create mode 100644 tunel diff --git a/Makefile b/Makefile index c3e7f19..7130931 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,7 @@ SRC = ./src/graph/add.c \ ./src/put/my_putchar.c \ ./src/put/my_putstr.c \ ./src/put/my_show_word_array.c \ + ./src/str/is_in_str.c \ ./src/str/my_str_to_word_array.c \ ./src/str/my_strcmp.c \ ./src/str/my_strcpy.c \ diff --git a/include/my.h b/include/my.h index 0d2648b..ee2c156 100644 --- a/include/my.h +++ b/include/my.h @@ -44,9 +44,11 @@ char *my_strcpy(char *dest, char *src); char *my_strncpy(char *dest, char *src, int i); char *my_strdup(char *src); char *my_strsub(char *str, char c); +char *rm_tag_str(char *str); +int is_in_str(char *str, char c); +int my_strcmp(char *str1, char *str2); int my_strlen(char *str); int tab_len(char **tab); -char *rm_tag_str(char *str); //Free void free_tab(char **tab); diff --git a/input b/input new file mode 100644 index 0000000..6afdd2b --- /dev/null +++ b/input @@ -0,0 +1,10 @@ +4 +0 47 42 +##start +1 13 18 +2 2 30 +3 4 16 +##end +4 28 39 +4-0 +4-1 diff --git a/robots b/robots new file mode 100644 index 0000000..ebd31c9 --- /dev/null +++ b/robots @@ -0,0 +1,2 @@ +#nb_bites +3 diff --git a/room b/room new file mode 100644 index 0000000..b21cc6e --- /dev/null +++ b/room @@ -0,0 +1,9 @@ +#nb_bites +3 +#bhc njsdlk +##start +0 1 0 dmage ca passe a la TA +##end +1 13 0 +1 15 48 +2 5 0 #je baize ton __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 \ No newline at end of file diff --git a/src/main.c b/src/main.c index 3ec9d6e..40afbbd 100644 --- a/src/main.c +++ b/src/main.c @@ -48,7 +48,7 @@ static void print_output(void *data) mini_printf("#number_of_robots\n%s\n", (temp)->str); (temp) = (temp)->next; mini_printf("#rooms\n"); - while ((temp)->str[1] != '-') { + while ((temp) != NULL && is_in_str((temp)->str, '-') == 0) { mini_printf("%s\n", (temp)->str); (temp) = (temp)->next; } diff --git a/src/str/is_in_str.c b/src/str/is_in_str.c new file mode 100644 index 0000000..8a9aa20 --- /dev/null +++ b/src/str/is_in_str.c @@ -0,0 +1,17 @@ +/* +** EPITECH PROJECT, 2023 +** A-Maze-d +** File description: +** is_in_str.c +*/ + +#include "my.h" + +int is_in_str(char *str, char c) +{ + for (int i = 0; str[i] != '\0'; i++) { + if (str[i] == c) + return 1; + } + return 0; +} diff --git a/tunel b/tunel new file mode 100644 index 0000000..775c698 --- /dev/null +++ b/tunel @@ -0,0 +1,10 @@ +3 +##start +0 1 0 +##end +1 13 0 +1 15 48 +2 5 0 +3 9 0 +0-2 +2-3