This commit is contained in:
Raphaël 2024-04-22 11:11:20 +02:00
parent d0fe1fb2fb
commit 2ecc64f778
3 changed files with 35 additions and 18 deletions

View file

@ -6,7 +6,7 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/13 12:08:16 by rparodi #+# #+# */
/* Updated: 2024/04/18 15:20:44 by rparodi ### ########.fr */
/* Updated: 2024/04/22 11:02:15 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
@ -42,9 +42,24 @@ static int ft_isnum(char *num)
return (1);
}
void ft_stack_utils(int i, long tmp, char **args)
{
while (args[i] != NULL)
{
tmp = ft_atoi(args[i]);
if (!ft_isnum(args[i]) || *args[i] == '\0')
error_message("not number stack", NULL, NULL, NULL);
if (ft_contains(tmp, args, i) == 1 || (chk_len(args[i]) > 11))
error_message("overflow stack", NULL, NULL, NULL);
if (tmp < -2147483648 || tmp > 2147483647)
error_message("over int stack", NULL, NULL, NULL);
i++;
}
}
void ft_check_args_utils(int i, char **args)
{
long tmp;
long tmp;
tmp = 0;
if (i == 0)
@ -54,7 +69,7 @@ void ft_check_args_utils(int i, char **args)
tmp = ft_atoi(args[i]);
if (!ft_isnum(args[i]) || *args[i] == '\0')
error_message("not number heap", NULL, NULL, args);
if (ft_contains(tmp, args, i) == 1 || (ft_len(args[i]) > 11))
if (ft_contains(tmp, args, i) == 1 || (chk_len(args[i]) > 11))
error_message("overflow heap", NULL, NULL, args);
if (tmp < -2147483648 || tmp > 2147483647)
error_message("over int heap", NULL, NULL, args);
@ -63,19 +78,7 @@ void ft_check_args_utils(int i, char **args)
free_string(args);
}
else
{
while (args[i] != NULL)
{
tmp = ft_atoi(args[i]);
if (!ft_isnum(args[i]) || *args[i] == '\0')
error_message("not number stack", NULL, NULL, NULL);
if (ft_contains(tmp, args, i) == 1 || (ft_len(args[i]) > 11))
error_message("overflow stack", NULL, NULL, NULL);
if (tmp < -2147483648 || tmp > 2147483647)
error_message("over int stack", NULL, NULL, NULL);
i++;
}
}
ft_stack_utils(i, tmp, args);
}
void check_args(char **argv)