-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_dot_utils.c
executable file
·114 lines (109 loc) · 2.72 KB
/
ft_dot_utils.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
102
103
104
105
106
107
108
109
110
111
112
113
114
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_dot_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bscamand <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/01/11 14:31:24 by bscamand #+# #+# */
/* Updated: 2021/01/11 14:32:20 by bscamand ### ########.fr */
/* */
/* ************************************************************************** */
#include "libftprintf.h"
void ft_accuracy_len(int len, t_parser *ptr)
{
if (DOT && TYPE == 's')
{
if (ACCURACY > len && ACCURACY)
ACCURACY = len;
}
else if (DOT && TYPE == 'p')
{
ACCURACY = 0;
}
else
{
if (ACCURACY <= len)
ACCURACY = len;
}
}
int ft_accuracy_and_value_di(t_parser *ptr)
{
if (MINUS)
{
if (DOT)
{
if (!WIDTH)
return (0);
ft_putchar_fd_tap(TAP, 1, ptr, WIDTH - ACCURACY);
return (1);
}
ft_putchar_fd(*DI_STR++, 1, ptr);
ft_putchar_fd_tap(TAP, 1, ptr, WIDTH - ACCURACY - 1);
return (1);
}
if (DOT)
{
if (!WIDTH)
return (0);
ft_putchar_fd_tap(TAP, 1, ptr, WIDTH - ACCURACY);
return (1);
}
ft_putchar_fd_tap(TAP, 1, ptr, WIDTH - ACCURACY - 1);
ft_putchar_fd(*DI_STR++, 1, ptr);
return (1);
}
int ft_accuracy_and_value_ux(char *str, t_parser *ptr)
{
if (MINUS)
{
if (DOT)
{
if (!WIDTH)
return (0);
ft_putchar_fd_tap(TAP, 1, ptr, WIDTH - ACCURACY);
return (1);
}
ft_putchar_fd(*str++, 1, ptr);
ft_putchar_fd_tap(TAP, 1, ptr, WIDTH - ACCURACY - 1);
return (1);
}
if (DOT)
{
if (!WIDTH)
return (0);
ft_putchar_fd_tap(TAP, 1, ptr, WIDTH - ACCURACY);
return (1);
}
ft_putchar_fd_tap(TAP, 1, ptr, WIDTH - ACCURACY - 1);
ft_putchar_fd(*str++, 1, ptr);
return (1);
}
int ft_accuracy_and_value_p(char *str, char *ox, t_parser *ptr)
{
if (MINUS)
{
if (DOT)
{
if (!WIDTH)
return (0);
ft_putstr_fd(ox, 1, ptr);
ft_putchar_fd_tap(' ', 1, ptr, WIDTH - ACCURACY - 2);
return (1);
}
ft_putstr_fd(ox, 1, ptr);
ft_putchar_fd(*str++, 1, ptr);
ft_putchar_fd_tap(TAP, 1, ptr, WIDTH - ACCURACY - 3);
return (1);
}
if (DOT)
{
ft_putchar_fd_tap(TAP, 1, ptr, WIDTH - ACCURACY - 2);
ft_putstr_fd(ox, 1, ptr);
return (1);
}
ft_putchar_fd_tap(TAP, 1, ptr, WIDTH - ACCURACY - 3);
ft_putstr_fd(ox, 1, ptr);
ft_putchar_fd(*P_STR++, 1, ptr);
return (1);
}