-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_will_fit.c
40 lines (37 loc) · 1.35 KB
/
ft_will_fit.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_will_fit.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jtrujill <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/17 15:02:43 by jtrujill #+# #+# */
/* Updated: 2017/02/09 20:16:53 by jtrujill ### ########.fr */
/* */
/* ************************************************************************** */
#include "fillit.h"
char *ft_will_fit(char **input, char *s2)
{
int i;
int j;
j = 0;
i = 0;
while (input[i] != NULL)
{
if ((ft_isfill(input[i], s2, j) == 0) && (s2[j + 1] == '\0'))
{
if ((i == 0) && (s2[j + 1] == '\0'))
return (ft_will_fit(input, ft_increase_size(s2)));
j = ft_laststart(input[--i], s2);
ft_reset(s2, input[i]);
}
else if (ft_isfill(input[i], s2, j) != 0)
{
ft_fill(input[i], s2, j);
j = -1;
i++;
}
j++;
}
return (s2);
}