GCC Code Coverage Report


Directory: ./
File: src/builtins/else.c
Date: 2024-05-07 14:54:03
Exec Total Coverage
Lines: 15 17 88.2%
Functions: 1 1 100.0%
Branches: 7 14 50.0%

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 7 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 5 times.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
9 while (size != -1 && (content == NULL || my_strcmp(content[0], "endif"))) {
26
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
7 IS_ATTY_PRINT("else? ");
27 7 free_str_and_tab(line, NULL);
28 7 size = my_getline(&line, stdin);
29 7 set_command_in_history(mysh, line);
30 7 free_str_and_tab(NULL, content);
31 7 content = str_to_array_inhibitors(line);
32 }
33
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
2 if (size == EOF || (content != NULL && my_strcmp(content[0], "endif"))) {
34 2 my_putstr_error("else: endif not found.\n");
35 2 free_str_and_tab(line, content);
36 2 return 1;
37 }
38 free_str_and_tab(line, content);
39 return 0;
40 }
41