-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_printf_u.c
52 lines (47 loc) · 1.76 KB
/
ft_printf_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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf_u.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mfrisby <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/07/11 13:15:10 by mfrisby #+# #+# */
/* Updated: 2017/07/11 13:15:11 by mfrisby ### ########.fr */
/* */
/* ************************************************************************** */
#include "libftprintf.h"
static char *ft_printf_check_ml(t_env *e)
{
char *tmp;
if (e->m_ll)
tmp = ft_utoa_base(va_arg(e->pa, unsigned long long), 10);
else if (e->m_l)
tmp = ft_utoa_base(va_arg(e->pa, unsigned long), 10);
else if (e->m_j)
tmp = ft_utoa_base(va_arg(e->pa, uintmax_t), 10);
else if (e->m_z)
tmp = ft_utoa_base(va_arg(e->pa, size_t), 10);
else if (e->m_h)
tmp = ft_utoa_base((unsigned short)va_arg(e->pa, unsigned int), 10);
else if (e->m_hh)
tmp = ft_utoa_base((unsigned char)va_arg(e->pa, unsigned int), 10);
else
tmp = ft_utoa_base(va_arg(e->pa, unsigned int), 10);
return (tmp);
}
void ft_printf_u(t_env *e)
{
char *tmp;
tmp = NULL;
e->type = 'u';
tmp = ft_printf_check_ml(e);
if (ft_strcmp(tmp, "0") == 0)
{
if (e->precision == 0)
ft_printf_putflags(e, ft_strdup(""));
else
ft_printf_putflags(e, tmp);
return ;
}
ft_printf_putflags(e, tmp);
}