| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | ** EPITECH PROJECT, 2023 | ||
| 3 | ** my_printf | ||
| 4 | ** File description: | ||
| 5 | ** The functions for apply an specifier on an number in different base | ||
| 6 | */ | ||
| 7 | /** | ||
| 8 | * @file specifier_base.c | ||
| 9 | * @brief The file containing the specifier_base function | ||
| 10 | * @author Nicolas TORO | ||
| 11 | */ | ||
| 12 | |||
| 13 | #include "myprintf.h" | ||
| 14 | |||
| 15 | 2 | static char *select_long_long(size_t temp, char *base) | |
| 16 | { | ||
| 17 | 2 | return my_str_nbr_base_unsigned_long((long)temp, base); | |
| 18 | } | ||
| 19 | |||
| 20 | 1 | static char *select_short(size_t temp, char *base) | |
| 21 | { | ||
| 22 | 1 | return my_str_nbr_base_unsigned_short((unsigned short)temp, base); | |
| 23 | } | ||
| 24 | |||
| 25 | 1 | static char *select_short_short(size_t temp, char *base) | |
| 26 | { | ||
| 27 | 1 | return my_str_nbr_base_unsigned_short_short((unsigned char)temp, base); | |
| 28 | } | ||
| 29 | |||
| 30 | 1 | static char *select_size_t(size_t temp, char *base) | |
| 31 | { | ||
| 32 | 1 | return my_str_nbr_base_unsigned_size_t(temp, base); | |
| 33 | } | ||
| 34 | |||
| 35 | 59 | char *specify_it_base(formating_t *formating, size_t temp, char *base) | |
| 36 | { | ||
| 37 | 59 | char *(*specify[])(size_t, char *) = | |
| 38 | {&select_long_long, &select_long_long, | ||
| 39 | &select_short, &select_short_short, &select_size_t, | ||
| 40 | &select_size_t, &select_size_t, &select_size_t}; | ||
| 41 | |||
| 42 |
2/2✓ Branch 0 taken 5 times.
✓ Branch 1 taken 54 times.
|
59 | if (formating->id_sp != -1) { |
| 43 | 5 | return specify[formating->id_sp](temp, base); | |
| 44 |
2/2✓ Branch 0 taken 11 times.
✓ Branch 1 taken 43 times.
|
54 | } else if (formating->flag == 'b') { |
| 45 | 11 | return my_convert_base_unsigned(my_str_nbr_unsigned(temp), | |
| 46 | "0123456789", "01"); | ||
| 47 | } else { | ||
| 48 | 43 | return my_str_nbr_base_unsigned((unsigned)temp, base); | |
| 49 | } | ||
| 50 | } | ||
| 51 |