-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_pieces.c
101 lines (90 loc) · 1.89 KB
/
make_pieces.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
94
95
96
97
98
99
100
101
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* make_pieces.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: qdegraev <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/12/17 17:31:02 by qdegraev #+# #+# */
/* Updated: 2015/12/17 17:31:06 by qdegraev ### ########.fr */
/* */
/* ************************************************************************** */
#include "fillit.h"
char *cut_empty_lin(char *s)
{
int i;
char *s2;
s2 = "....\n\0";
i = 0;
while (s[i])
{
if (ft_strnequ(s + i, s2, 4) == 1)
str_replace(s + i, "\n\n\n\n");
i++;
}
s = src_emptycol(s);
return (s);
}
char *src_emptycol(char *s)
{
int i;
int j;
int k;
j = 0;
i = 0;
while (i < 4)
{
k = 0;
if (s[k + i] == '.' || s[k + i] == '\n')
{
while (s[k + i] && (s[k + i] == '.' || s[k +i] == '\n'))
{
k += 5;
j++;
}
}
if (j == 4 || j == 5)
str_replace_col(s + i, "\n\n\n\n");
i++;
j = 0;
}
return (s);
}
char *cut_empty_col(char *s)
{
int i;
i = 0;
while (i < 4)
{
if (src_emptycol(s + i))
{
ft_putendl("srcemptycol ok");
str_replace_col(s + i, "\n\n\n\n");
}
i++;
}
return (s);
}
void str_replace(char *dest, const char *src)
{
int i;
i = 0;
while (src[i])
{
dest[i] = src[i];
i++;
}
}
void str_replace_col(char *dest, const char *src)
{
int i;
int j;
j = 0;
i = 0;
while (src[i] && j < 20)
{
dest[j] = src[i];
i++;
j += 5;
}
}