-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.c
72 lines (65 loc) · 1.63 KB
/
error.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* error.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rlechapt <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/02/02 11:04:45 by rlechapt #+# #+# */
/* Updated: 2015/03/11 05:59:01 by rlechapt ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void ft_puterror(char *str)
{
int i;
i = 0;
while (str[i] != '\0')
{
write(1, &str[i], 1);
i++;
}
exit(0);
}
void check_error(t_env *e, char **av)
{
int i;
int j;
i = e->i;
while (av[i] != '\0')
{
j = 0;
while (av[i][j] != '\0')
{
if ((av[i][j] == 43 || av[i][j] == 45) && (av[i][j + 1] >= 48 &&
av[i][j + 1] <= 57))
{
if (av[i][j - 1] >= 48 && av[i][j - 1] <= 57)
ft_puterror("Error\n");
}
else if (av[i][j] >= 48 && av[i][j] <= 57)
;
else
ft_puterror("Error\n");
j++;
}
i++;
}
}
void check_pile(t_env *e)
{
int j;
int i;
i = 0;
while (i < e->len_a)
{
j = i + 1;
while (j < e->len_a)
{
if (e->pile_a[i] == e->pile_a[j])
ft_puterror("Error\n");
j++;
}
i++;
}
}