-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_check_instructions.c
37 lines (35 loc) · 1.45 KB
/
ft_check_instructions.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_check_instructions.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dlana <dlana@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/10/01 21:17:24 by dlana #+# #+# */
/* Updated: 2021/10/01 21:20:09 by dlana ### ########.fr */
/* */
/* ************************************************************************** */
#include "checker.h"
void ft_check_instructions(const char *s, int i)
{
if ((s[i] == 's' && s[i - 1] == 's') || (s[i] == 'r' && s[i - 1] == 'r'))
{
if (((s[i - 2] == '\0' || s[i - 2] == '\n') && i > 1) || i == 1)
return ;
}
if (s[i] == 'a' || s[i] == 'b' || s[i] == 'r')
{
i--;
if ((s[i] == 'r' && s[i - 1] == 'r'))
{
if (((s[i - 2] == '\0' || s[i - 2] == '\n') && i > 1) || i == 1)
return ;
}
if ((s[i] == 's' || s[i] == 'r' || s[i] == 'p') && s[i + 1] != 'r')
{
if (((s[i - 1] == '\0' || s[i - 1] == '\n') && i > 0) || i == 0)
return ;
}
}
ft_error();
}