-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfind_utils_two.c
More file actions
110 lines (105 loc) · 2.12 KB
/
find_utils_two.c
File metadata and controls
110 lines (105 loc) · 2.12 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include "minishell.h"
int finding_quotes_cmd(char *s, int i, t_source *src)
{
if (s[i] == '\"' && i == 0)
src->dquotes = 1;
else if (s[i] == '\'' && i == 0 && src->dquotes == 0)
src->squotes = 1;
else if (s[i] == '\"' && src->squotes == 0 && src->aslash == 0)
{
if (src->dquotes == 0)
{
src->dquotes = 1;
}
else
src->dquotes = 0;
}
else if (s[i] == '\'' && src->dquotes == 0)
{
if (src->squotes == 0)
src->squotes = 1;
else
src->squotes = 0;
}
finding_aslash(s, i, src);
return (0);
}
int finding_quotes(char *s, int i, t_source *src)
{
if (s[i] == '\"' && src->squotes == 0 && src->aslash == 0)
{
if (src->dquotes == 0)
{
src->dquotes = 1;
}
else
src->dquotes = 0;
}
else if (s[i] == '\'' && src->dquotes == 0 && src->aslash == 0)
{
if (src->squotes == 0)
{
src->squotes = 1;
}
else
src->squotes = 0;
}
finding_aslash_split(s, i, src);
return (0);
}
int finding_aslash(char *s, int i, t_source *src)
{
if (s[i] == '\\' && s[i + 1] == '\'' && src->dquotes == 1)
src->aslash = 0;
else if (s[i] == '\\' && (s[i + 1] == '\"' || s[i + 1] == '\\'
|| s[i + 1] == '\'' || s[i + 1] == '$')
&& src->aslash == 0 && src->squotes == 0)
src->aslash = 1;
else if (s[i] == '\\' && (src->dquotes == 0 && src->squotes == 0))
{
if (ft_isascii(s[i + 1]) == 0)
src->founderror = 1;
else
return (1);
}
else
src->aslash = 0;
return (0);
}
int finding_aslash2(char *s, int i, t_source *src)
{
if (s[i] == '\\' && s[i + 1] == '\'' && src->dquotes == 1)
src->aslash = 0;
else if (s[i] == '\\' && (s[i + 1] == '\"' || s[i + 1] == '\\'
|| s[i + 1] == '\'' || s[i + 1] == '$')
&& src->aslash == 0 && src->squotes == 0)
{
src->aslash = 1;
}
else
src->aslash = 0;
return (0);
}
int finding_quotes2(char *s, int i, t_source *src)
{
if (s[i] == '\"' && src->squotes == 0 && src->aslash == 0)
{
if (src->dquotes == 0)
{
src->dquotes = 1;
}
else
src->dquotes = 0;
}
else if (s[i] == '\'' && src->dquotes == 0 && src->aslash == 0)
{
if (src->squotes == 0)
{
src->squotes = 1;
}
else
src->squotes = 0;
}
finding_aslash2(s, i, src);
return (0);
}