-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_execute_flags_u.c
111 lines (102 loc) · 2.75 KB
/
ft_execute_flags_u.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_execute_flags_u.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mbifenzi <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/18 23:15:24 by mbifenzi #+# #+# */
/* Updated: 2020/02/19 00:00:00 by mbifenzi ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void ft_execute_flags_u(t_f *f, char *s)
{ //printf("%d", f->preminus);
int len;
int bonus;
int a;
bonus = 0;
a = f->precision;
len = ft_strlen(s);
if(!f->precision && !f->width && !f->no9ta && !f->minus)
ft_putstr(s);
if (f->no9ta && !f->precision && *s == '0')
{ if (f->width)
*s = ' ';
else
{
*s = 0;
}
}
if(f->minus == 1)
{
bonus = 1;
ft_minus_u(f, s, len);
}
if (f->width)
{
ft_width_u(f, s, len);
}
if (f->no9ta && bonus == 0)
ft_precision_u( f, s, len);
}
void ft_minus_u(t_f *f, char *s, int len)
{
ft_precision_i(f, s, len);
}
void ft_width_u( t_f *f ,char *s, int len)
{
int a;
a = f->width;
if(f->width > len && !f->zero)
{
/*printf("%d-%d", f->width, f->precision);*/
while (f->width > f->precision && f->width > len)
{
ft_putchar(' ');
f->width--;
}
}
else if (f->width > len && f->zero)
{
while (f->width > f->precision && f->width > len)
{
if (!f->no9ta)
{
ft_putchar('0');
f->width--;
}
if (f->no9ta)
{
ft_putchar(' ');
f->width--;
}
}
}
else
{
while (f->width > len && f->width > f->precision)
{
ft_putchar('0');
f->width--;
}
}
if(!f->no9ta && !f->minus)
ft_putstr(s);
}
void ft_precision_u(t_f *f, char *s, int len)
{
int a;
a = f->precision;
while (f->precision > len)
{
ft_putchar('0');
f->precision--;
}
while (f->precision <= len && *s)
{
ft_putchar(*s);
s++;
}
f->precision = a;
}