diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-01-28 16:01:25 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-01-28 16:01:25 +0100 |
commit | 1b3cf4e3ce43e556ef47c669511620815b747221 (patch) | |
tree | be53e93d6fd39578ce71e82502c1289aac98e819 /src/ft_get_res.c | |
parent | Everything is terrible but this might work (diff) | |
download | 42-cub3d-1b3cf4e3ce43e556ef47c669511620815b747221.tar.gz 42-cub3d-1b3cf4e3ce43e556ef47c669511620815b747221.tar.bz2 42-cub3d-1b3cf4e3ce43e556ef47c669511620815b747221.tar.xz 42-cub3d-1b3cf4e3ce43e556ef47c669511620815b747221.tar.zst 42-cub3d-1b3cf4e3ce43e556ef47c669511620815b747221.zip |
I understood
Diffstat (limited to 'src/ft_get_res.c')
-rw-r--r-- | src/ft_get_res.c | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/src/ft_get_res.c b/src/ft_get_res.c index 66eb1df..42b3f19 100644 --- a/src/ft_get_res.c +++ b/src/ft_get_res.c @@ -10,30 +10,22 @@ ft_checkdigit(const char *word, t_cub *clist) while (ft_isdigit(word[i])) i++; if (i != ft_strlen(word)) - ft_map_error(1, clist); + ft_map_error(clist); } int -ft_get_res(int fd, t_cub *clist) +ft_get_res(char **words, t_cub *clist) { - char *line; - char **words; - - if (get_next_line(fd, &line) <= 0 || !(words = ft_split(line, ' '))) - { - ft_memdel(line); - return (ft_map_error(1, clist)); - } - if (!(*words) || ft_strcmp(*words, "R") || !(*(words + 1)) + if (!(*words + 0) || !(*(words + 1)) || !(*(words + 2)) || (*(words + 3))) { - ft_free_words(words, line); - return (ft_map_error(1, clist)); + ft_free_words(words); + return (ft_map_error(clist)); } ft_checkdigit(words[1], clist); ft_checkdigit(words[2], clist); clist->wlist->x_size = ft_atoi(words[1]); clist->wlist->y_size = ft_atoi(words[2]); - ft_free_words(words, line); + ft_free_words(words); return (0); } |