-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_flag.c
More file actions
61 lines (56 loc) · 1.6 KB
/
ft_flag.c
File metadata and controls
61 lines (56 loc) · 1.6 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
50
51
52
53
54
55
56
57
58
59
60
61
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_flag.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rbiodies <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/10/28 11:56:53 by rbiodies #+# #+# */
/* Updated: 2021/10/31 13:58:37 by rbiodies ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_dot(t_list *flag, const char *format, int i)
{
i++;
if (format[i] == '*')
{
flag->dot = va_arg(flag->args, int);
i++;
}
else
{
flag->dot = 0;
while (format[i] >= '0' && format[i] <= '9')
{
flag->dot = flag->dot * 10 + (format[i] - '0');
i++;
}
}
return (i);
}
t_list *ft_minus(t_list *flag)
{
flag->minus = 1;
flag->zero = 0;
return (flag);
}
t_list *ft_star(t_list *flag)
{
flag->star = 1;
flag->wdt = va_arg(flag->args, int);
if (flag->wdt < 0)
{
flag->minus = 1;
flag->wdt *= -1;
flag->zero = 0;
}
return (flag);
}
t_list *ft_digit(t_list *flag, const char format)
{
if (flag->star == 1)
flag->wdt = 0;
flag->wdt = flag->wdt * 10 + (format - '0');
return (flag);
}