Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | ** EPITECH PROJECT, 2023 | ||
3 | ** my_printf | ||
4 | ** File description: | ||
5 | ** Flag to print a %n (store a int) | ||
6 | */ | ||
7 | |||
8 | #include <stdarg.h> | ||
9 | #include <stddef.h> | ||
10 | #include "my.h" | ||
11 | #include "myformats.h" | ||
12 | |||
13 | 1 | static void signed_char(va_list list, int len) | |
14 | { | ||
15 | 1 | signed char *variable_char = va_arg(list, signed char *); | |
16 | |||
17 | 1 | *variable_char = len; | |
18 | 1 | } | |
19 | |||
20 | 1 | static void short_int(va_list list, int len) | |
21 | { | ||
22 | 1 | short *variable_short = va_arg(list, short *); | |
23 | |||
24 | 1 | *variable_short = len; | |
25 | 1 | } | |
26 | |||
27 | 1 | static void basic_int(va_list list, int len) | |
28 | { | ||
29 | 1 | int *variable_int = va_arg(list, int *); | |
30 | |||
31 | 1 | *variable_int = len; | |
32 | 1 | } | |
33 | |||
34 | 1 | static void long_int(va_list list, int len) | |
35 | { | ||
36 | 1 | long int *variable_long = va_arg(list, long *); | |
37 | |||
38 | 1 | *variable_long = len; | |
39 | 1 | } | |
40 | |||
41 | 1 | static void long_long_int(va_list list, int len) | |
42 | { | ||
43 | 1 | long long int *variable_long_long = va_arg(list, long long *); | |
44 | |||
45 | 1 | *variable_long_long = len; | |
46 | 1 | } | |
47 | |||
48 | 4 | static void basic_size_t(va_list list, int len) | |
49 | { | ||
50 | 4 | size_t *variable_size_t = va_arg(list, size_t *); | |
51 | |||
52 | 4 | *variable_size_t = len; | |
53 | 4 | } | |
54 | |||
55 | 9 | int flag_n(va_list list, formating_t *formating, int len) | |
56 | { | ||
57 | 9 | void (*specify[])(va_list, int) = {&long_int, &long_long_int, | |
58 | &short_int, &signed_char, &basic_size_t, | ||
59 | &basic_size_t, &basic_size_t, &basic_size_t}; | ||
60 | |||
61 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1 times.
|
9 | if (formating->id_sp != -1) { |
62 | 8 | specify[formating->id_sp](list, len); | |
63 | } else { | ||
64 | 1 | basic_int(list, len); | |
65 | } | ||
66 | 9 | return 0; | |
67 | } | ||
68 |