-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_print_int_help.c
86 lines (80 loc) · 2.19 KB
/
ft_print_int_help.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_print_int_help.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tblaase <tblaase@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/07/09 12:54:40 by tblaase #+# #+# */
/* Updated: 2021/07/14 14:18:42 by tblaase ### ########.fr */
/* */
/* ************************************************************************** */
#include "libftprintf.h"
void ft_int_help_one(t_print *tab, int len, int z)
{
if (tab->precision > len)
ft_prec_greater_intlen(tab, len, z);
else
{
ft_putnbr_fd(z, 1);
tab->printlen = tab->printlen + len;
}
}
void ft_int_help_two(t_print *tab, int len, int z)
{
if (tab->precision > len)
{
if (z < 0)
tab->precision++;
ft_width_right(tab, tab->precision);
if (z < 0)
tab->precision--;
ft_prec_greater_intlen(tab, len, z);
}
else
{
tab->zero = 0;
ft_width_right(tab, len);
ft_putnbr_fd(z, 1);
tab->printlen = tab->printlen + len;
}
}
void ft_int_help_three(t_print *tab, int len, int z)
{
if (tab->precision > len)
{
ft_prec_greater_intlen(tab, len, z);
if (z < 0)
tab->precision++;
ft_width_left(tab, tab->precision);
}
else
{
ft_putnbr_fd(z, 1);
ft_width_right(tab, len);
tab->printlen = tab->printlen + len;
}
}
void ft_int_help_four(t_print *tab, int len, int z)
{
if (z < 0 && tab->precision == -1)
{
write(1, &"-", 1);
z = z * -1;
}
if (tab->precision != -1)
tab->zero = 0;
ft_width_right(tab, len);
ft_putnbr_fd(z, 1);
tab->printlen = tab->printlen + len;
}
void ft_int_help_five(t_print *tab, int len, int z)
{
tab->zero = 0;
if (z < 0)
tab->precision++;
ft_width_right(tab, tab->precision);
if (z < 0)
tab->precision--;
ft_prec_greater_intlen(tab, len, z);
}