diff options
author | Rudy Bousset <rbousset@z2r4p3.le-101.fr> | 2020-02-17 16:25:11 +0100 |
---|---|---|
committer | Rudy Bousset <rbousset@z2r4p3.le-101.fr> | 2020-02-17 16:25:11 +0100 |
commit | 4f207400fd8e6724d321b6f2fa79fba5f16f9d59 (patch) | |
tree | 3896037d8a5938044bd6b6d49a18ad6305b948f0 /src/ft_get_res.c | |
parent | Added libbsd to linux Makefile (diff) | |
parent | ready to merge (diff) | |
download | 42-cub3d-4f207400fd8e6724d321b6f2fa79fba5f16f9d59.tar.gz 42-cub3d-4f207400fd8e6724d321b6f2fa79fba5f16f9d59.tar.bz2 42-cub3d-4f207400fd8e6724d321b6f2fa79fba5f16f9d59.tar.xz 42-cub3d-4f207400fd8e6724d321b6f2fa79fba5f16f9d59.tar.zst 42-cub3d-4f207400fd8e6724d321b6f2fa79fba5f16f9d59.zip |
Merge branch 'better_parse'
Diffstat (limited to '')
-rw-r--r-- | src/ft_get_res.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/ft_get_res.c b/src/ft_get_res.c index 86a3186..8607f62 100644 --- a/src/ft_get_res.c +++ b/src/ft_get_res.c @@ -12,9 +12,10 @@ #include <libft.h> #include <cub3d.h> +#include <stdint.h> static int8_t - ft_checkdigit(const char *word) + ft_checkdigit(const char *word, t_cub *clist) { size_t i; @@ -22,7 +23,11 @@ static int8_t while (ft_isdigit(word[i])) i++; if (i != ft_strlen(word)) + { + ft_strlcpy(clist->errmsg, FT_ERR_RES_ALPHA, + ft_strlen(FT_ERR_RES_ALPHA) + 1); return (-1); + } return (0); } @@ -34,20 +39,23 @@ int8_t wlist = clist->wlist; if (!(*words + 0) || !(*(words + 1)) || !(*(words + 2)) || (*(words + 3))) + { + ft_strlcpy(clist->errmsg, FT_ERR_ARGS, ft_strlen(FT_ERR_ARGS) + 1); return (-1); - if ((ft_checkdigit(words[1]) < 0) || - (ft_checkdigit(words[2]) < 0)) + } + if ((ft_checkdigit(words[1], clist) < 0) || + (ft_checkdigit(words[2], clist) < 0)) return (-1); wlist->x_size = ft_atoi(words[1]); wlist->y_size = ft_atoi(words[2]); - if (wlist->x_size < 1 - || wlist->y_size < 1) + if (wlist->x_size <= 1 + || wlist->y_size <= 1) + { + ft_strlcpy(clist->errmsg, FT_ERR_RES_SMALL, + ft_strlen(FT_ERR_RES_SMALL) + 1); return (-1); + } if (ft_get_screen_size(wlist) < 0) return (-1); - if (wlist->x_size > wlist->x_max_size) - wlist->x_size = wlist->x_max_size; - if (wlist->y_size > wlist->y_max_size) - wlist->y_size = wlist->y_max_size; return (0); } |