Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | ** EPITECH PROJECT, 2023 | ||
3 | ** find the first format | ||
4 | ** File description: | ||
5 | ** find the first format | ||
6 | */ | ||
7 | |||
8 | #include "myformats.h" | ||
9 | #include "my.h" | ||
10 | |||
11 | 38 | static void check_operator(formating_t *formating) | |
12 | { | ||
13 |
4/4✓ Branch 0 taken 30 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 29 times.
|
38 | if (formating->next_chara == '+' || formating->next_chara == '-') { |
14 | 9 | formating->nb_format += 2; | |
15 | } else { | ||
16 | 29 | (formating->nb_format) += 1; | |
17 | } | ||
18 | 38 | } | |
19 | |||
20 | 213 | void format_first(user_t *user, flags_t *flgs, | |
21 | formating_t *formating, int *copy) | ||
22 | { | ||
23 |
2/2✓ Branch 0 taken 94954 times.
✓ Branch 1 taken 175 times.
|
95129 | for (; user->str[*copy - 1] != flgs->str[flgs->index_flag]; (*copy)++) { |
24 | 94954 | find_first(user, copy, formating); | |
25 |
2/2✓ Branch 0 taken 38 times.
✓ Branch 1 taken 94916 times.
|
94954 | if (formating->id_ft != -1) { |
26 | 38 | check_operator(formating); | |
27 | 38 | break; | |
28 | } | ||
29 | } | ||
30 | 213 | } | |
31 | |||
32 | 213 | void format_width(user_t *user, flags_t *flgs, | |
33 | formating_t *formating, int *copy) | ||
34 | { | ||
35 |
2/2✓ Branch 0 taken 98932 times.
✓ Branch 1 taken 179 times.
|
99111 | for (; user->str[*copy - 1] != flgs->str[flgs->index_flag]; (*copy)++) { |
36 | 98932 | find_width(user, copy, formating); | |
37 |
2/2✓ Branch 0 taken 34 times.
✓ Branch 1 taken 98898 times.
|
98932 | if (formating->id_wd != -1) { |
38 | 34 | (formating->nb_format) += my_strlen(my_str_nbr(formating->id_wd)); | |
39 | 34 | break; | |
40 | } | ||
41 | } | ||
42 | 213 | } | |
43 | |||
44 | 213 | void format_precision(user_t *user, flags_t *flgs, | |
45 | formating_t *formating, int *copy) | ||
46 | { | ||
47 |
2/2✓ Branch 0 taken 101446 times.
✓ Branch 1 taken 198 times.
|
101644 | for (; user->str[*copy - 1] != flgs->str[flgs->index_flag]; (*copy)++) { |
48 | 101446 | find_precision(user, copy, formating); | |
49 |
2/2✓ Branch 0 taken 15 times.
✓ Branch 1 taken 101431 times.
|
101446 | if (formating->id_prc != -1) { |
50 | 15 | formating->nb_format += 1; | |
51 | 15 | break; | |
52 | } | ||
53 | } | ||
54 | 213 | } | |
55 | |||
56 | 213 | void format_numbers(user_t *user, flags_t *flgs, | |
57 | formating_t *formating, int *copy) | ||
58 | { | ||
59 |
2/2✓ Branch 0 taken 101277 times.
✓ Branch 1 taken 196 times.
|
101473 | for (; user->str[*copy - 1] != flgs->str[flgs->index_flag]; (*copy)++) { |
60 | 101277 | find_numbers(user, copy, formating); | |
61 |
2/2✓ Branch 0 taken 17 times.
✓ Branch 1 taken 101260 times.
|
101277 | if (formating->id_nb != -1) { |
62 | 17 | (formating->nb_format) += my_strlen(my_str_nbr(formating->id_nb)); | |
63 | 17 | break; | |
64 | } | ||
65 | } | ||
66 | 213 | } | |
67 | |||
68 | 213 | void format_specifier(user_t *user, flags_t *flgs, | |
69 | formating_t *formating, int *copy) | ||
70 | { | ||
71 | 213 | find_specifier(user, copy, formating); | |
72 |
4/4✓ Branch 0 taken 208 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 205 times.
|
213 | if (formating->id_sp == 1 || formating->id_sp == 3) { |
73 | 8 | formating->nb_format += 2; | |
74 |
2/2✓ Branch 0 taken 13 times.
✓ Branch 1 taken 192 times.
|
205 | } else if (formating->id_sp != - 1) { |
75 | 13 | formating->nb_format += 1; | |
76 | } | ||
77 | 213 | } | |
78 |