-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtoken_utils2.c
58 lines (53 loc) · 1.52 KB
/
token_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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* token_utils2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bmachado <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/10/22 11:27:10 by bmachado #+# #+# */
/* Updated: 2022/02/23 11:13:05 by bmachado ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int define_type(char c)
{
if (c == '$')
return (DOLLAR);
else if (c == '|')
return (PIPE);
else if (c == '\"')
return (D_QUOTES);
else if (c == '\'')
return (QUOTES);
else if (c == ' ')
return (SPACE);
else if (c == '=')
return (EQUAL);
else
return (CHAR);
}
int not_var_name(char *input, int i)
{
while (i >= 0)
{
if (define_type(input[i]) == DOLLAR)
return (0);
i--;
}
return (1);
}
int peek_next_one(char *input, int i)
{
return (define_type(input[i + 1]));
}
int only_char_before(char *input, int i)
{
while (i > 0)
{
if (define_type(input[i - 1]) != CHAR)
return (0);
i--;
}
return (1);
}