Branch Coverage

deps/libgit2/src/util.c
Criterion Covered Total %
branch 113 296 38.1


line true false branch
29 0 28 if (array == NULL)
32 13 28 for (i = 0; i < array->count; ++i)
44 0 0 assert(tgt && src);
0 0 assert(tgt && src);
48 0 0 if (!src->count)
52 0 0 GIT_ERROR_CHECK_ALLOC(tgt->strings);
54 0 0 for (i = 0; i < src->count; ++i) {
55 0 0 if (!src->strings[i])
59 0 0 if (!tgt->strings[tgt->count]) {
86 2593 0 while (nptr_len && git__isspace(*p))
0 2593 while (nptr_len && git__isspace(*p))
89 0 2593 if (!nptr_len)
95 2584 9 if (*p == '-' || *p == '+') {
0 2584 if (*p == '-' || *p == '+') {
96 9 0 if (*p == '-')
102 0 2593 if (!nptr_len)
111 45 2548 if (base == 0) {
112 1 44 if (*p != '0')
114 0 44 else if (nptr_len > 2 && (p[1] == 'x' || p[1] == 'X'))
0 0 else if (nptr_len > 2 && (p[1] == 'x' || p[1] == 'X'))
0 0 else if (nptr_len > 2 && (p[1] == 'x' || p[1] == 'X'))
120 2593 0 if (base < 0 || 36 < base)
2593 0 if (base < 0 || 36 < base)
130 0 2593 if (base == 16 && nptr_len > 2 && p[0] == '0' && (p[1] == 'x' || p[1] == 'X')) {
0 0 if (base == 16 && nptr_len > 2 && p[0] == '0' && (p[1] == 'x' || p[1] == 'X')) {
0 0 if (base == 16 && nptr_len > 2 && p[0] == '0' && (p[1] == 'x' || p[1] == 'X')) {
0 0 if (base == 16 && nptr_len > 2 && p[0] == '0' && (p[1] == 'x' || p[1] == 'X')) {
0 0 if (base == 16 && nptr_len > 2 && p[0] == '0' && (p[1] == 'x' || p[1] == 'X')) {
138 12866 1753 for (; nptr_len > 0; p++,ndig++,nptr_len--) {
141 12026 840 if ('0'<=c && c<='9')
12026 0 if ('0'<=c && c<='9')
143 0 840 else if ('a'<=c && c<='z')
0 0 else if ('a'<=c && c<='z')
145 0 840 else if ('A'<=c && c<='Z')
0 0 else if ('A'<=c && c<='Z')
147 840 12026 if (v >= base)
149 9 12017 v = neg ? -v : v;
150 12026 0 if (n > INT64_MAX / base || n < INT64_MIN / base) {
0 12026 if (n > INT64_MAX / base || n < INT64_MIN / base) {
156 9028 2998 if ((v > 0 && nn > INT64_MAX - v) ||
9028 0 if ((v > 0 && nn > INT64_MAX - v) ||
9 12017 if ((v > 0 && nn > INT64_MAX - v) ||
157 0 9 (v < 0 && nn < INT64_MIN - v)) {
166 0 2593 if (ndig == 0) {
171 1465 1128 if (endptr)
174 0 2593 if (ovfl) {
190 0 836 if ((error = git__strntol64(&tmp_long, nptr, nptr_len, &tmp_endptr, base)) < 0)
194 0 836 if (tmp_int != tmp_long) {
201 836 0 if (endptr)
209 36 1 while (*a && *b && git__tolower(*a) == git__tolower(*b))
34 2 while (*a && *b && git__tolower(*a) == git__tolower(*b))
20 14 while (*a && *b && git__tolower(*a) == git__tolower(*b))
218 0 0 while (*a && *b) {
0 0 while (*a && *b) {
219 0 0 if (*a != *b) {
220 0 0 if (git__tolower(*a) != git__tolower(*b))
223 0 0 if (!cmp)
230 0 0 if (*a || *b)
0 0 if (*a || *b)
244 28 8 } while (--sz && al && al == bl);
28 0 } while (--sz && al && al == bl);
22 6 } while (--sz && al && al == bl);
253 0 0 for (i = 0; i < len; ++i) {
267 8232 1128 while (str_n--) {
271 0 8232 if (icase) {
276 178 8054 if (!p)
279 1504 6550 if (s != p)
294 6321 220094 if (!p)
297 4790 215304 if (s != p)
321 1017 1298 if (a < b)
330 0 0 while (*ptr && strchr(sep, *ptr))
0 0 while (*ptr && strchr(sep, *ptr))
333 0 0 if (*ptr) {
337 0 0 while (**end && !strchr(sep, **end))
0 0 while (**end && !strchr(sep, **end))
340 0 0 if (**end) {
356 0 0 while (*ptr && !strchr(sep, *ptr))
0 0 while (*ptr && !strchr(sep, *ptr))
359 0 0 if (*ptr) {
372 2420 186 return nl ? (size_t)(nl - buffer) + 1 : buffer_len;
384 0 0 if (needlelen > haystacklen || !haystacklen || !needlelen)
0 0 if (needlelen > haystacklen || !haystacklen || !needlelen)
0 0 if (needlelen > haystacklen || !haystacklen || !needlelen)
390 0 0 if (needlelen == 1)
393 0 0 if (n[0] == n[1]) {
402 0 0 while (j <= haystacklen - needlelen) {
403 0 0 if (n[1] != h[j + 1]) {
406 0 0 if (memcmp(n + 2, h + j + 2, needlelen - 2) == 0 &&
0 0 if (memcmp(n + 2, h + j + 2, needlelen - 2) == 0 &&
426 0 0 for (i = 0; i < line_count; ++i) {
428 0 0 for (j = 0; j < LINE_WIDTH; ++j, ++line)
434 0 0 for (j = 0; j < LINE_WIDTH; ++j, ++line)
435 0 0 printf("%c", (*line >= 32 && *line <= 126) ? *line : '.');
0 0 printf("%c", (*line >= 32 && *line <= 126) ? *line : '.');
440 0 0 if (last_line > 0) {
443 0 0 for (j = 0; j < last_line; ++j, ++line)
446 0 0 for (j = 0; j < (LINE_WIDTH - last_line); ++j)
452 0 0 for (j = 0; j < last_line; ++j, ++line)
453 0 0 printf("%c", (*line >= 32 && *line <= 126) ? *line : '.');
0 0 printf("%c", (*line >= 32 && *line <= 126) ? *line : '.');
532 0 0 for (i = -nblocks; i; i++) {
600 4175 3095 for (lim = array_len; lim != 0; lim >>= 1) {
603 205 3970 if (cmp == 0) {
607 1139 2831 if (cmp > 0) { /* key > p; take right partition */
613 3297 3 if (position)
616 205 3095 return (cmp == 0) ? 0 : GIT_ENOTFOUND;
631 0 0 for (lim = array_len; lim != 0; lim >>= 1) {
634 0 0 if (cmp == 0) {
638 0 0 if (cmp > 0) { /* key > p; take right partition */
644 0 0 if (position)
647 0 0 return (cmp == 0) ? 0 : GIT_ENOTFOUND;
669 638 0 if (value == NULL ||
275 363 if (value == NULL ||
670 275 0 !strcasecmp(value, "true") ||
671 0 275 !strcasecmp(value, "yes") ||
676 14 261 if (!strcasecmp(value, "false") ||
14 0 if (!strcasecmp(value, "false") ||
677 14 0 !strcasecmp(value, "no") ||
678 0 14 !strcasecmp(value, "off") ||
691 0 32 if (!str)
694 141 32 for (scan = str; *scan; pos++, scan++) {
695 0 141 if (*scan == '\\' && *(scan + 1) != '\0')
0 0 if (*scan == '\\' && *(scan + 1) != '\0')
697 0 141 if (pos != scan)
701 0 32 if (pos != scan) {
730 4 4 while (elsize) {
747 50 22 for (i = base + elsize; i < end; i += elsize)
748 54 0 for (j = i; j > base && cmp(j, j - elsize, payload) < 0; j -= elsize)
4 50 for (j = i; j > base && cmp(j, j - elsize, payload) < 0; j -= elsize)
818 0 522 if (!length)
821 522 0 if (str_len > 0 && length > str_len)
0 522 if (str_len > 0 && length > str_len)
824 0 522 for (i = 1; i < length; i++) {
825 0 0 if ((str[i] & 0xC0) != 0x80)
839 0 0 if (length < 0)
848 0 0 if (uc < 0x80) uc = -1;
853 0 0 if (uc < 0x800 || (uc >= 0xD800 && uc < 0xE000) ||
0 0 if (uc < 0x800 || (uc >= 0xD800 && uc < 0xE000) ||
0 0 if (uc < 0x800 || (uc >= 0xD800 && uc < 0xE000) ||
0 0 if (uc < 0x800 || (uc >= 0xD800 && uc < 0xE000) ||
854 0 0 (uc >= 0xFDD0 && uc < 0xFDF0)) uc = -1;
859 0 0 if (uc < 0x10000 || uc >= 0x110000) uc = -1;
0 0 if (uc < 0x10000 || uc >= 0x110000) uc = -1;
863 0 0 if (uc < 0 || ((uc & 0xFFFF) >= 0xFFFE))
0 0 if (uc < 0 || ((uc & 0xFFFF) >= 0xFFFE))
874 522 38 while (offset < str_len) {
877 0 522 if (length < 0)
923 86 172 if (!val)