aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRudy Bousset <rbousset@z2r4p3.le-101.fr>2020-02-24 20:54:28 +0100
committerRudy Bousset <rbousset@z2r4p3.le-101.fr>2020-02-24 20:54:28 +0100
commitaa0fc403f7f81dedfa3fe22235aecceaf7b91e27 (patch)
tree2ae016d6fb79acf8c7e734e05bfb46bab70b1765 /src
parentNorme (diff)
download42-cub3d-aa0fc403f7f81dedfa3fe22235aecceaf7b91e27.tar.gz
42-cub3d-aa0fc403f7f81dedfa3fe22235aecceaf7b91e27.tar.bz2
42-cub3d-aa0fc403f7f81dedfa3fe22235aecceaf7b91e27.tar.xz
42-cub3d-aa0fc403f7f81dedfa3fe22235aecceaf7b91e27.tar.zst
42-cub3d-aa0fc403f7f81dedfa3fe22235aecceaf7b91e27.zip
sprintf is bav
Diffstat (limited to 'src')
-rw-r--r--src/ft_check_map_line.c15
-rw-r--r--src/ft_get_colors.c19
-rw-r--r--src/ft_get_map.c7
-rw-r--r--src/ft_get_res.c8
-rw-r--r--src/ft_get_sprite.c10
-rw-r--r--src/ft_get_tex.c40
6 files changed, 38 insertions, 61 deletions
diff --git a/src/ft_check_map_line.c b/src/ft_check_map_line.c
index 1009aa3..017d63a 100644
--- a/src/ft_check_map_line.c
+++ b/src/ft_check_map_line.c
@@ -20,16 +20,14 @@ static int8_t
{
if (!ft_ischarset("012NSEW ", line[i]))
{
- ft_strlcpy(clist->errmsg, FT_ERR_ILL_MAP,
- ft_strlen(FT_ERR_ILL_MAP) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_ILL_MAP);
return (-1);
}
if (ft_ischarset("NSEW", line[i]))
clist->mlist->isspawn += 1;
if (clist->mlist->isspawn > 1)
{
- ft_strlcpy(clist->errmsg, FT_ERR_MULT_SPAWN,
- ft_strlen(FT_ERR_MULT_SPAWN) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_MULT_SPAWN);
return (-1);
}
return (0);
@@ -40,8 +38,7 @@ static int8_t
{
if (!ft_ischarset("1 ", line[i]))
{
- ft_strlcpy(clist->errmsg, FT_ERR_ILL_MAP,
- ft_strlen(FT_ERR_ILL_MAP) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_ILL_MAP);
return (-1);
}
return (0);
@@ -69,8 +66,7 @@ static int8_t
{
if (line[0] != '1' || line[i - 1] != '1')
{
- ft_strlcpy(clist->errmsg, FT_ERR_ILL_ENTRY,
- ft_strlen(FT_ERR_ILL_ENTRY) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_ILL_ENTRY);
return (-1);
}
return (0);
@@ -99,8 +95,7 @@ int8_t
return (-1);
if (ft_get_line_len(line) != clist->mlist->map_w)
{
- ft_strlcpy(clist->errmsg, FT_ERR_MAP_LEN,
- ft_strlen(FT_ERR_MAP_LEN) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_MAP_LEN);
return (-1);
}
return (0);
diff --git a/src/ft_get_colors.c b/src/ft_get_colors.c
index f54fabc..96be925 100644
--- a/src/ft_get_colors.c
+++ b/src/ft_get_colors.c
@@ -30,8 +30,7 @@ static int8_t
if (i != ft_strlen(num[j]))
{
ft_free_words(num);
- ft_strlcpy(clist->errmsg, FT_ERR_COLOR_ALPHA,
- ft_strlen(FT_ERR_COLOR_ALPHA) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_COLOR_ALPHA);
return (-1);
}
i = 0;
@@ -46,8 +45,7 @@ static int8_t
if (ft_atoi(num[0]) > 255 || ft_atoi(num[1]) > 255
|| ft_atoi(num[2]) > 255)
{
- ft_strlcpy(clist->errmsg, FT_ERR_COLOR_MAX,
- ft_strlen(FT_ERR_COLOR_MAX) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_COLOR_MAX);
ft_free_words(num);
return (-1);
}
@@ -59,8 +57,7 @@ static int8_t
{
if (!num[0] || !num[1] || !num[2] || num[3])
{
- ft_strlcpy(clist->errmsg, FT_ERR_COLOR_ARGS,
- ft_strlen(FT_ERR_COLOR_ARGS) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_COLOR_ARGS);
ft_free_words(num);
return (-1);
}
@@ -74,13 +71,12 @@ int8_t
if (!(*words) || !words[1] || words[2])
{
- ft_strlcpy(clist->errmsg, FT_ERR_ARGS, ft_strlen(FT_ERR_ARGS) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_ARGS);
return (-1);
}
if (!(num = ft_split(words[1], ',')))
{
- ft_strlcpy(clist->errmsg, FT_ERR_ALLOCATE,
- ft_strlen(FT_ERR_ALLOCATE) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_ALLOCATE);
return (-1);
}
if (ft_check_nums_amount(num, clist) < 0)
@@ -103,13 +99,12 @@ int8_t
if (!(*words) || !words[1] || words[2])
{
- ft_strlcpy(clist->errmsg, FT_ERR_ARGS, ft_strlen(FT_ERR_ARGS) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_ARGS);
return (-1);
}
if (!(num = ft_split(words[1], ',')))
{
- ft_strlcpy(clist->errmsg, FT_ERR_ALLOCATE,
- ft_strlen(FT_ERR_ALLOCATE) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_ALLOCATE);
return (-1);
}
if (ft_check_nums_amount(num, clist) < 0)
diff --git a/src/ft_get_map.c b/src/ft_get_map.c
index cb677da..f609c50 100644
--- a/src/ft_get_map.c
+++ b/src/ft_get_map.c
@@ -54,8 +54,7 @@ static int8_t
((clist->mlist->map_w + 1) * i) * sizeof(char),
((clist->mlist->map_w + 1) * (i + 1)) * sizeof(char))))
{
- ft_strlcpy(clist->errmsg, FT_ERR_ALLOCATE,
- ft_strlen(FT_ERR_ALLOCATE) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_ALLOCATE);
return (-1);
}
ft_linecpy(line, clist->mlist->mapl, (clist->mlist->map_w + 1) * i);
@@ -69,14 +68,14 @@ int
if (!line[0])
{
ft_memdel((void**)&line);
- ft_strlcpy(clist->errmsg, FT_ERR_READ, ft_strlen(FT_ERR_READ) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_READ);
return (-1);
}
clist->mlist->map_w = ft_get_line_len(line);
if (ft_check_map_line(line, 1, clist) < 0)
{
ft_memdel((void**)&line);
- ft_strlcpy(clist->errmsg, FT_ERR_READ, ft_strlen(FT_ERR_READ) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_READ);
return (-1);
}
ft_memdel((void**)&clist->mlist->mapl);
diff --git a/src/ft_get_res.c b/src/ft_get_res.c
index 26853be..9bcf4ef 100644
--- a/src/ft_get_res.c
+++ b/src/ft_get_res.c
@@ -24,8 +24,7 @@ static int8_t
i++;
if (i != ft_strlen(word))
{
- ft_strlcpy(clist->errmsg, FT_ERR_RES_ALPHA,
- ft_strlen(FT_ERR_RES_ALPHA) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_RES_ALPHA);
return (-1);
}
return (0);
@@ -49,7 +48,7 @@ int8_t
if (!(*words + 0) || !(*(words + 1)) ||
!(*(words + 2)) || (*(words + 3)))
{
- ft_strlcpy(clist->errmsg, FT_ERR_ARGS, ft_strlen(FT_ERR_ARGS) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_ARGS);
return (-1);
}
if ((ft_checkdigit(words[1], clist) < 0) ||
@@ -60,8 +59,7 @@ int8_t
if (wlist->x_size <= 10
|| wlist->y_size <= 10)
{
- ft_strlcpy(clist->errmsg, FT_ERR_RES_SMALL,
- ft_strlen(FT_ERR_RES_SMALL) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_RES_SMALL);
return (-1);
}
if (ft_get_screen_size(wlist) < 0)
diff --git a/src/ft_get_sprite.c b/src/ft_get_sprite.c
index 806489f..c9546fb 100644
--- a/src/ft_get_sprite.c
+++ b/src/ft_get_sprite.c
@@ -44,25 +44,23 @@ int8_t
{
if (!(*words) || !words[1] || words[2])
{
- ft_strlcpy(clist->errmsg, FT_ERR_ARGS, ft_strlen(FT_ERR_ARGS) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_ARGS);
return (-1);
}
if (ft_check_ext(*(words + 1), ".xpm") < 0)
{
- ft_strlcpy(clist->errmsg, FT_ERR_NOT_A_XPM,
- ft_strlen(FT_ERR_NOT_A_XPM) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_NOT_A_XPM);
return (-1);
}
ft_memdel((void**)&clist->mlist->sprite_path);
if (!(clist->mlist->sprite_path = ft_strdup(*(words + 1))))
{
- ft_strlcpy(clist->errmsg, FT_ERR_ALLOCATE,
- ft_strlen(FT_ERR_ALLOCATE) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_ALLOCATE);
return (-1);
}
if (ft_check_not_found(clist->mlist->sprite_path) < 0)
{
- ft_strlcpy(clist->errmsg, FT_ERR_RD_SP, ft_strlen(FT_ERR_RD_SP) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_RD_SP);
return (-1);
}
return (0);
diff --git a/src/ft_get_tex.c b/src/ft_get_tex.c
index 58a0358..1327d58 100644
--- a/src/ft_get_tex.c
+++ b/src/ft_get_tex.c
@@ -19,25 +19,23 @@ int8_t
{
if (!(*words) || !(*(words + 1)) || (*(words + 2)))
{
- ft_strlcpy(clist->errmsg, FT_ERR_ARGS, ft_strlen(FT_ERR_ARGS) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_ARGS);
return (-1);
}
if (ft_check_ext(*(words + 1), ".xpm") < 0)
{
- ft_strlcpy(clist->errmsg, FT_ERR_NOT_A_XPM,
- ft_strlen(FT_ERR_NOT_A_XPM) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_NOT_A_XPM);
return (-1);
}
ft_memdel((void**)&clist->mlist->no_tex_path);
if (!(clist->mlist->no_tex_path = ft_strdup(*(words + 1))))
{
- ft_strlcpy(clist->errmsg, FT_ERR_ALLOCATE,
- ft_strlen(FT_ERR_ALLOCATE) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_ALLOCATE);
return (-1);
}
if (ft_check_not_found(clist->mlist->no_tex_path) < 0)
{
- ft_strlcpy(clist->errmsg, FT_ERR_RD_NO, ft_strlen(FT_ERR_RD_NO) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_RD_NO);
return (-1);
}
return (0);
@@ -48,25 +46,23 @@ int8_t
{
if (!(*words) || !(*(words + 1)) || (*(words + 2)))
{
- ft_strlcpy(clist->errmsg, FT_ERR_ARGS, ft_strlen(FT_ERR_ARGS) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_ARGS);
return (-1);
}
if (ft_check_ext(*(words + 1), ".xpm") < 0)
{
- ft_strlcpy(clist->errmsg, FT_ERR_NOT_A_XPM,
- ft_strlen(FT_ERR_NOT_A_XPM) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_NOT_A_XPM);
return (-1);
}
ft_memdel((void**)&clist->mlist->so_tex_path);
if (!(clist->mlist->so_tex_path = ft_strdup(*(words + 1))))
{
- ft_strlcpy(clist->errmsg, FT_ERR_ALLOCATE,
- ft_strlen(FT_ERR_ALLOCATE) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_ALLOCATE);
return (-1);
}
if (ft_check_not_found(clist->mlist->so_tex_path) < 0)
{
- ft_strlcpy(clist->errmsg, FT_ERR_RD_SO, ft_strlen(FT_ERR_RD_SO) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_RD_SO);
return (-1);
}
return (0);
@@ -77,25 +73,23 @@ int8_t
{
if (!(*words) || !(*(words + 1)) || (*(words + 2)))
{
- ft_strlcpy(clist->errmsg, FT_ERR_ARGS, ft_strlen(FT_ERR_ARGS) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_ARGS);
return (-1);
}
if (ft_check_ext(*(words + 1), ".xpm") < 0)
{
- ft_strlcpy(clist->errmsg, FT_ERR_NOT_A_XPM,
- ft_strlen(FT_ERR_NOT_A_XPM) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_NOT_A_XPM);
return (-1);
}
ft_memdel((void**)&clist->mlist->ea_tex_path);
if (!(clist->mlist->ea_tex_path = ft_strdup(*(words + 1))))
{
- ft_strlcpy(clist->errmsg, FT_ERR_ALLOCATE,
- ft_strlen(FT_ERR_ALLOCATE) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_ALLOCATE);
return (-1);
}
if (ft_check_not_found(clist->mlist->ea_tex_path) < 0)
{
- ft_strlcpy(clist->errmsg, FT_ERR_RD_EA, ft_strlen(FT_ERR_RD_EA) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_RD_EA);
return (-1);
}
return (0);
@@ -106,25 +100,23 @@ int8_t
{
if (!(*words) || !(*(words + 1)) || (*(words + 2)))
{
- ft_strlcpy(clist->errmsg, FT_ERR_ARGS, ft_strlen(FT_ERR_ARGS) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_ARGS);
return (-1);
}
if (ft_check_ext(*(words + 1), ".xpm") < 0)
{
- ft_strlcpy(clist->errmsg, FT_ERR_NOT_A_XPM,
- ft_strlen(FT_ERR_NOT_A_XPM) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_NOT_A_XPM);
return (-1);
}
ft_memdel((void**)&clist->mlist->we_tex_path);
if (!(clist->mlist->we_tex_path = ft_strdup(*(words + 1))))
{
- ft_strlcpy(clist->errmsg, FT_ERR_ALLOCATE,
- ft_strlen(FT_ERR_ALLOCATE) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_ALLOCATE);
return (-1);
}
if (ft_check_not_found(clist->mlist->we_tex_path) < 0)
{
- ft_strlcpy(clist->errmsg, FT_ERR_RD_WE, ft_strlen(FT_ERR_RD_WE) + 1);
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_RD_WE);
return (-1);
}
return (0);