Archived
1
0
This repository has been archived on 2024-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
push_swap/src/check_error.c

61 lines
1.6 KiB
C
Raw Normal View History

2024-02-22 11:05:04 +01:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* check_error.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/15 13:45:25 by adjoly #+# #+# */
2024-03-11 16:24:15 +01:00
/* Updated: 2024/03/11 15:56:15 by adjoly ### ########.fr */
2024-02-22 11:05:04 +01:00
/* */
/* ************************************************************************** */
#include "push_swap.h"
void ft_check_args_format(char **av)
{
2024-03-11 16:24:15 +01:00
char **tmp;
char *tmp_av;
2024-02-22 11:05:04 +01:00
2024-03-11 16:24:15 +01:00
tmp = av;
tmp++;
while (*tmp)
2024-02-22 11:05:04 +01:00
{
2024-03-11 16:24:15 +01:00
tmp_av = *tmp;
while (*tmp_av)
2024-02-22 11:05:04 +01:00
{
2024-03-11 16:24:15 +01:00
if (!ft_isdigit(*tmp_av) && *tmp_av != 32 \
&& *tmp_av != '-' && *tmp_av != '+')
2024-02-22 11:05:04 +01:00
{
ft_putendl_fd("Error", STDERR_FILENO);
exit(EXIT_SUCCESS);
}
2024-03-11 16:24:15 +01:00
tmp_av++;
2024-02-22 11:05:04 +01:00
}
2024-03-11 16:24:15 +01:00
tmp++;
2024-02-22 11:05:04 +01:00
}
}
void ft_check_double(t_stack **stack)
{
t_stack *index;
t_stack *tmp;
index = *stack;
while (index)
{
tmp = index->next;
while (tmp)
{
if (index->nb == tmp->nb)
{
ft_stackclear(stack);
ft_putendl_fd("Error", STDERR_FILENO);
exit(EXIT_FAILURE);
}
tmp = tmp->next;
}
index = index->next;
}
}