-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_flags.c
59 lines (52 loc) · 1.58 KB
/
ft_flags.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_flags.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tblaase <tblaase@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/07/03 09:55:46 by tblaase #+# #+# */
/* Updated: 2021/07/13 15:22:42 by tblaase ### ########.fr */
/* */
/* ************************************************************************** */
#include "libftprintf.h"
int ft_dash(t_print *tab, const char *format, int i)
{
tab->dash = 1;
while (format[i] == '-')
i++;
return (i);
}
int ft_precision(t_print *tab, const char *format, int i)
{
int n;
tab->precision = 0;
i++;
if (!ft_isdigit(format[i]))
return (i);
while (format[i] == '0')
i++;
if (ft_isdigit(format[i]))
{
n = ft_atoi(&format[i]);
tab->precision = n;
i = i + ft_intlen(n);
}
return (i);
}
int ft_zero(t_print *tab, const char *format, int i)
{
tab->zero = 1;
while (format[i] == '0')
i++;
return (i);
}
int ft_width(t_print *tab, const char *format, int i)
{
int n;
n = ft_atoi(&format[i]);
tab->width = n;
while (ft_isdigit(format[i]))
i++;
return (i);
}