-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_width_char.c
62 lines (55 loc) · 1.71 KB
/
ft_width_char.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_width_char.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mlegeay <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/05/30 04:35:35 by mlegeay #+# #+# */
/* Updated: 2017/05/30 04:40:16 by mlegeay ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void ft_zero_char(t_list *f)
{
int nb_space;
nb_space = f->flags[1] - ft_strlen(f->result);
if ((f->spe == 'c' && f->result[0] == 0) ||
(f->spe == 'C' && f->result[0] == 0))
nb_space--;
while (nb_space-- > 0)
{
if (f->flags[3] == 1 && f->flags[0] <= 0)
ft_buf('0', f);
else
ft_buf(' ', f);
}
ft_display_result(f);
}
void ft_minus_char(t_list *f)
{
int nb_space;
nb_space = f->flags[1] - ft_strlen(f->result);
if ((f->spe == 'c' && f->result[0] == 0) ||
(f->spe == 'C' && f->result[0] == 0))
nb_space--;
ft_display_result(f);
while (nb_space-- > 0)
ft_buf(' ', f);
}
void ft_width_char(t_list *f)
{
int i;
i = 0;
if (f->result)
i = ft_strlen(f->result);
if (i < f->flags[1])
{
if (f->flags[4] == 1)
ft_minus_char(f);
else
ft_zero_char(f);
}
else
ft_display_result(f);
}