-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_printf_o2.c
66 lines (57 loc) · 2.56 KB
/
ft_printf_o2.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
/* ************************************************************************** */
/* LE - / */
/* / */
/* ft_printf_o2.c .:: .:/ . .:: */
/* +:+:+ +: +: +:+:+ */
/* By: bpajot <[email protected]> +:+ +: +: +:+ */
/* #+# #+ #+ #+# */
/* Created: 2018/02/12 10:00:15 by bpajot #+# ## ## #+# */
/* Updated: 2018/02/12 10:01:14 by bpajot ### #+. /#+ ###.fr */
/* / */
/* / */
/* ************************************************************************** */
#include "ft_printf.h"
void ft_printf_lo(t_field *cur, va_list *va)
{
unsigned long lo;
lo = va_arg(*va, unsigned long);
cur->l = (cur->preci == 0 && lo == 0) ? 0 : ft_nbr_long_size_base(lo, 8);
cur->l += (cur->flag & SHARP && lo) ? 1 : 0;
ft_printf_o_flag_space(cur);
if ((!(cur->flag & SHARP) || lo) && (cur->preci || lo))
cur->ret += ft_putnbr_long_base(lo, 8, 0);
cur->ret += ft_putchar_sizel(' ', cur->spc_aft);
}
void ft_printf_llo(t_field *cur, va_list *va)
{
unsigned long long llo;
llo = va_arg(*va, unsigned long long);
cur->l = (cur->preci == 0 && llo == 0) ? 0 : ft_nbr_long_size_base(llo, 8);
cur->l += (cur->flag & SHARP && llo) ? 1 : 0;
ft_printf_o_flag_space(cur);
if ((!(cur->flag & SHARP) || llo) && (cur->preci || llo))
cur->ret += ft_putnbr_long_base(llo, 8, 0);
cur->ret += ft_putchar_sizel(' ', cur->spc_aft);
}
void ft_printf_jo(t_field *cur, va_list *va)
{
uintmax_t jo;
jo = va_arg(*va, uintmax_t);
cur->l = (cur->preci == 0 && jo == 0) ? 0 : ft_nbr_long_size_base(jo, 8);
cur->l += (cur->flag & SHARP && jo) ? 1 : 0;
ft_printf_o_flag_space(cur);
if ((!(cur->flag & SHARP) || jo) && (cur->preci || jo))
cur->ret += ft_putnbr_long_base(jo, 8, 0);
cur->ret += ft_putchar_sizel(' ', cur->spc_aft);
}
void ft_printf_zo(t_field *cur, va_list *va)
{
size_t zo;
zo = va_arg(*va, size_t);
cur->l = (cur->preci == 0 && zo == 0) ? 0 : ft_nbr_long_size_base(zo, 8);
cur->l += (cur->flag & SHARP && zo) ? 1 : 0;
ft_printf_o_flag_space(cur);
if ((!(cur->flag & SHARP) || zo) && (cur->preci || zo))
cur->ret += ft_putnbr_long_base(zo, 8, 0);
cur->ret += ft_putchar_sizel(' ', cur->spc_aft);
}