-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_errors_var.c
73 lines (67 loc) · 1.08 KB
/
check_errors_var.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
73
#include "cub3d.h"
void help_check_res(char *line, int *i, int *set_of_n)
{
if (line[*i] == ' ')
{
while (line[*i] == ' ')
(*i)++;
}
if (ft_isdigit(line[*i]) == 1)
{
(*set_of_n)++;
while (ft_isdigit(line[*i]) == 1)
(*i)++;
}
}
int check_resolution(char *line)
{
int i;
int set_of_n;
i = 1;
set_of_n = 0;
while (line[i])
{
if (ft_isdigit(line[i]) == 0 && line[i] != ' ')
return (-1);
i++;
}
i = 1;
while (line[i])
help_check_res(line, &i, &set_of_n);
if (set_of_n != 2)
return (-1);
return (0);
}
void help_check_cf(char *line, int *i, int *set_of_n)
{
if (line[*i] == ' ' || line[*i] == ',')
{
while (line[*i] == ' ' || line[*i] == ',')
(*i)++;
}
if (ft_isdigit(line[*i]) == 1)
{
(*set_of_n)++;
while (ft_isdigit(line[*i]) == 1)
(*i)++;
}
}
int check_c_f(char *line)
{
int i;
int set_of_n;
i = 1;
set_of_n = 0;
while (line[i])
{
if (ft_isdigit(line[i]) == 0 && line[i] != ' ' && line[i] != ',')
return (-1);
i++;
}
i = 1;
while (line[i])
help_check_cf(line, &i, &set_of_n);
if (set_of_n != 3)
return (-1);
return (0);
}