From a06d2d08ebd83a79731a054fda690959eed0c45d Mon Sep 17 00:00:00 2001 From: Rudy Bousset Date: Sun, 2 Feb 2020 18:21:29 +0100 Subject: Best parse --- src/ft_parse_map.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/ft_parse_map.c') 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 @@ -61,6 +61,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) { @@ -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); -- cgit v1.2.3