Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | ** EPITECH PROJECT, 2023 | ||
3 | ** my_printf | ||
4 | ** File description: | ||
5 | ** The functions for format a char | ||
6 | */ | ||
7 | |||
8 | #include "my.h" | ||
9 | #include "myformats.h" | ||
10 | |||
11 | 3 | static void do_next_char(char *str_finale, | |
12 | formating_t *formating, char c) | ||
13 | { | ||
14 | 3 | void (*format[])(char *, formating_t *, char) = | |
15 | {&format_moins_char, &format_plus_char, &format_esp_char, | ||
16 | &format_hash_char, &format_zero_char}; | ||
17 | |||
18 |
2/2✓ Branch 0 taken 12 times.
✓ Branch 1 taken 2 times.
|
14 | for (int j = 0; j < 5; j++) { |
19 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 11 times.
|
12 | if (formating->next_chara == FORMATAGE[j]) { |
20 | 1 | format[j](str_finale, formating, c); | |
21 | 1 | return; | |
22 | } | ||
23 | } | ||
24 | } | ||
25 | |||
26 | 2 | void format_plus_char(char *str_finale, | |
27 | formating_t *formating, char c) | ||
28 | { | ||
29 | 2 | format_esp_char(str_finale, formating, c); | |
30 | 2 | return; | |
31 | } | ||
32 | |||
33 | 2 | void format_moins_char(char *str_finale, | |
34 | formating_t *formating, char c) | ||
35 | { | ||
36 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | if ((my_strlen(str_finale) < formating->id_wd |
37 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | && formating->next_chara == '+') |
38 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | || my_strlen(str_finale) < formating->id_wd) { |
39 |
2/2✓ Branch 1 taken 18 times.
✓ Branch 2 taken 2 times.
|
20 | for (int i = my_strlen(str_finale); i < formating->id_wd; i++) { |
40 | 18 | my_strcat(str_finale, " "); | |
41 | } | ||
42 | } | ||
43 | 2 | do_next_char(str_finale, formating, c); | |
44 | 2 | } | |
45 | |||
46 | 6 | void format_esp_char(char *str_finale, | |
47 | formating_t *formating, char c) | ||
48 | { | ||
49 | 6 | my_revstr(str_finale); | |
50 |
2/2✓ Branch 1 taken 13 times.
✓ Branch 2 taken 6 times.
|
19 | for (int i = my_strlen(str_finale); i < formating->id_wd; i++) |
51 | 13 | my_strcat(str_finale, " "); | |
52 | 6 | my_revstr(str_finale); | |
53 | 6 | } | |
54 | |||
55 | 1 | void format_zero_char(char *str_finale, | |
56 | formating_t *formating, char c) | ||
57 | { | ||
58 | 1 | long long int i = my_strlen(str_finale); | |
59 | |||
60 | 1 | my_revstr(str_finale); | |
61 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
2 | for (i;(i < formating->id_wd && formating->next_chara != '+') |
62 |
3/6✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
2 | || (i < formating->id_wd - 1 && formating->next_chara == '+') |
63 | 1 | ; i++) | |
64 | 1 | my_strcat(str_finale, "0"); | |
65 | 1 | my_revstr(str_finale); | |
66 | 1 | do_next_char(str_finale, formating, c); | |
67 | 1 | } | |
68 | |||
69 | 3 | void format_hash_char(char *str_finale, | |
70 | formating_t *formating, char c) | ||
71 | { | ||
72 | 3 | format_esp_char(str_finale, formating, c); | |
73 | 3 | return; | |
74 | } | ||
75 |