GCC Code Coverage Report


Directory: ./
File: s21_sscanf_utils.c
Date: 2025-07-13 17:59:14
Exec Total Coverage
Lines: 41 41 100.0%
Branches: 20 20 100.0%

Line Branch Exec Source
1 #include "s21_sscanf.h"
2
3 117 void setAssignable(const char **format, FormatSpecifierScan *fs) {
4
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 97 times.
117 if (**format == '*') {
5 20 fs->assignable = 0;
6 20 (*format)++;
7 } else {
8 97 fs->assignable = 1;
9 }
10 117 }
11
12 117 void setWidth(const char **format, FormatSpecifierScan *fs) {
13 117 fs->width = 0;
14
4/4
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 114 times.
147 while (**format >= '0' && **format <= '9') {
15 30 fs->width = fs->width * 10 + (int)(**format - '0');
16 30 (*format)++;
17 }
18 117 }
19
20 117 void setLength(const char **format, FormatSpecifierScan *fs) {
21
2/2
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 103 times.
117 if (s21_strchr("hlL", **format) != NULL) {
22
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13 times.
14 if (*(*format + 1) == 'l') {
23 1 fs->length = 'L';
24 1 (*format) += 2;
25 } else {
26 13 fs->length = **format;
27 13 (*format)++;
28 }
29 } else {
30 103 fs->length = '\0';
31 }
32 117 }
33
34 117 void setSpecifier(const char **format, FormatSpecifierScan *fs) {
35 117 fs->specifier = **format;
36 117 (*format)++;
37 117 }
38
39 94 int isInvalid(const char *str, const char *format) {
40 94 int check = 0;
41
4/4
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 51 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 42 times.
94 if (!*str && s21_strchr(format, '%') != S21_NULL) {
42 1 check = S21_EOF;
43 }
44
45 94 return check;
46 }
47
48 100 int requireStrNotEmpty(const char **str, int *countOfRead) {
49 100 int check = 1;
50
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 97 times.
100 if (!**str) {
51 3 check = 0;
52 3 (*countOfRead) = S21_EOF;
53 }
54
55 100 return check;
56 }
57
58 116 void skipBlankChars(const char **str) {
59
4/4
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 5 times.
✓ Branch 3 taken 61 times.
✓ Branch 4 taken 111 times.
177 while (**str && charIsBlank(**str)) {
60 61 (*str)++;
61 }
62 116 }
63
64 414 int charIsBlank(char c) { return s21_strchr(" \t\n\v\f\r", c) != S21_NULL; }
65