This repository was archived by the owner on Mar 28, 2026. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathft_flags2.c
More file actions
126 lines (116 loc) · 2.72 KB
/
Copy pathft_flags2.c
File metadata and controls
126 lines (116 loc) · 2.72 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_flags2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jijerde <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/09/18 08:21:17 by jijerde #+# #+# */
/* Updated: 2019/09/20 02:07:26 by jijerde ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int flagsdi2(const char *fo, t_flags *fl)
{
int f;
f = 0;
while (fo[f] != 'd' && fo[f] != 'i' && fo[f] != 'l' && fo[f] != 'h'
&& fo[f] != '.' && !(fo[f] >= 49 && fo[f] <= 57) && fo[f] != '*')
{
if (fo[f] == '-' && !(fl->ze = 0))
fl->mi = 1;
else if (fo[f] == '+')
{
if (!(fl->sp = 0))
fl->pl = 1;
}
else if (fo[f] == ' ')
fl->sp = (!(fl->pl)) ? 1 : 0;
else if (fo[f] == '0')
{
if (!(fl->mi))
fl->ze = 1;
}
else
return (-1);
f++;
}
return (f);
}
int flagscsp2(const char *fo, t_flags *fl)
{
int f;
f = 0;
while (fo[f] != 'c' && fo[f] != 's' && fo[f] != 'p' && fo[f] != '.'
&& !(fo[f] >= 49 && fo[f] <= 57) && fo[f] != '*' && fo[f] != 'r')
{
if (fo[f] == '-')
fl->mi = 1;
else if (fo[f] == ' ' || fo[f] == '#')
;
else
return (-1);
f++;
}
return (f);
}
int flagsf3(const char *fo, t_flags *fl, int f)
{
if (fo[f] == '-')
{
if (!(fl->ze = 0))
fl->mi = 1;
}
else if (fo[f] == '+')
{
if (!(fl->sp = 0))
fl->pl = 1;
}
else if (fo[f] == ' ')
fl->sp = !(fl->pl) ? 1 : 0;
else if (fo[f] == '0')
fl->ze = !(fl->mi) ? 1 : 0;
else if (fo[f] == '#')
fl->oc = 1;
else
return (-1);
return (0);
}
int flagsf2(const char *fo, t_flags *fl)
{
int f;
f = 0;
while (fo[f] != 'f' && fo[f] != '.' && fo[f] != 'l' && fo[f] != 'L' &&
!(fo[f] >= 49 && fo[f] <= 57) && fo[f] != '*')
{
if (flagsf3(fo, fl, f) == -1)
return (-1);
f++;
}
return (f);
}
int ft_flagsu2(const char *fo, t_flags *fl)
{
int f;
f = 0;
while (fo[f] != 'u' && fo[f] != '.' && fo[f] != 'l' && fo[f] != 'h'
&& !(fo[f] >= 49 && fo[f] <= 57) && fo[f] != '*')
{
if (fo[f] == '-')
{
if (!(fl->ze = 0))
fl->mi = 1;
}
else if (fo[f] == '0')
{
if ((!fl->mi))
fl->ze = 1;
}
else if (fo[f] == ' ' || fo[f] == '+')
;
else
return (-1);
f++;
}
return (f);
}