-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvert_c.c
More file actions
36 lines (33 loc) · 1.48 KB
/
convert_c.c
File metadata and controls
36 lines (33 loc) · 1.48 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* convert_c.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: yazhu <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/12/28 20:08:47 by yazhu #+# #+# */
/* Updated: 2018/01/09 21:30:09 by yazhu ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void convert_c(t_format *format, va_list ap, int *count, int has_l_mod)
{
wchar_t wc;
int left_adjust;
char fill;
left_adjust = ft_haschar(format->flag, '-');
fill = ' ';
wc = (format->conv == '%') ? '%' : va_arg(ap, int);
(*count)++;
format->min_w--;
if (ft_haschar(format->flag, '0') && !left_adjust)
fill = '0';
while (!left_adjust && format->min_w-- > 0 && ++(*count))
ft_putchar(fill);
if ((format->conv == 'c' && has_l_mod) || format->conv == 'C')
ft_putwchar(wc);
else
ft_putchar((char)wc);
while (left_adjust && format->min_w-- > 0 && ++(*count))
ft_putchar(fill);
}