-
Notifications
You must be signed in to change notification settings - Fork 0
/
split_utils.c
71 lines (66 loc) · 1.52 KB
/
split_utils.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
/* ************************************************************************** */
/* */
/* :::::::: */
/* split_utils.c :+: :+: */
/* +:+ */
/* By: jvan-hal <[email protected]> +#+ */
/* +#+ */
/* Created: 2023/03/21 15:26:42 by jvan-hal #+# #+# */
/* Updated: 2023/03/23 11:55:03 by jvan-hal ######## odam.nl */
/* */
/* ************************************************************************** */
#include<stddef.h>
int skip_single(char *s, int i)
{
while (s[i])
{
if (s[i] == 39)
break ;
else
++i;
}
return (i);
}
int skip_double(char *s, int i)
{
while (s[i])
{
if (s[i] == 34)
break ;
else
++i;
}
return (i);
}
int skip_quotes(char ***s, int *quotes, int i)
{
if (s[0][0][i] == 39)
{
++(*quotes);
++s[0][0];
i = skip_single(s[0][0], i);
}
if (s[0][0][i] == 34)
{
++(*quotes);
++s[0][0];
i = skip_double(s[0][0], i);
}
return (i);
}
int skip_quotes_count(char *s, int i)
{
if (s[i] == 39)
{
++i;
i = skip_single(s, i);
++i;
}
if (s[i] == 34)
{
++i;
i = skip_double(s, i);
++i;
}
return (i);
}