GCC Code Coverage Report


Directory: ./
File: src/builtins/else.c
Date: 2024-06-05 00:36:48
Exec Total Coverage
Lines: 14 17 82.4%
Functions: 1 1 100.0%
Branches: 9 14 64.3%

Line Branch Exec Source
1 /*
2 ** EPITECH PROJECT, 2024
3 ** 42sh
4 ** File description:
5 ** The file containing the else builtin
6 */
7 /**
8 * @file else.c
9 * @brief The file containing the else builtin
10 */
11
12 #include "../../include/myshell.h"
13
14 /**
15 * @brief The else builtin
16 * @param mysh The shell structure
17 * @return <b>int</b> <u>0</u> if the command succeed, <u>1</u> otherwise
18 */
19 2 int exec_else(mysh_t *mysh)
20 {
21 2 int size = 0;
22 2 char *line = NULL;
23 2 char **content = NULL;
24
25
5/6
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 4 times.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 2 times.
6 while (size != -1 && (content == NULL || my_strcmp(content[0], "endif"))) {
26
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 IS_ATTY_PRINT("else? ");
27 4 free_str_and_tab(line, NULL);
28 4 size = my_getline(&line, stdin);
29 4 set_command_in_history(mysh, line);
30 4 free_str_and_tab(NULL, content);
31 4 content = str_to_array_inhibitors(line);
32 }
33
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
2 if (size == EOF || (content != NULL && my_strcmp(content[0], "endif"))) {
34 my_putstr_error("else: endif not found.\n");
35 free_str_and_tab(line, content);
36 return 1;
37 }
38 2 free_str_and_tab(line, content);
39 2 return 0;
40 }
41