aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_parse_map.c
diff options
context:
space:
mode:
authorRudy Bousset <rbousset@z2r5p6.le-101.fr>2020-02-02 18:21:29 +0100
committerRudy Bousset <rbousset@z2r5p6.le-101.fr>2020-02-02 18:21:29 +0100
commita06d2d08ebd83a79731a054fda690959eed0c45d (patch)
treea8bdde446a6bdd2abb5dca3e9ee90b10e51ebafe /src/ft_parse_map.c
parentNorme again (diff)
download42-cub3d-a06d2d08ebd83a79731a054fda690959eed0c45d.tar.gz
42-cub3d-a06d2d08ebd83a79731a054fda690959eed0c45d.tar.bz2
42-cub3d-a06d2d08ebd83a79731a054fda690959eed0c45d.tar.xz
42-cub3d-a06d2d08ebd83a79731a054fda690959eed0c45d.tar.zst
42-cub3d-a06d2d08ebd83a79731a054fda690959eed0c45d.zip
Best parse
Diffstat (limited to 'src/ft_parse_map.c')
-rw-r--r--src/ft_parse_map.c16
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);