-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_printf_di.c
More file actions
49 lines (44 loc) · 1.69 KB
/
ft_printf_di.c
File metadata and controls
49 lines (44 loc) · 1.69 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf_di.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mfrisby <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/07/11 13:11:37 by mfrisby #+# #+# */
/* Updated: 2017/07/11 13:11:40 by mfrisby ### ########.fr */
/* */
/* ************************************************************************** */
#include "libftprintf.h"
static char *ft_printf_check_ml(t_env *e)
{
char *tmp;
tmp = NULL;
if (e->m_ll)
tmp = ft_stoa_base(va_arg(e->pa, long long), 10);
else if (e->m_l)
tmp = ft_stoa_base(va_arg(e->pa, long), 10);
else if (e->m_j)
tmp = ft_stoa_base(va_arg(e->pa, intmax_t), 10);
else if (e->m_z)
tmp = ft_stoa_base(va_arg(e->pa, ssize_t), 10);
else if (e->m_h)
tmp = ft_stoa_base((short)va_arg(e->pa, int), 10);
else if (e->m_hh)
tmp = ft_stoa_base((char)va_arg(e->pa, int), 10);
else
tmp = ft_stoa_base(va_arg(e->pa, int), 10);
return (tmp);
}
void ft_printf_di(t_env *e)
{
char *tmp;
tmp = NULL;
tmp = ft_printf_check_ml(e);
tmp = remove_min(e, tmp);
e->type = 'd';
if (ft_strcmp(tmp, "0") == 0 && e->precision == 0)
ft_printf_putflags(e, ft_strdup(""));
else
ft_printf_putflags(e, tmp);
}