-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils2.c
83 lines (75 loc) · 2.09 KB
/
utils2.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: abel-bou <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/08/03 19:15:44 by zwalad #+# #+# */
/* Updated: 2022/08/23 16:25:44 by abel-bou ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
t_list *struct_builtins(t_list *p, t_var *var)
{
p->var = var;
return (p);
}
int ret_pipe(t_list *p)
{
free(p->line2);
ft_err("minishell:", " syntax error near unexpected token", " `|'\n", 258);
p->errorx = 1;
return (1);
}
int check_piipe(t_list *p)
{
char c;
int i;
i = skip_space(p->line2, 0);
if (p->line2[i] == '|')
return (ret_pipe(p));
while (p->line2[i])
{
if (p->line2[i] == '"' || p->line2[i] == '\'')
{
c = p->line2[i++];
while (p->line2[i] != c && p->line2[i])
i++;
}
if (p->line2[i] == '|')
{
i++;
i = skip_space(p->line2, i);
if (p->line2[i] == '|' || p->line2[i] == '\0'
|| p->line2[i] == '\n')
return (ret_pipe(p));
}
i++;
}
return (0);
}
int *wnbb_beta(int *ij, char *str)
{
char cc;
cc = str[ij[0]];
ij[0]++;
while (str[ij[0]] != cc && str[ij[0]])
ij[0]++;
if (str[ij[0]])
ij[0]++;
ij[1]++;
return (ij);
}
int wnb_check(char *str, int *ij, char c)
{
if ((str[0] != c && ij[0] == 0) || (str[ij[0]] != c
&& str[ij[0] - 1] == c) || (str[0] != '<' && ij[0] == 0)
|| (str[ij[0]] != '<' && str[ij[0] - 1] == '<')
|| (str[0] != '>' && ij[0] == 0) || (str[ij[0]] != '>'
&& str[ij[0] - 1] == '>'))
{
return (1);
}
return (0);
}