From fe802c525db1ffa07f5cd6c6f0957566ed5ffdb0 Mon Sep 17 00:00:00 2001 From: Rudy Bousset Date: Wed, 29 Jan 2020 18:12:33 +0100 Subject: dur dur --- src/ft_parse_map.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'src/ft_parse_map.c') diff --git a/src/ft_parse_map.c b/src/ft_parse_map.c index 0be76bc..af11e2f 100644 --- a/src/ft_parse_map.c +++ b/src/ft_parse_map.c @@ -48,14 +48,17 @@ ft_check_cub(const char *map_path, t_cub *clist) /* } */ /* } */ -static int +static int8_t ft_parse_it(int fd, t_cub *clist) { char *line; char **words; + int ret; clist->line_chk += 1; - if (get_next_line(fd, &line) <= 0) + if ((ret = get_next_line(fd, &line)) < 0) + return (ft_map_error(clist)); + if (ret == 0) { ft_memdel(line); return (ft_map_error(clist)); @@ -70,15 +73,22 @@ ft_parse_it(int fd, t_cub *clist) ft_memdel(line); return (ft_map_error(clist)); } + ft_printf("%s\n", line); + if ((ret = ft_select_get(words, clist)) == 12) + { + if (ft_get_first_line(line, clist) < 0) + return (-1); + return (12); + } ft_memdel(line); - return (ft_select_get(words, clist)); + return (ret); } void ft_parse_map(const char *map_path, t_cub *clist) { int fd; - uint8_t ret; + int8_t ret; ft_check_cub(map_path, clist); fd = open(map_path, O_RDONLY); @@ -89,11 +99,14 @@ ft_parse_map(const char *map_path, t_cub *clist) ft_exit(2, clist); } ret = 1; - while (ret != 12) + while (ret != 12 && ret != -1) ret = ft_parse_it(fd, clist); - ft_check_missing(clist); + if (ret == -1) + ft_map_error(clist); + clist->nsew = 0; if (ft_get_map(fd, clist) < 0) ft_map_error(clist); + ft_check_missing(clist); /* if (ft_get_tex(fd, clist) < 0) */ /* return ; */ /* ft_check_empty_line(fd, 6, clist); */ -- cgit v1.2.3