diff options
-rw-r--r-- | src/ft_parse_map.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/ft_parse_map.c b/src/ft_parse_map.c index 3ca2052..eb69e28 100644 --- a/src/ft_parse_map.c +++ b/src/ft_parse_map.c @@ -62,6 +62,13 @@ static void } static int8_t + ft_error_here(char *line, t_cub *clist) +{ + ft_memdel((void**)&line); + return (ft_map_error(clist)); +} + +static int8_t ft_parse_it(int fd, t_cub *clist) { char *line; @@ -71,17 +78,16 @@ static int8_t clist->line_chk += 1; if ((ret = get_next_line(fd, &line)) < 0) return (ft_map_error(clist)); + if (ret == 0) + return (ft_error_here(line, clist)); if (!line[0]) { ft_memdel((void**)&line); return (ft_parse_it(fd, clist)); } - if (ret == 0 || !ft_ischarset("RNSEWFC1\0", line[0]) + if (!ft_ischarset("RNSEWFC1\0", line[0]) || !(words = ft_split(line, ' '))) - { - ft_memdel((void**)&line); - return (ft_map_error(clist)); - } + return (ft_error_here(line, clist)); if ((ret = ft_select_get(words, clist)) == 12) return ((ft_get_map_first_line(line, clist) < 0) ? (-1) : (12)); ft_memdel((void**)&line); |