diff options
author | Rudy Bousset <rbousset@z2r5p2.le-101.fr> | 2020-01-29 19:25:53 +0100 |
---|---|---|
committer | Rudy Bousset <rbousset@z2r5p2.le-101.fr> | 2020-01-29 19:25:53 +0100 |
commit | efeb187c12a62322a8e113173d7b4d311ad32c50 (patch) | |
tree | a2ba40ced3dd0c653dfb9f338843969d01efd124 /src/ft_get_map_redo.c | |
parent | C'est bav (diff) | |
download | 42-cub3d-efeb187c12a62322a8e113173d7b4d311ad32c50.tar.gz 42-cub3d-efeb187c12a62322a8e113173d7b4d311ad32c50.tar.bz2 42-cub3d-efeb187c12a62322a8e113173d7b4d311ad32c50.tar.xz 42-cub3d-efeb187c12a62322a8e113173d7b4d311ad32c50.tar.zst 42-cub3d-efeb187c12a62322a8e113173d7b4d311ad32c50.zip |
Missing error management but ok
Diffstat (limited to 'src/ft_get_map_redo.c')
-rw-r--r-- | src/ft_get_map_redo.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/ft_get_map_redo.c b/src/ft_get_map_redo.c index e337849..32cc178 100644 --- a/src/ft_get_map_redo.c +++ b/src/ft_get_map_redo.c @@ -21,7 +21,7 @@ ft_linecpy(char *line, char *mapl, size_t start) i++; j++; } - mapl[j] = '\0'; + mapl[j] = '\n'; } static int8_t @@ -32,7 +32,6 @@ ft_cat_mapl(char *line, size_t i, t_cub *clist) ((clist->map_w + 1) * (i + 1)) * sizeof(char)))) return (-1); ft_linecpy(line, clist->mapl, (clist->map_w + 1) * i); - ft_printf("mapl >>>> [%s]\n", clist->mapl); return (0); } @@ -51,7 +50,7 @@ ft_get_map_first_line(char *line, t_cub *clist) } clist->map_w = ft_get_line_len(line); clist->mapl = NULL; - if ((clist->mapl = ft_cat_mapl(line, 0, clist)) < 0) + if (ft_cat_mapl(line, 0, clist) < 0) { ft_memdel(line); return (-1); @@ -65,10 +64,23 @@ ft_get_map_core(int fd, t_cub *clist) { int ret; size_t i; + char *line; i = 1; - (void)fd; - (void)ret; - (void)clist; + ret = 1; + while (ret > 0) + { + ret = get_next_line(fd, &line); + if (ret < 0) + return (-1); + if (ft_cat_mapl(line, i, clist) < 0) + { + ft_memdel(line); + return (-1); + } + i++; + } + clist->mapl[((clist->map_w + 1) * i) - 1] = '\0'; + ft_printf("mapl >>>> [%s]\n", clist->mapl); return (0); } |