From b4c1857d884895f970afc18c594d3a7d34baaa03 Mon Sep 17 00:00:00 2001 From: Manzovince Date: Sun, 14 Apr 2019 14:24:50 +0200 Subject: [PATCH] basic corrections --- Makefile | 10 +-- author | 1 + samples/26tetri | 129 +++++++++++++++++++++++++++++++++++ samples/27tetri | 134 +++++++++++++++++++++++++++++++++++++ samples/2nl | 10 +++ samples/Valide1 | 19 ------ srcs/get_smallest_square.c | 8 ++- srcs/handle_errors.c | 16 ++++- srcs/main.c | 39 +++++------ srcs/read_file.c | 2 +- srcs/tetri_to_letters.c | 18 ----- 11 files changed, 315 insertions(+), 71 deletions(-) create mode 100644 samples/26tetri create mode 100644 samples/27tetri create mode 100644 samples/2nl delete mode 100644 samples/Valide1 delete mode 100644 srcs/tetri_to_letters.c diff --git a/Makefile b/Makefile index f1cfac1..c8b192f 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: vmanzoni +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2019/03/01 13:24:35 by vmanzoni #+# #+# # -# Updated: 2019/04/12 22:33:31 by vmanzoni ### ########.fr # +# Updated: 2019/04/14 14:21:26 by vmanzoni ### ########.fr # # # # **************************************************************************** # @@ -28,18 +28,18 @@ CC = gcc CFLAGS = -Wall -Werror -Wextra -RM = rm -f +RM = rm -rf all: $(NAME) -$(NAME) +$(NAME): $(CC) $(CFLAGS) -I$(HEADER) -c $(addprefix $(SRC_DIR), $(SRCS)) $(CC) $(OBJS) -o $(NAME) mkdir $(OBJ_DIR) - mv *.o $(OBJ_DIR) + mv $(OBJS) $(OBJ_DIR) clean: - $(RM) $(OBJS) + $(RM) $(OBJ_DIR) fclean: clean $(RM) $(NAME) diff --git a/author b/author index 5317771..884dc49 100644 --- a/author +++ b/author @@ -1 +1,2 @@ +hulamy vmanzoni diff --git a/samples/26tetri b/samples/26tetri new file mode 100644 index 0000000..5b0667a --- /dev/null +++ b/samples/26tetri @@ -0,0 +1,129 @@ +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# diff --git a/samples/27tetri b/samples/27tetri new file mode 100644 index 0000000..9dd01c6 --- /dev/null +++ b/samples/27tetri @@ -0,0 +1,134 @@ +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# + +...# +...# +...# +...# diff --git a/samples/2nl b/samples/2nl new file mode 100644 index 0000000..77ea3e5 --- /dev/null +++ b/samples/2nl @@ -0,0 +1,10 @@ +...# +...# +...# +...# + + +...# +...# +...# +...# diff --git a/samples/Valide1 b/samples/Valide1 deleted file mode 100644 index 8c28d9d..0000000 --- a/samples/Valide1 +++ /dev/null @@ -1,19 +0,0 @@ -...# -...# -...# -...# - -.... -.... -.... -#### - -.### -...# -.... -.... - -.... -..## -.##. -.... diff --git a/srcs/get_smallest_square.c b/srcs/get_smallest_square.c index 4554253..03893e4 100644 --- a/srcs/get_smallest_square.c +++ b/srcs/get_smallest_square.c @@ -6,13 +6,15 @@ /* By: vmanzoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/04/12 22:29:45 by vmanzoni #+# #+# */ -/* Updated: 2019/04/14 12:02:22 by vmanzoni ### ########.fr */ +/* Updated: 2019/04/14 14:17:47 by vmanzoni ### ########.fr */ /* */ /* ************************************************************************** */ #include "../includes/fillit.h" -char *get_smallest_square(/*args*/) +/* +char *get_smallest_square() { - /*backtracking*/ + } +*/ diff --git a/srcs/handle_errors.c b/srcs/handle_errors.c index dedfac7..09b7c72 100644 --- a/srcs/handle_errors.c +++ b/srcs/handle_errors.c @@ -6,17 +6,28 @@ /* By: vmanzoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/03/01 13:29:05 by vmanzoni #+# #+# */ -/* Updated: 2019/04/14 12:35:46 by vmanzoni ### ########.fr */ +/* Updated: 2019/04/14 14:16:01 by vmanzoni ### ########.fr */ /* */ /* ************************************************************************** */ #include "../includes/fillit.h" +/* +** Function that display error message *s on fd +*/ + void ft_display_error(char *s, int fd) { write(fd, s, strlen(s)); } +/* +** Function to see if there if an error if the file +** - less than 4 lines +** - more than 104 (26 tetri) + 25 (\n) = 129 lines +** - two \n in a row +*/ + int ft_file_errors(char *file) { int line_nbr; @@ -27,8 +38,9 @@ int ft_file_errors(char *file) if (*file == '\n') line_nbr++; file++; + if (*file == '\n') + return (1); } - /*less than 4 lines or more than 104 (26 tetri) + 25 = 129 lines*/ if (line_nbr < 4 || line_nbr > 129) return (1); return (0); diff --git a/srcs/main.c b/srcs/main.c index f14e429..cfb8a6a 100644 --- a/srcs/main.c +++ b/srcs/main.c @@ -6,7 +6,7 @@ /* By: vmanzoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/02/12 13:20:48 by vmanzoni #+# #+# */ -/* Updated: 2019/04/14 12:44:14 by vmanzoni ### ########.fr */ +/* Updated: 2019/04/14 14:17:22 by vmanzoni ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,30 +15,23 @@ int main(int argc, char **argv) { char *input; - short i; - if (argc != 2) + if (argc == 2) { + if (!(input = read_file(argv[1]))) + ft_display_error("Error: Could not read file.\n", 2); + if (ft_file_errors(input)) + ft_display_error("Error: Invalid file.\n", 2); + /* + Check if every tetrimino is valid + Transform input to tetriminos + Backtracking for smallest square + Transform tetriminos with letters + Print result + */ + } + else ft_display_error("Error: Please submit a file.\n", 2); - return (0); - } - else if (!(input = read_file(argv[1]))) - { - ft_display_error("Error: Could not read file.\n", 2); - return (0); - } - else if (ft_file_errors(input)) - { - ft_display_error("Error: Invalid file.\n", 2); - return (0); - } - /* - Check if every tetrimino is valid - Transform input to tetriminos - Backtracking for smallest square - Transform tetriminos with letters - Print result - */ - print_test(input); return (0); + print_test(input); } diff --git a/srcs/read_file.c b/srcs/read_file.c index 4fc2a60..837ce68 100644 --- a/srcs/read_file.c +++ b/srcs/read_file.c @@ -6,7 +6,7 @@ /* By: vmanzoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/04/13 12:09:46 by vmanzoni #+# #+# */ -/* Updated: 2019/04/14 12:08:12 by vmanzoni ### ########.fr */ +/* Updated: 2019/04/14 14:23:24 by vmanzoni ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/srcs/tetri_to_letters.c b/srcs/tetri_to_letters.c deleted file mode 100644 index 6af453a..0000000 --- a/srcs/tetri_to_letters.c +++ /dev/null @@ -1,18 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tetri_to_letters.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: vmanzoni +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/04/12 22:31:30 by vmanzoni #+# #+# */ -/* Updated: 2019/04/14 12:08:58 by vmanzoni ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "../includes/fillit.h" - -char *tetri_to_letters() -{ - -}