-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_print_diu_cs.c
executable file
·95 lines (86 loc) · 2.12 KB
/
ft_print_diu_cs.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_print_diu_cs.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bscamand <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/01/11 14:21:36 by bscamand #+# #+# */
/* Updated: 2021/01/11 14:22:11 by bscamand ### ########.fr */
/* */
/* ************************************************************************** */
#include "libftprintf.h"
void ft_char_minus(int flag, t_parser *ptr)
{
if (DI < 0 && flag)
{
ft_putchar_fd('-', 1, ptr);
DI_STR++;
}
if (DI < 0 && DOT && !flag)
{
LEN_DI--;
WIDTH--;
}
}
void ft_print_di(t_parser *ptr)
{
char *di_str;
di_str = ft_itoa(DI);
DI_STR = di_str;
free(di_str);
LEN_DI = ft_strlen(DI_STR);
ft_char_minus(0, ptr);
if (!ACCURACY && !DI)
{
if (!(ft_accuracy_and_value_di(ptr)))
ft_accuracy_and_value_di(ptr);
else
return ;
}
else if (MINUS)
ft_process_di_minus(ptr);
else
ft_process_di(ptr);
}
void ft_print_u(t_parser *ptr)
{
char *u_str;
u_str = ft_itoa(U);
U_STR = u_str;
free(u_str);
LEN_U = ft_strlen(U_STR);
if (!ACCURACY && !U)
{
if (!(ft_accuracy_and_value_ux(U_STR, ptr)))
ft_accuracy_and_value_ux(U_STR, ptr);
else
return ;
}
else if (MINUS)
ft_process_u_minus(ptr);
else
ft_process_u(ptr);
}
void ft_print_c(t_parser *ptr)
{
if (!WIDTH)
ft_putchar_fd(C, 1, ptr);
else if (MINUS)
{
ft_putchar_fd(C, 1, ptr);
ft_putchar_fd_tap(TAP, 1, ptr, WIDTH - 1);
}
else
{
ft_putchar_fd_tap(TAP, 1, ptr, WIDTH - 1);
ft_putchar_fd(C, 1, ptr);
}
}
void ft_print_s(t_parser *ptr)
{
int len_s;
len_s = ft_strlen(S);
ft_accuracy_len(len_s, ptr);
ft_process_s(len_s, ptr);
}