-
Notifications
You must be signed in to change notification settings - Fork 0
/
files1.c
93 lines (85 loc) · 2.71 KB
/
files1.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* files1.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: abel-bou <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/08/03 12:22:08 by zwalad #+# #+# */
/* Updated: 2022/08/18 23:24:01 by abel-bou ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
t_list *grep_files(t_list *p)
{
if (p->line[p->i] == '<' && p->error != 1)
p = south_face(p);
if (p->line[p->i] == '>' && p->error != 1)
p = north_face(p);
if (p->error != 1)
p->i = skip_space(p->line, p->i);
return (p);
}
t_list *north_face(t_list *p)
{
p = north_errors(p);
if (p->error != 1)
{
if (p->line[p->i] == '>' && p->line[p->i + 1] == '>')
p = north_help(p, APPENDD);
else if (p->line[p->i] == '>' && check_ffile(p->line[p->i + 1])
&& p->line[p->i + 1])
p = north_help(p, OUTFILEE);
}
return (p);
}
t_list *south_face(t_list *p)
{
p = south_errors(p);
if (p->error != 1)
{
if (p->line[p->i] == '<' && p->line[p->i + 1] == '<')
p = south_herdo(p);
else if (p->line[p->i] == '<' && check_ffile(p->line[p->i + 1]))
p = south_inpu(p);
}
return (p);
}
t_list *north_errors(t_list *p)
{
int i;
if (p->error != 1)
{
i = p->i;
if ((p->line[i] == '>' && p->line[i + 1] == '<') && p->error != 1)
p = erorat("syntax error", p);
while ((p->line[i] == '>' || p->line[i] == '<') && p->error != 1)
i++;
if (((i - p->i) >= 3) && p->error != 1)
p = erorat("syntax error", p);
i = skip_space(p->line, i);
if ((p->line[i] == '>' || p->line[i] == '<' || p->line[i] == '|'
|| p->line[i] == '\0' || p->line[i] == '\n') && p->error != 1)
p = erorat("syntax error", p);
}
return (p);
}
t_list *south_errors(t_list *p)
{
int i;
if (p->error != 1)
{
i = p->i;
if (p->line[i] == '<' && p->line[i + 1] == '>')
p = erorat("syntax error", p);
while (p->line[i] == '<' && p->error != 1)
i++;
if (((i - p->i) >= 3) && p->error != 1)
p = erorat("syntax error", p);
i = skip_space(p->line, i);
if ((p->line[i] == '>' || p->line[i] == '<' || p->line[i] == '|'
|| p->line[i] == '\0' || p->line[i] == '\n') && p->error != 1)
p = erorat("syntax error", p);
}
return (p);
}